opencv / opencv_contrib

Repository for OpenCV's extra modules
Apache License 2.0
9.34k stars 5.75k forks source link

Structured Edge Detection: Model conversion from .mat to .yml #1282

Open greenflash1357 opened 7 years ago

greenflash1357 commented 7 years ago

I have used the Matlab script opencv_contrib/modules/ximgproc/tutorials/scripts/modelConvert.m to convert a model. Loading the model when creating a pointer to a StructuredEdgeDetection works, but detectEdges() returns blurry, foggy, image-unrelated edge maps.

Is the script outdated? Is there a maximum size for models? The converted .yml file looks very similiar to the provided opencv_extra/testdata/cv/ximgproc/model.yml.gz except for a lot more edgeBoundaries and edgeBins.

The issue seems not to be related to #716. I have tried converting from BGR2RGB.

System information
Steps to reproduce
greenflash1357 commented 6 years ago

According to this answer, the issue is related to the different versions of SED. The OpenCV implementation seems to be based on the first version, while the model I have trained and the one that is provided by P. Dollárs git repo are created with newer versions of SED.

In particualr, the sharpening option is involved. I was able to train, load and execute a model with sharpen=0 in OpenCV and got kind of the expected results (a bit blurry though. Why is the OpenCV implementation smoothing the result?).

The mentioned link might provided some kind of fix for the code in OpenCV. Are there any plans to update the OpenCV implementation to fit the newer releases of SED?

zhangyuygss commented 6 years ago

Any idea when will the code change @bommo1 mentioned be included in the opencv python release? Or should I compile it manually? I'm using anaconda python.