Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

fix type cast in drawDetectedMarkers, drawDetectedCornersCharuco, drawDetectedDiamonds#24247

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

@AleksandrPanov
Copy link
Contributor

@AleksandrPanovAleksandrPanov commentedSep 8, 2023
edited
Loading

  • drawDetectedMarkers(), drawDetectedCornersCharuco(), drawDetectedDiamonds() uses onlyPoint2f (CV_32FC2) for detected corners. But this corners are casted toint later in the code.
  • drawDetectedMarkers(), drawDetectedDiamonds() has a requirement on CV_32FC2 for corners. This requirement is lost in drawDetectedCornersCharuco().

Strict input data requirements have been removed. Added only the requirement to have 2 channels. The input corners are then casted to CV_32SC2.

added tests

Pull Request Readiness Checklist

See details athttps://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

(_image.getMat().channels() ==1 || _image.getMat().channels() ==3));
CV_Assert((_charucoCorners.getMat().total() == _charucoIds.getMat().total()) ||
_charucoIds.getMat().total() ==0);
CV_Assert(_charucoCorners.getMat().type() == CV_32FC2);
Copy link
Contributor

@asmorkalovasmorkalovSep 8, 2023
edited
Loading

Choose a reason for hiding this comment

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

I propose alternative:

CV_Assert(_charucoCorners.channels() == 2);..._charucoCorners.getMat().convertTo(..., ...);

Copy link
Contributor

Choose a reason for hiding this comment

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

No need to limit type here. Just use proper conversions.

AleksandrPanov reacted with thumbs up emoji
Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

then I will remove the limits from all functions (drawDetectedMarkers, drawDetectedCornersCharuco, drawDetectedDiamonds)

asmorkalov reacted with thumbs up emoji
_charucoIds.getMat().total() ==0);
CV_Assert(_charucoCorners.getMat().type() == CV_32FC2);

size_t nCorners = _charucoCorners.getMat().total();
Copy link
Contributor

Choose a reason for hiding this comment

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

InputArray hastotal() method. getMat() is redundant.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

removed getMat()

@asmorkalovasmorkalov added this to the4.9.0 milestoneSep 8, 2023
@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch fromd65f3d3 to093878aCompareSeptember 8, 2023 14:12
@AleksandrPanovAleksandrPanov changed the titlefix drawDetectedCornersCharuco type errorfix type cast in drawDetectedMarkers, drawDetectedCornersCharuco, drawDetectedDiamondsSep 8, 2023
@AleksandrPanovAleksandrPanov marked this pull request as draftSeptember 8, 2023 15:53
@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch 3 times, most recently from4dde75d tob7b8183CompareSeptember 8, 2023 17:47
@AleksandrPanovAleksandrPanov marked this pull request as ready for reviewSeptember 8, 2023 17:58
@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch 4 times, most recently from4bfb003 to587dc3fCompareSeptember 9, 2023 09:38
Mat currentMarker = _corners.getMat(i);
CV_Assert(currentMarker.total() ==4 && currentMarker.type() == CV_32FC2);
CV_Assert(currentMarker.total() ==4 && currentMarker.channels() ==2);
currentMarker.convertTo(currentMarker, CV_32SC2);
Copy link
Contributor

Choose a reason for hiding this comment

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

It makes sense, to check if the input is already32SC2.convertTo does not check it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

added check:

        if (currentMarker.type() != CV_32SC2)            currentMarker.convertTo(currentMarker, CV_32SC2);

Mat currentMarker = _corners.getMat(i);
CV_Assert(currentMarker.total() ==4 && currentMarker.type() == CV_32FC2);
CV_Assert(currentMarker.total() ==4 && currentMarker.channels() ==2);
currentMarker.convertTo(currentMarker, CV_32SC2);
Copy link
Contributor

Choose a reason for hiding this comment

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

The same for type check.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

added check:

        if (currentMarker.type() != CV_32SC2)            currentMarker.convertTo(currentMarker, CV_32SC2);

Comment on lines 694 to 695
vector<vector<Point2d>> detected_double = {{Point2d(0.,0.),Point2d(10.,0.),Point2d(10.,10.),Point2d(0.,10.)}};
vector<vector<Point2d>> detected_int = {{Point(0,0),Point(10,0),Point2d(10,10),Point2d(0,10)}};
Copy link
Contributor

Choose a reason for hiding this comment

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

The same test typePoint2d andPoint2d. Should it be2i in the second case?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

fixed:
vector<vector<Point2i>> detected_int = {{Point(0, 0), Point(10, 0), Point(10, 10), Point(0, 10)}};

@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch from587dc3f tofdec321CompareSeptember 11, 2023 07:56
@AleksandrPanovAleksandrPanov marked this pull request as draftSeptember 11, 2023 13:01
@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch fromfdec321 to8f24080CompareSeptember 11, 2023 16:43
for (size_t i =0ull; i <4ull; i++) {
m =moments(contours[i]);
detectedCenter =Point(cvRound(m.m10/m.m00),cvRound(m.m01/m.m00));
ASSERT_TRUE(find(detected_int[0].begin(), detected_int[0].end(), detectedCenter) != detected_int[0].end());
Copy link
Contributor

Choose a reason for hiding this comment

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

drawDetectedCornersCharuco is called for _float, but checked for _int. Also _double version is initialized, but not used.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

detected_int and detected_float are equal, using int will help to avoid rounding errors
the "_double" version will be added

@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch from8f24080 to100b163CompareSeptember 11, 2023 21:52
@AleksandrPanovAleksandrPanov marked this pull request as ready for reviewSeptember 11, 2023 21:53
@AleksandrPanovAleksandrPanovforce-pushed thefix_drawDetectedCornersCharuco_type_error branch from100b163 toae1d1b6CompareSeptember 12, 2023 09:18
Copy link
Contributor

@asmorkalovasmorkalov left a comment

Choose a reason for hiding this comment

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

👍

@asmorkalovasmorkalov merged commit9761492 intoopencv:4.xSep 12, 2023
@asmorkalovasmorkalov self-assigned thisSep 12, 2023
@asmorkalovasmorkalov mentioned this pull requestSep 28, 2023
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@asmorkalovasmorkalovasmorkalov approved these changes

Assignees

@asmorkalovasmorkalov

Projects

None yet

Milestone

4.9.0

Development

Successfully merging this pull request may close these issues.

2 participants

@AleksandrPanov@asmorkalov

[8]ページ先頭

©2009-2025 Movatter.jp