Skip to content

Fix squares sample failure when a single file passed#19988

Merged
opencv-pushbot merged 1 commit intoopencv:3.4from
alexkalmuk:fix-squares-cpp-sample
Apr 28, 2021
Merged

Fix squares sample failure when a single file passed#19988
opencv-pushbot merged 1 commit intoopencv:3.4from
alexkalmuk:fix-squares-cpp-sample

Conversation

@alexkalmuk
Copy link
Copy Markdown
Contributor

Fix samples/cpp/squares.cpp:

$ ../build/opencv_squares pic1.png 

A program using pyramid scaling, Canny, contours and contour simplification
to find squares in a list of images (pic1-6.png)
Returns sequence of squares detected on the image.
Call:
./../build/opencv_squares [file_name (optional)]
Using OpenCV version 4.5.2-dev

[ WARN:0] global /home/alexander/git/opencv/modules/core/src/utils/samples.cpp (59) findFile cv::samples::findFile('0') => ''
terminate called after throwing an instance of 'cv::Exception'
  what():  OpenCV(4.5.2-dev) /home/alexander/git/opencv/modules/core/src/utils/samples.cpp:62: error: (-2:Unspecified error) OpenCV samples: Can't find required data file: 0 in function 'findFile'

Aborted (core dumped)

It tries to find file "0" and fails.

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 other license that is incompatible with OpenCV
  • The PR is proposed to proper branch
  • There is reference to 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

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Thank you for contribution!

This patch should go into 3.4 branch first.
We will merge changes from 3.4 into master regularly (weekly/bi-weekly).

Please:

  • change "base" branch of this PR: master => 3.4 (use "Edit" button near PR title)
  • rebase your commits from master onto 3.4 branch. For example:
    git rebase -i --onto upstream/3.4 upstream/master
    (check list of your commits, save and quit (Esc + "wq" + Enter)
    where upstream is configured by following this GitHub guide and fetched (git fetch upstream).
  • push rebased commits into source branch of your fork (with --force option)

Note: no needs to re-open PR, apply changes "inplace".

{
names[0] = argv[1];
names[1] = "0";
names[1] = 0;
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.

Could you please remove static from names declaration too (doesn't make sense):

-static const char* names
+const char* names

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Yes, of course. I fixed this and squashed it in a single commit.

@alexkalmuk alexkalmuk changed the base branch from master to 3.4 April 28, 2021 06:30
@alexkalmuk alexkalmuk force-pushed the fix-squares-cpp-sample branch from 11904c6 to 5d5506b Compare April 28, 2021 06:31
@alexkalmuk alexkalmuk force-pushed the fix-squares-cpp-sample branch from 5d5506b to b04d6a2 Compare April 28, 2021 06:36
@alexkalmuk
Copy link
Copy Markdown
Contributor Author

@alalek Thanks for the tips! Done.

Copy link
Copy Markdown
Member

@alalek alalek left a comment

Choose a reason for hiding this comment

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

Well done 👍

@opencv-pushbot opencv-pushbot merged commit d4f104f into opencv:3.4 Apr 28, 2021
@alalek alalek mentioned this pull request May 1, 2021
@alalek alalek mentioned this pull request Jun 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants