【问题标题】:opencv structured forest edge detection and findcontoursopencv结构化森林边缘检测和findcontours
【发布时间】:2016-02-10 18:11:42
【问题描述】:

我正在尝试通过 Visual C++ 使用 opencv 来提取图像的轮廓。我能够使用 opencv tutorial for findcontours 做到这一点。 findcontours 分两步工作

  1. 使用 canny 边缘检测器检测边缘。
  2. 将 canny 的输出提供给 findcontours。

我想对“Structured Forest Edge Detection”(Zitnick 等人)进行同样的尝试。我能够提取边缘并显示它们,但是当我尝试将输出提供给 findcontours 时。我在内存位置 0x0020EE9C 处收到“cv::Exception”错误。 (见下面的代码)。我做错了什么?

Mat src = imread("image.jpg");

src.convertTo(src, CV_32F, 1.0 / 255.0);

Mat edges(src.size(), src.type());

Ptr<StructuredEdgeDetection> pDollar = createStructuredEdgeDetection("model.yml.gz");

pDollar->detectEdges(src, edges);

findContours(edges, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0));

【问题讨论】:

  • 我尝试将边缘从 CV_32F 转换为 CV_8U,如下所示edges.convertTo(edges_cv8u, CV_8U, 255.0 / (max - min), -255.0 / min),然后将 edges_cv8u 传递给 findContours。还是一样的例外。

标签: opencv visual-c++ image-processing edge-detection opencv3.0


【解决方案1】:
pDollar->detectEdges(src, edges);

edges 类型为 CV_32F。您必须将其转换为 8 位单通道图像

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-12-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-01-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多