【问题标题】:OpenCV findContours crashOpenCV findContours 崩溃
【发布时间】:2012-06-05 02:09:01
【问题描述】:

我有这个代码:

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);

但它会因此错误而崩溃:

OpenCV 错误:断言失败 (type == type0 || (CV_MAT_CN(type) == CV_MAT_CN(type0) && ((1

由于 cvtColor 调用,我认为我的 Mat 已经处于 1 通道灰度...

我该如何解决这个问题?

【问题讨论】:

  • 您希望 cvtColor 如何就地工作以将图像从 3 通道转换为 1 通道?
  • 我也在使用 cv::adaptiveThreshold 来转换为 1 通道图像,我想...如果我错了,请告诉我如何从我的垫子中获得 1 通道图像
  • @Progeny 如果它解决了您的问题,您应该接受答案

标签: ios opencv


【解决方案1】:

代替:

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

你试过了吗?

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

【讨论】:

  • 我用 Point 代替了 CvPoint,因为我没有花时间正确阅读编译器错误。更改为 cv::Point 对我有用。
猜你喜欢
  • 1970-01-01
  • 2019-07-02
  • 1970-01-01
  • 1970-01-01
  • 2012-12-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2016-04-15
相关资源
最近更新 更多