1
0
mirror of https://github.com/opencv/opencv_contrib.git synced 2025-10-21 14:41:58 +08:00

16 Commits

Author SHA1 Message Date
Troels Ynddal
84024547e3 Merge pull request #3970 from troelsy:4.x
Fix race condition in Otsu's method #3970

I found that in some cases, Otsu's method can have two or more equal thresholds. In case of the CUDA implementation, this would create a race-condition where the last thread to write the output gets to choose which Otsu threshold to use. The resulting image from cv::cuda::threshold would be the same, but the returned threshold would vary for each run.

I solve this by first doing a poll to check if there are multiple matches with `__syncthreads_count`. If not, we can return the threshold as before. If there are more than one, the kernel does a minimum reduction to find the lowest threshold that matches the otsu score. It doesn't matter which threshold you choose as long as it is consistent, so I choose the smallest one.

I'm unsure when `__syncthreads_count` as introduced, but it is compatible with CC≥2.0. CUDA Toolkit's archive only goes back to version 8.0, but it was documented back then (https://docs.nvidia.com/cuda/archive)


### 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-07-17 09:36:33 +03:00
Troels Ynddal
6329974d4d Merge pull request #3943 from troelsy:4.x
Add Otsu's method to cv::cuda::threshold #3943

I implemented Otsu's method in CUDA for a separate project and want to add it to cv::cuda::threshold

I have made an effort to use existing OpenCV functions in my code, but I had some trouble with `ThresholdTypes` and `cv::cuda::calcHist`. I couldn't figure out how to include `precomp.hpp` to get the definition of `ThresholdTypes`. For `cv::cuda::calcHist` I tried adding `opencv_cudaimgproc`, but it creates a circular dependency on `cudaarithm`. I have include a simple implementation of `calcHist` so the code runs, but I would like input on how to use `cv::cuda::calcHist` instead. 

### 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-06-19 16:38:53 +03:00
Pierre Chatelier
667a66ee0e Merge pull request #3607 from chacha21:cuda_phase_interleaved
Add interleaved versions of phase/cartToPolar/polarToCart #3607

This PR is for performance only (at the cost of more template code and increased GPU code size) The additional variants can help the caller skip the creation of temporary GPU mats (where memory is more likely to be a critical resource), and can even allow in-place processing. magnitude/angles/x/y are often already interleaved when dealing with DFTs.

### 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.
- [X] The feature is well documented and sample code can be built with the project CMake
2024-07-22 16:00:24 +03:00
Alexander Smorkalov
51de5807e8 Set of build fixes for ## 3580, 3574. 2023-10-26 20:19:11 +03:00
Alexander Alekhin
dd8be233ad Merge pull request #3191 from asmorkalov:as/cuda_meanstddev 2022-03-11 17:53:49 +00:00
Alexander Smorkalov
df101fd7e3 Added 32FC1 type support and mask to cuda::meanStdDev implementation. 2022-03-11 08:33:03 +03:00
cudawarped
55cbe767ac Add locateROI test case to check GpuMat::dataend calculation. 2022-02-02 14:26:56 +00:00
cudawarped
fdb53d633d Merge pull request #3144 from cudawarped:test_cuda_event
Test cv::cuda::event
2022-01-11 23:58:30 +03:00
Aaron Miller
f1c0b5eae6 Implement cv::cuda::inRange (Fixes OpenCV #6295) 2021-01-18 21:50:41 -05:00
Tomoaki Teshima
46dba0f855 [moved from opencv] brush up by following the comments
original commit: 234117800f
2020-09-25 23:57:15 +09:00
Tomoaki Teshima
2ae9011019 [moved from opencv] use only even number for inplace flip
original commit: a61546680b
2020-09-16 15:45:03 +09:00
Namgoo Lee
b364cfed1d [moved from opencv] test code
original commit: 11ac26bfb4
2020-07-30 01:42:44 +09:00
Tomoaki Teshima
ccc5f3293a [moved from opencv] let the test pass on Jetson
original commit: 19646ad049
2020-07-25 23:45:51 +09:00
Namgoo Lee
3ba40a5316 Port opencv/#17863 2020-07-22 16:30:03 +09:00
Hamdi Sahloul
96320cacfc [moved from opencv] cuda::polarToCart: test double precision and tune tolerance
original commit: 9932612373
2018-09-22 07:02:43 +09:00
Alexander Alekhin
82733fe56b cuda: move CUDA modules to opencv_contrib
OpenCV 4.0+
2018-09-19 18:57:43 +03:00