0

I was trying to port an existing C++ desktop project to Android. For this I need to read images from the file system - which I was able do to now with copying the .jpg files in code.

Now I am facing this error:

OpenCV Error: Assertion failed (src.type() == CV_8UC1) in void createReflectionMask(const cv::Mat&, cv::Mat&, float, float, int, int), file jni/wahet.cpp, line 782

Code:

Mat img = imread(*inFile);
CV_Assert(img.data != 0);
Mat orig;
if (!segresFiles.empty())
img.copyTo(orig);
int width = img.cols;
int height = img.rows;
Mat mask(height, width, CV_8UC1);
createReflectionMask(img, mask);


void createReflectionMask(const Mat& src, Mat& mask) {
    CV_Assert(src.type() == CV_8UC1);

Error thrown in the first line of createReflectionMask().

As I used the code of this project under Windows with the same images there must be some problem with the Android file system or copying the files.

Community
  • 1
  • 1
4ndro1d
  • 2,926
  • 7
  • 35
  • 65
  • imread(*inFile, 0); // will read a 8bit grayscale image. without the flag(default), it will read a 3channel color image – berak Sep 30 '14 at 13:23
  • Sure... Post this as answer pls. Had to add CV_LOAD_IMAGE_GRAYSCALE – 4ndro1d Sep 30 '14 at 15:39

0 Answers0