Model file for OpenCV's structured edge detector

匿名 (未验证) 提交于 2019-12-03 02:20:02

问题:

OpenCV implements StructuredEdgeDetection based on the random forest based approach outlined in "Structured Forests for Fast Edge Detection" (2013) by P. Dollár and C. Zitnick. The authors have published an implementation for Matlab and there's also one for Python, both of which also contain a pretrained model based on the BSDS500 dataset.

The OpenCV implementation seems to be lacking a pretrained model and I'm also unable to uncover what format the only constructor it offers expects:

Ptr<cv::StructuredEdgeDetection> createStructuredEdgeDetection(String model)
The only available constructor
Parameters: model

The documentation also doesn't outline how to train the OpenCV implementation, so I'm left quite in the dark.

To recap, how to use the OpenCV implementation? Is a trained model available? If not, how to train one using OpenCV?

回答1:

You can use this model from opencv_extra ximgproc test data.

If you want to train your own model, you can follow instructions on OpenCV tutorials.

Image:

Edges:

Code:

#include <opencv2\opencv.hpp> #include <opencv2\ximgproc.hpp>  using namespace cv; using namespace cv::ximgproc;  int main() {     Ptr<StructuredEdgeDetection> pDollar = createStructuredEdgeDetection("path_to_model.yml.gz");      Mat3b src = imread("path_to_image");      Mat3f fsrc;     src.convertTo(fsrc, CV_32F, 1.0 / 255.0);      Mat1f edges;     pDollar->detectEdges(fsrc, edges);      imshow("Image", src);     imshow("Edges", edges);     waitKey();      return 0; }


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