OpenCV findContours crash

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?

Answers


Instead of:

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

have you tried?

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

Need Your Help

How to access language resource file values in code behind

asp.net resources globalization resx

I can access language resource file values in mark up fine using below code:

RenderScript Text Size

android renderscript

How do I set the font characteristics before calling rsgDrawText? I'm specifically interested in being able to set the font size.