1
0
mirror of https://github.com/opencv/opencv.git synced 2026-07-21 19:33:03 +04:00

Merge pull request #27379 from cudawarped:fix_cuda_convertTo

cuda: Fix GpuMat::convertTo issues described in 27373 #27379

Fix https://github.com/opencv/opencv/issues/27373.

1. `GpuMat::convertTo` uses `convertToScale` due to incorrect overload.
2. There are no runtime checks to prevent the use of `CV_16U` data types in Release builds.

### 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
This commit is contained in:
cudawarped
2025-06-21 16:32:31 +03:00
committed by GitHub
parent 2ffca501e7
commit 1950c4dbb9
2 changed files with 11 additions and 2 deletions
+8 -1
View File
@@ -240,6 +240,10 @@ public:
//! converts GpuMat to another datatype (Blocking call)
void convertTo(OutputArray dst, int rtype) const;
//! bindings overload which converts GpuMat to another datatype (Blocking call)
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype) const {
convertTo(static_cast<OutputArray>(dst), rtype);
}
//! converts GpuMat to another datatype (Non-Blocking call)
void convertTo(OutputArray dst, int rtype, Stream& stream) const;
@@ -250,10 +254,13 @@ public:
//! converts GpuMat to another datatype with scaling (Blocking call)
void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const;
//! bindings overload which converts GpuMat to another datatype with scaling(Blocking call)
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype, double alpha = 1.0, double beta = 0.0) const {
#ifdef OPENCV_BINDINGS_PARSER
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype, double alpha=1.0, double beta = 0.0) const {
convertTo(static_cast<OutputArray>(dst), rtype, alpha, beta);
}
#endif
//! converts GpuMat to another datatype with scaling (Non-Blocking call)
void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const;
+3 -1
View File
@@ -546,7 +546,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co
return;
}
CV_DbgAssert( sdepth <= CV_64F && ddepth <= CV_64F );
CV_Assert( sdepth <= CV_64F && ddepth <= CV_64F );
GpuMat src = *this;
@@ -578,6 +578,8 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, doub
const int sdepth = depth();
const int ddepth = CV_MAT_DEPTH(rtype);
CV_Assert(sdepth <= CV_64F && ddepth <= CV_64F);
GpuMat src = *this;
_dst.create(size(), rtype);