I am processing a UIImage for contour creation and in that process I am firstly inverting it, then making it gray. Here is the code:
+(UIImage *)processInvertedImage:(UIImage *)image {
cv::Mat mat;
UIImageToMat(image, mat);
cv::Mat gray;
cv::cvtColor(mat, gray, CV_RGB2GRAY);
cv::Mat inverted;
cv::invert(gray, inverted); //// here it crashes
UIImage *binImg = MatToUIImage(inverted);
return binImg;
}
This is the error code:
libc++abi.dylib: terminating with uncaught exception of type cv::Exception: OpenCV(3.4.2) /Volumes/build-storage/build/3_4_iOS-mac/opencv/modules/core/src/lapack.cpp:839: error: (-215:Assertion failed) type == 5 || type == 6 in function 'invert'
(lldb)
Why can't I use the invert methode? I tried to invert before converting to gray, but that did not make a difference.