Skip to content

Unable to detect edges with modelBsds.mat #1559

@hoonkai

Description

@hoonkai
System information (version)
  • OpenCV => 3.4
  • Operating System / Platform => Ubuntu 17.10
  • Compiler => gcc 7
Detailed description

I'm unable to detect edges using structured forest training's original BSDS model (https://github.com/pdollar/edges/blob/master/models/forest/modelBsds.mat). When I try loading the model and running edge detection, I get this:

screen shot 2018-02-15 at 01 05 32

for the input image:

screen shot 2018-02-15 at 01 07 20

modelBsds.mat works fine within Matlab, but after converting to .yaml, detection fails. I believe something might be wrong with the mat-to-yaml conversion script.

Steps to reproduce

(Based on https://docs.opencv.org/master/d2/d59/tutorial_ximgproc_training.html#gsc.tab=0)

  1. Download and load in Matlab (R2017b) https://github.com/pdollar/edges/blob/master/models/forest/modelBsds.mat
  2. Download https://github.com/opencv/opencv_contrib/blob/master/modules/ximgproc/tutorials/scripts/modelConvert.m
  3. Convert trained model from Matlab binary format to YAML by running modelConvert(model, "model.yml") in Matlab
  4. Run
import cv2
img = cv2.imread('./kermit.jpg')
edgedetector = cv2.ximgproc.createStructuredEdgeDetection('./model.yml')
src = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
edges = edgedetector.detectEdges(np.float32(src) / 255.0)
cv2.imshow("edges", edges)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions