Added flag to GaussianBlur for faster but not bit-exact implementation#25792
Added flag to GaussianBlur for faster but not bit-exact implementation#25792asmorkalov merged 8 commits intoopencv:4.xfrom
Conversation
1c62df7 to
b5df286
Compare
671ce14 to
ea56bd9
Compare
|
Discussion result:
|
|
@mshabunin @opencv-alalek @vpisarev I reworked interface as discussed offline and added accuracy tests for IPP branch. Could you take a look? |
a753443 to
8fa2e47
Compare
| cv::absdiff(dst, gt, diff); | ||
| cv::Mat flatten_diff = diff.reshape(1, diff.rows); | ||
|
|
||
| int nz = countNonZero(flatten_diff); |
There was a problem hiding this comment.
norm is faster than countNonZero approach.
Use relative NORM_L1/L2 and NORM_INF instead.
There was a problem hiding this comment.
I intentionally split the check on min-max deviation and amount of different pixels.
There was a problem hiding this comment.
EXPECT_LE(max_val, 2); // expectes results floating +-1
comment doesn't follow to the check anyway.
NORM_INF <=1 works perfect.
With 1-limited NORM_INF, we could use NORM_L1 + RELATIVE to define the part of pixels of different values.
|
@opencv-alalek I fixed your review notes. Please take a look again. |
a47f442 to
ee840b5
Compare
ee840b5 to
13b6caa
Compare
| ALGO_APPROX = 2, //!< Allow alternative approximations to get faster implementation. Behaviour and result depends on a platform | ||
| }; | ||
|
|
||
| /*! @brief Returns ImplementationHint selected by default, a.k.a. `IMPL_DEFAULT` defined during OpenCV compilation. |
There was a problem hiding this comment.
ImplementationHint
not renamed
IMPL_DEFAULT
What is that?
| */ | ||
| enum AlgorithmHint { | ||
| ALGO_DEFAULT = 0, //!< Default algorithm behaviour defined during OpenCV build | ||
| ALGO_ACCURATE = 1, //!< Use generic portable implementation |
| #include <iostream> | ||
| #include <ostream> | ||
|
|
||
| #include <opencv2/core.hpp> |
|
|
||
| /*! @brief Returns ImplementationHint selected by default, a.k.a. `IMPL_DEFAULT` defined during OpenCV compilation. | ||
| */ | ||
| CV_EXPORTS_W AlgorithmHint getDefaultAlgorithmHint(); |
There was a problem hiding this comment.
Should go to utility.hpp somewhere near setUseOptimized()
There was a problem hiding this comment.
setUseOptimized() should also control behavior of that:
setUseOptimized(false)disables these hints and use accurate versions.
| cv::absdiff(dst, gt, diff); | ||
| cv::Mat flatten_diff = diff.reshape(1, diff.rows); | ||
|
|
||
| int nz = countNonZero(flatten_diff); |
There was a problem hiding this comment.
EXPECT_LE(max_val, 2); // expectes results floating +-1
comment doesn't follow to the check anyway.
NORM_INF <=1 works perfect.
With 1-limited NORM_INF, we could use NORM_L1 + RELATIVE to define the part of pixels of different values.
Added xxxApprox overloads for YUV color conversions in HAL and AlgorithmHint to cvtColor #25932 The xxxApprox to implement HAL functions with less bits for arithmetic of FP. The hint was introduced in #25792 and #25911 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Added flag to GaussianBlur for faster but not bit-exact implementation opencv#25792 Rationale: Current implementation of GaussianBlur is almost always bit-exact. It helps to get predictable results according platforms, but prohibits most of approximations and optimization tricks. The patch converts `borderType` parameter to more generic `flags` and introduces `GAUSS_ALLOW_APPROXIMATIONS` flag to allow not bit-exact implementation. With the flag IPP and generic HAL implementation are called first. The flag naming and location is a subject for discussion. Replaces opencv#22073 Possibly related issue: opencv#24135 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] 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
Added xxxApprox overloads for YUV color conversions in HAL and AlgorithmHint to cvtColor opencv#25932 The xxxApprox to implement HAL functions with less bits for arithmetic of FP. The hint was introduced in opencv#25792 and opencv#25911 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Added flag to GaussianBlur for faster but not bit-exact implementation opencv#25792 Rationale: Current implementation of GaussianBlur is almost always bit-exact. It helps to get predictable results according platforms, but prohibits most of approximations and optimization tricks. The patch converts `borderType` parameter to more generic `flags` and introduces `GAUSS_ALLOW_APPROXIMATIONS` flag to allow not bit-exact implementation. With the flag IPP and generic HAL implementation are called first. The flag naming and location is a subject for discussion. Replaces opencv#22073 Possibly related issue: opencv#24135 See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] 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
Added flag to GaussianBlur for faster but not bit-exact implementation opencv#25792 Rationale: Current implementation of GaussianBlur is almost always bit-exact. It helps to get predictable results according platforms, but prohibits most of approximations and optimization tricks. The patch converts `borderType` parameter to more generic `flags` and introduces `GAUSS_ALLOW_APPROXIMATIONS` flag to allow not bit-exact implementation. With the flag IPP and generic HAL implementation are called first. The flag naming and location is a subject for discussion. Replaces opencv#22073 Possibly related issue: opencv#24135 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] 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
Added flag to GaussianBlur for faster but not bit-exact implementation opencv#25792 Rationale: Current implementation of GaussianBlur is almost always bit-exact. It helps to get predictable results according platforms, but prohibits most of approximations and optimization tricks. The patch converts `borderType` parameter to more generic `flags` and introduces `GAUSS_ALLOW_APPROXIMATIONS` flag to allow not bit-exact implementation. With the flag IPP and generic HAL implementation are called first. The flag naming and location is a subject for discussion. Replaces opencv#22073 Possibly related issue: opencv#24135 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] 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
Added flag to GaussianBlur for faster but not bit-exact implementation opencv#25792 Rationale: Current implementation of GaussianBlur is almost always bit-exact. It helps to get predictable results according platforms, but prohibits most of approximations and optimization tricks. The patch converts `borderType` parameter to more generic `flags` and introduces `GAUSS_ALLOW_APPROXIMATIONS` flag to allow not bit-exact implementation. With the flag IPP and generic HAL implementation are called first. The flag naming and location is a subject for discussion. Replaces opencv#22073 Possibly related issue: opencv#24135 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [ ] There is a reference to the original bug report and related work - [x] 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
Added xxxApprox overloads for YUV color conversions in HAL and AlgorithmHint to cvtColor opencv#25932 The xxxApprox to implement HAL functions with less bits for arithmetic of FP. The hint was introduced in opencv#25792 and opencv#25911 ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] 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 - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
Rationale:
Current implementation of GaussianBlur is almost always bit-exact. It helps to get predictable results according platforms, but prohibits most of approximations and optimization tricks.
The patch converts
borderTypeparameter to more genericflagsand introducesGAUSS_ALLOW_APPROXIMATIONSflag to allow not bit-exact implementation. With the flag IPP and generic HAL implementation are called first. The flag naming and location is a subject for discussion.Replaces #22073
Possibly related issue: #24135
Pull Request Readiness Checklist
See 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.