Commit Graph

3543 Commits

Author SHA1 Message Date
天音あめ
fa58c1205b
Merge pull request #27119 from amane-ame:warp_hal_rvv
Add RISC-V HAL implementation for cv::warp series #27119

This patch implements `cv_hal_remap`, `cv_hal_warpAffine` and `cv_hal_warpPerspective` using native intrinsics, optimizing the performance of `cv::remap/cv::warpAffine/cv::warpPerspective` for `CV_HAL_INTER_NEAREST/CV_HAL_INTER_LINEAR/CV_HAL_INTER_CUBIC/CV_HAL_INTER_LANCZOS4` modes.

Tested on MUSE-PI (Spacemit X60) for both gcc 14.2 and clang 20.0.

```
$ ./opencv_test_imgproc --gtest_filter="*Remap*:*Warp*"
$ ./opencv_perf_imgproc --gtest_filter="*Remap*:*remap*:*Warp*" --perf_min_samples=200 --perf_force_samples=200
```

View the full perf table here: [hal_rvv_warp.pdf](https://github.com/user-attachments/files/19403718/hal_rvv_warp.pdf)

### 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
- [ ] 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
2025-03-25 11:57:47 +03:00
Gianluca Nordio
931af518d9
Merge pull request #27139 from GianlucaNordio:patch-4
Fix minAreaRect and boxPoints docs (#26799) #27139

As requested from issue #26799 the docs regarding minAreaRect and boxPoints are extended specifying the order of the corners for boxPoints and the way the angle is computed for the rotated rect returned by minAreaRect
2025-03-25 09:30:56 +03:00
Scorpion1234567
2e9345570f
Merge pull request #27108 from Scorpion1234567:Multithreading-wrapPolar
When WARP_INVERSE_MAP is used, accelerate the calculation with multi-threading #27108

### 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
- [ ] 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
2025-03-20 17:46:18 +03:00
JavaTypedScript
259ec3674d fixed typo 2025-03-19 21:38:08 +05:30
Liutong HAN
fd62bd0991 Relax the loop condition to process the final batch. 2025-03-13 07:54:41 +00:00
Pierre Chatelier
d83df66ff0
Merge pull request #26834 from chacha21:findContours_speedup
Find contours speedup #26834

It is an attempt, as suggested by #26775, to restore lost speed when migrating `findContours()` implementation from C to C++

The patch adds an "Arena" (a pool) of pre-allocated memory so that contours points (and TreeNodes) can be picked from the Arena.
The code of `findContours()` is mostly unchanged, the arena usage being implicit through a utility class Arena::Item that provides C++ overloaded operators and construct/destruct logic.

As mentioned in #26775, the contour points are allocated and released in order, and can be represented by ranges of indices in their arena. No range subset will be released and drill a hole, that's why the internal representation as a range of indices makes sense.

The TreeNodes use another Arena class that does not comply to that range logic.

Currently, there is a significant improvement of the run-time on the test mentioned in #26775, but it is still far from the `findContours_legacy()` performance.


- [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
- [ ] 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
2025-03-12 18:00:01 +03:00
Pierre Chatelier
0db6a496ba
Merge pull request #26842 from chacha21:threshold_with_mask
Added optional mask to cv::threshold #26842
 
Proposal for #26777

To avoid code duplication, and keep performance when no mask is used, inner implementation always propagate the const cv::Mat& mask, but they use a template<bool useMask> parameter that let the compiler optimize out unnecessary tests when the mask is not to be used.

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.
- [ ] The feature is well documented and sample code can be built with the project CMake
2025-03-12 17:55:07 +03:00
Alexander Smorkalov
f833519506 Warning fix on Windows. 2025-03-11 11:17:20 +03:00
Alexander Smorkalov
4bb57ceb73
Merge pull request #26868 from FantasqueX/bayer2gray-simd-2
Use universal intrinsics in bayer2gray
2025-03-11 09:55:09 +03:00
Pierre Chatelier
e813326c17
Merge pull request #27039 from chacha21:threshold_otsu_doc_update
Threshold otsu doc update #27039 
 
PR for #27038

(I had already done that, but encounters git madness after branch renaming)

- [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
- [ ] 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
2025-03-10 19:40:45 +03:00
Alexander Smorkalov
40843d06ab Disable CV_SIMD_SCALABLE for demosaicing as the implementation is not efficient on RISC-V RVV. 2025-03-07 16:24:20 +03:00
Alexander Smorkalov
648424eaf2 Code review fixes. 2025-03-07 15:33:54 +03:00
Alexander Smorkalov
fbffaa5276 Warning fix. 2025-03-07 11:56:26 +03:00
天音あめ
cbcfd772ce
Merge pull request #26958 from amane-ame:pyramids_hal_rvv
Add RISC-V HAL implementation for cv::pyrDown and cv::pyrUp #26958

This patch implements `cv_hal_pyrdown/cv_hal_pyrup` function in RVV_HAL using native intrinsics, optimizing the performance for `cv::pyrDown`, `cv::pyrUp` and `cv::buildPyramids` with data types `{8U,16S,32F} x {C1,C2,C3,C4,Cn}`.

Tested on MUSE-PI (Spacemit X60) for both gcc 14.2 and clang 20.0.

```
$ ./opencv_test_imgproc --gtest_filter="*pyr*:*Pyr*"
$ ./opencv_perf_imgproc --gtest_filter="*pyr*:*Pyr*" --perf_min_samples=300 --perf_force_samples=300
```

<img width="1112" alt="Untitled" src="https://github.com/user-attachments/assets/235a9fba-0d29-434e-8a10-498212bac657" />


### 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
- [ ] 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
2025-03-04 15:41:15 +03:00
Maxim Smolskiy
dbd3ef9a6f
Merge pull request #26926 from MaximSmolskiy:fix-getPerspectiveTransform-for-singular-case
Fix getPerspectiveTransform for singular case #26926

### Pull Request Readiness Checklist

Fix #26916 

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
2025-03-02 12:44:39 +03:00
Alexander Smorkalov
acc9084044 Move OpenVX integrations to imgproc to OpenVX HAL
Covered functions:
- medianBlur
- Sobel
- Canny
- pyrDown
- BoxFilter
- equalizeHist
- GaussianBlur
- remap
- threshold
2025-02-15 09:55:37 +03:00
shyama7004
076bfa6431 Fix _DEBUG/NDEBUG handling across modules (#26151) 2025-02-11 22:00:44 +05:30
Letu Ren
0fa61de22a Fix bayer2RGB_EA macro 2025-02-03 14:19:52 +08:00
Letu Ren
d6dc22d03c Fix build on RISC-V 2025-02-03 00:09:36 +08:00
shyama7004
0cfc2e8fd8 minor change 2025-01-31 21:12:36 +05:30
Skreg
e62ab4ff71
Merge pull request #26850 from shyama7004:update-headers
Update includes in filter.hpp #26850

Fixes :
```
identifier "Mat" is undefinedC/C++(20)
namespace "std" has no member "vector"C/C++(135)
```

### 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
- [ ] 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
2025-01-28 07:26:40 +03:00
Vincent Rabaud
c5f6ed6fef Fix overlow pointers.
`step` and `maskStep` are used to increase/decrease `pImage`.
But it's done on unsigned type, relying on overflow, which is UB.
(step is size_t but seed.y is int and can be negative, the result
is therefore unsigned which can overflow)
2025-01-27 11:55:10 +01:00
Pierre Chatelier
3cbb4acd2d
Merge pull request #26836 from chacha21:thresholding_compute_threshold_only
Add cv::THRESH_DRYRUN flag to get adaptive threshold values without thresholding #26836

A first proposal for #26777

Adds a `cv::THRESH_DRYRUN` flag to let cv::threshold() compute the threshold (useful for OTSU/TRIANGLE), but without actually running the thresholding. This flags is a proposal instead of a new function cv::computeThreshold()

- [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.
- [ ] The feature is well documented and sample code can be built with the project CMake
2025-01-24 14:25:21 +03:00
Maxim Smolskiy
8ab0ad6e1b
Merge pull request #26810 from MaximSmolskiy:improve-robustness-for-fitEllipseAMS
Improve robustness for fitEllipseAMS #26810

### Pull Request Readiness Checklist

Related to #26694 

Added functionality to add noise to points in degenerate cases and try again for `fitEllipseAMS`. `fitEllipseNoDirect` and `fitEllipseDirect` already have this

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
2025-01-22 12:49:12 +03:00
Alexander Smorkalov
459bb12466
Merge pull request #26778 from vidipsingh:doc-fix-fontscale-behavior-puttext
Added fontScale behavior description to putText() documentation
2025-01-21 11:21:42 +03:00
Skreg
fe9405e8c0
Merge pull request #26806 from shyama7004:fix-typo
* fix a small typo

* removal of unused variable
2025-01-20 17:14:27 +03:00
Maxim Smolskiy
a2a3f5e86c
Merge pull request #26773 from MaximSmolskiy:improve-robustness-for-ellipse-fitting
Improve robustness for ellipse fitting #26773

### Pull Request Readiness Checklist

Related to #26694 

Current noise addition is not very good because for example it turns degenerate case of one horizontal line into degenerate case of two parallel horizontal lines

Improving noise addition leads to improved robustness of algorithms

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
2025-01-20 14:25:40 +03:00
MaximSmolskiy
500e1ff763 Fix typo in matchTemplate description 2025-01-19 17:31:03 +03:00
Vidip Singh
6ba8f4838b Added fontScale behavior description to putText() documentation
- Updated the documentation of the putText function to clarify the behavior of the fontScale parameter.
- Explained how fontScale affects text rendering: magnifying (>1), minimizing (<1), and mirroring (<0).
2025-01-15 19:17:29 +05:30
Vincent Rabaud
e76924ef0d Don't overflow pointer addition
In both cases we add negative value (as unsigned type), so
pointer addition wraps, which is undefined behavior.
2025-01-15 11:07:43 +01:00
Yannis Guyon
b62ab874d1
Avoid adding value to nullptr
This UB can be avoided by postponing calculation until needed.
2025-01-14 10:50:53 +01:00
Vincent Rabaud
bfb54aa691 Remove useless C headers 2025-01-13 16:34:28 +01:00
Diego1V
052b2c43c3 Update types inside HoughLinesProbabilistic in order to handle great images. 2025-01-13 09:36:44 +03:00
Alexander Smorkalov
38b86591ba
Merge pull request #26729 from MaximSmolskiy:change-article-for-fitEllipseDirect-function
Change article for fitEllipseDirect function
2025-01-08 12:14:45 +03:00
Alexander Smorkalov
e34eff9ab2
Merge pull request #26721 from MaximSmolskiy:fix-comment-for-fitEllipse-Java-case-accurracy-test
Fix comment for fitEllipse Java case accurracy test
2025-01-08 11:09:32 +03:00
Alexander Smorkalov
0dfd2b3628
Merge pull request #26719 from MaximSmolskiy:remove-code-duplication-from-tests-for-ellipse-fitting
Remove code duplication from tests for ellipse fitting
2025-01-08 11:07:55 +03:00
MaximSmolskiy
0331af01ae Change article for fitEllipseDirect function 2025-01-07 22:24:48 +03:00
MaximSmolskiy
9b85ab0a63 Fix comment for fitEllipse Java case accurracy test 2025-01-06 19:14:57 +03:00
MaximSmolskiy
56dd9d51b1 Remove code duplication from tests for ellipse fitting 2025-01-06 17:13:32 +03:00
Masahiro Ogawa
fc994a6ae8
Merge pull request #21407 from sensyn-robotics:feature/weighted_hough
Feature: weighted Hough Transform #21407

### 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 other license that is incompatible with OpenCV
- [x] The PR is proposed to proper branch
- [x] There is reference to 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
2025-01-06 15:35:35 +03:00
MaximSmolskiy
3e534bb7c8 Fix tests for ellipse fitting 2025-01-06 01:27:06 +03:00
MaximSmolskiy
f15fa21c6b Speed up and reduce memory consumption for findContours 2024-12-31 02:49:15 +03:00
Alexander Alekhin
09892c9d17 fix FFmpeg wrapper build 2024-12-26 12:15:46 +00:00
Maksim Shabunin
0756dbfe3d RISC-V: enabled intrinsics in dotProd, relaxed test thresholds 2024-12-24 00:58:54 +03:00
Letu Ren
f1a775825f Use universal intrinsics in bayer2Gray 2024-12-21 23:29:39 +08:00
Alexander Smorkalov
cdad0b7027
Merge pull request #26082 from mshabunin:fix-hal-cvt-functions
imgproc: restore multiplanar conversion functions in cv::hal namespace
2024-12-19 11:56:04 +03:00
Alexander Smorkalov
ebf3c400d2
Merge pull request #26387 from sturkmen72:js-imgproc
Add some functions to OpenCV JS API
2024-12-19 09:45:23 +03:00
Letu Ren
428d93114f fix typo 2024-12-19 10:59:17 +08:00
Kumataro
260f511dfb
Merge pull request #26590 from Kumataro:fix26589
Support C++20 standard #26590

Close https://github.com/opencv/opencv/issues/26589
Related https://github.com/opencv/opencv_contrib/pull/3842
Related: https://github.com/opencv/opencv/issues/20269

- do not arithmetic enums and ( different enums or floating numeric) 
- remove unused variable

### 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
2024-12-17 07:40:27 +03:00
Alexander Smorkalov
03cedee0b0
Merge pull request #26547 from mshabunin:fix-type-cast
Fixed several cases of unaligned pointer cast
2024-12-03 11:08:45 +03:00