Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved edge detection sample #25515

Open
wants to merge 14 commits into
base: 5.x
Choose a base branch
from

Conversation

gursimarsingh
Copy link

#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

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
samples/dnn/edge_detection.cpp Outdated Show resolved Hide resolved
samples/dnn/edge_detection.cpp Outdated Show resolved Hide resolved
string onnxModel = parser.get<string>("model");
int backend = parser.get<int>("backend");
int target = parser.get<int>("target");
int imageSize = parser.get<int>("imageSize");
Copy link
Contributor

Choose a reason for hiding this comment

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

There is issue with command line parameters handling. Invocation without params leads to sigsegv:

[ WARN:0@0.002] global samples.cpp:61 findFile cv::samples::findFile('baboon.jpg') => '/home/alexander/Projects/OpenCV/opencv-next-build/../opencv-next/samples/data/baboon.jpg'
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(5.0.0-pre) /home/alexander/Projects/OpenCV/opencv-next/modules/dnn/src/onnx/onnx_importer.cpp:278: error: (-5:Bad argument) Can't read ONNX file:  in function 'ONNXImporter'

Abort (core dumped)

Copy link
Author

Choose a reason for hiding this comment

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

fixed, canny is now default

samples/dnn/edge_detection.cpp Outdated Show resolved Hide resolved
@@ -0,0 +1,31 @@
import cv2 as cv
Copy link
Contributor

Choose a reason for hiding this comment

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

The new approach destroys original sample with custom layer. Formally, all code blocks are there, but the sample does not create Net and does not use the new layer.

@@ -1886,7 +1886,7 @@ CV_EXPORTS_W void Laplacian( InputArray src, OutputArray dst, int ddepth,
//! @addtogroup imgproc_feature
//! @{

/** @example samples/cpp/edge.cpp
/** @example samples/dnn/edge_detection.cpp
Copy link
Contributor

Choose a reason for hiding this comment

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

We still need simplified API usage example.
Code with 200+ lines are just not suitable for initial leaning steps.

We need 2 kind of "samples":

  • simplified API usage example (e.g. move to part of documentation - tutorial_code)
  • large "task solution" "demos"

Copy link
Author

Choose a reason for hiding this comment

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

edge.cpp has been moved to samples/cpp/snippets directory as it has been done for other basic cpp samples

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: Todo
Development

Successfully merging this pull request may close these issues.

None yet

4 participants