Skip to content

Improved edge detection sample#25515

Merged
asmorkalov merged 41 commits intoopencv:5.xfrom
gursimarsingh:improved_edge_detection_sample
Sep 6, 2024
Merged

Improved edge detection sample#25515
asmorkalov merged 41 commits intoopencv:5.xfrom
gursimarsingh:improved_edge_detection_sample

Conversation

@gursimarsingh
Copy link
Copy Markdown
Contributor

@gursimarsingh gursimarsingh commented Apr 30, 2024

#25006 #25314
This pull request removes hed_pretrained caffe model to the SOTA dexined onnx model for edge detection. Usage of conventional methods like canny has also been added

The obsolete cpp and python sample has been removed

TODO:

Pull Request Readiness Checklist

See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request

  • I agree to contribute to the project under Apache 2 License.
  • To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV
  • The PR is proposed to the proper branch
  • There is a reference to the original bug report and related work
  • There is accuracy test, performance test and test data in opencv_extra repository, if applicable
    Patch to opencv_extra has the same branch name.
  • The feature is well documented and sample code can be built with the project CMake

@gursimarsingh gursimarsingh self-assigned this May 1, 2024
@gursimarsingh gursimarsingh added category: samples cleanup Code cleanup (e.g, drop legacy C-API, legacy unmaintained code) OpenCV5 labels May 1, 2024
@gursimarsingh gursimarsingh added this to the 5.0 milestone May 1, 2024
@gursimarsingh
Copy link
Copy Markdown
Contributor Author

@vpisarev

  1. applyDexined function has been implemented
  2. nullptr has been passed to callbacks for createTrackbar()
  3. --model argument has been described and error messages have been updated

Other changes related to findFile and findModel will be added once classification sample pull request is approved and merged

@vpisarev
Copy link
Copy Markdown
Contributor

vpisarev commented Aug 9, 2024

  1. for some reason download_models.py cannot store dexined model properly. It says that the model was downloaded successfully, but I don't see da39a3ee5e6b4b0d3255bfef95601890afd80709 directory, nor the sample can locate it.
  2. since dexined is the only model supported by the sample, can we always load it, even when sample is run without parameters?

@asmorkalov
Copy link
Copy Markdown
Contributor

Looks like the model cannot be downloaded with download_models.py. I downloaded it manually and dnn path leads to crash:

 ./bin/example_dnn_edge_detection --method=dexined --model=dexined.onnx --zoo=../opencv-next/samples/dnn/models.yml 
[WARN] set the environment variables or pass path to dexined.onnx model file and models.yml file for using dexined based edge detector.[ WARN:0@1.572] global cap_gstreamer.cpp:1777 open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
To switch between canny and dexined press space bar.
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(5.0.0-pre) /home/alexander/Projects/OpenCV/opencv-next/modules/imgproc/src/resize.cpp:4154: error: (-215:Assertion failed) inv_scale_x > 0 in function 'resize'

{
CV_Assert(src.getObj() != dst.getObj());
CV_Check(axis, axis >= 0 && axis < src.dims(), "Axis out of range");
CV_Check(axis, axis >= 0 && (axis < src.dims() || (src.dims()==1 && axis==1)), "axis is out of range");
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src.dims()==1 && axis==1

It does not look valid to me for the general cases.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@fengyuentau, yes, this is hack, because the generated model contains incorrect, out-of-range axis specification. The script needs to be fixed and then dexined model should be regenerated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, then @gursimarsingh could you add a comment for this?

@vpisarev vpisarev self-requested a review September 6, 2024 05:59
@vpisarev
Copy link
Copy Markdown
Contributor

vpisarev commented Sep 6, 2024

@asmorkalov, let's finally merge it

Copy link
Copy Markdown
Member

@fengyuentau fengyuentau left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the meantime, please take a look at my comment in the PR in model zoo: opencv/opencv_zoo#272 (review)

@asmorkalov asmorkalov assigned vpisarev and unassigned gursimarsingh Sep 6, 2024
@asmorkalov asmorkalov merged commit f8fb3a7 into opencv:5.x Sep 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

category: samples cleanup Code cleanup (e.g, drop legacy C-API, legacy unmaintained code) OpenCV5

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants