我正在处理用于创建轮廓的UIImage,在此过程中,我首先将其反转,然后使其变为灰色。这是代码:
+(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;
}
这是错误代码:
libc ++ abi.dylib:终止于cv :: Exception类型的未捕获异常:OpenCV(3.4.2)/ Volumes / build-storage / build / 3_4_iOS-mac / opencv / modules / core / src / lapack。 cpp:839:错误:(-215:断言失败)类型== 5 ||在功能“反转”中输入== 6
(lldb)
为什么我不能使用invert方法?在转换为灰色之前,我试图进行反转,但这并没有改变。
答案 0 :(得分:0)
在the document 中:cv::invert()
需要CV_32F
或CV_64F
作为类型,而不是CV_8U
。另外,只要确定要使用正确的逆,cv::inverse()
是数学逆,而不是图像处理逆。