为什么在openCV中反转图像时出现错误消息?

时间:2018-11-08 07:44:13

标签: opencv image-processing

我正在处理用于创建轮廓的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方法?在转换为灰色之前,我试图进行反转,但这并没有改变。

1 个答案:

答案 0 :(得分:0)

the document 中:cv::invert()需要CV_32FCV_64F作为类型,而不是CV_8U。另外,只要确定要使用正确的逆,cv::inverse()是数学逆,而不是图像处理逆。