OpenCV的结构化边缘检测器的模型文件 [英] Model file for OpenCV's structured edge detector

查看:297
本文介绍了OpenCV的结构化边缘检测器的模型文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

OpenCV基于随机森林实现 StructuredEdgeDetection P在用于快速边缘检测的结构化森林"(2013)中概述的方法. Dollár和C. Zitnick.作者已经发布了 Matlab的实现,还有

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.

OpenCV实现似乎缺少预先训练的模型,而且我也无法揭示它提供的唯一构造函数期望的格式:

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)
唯一可用的构造函数
参数:模型 –模型文件名

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

该文档也没有概述如何训练OpenCV实现,因此我处于黑暗之中.

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

回顾一下,如何使用OpenCV实现?有训练有素的模型吗?如果没有,如何使用OpenCV训练一个人?

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

推荐答案

您可以使用

You can use this model from opencv_extra ximgproc test data.

如果您想训练自己的模型,可以按照 OpenCV教程.

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

图片:

边缘:

代码:

#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;
}

这篇关于OpenCV的结构化边缘检测器的模型文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆