opencv structured forest edge detection and findcontours

≯℡__Kan透↙ 提交于 2020-01-17 06:38:57

问题


I am trying to use opencv via visual c++ to extract contours of an image. I was able to do that using the opencv tutorial for findcontours. findcontours works in two steps

  1. Detect edges using canny edge detector.
  2. Feed the output of canny to findcontours.

I want to try out the same with 'Structured Forest Edge Detection' (Zitnick et al). I am able to extract the edges and display them, but when I try to feed the output to findcontours. I am getting a 'cv::Exception at memory location 0x0020EE9C' error. (see code below). What am I doing wrong?

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

回答1:


pDollar->detectEdges(src, edges);

edges type is CV_32F. you must convert it to 8-bit single-channel image



来源:https://stackoverflow.com/questions/33620293/opencv-structured-forest-edge-detection-and-findcontours

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!