Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OpenCV findContours crash

Tags:

ios

opencv

I've got 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 it crashes with this error:

OpenCV Error: Assertion failed (type == type0 || (CV_MAT_CN(type) == CV_MAT_CN(type0) && ((1 << type0) & fixedDepthMask) != 0)) in create, file /Users/robin/Projects/OpenCVForiPhone/opencv/opencv/modules/core/src/matrix.cpp, line 1249 terminate called throwing an exception

I think my Mat is already in 1-channel gray-scale because of cvtColor call...

How can I fix this?

like image 483
Progeny Avatar asked Dec 27 '22 00:12

Progeny


1 Answers

Instead of:

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

have you tried?

std::vector<std::vector<cv::Point> > contours;
like image 171
mmackh Avatar answered Jan 06 '23 23:01

mmackh