You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Problem is in using Mat::mul method when second argument is Matx41d - in the end it calls arithm_op but second argument is casted to Mat before, but in arithm_op there is logic which relies on arguments perfect forwarding and it stops working
@MaximSmolskiy, thank you for the patch. It looks like those matrix expression-based calculations are often done on single-element scalars, and the only reason why cv::Scalar and div are used is because cv::sum() returns a scalar, rather than, say, double. I wonder, if we change mask_sum definition to:
double mask_sum = sum(mask)[0];
maybe the patch can be further simplified and some of matrix expressions could be replaced with simple arithmetic operations (which is much faster)?
thank you for the patch. It looks like those matrix expression-based calculations are often done on single-element scalars, and the only reason why cv::Scalar and div are used is because cv::sum() returns a scalar, rather than, say, double. I wonder, if we change mask_sum definition to:
double mask_sum = sum(mask)[0];
maybe the patch can be further simplified and some of matrix expressions could be replaced with simple arithmetic operations (which is much faster)?
@vpisarev Then this will probably require adding additional branches, because in some cases mask_sum has several different elements:
[ RUN ] MultiChannelMask/Imgproc_MatchTemplateWithMask.CompareNaiveImplCCOEFF/0, where GetParam() = (32FC3, 32FC3)
mask_sum = [678.275, 646.07, 686.876, 0]
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Pull Request Readiness Checklist
Fix #26389
Problem is in using
Mat::mul
method when second argument isMatx41d
- in the end it callsarithm_op
but second argument is casted toMat
before, but inarithm_op
there is logic which relies on arguments perfect forwarding and it stops workingopencv/modules/core/src/arithm.cpp
Lines 642 to 644 in 4d26e16
multiply
function is equivalent toMat::mul
method (I hope so) with second argument perfect forwarding, so necessary logic continues to workSee details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request
Patch to opencv_extra has the same branch name.