Opencv findcontours crash

I have this code:

mat.copyTo(tmpMat); cvtColor(tmpMat, tmpMat, CV_BGR2GRAY); cv::equalizeHist(tmpMat, tmpMat); cv::Mat browMat = tmpMat(eyebrowRect); std::vector<std::vector<Point> > contours; cv::findContours(browMat, contours, cv::RETR_LIST, cv::CHAIN_APPROX_NONE); 

but this error fails:

OpenCV error: statement failed (type == type0 || (CV_MAT_CN (type) == CV_MAT_CN (type0) && ((1 <type0) and fixedDepthMask)! = 0)) in the creation, file / Users / robin / Projects / OpenCVForiPhone / opencv / opencv / modules / core / src / matrix.cpp, line 1249 ending the call throwing exception

I think my Mat is already on a 1-channel gray scale due to a call to cvtColor ...

How can i fix this?

+4
source share
1 answer

Instead:

 std::vector<std::vector<Point> > contours; 

You tried?

 std::vector<std::vector<cv::Point> > contours; 
+9
source

Source: https://habr.com/ru/post/1415241/


All Articles