Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Return Mat_<float> data not uchar

I'm refactoring some code from cimg to opencv. I have the following lines that should return Mat_<float>.data.

  // Get a pointer to the data.
  //  T* Data() { return; } <-cimg calls
  //  const T* Data() const { return; } <-cimg.calls
  T* Data() { return; }
  const T* Data() const { return; }

but I get a compile error:

error: cannot initialize return object of type 'float *' with an lvalue of type 'uchar *' (aka 'unsigned char *')
  T* Data() { return; }

Other part of the code:

      cv::Mat_<T> image_;
      image_ = cv::imread(filename.c_str(), CV_LOAD_IMAGE_ANYCOLOR | CV_LOAD_IMAGE_ANYDEPTH);

From what I've read is of type uchar. But shouldn't data be float when I use Mat_<float>?

Thanks, Jason