Skip to content

Fix unsigned int bug in computeECC#19993

Merged
alalek merged 4 commits intoopencv:3.4from
danielenricocahall:fix-compute-ecc-issue
Apr 30, 2021
Merged

Fix unsigned int bug in computeECC#19993
alalek merged 4 commits intoopencv:3.4from
danielenricocahall:fix-compute-ecc-issue

Conversation

@danielenricocahall
Copy link
Copy Markdown
Contributor

Addresses #14657. The problem in the original issue was they were using unsigned int values. This causes problems in the ECC computation, as subtracting the mean will result in certain being 0 instead of negative, and this impacts the dot product / norm.

I know this isn't pretty - the alternative solution is just raise an exception if a matrix of type CV_8U or CV_16U is supplied.

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.

Well done! Thank you for contribution

*/
if(type == CV_8U) {
templateMat.convertTo(templateMat, CV_16S);
inputMat.convertTo(inputMat, CV_16S);
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.

Please avoid inplace src / dst parameters.
Current implementation is ineffective (extra copy can be done due to non-inplace operation).

Use swap() to update "local" Mat.

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.

Done - thank you!

@alalek alalek merged commit 1b844f8 into opencv:3.4 Apr 30, 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.

2 participants