Skip to content

Commit 1950c4d

Browse files
authored
Merge pull request #27379 from cudawarped:fix_cuda_convertTo
cuda: Fix GpuMat::convertTo issues described in 27373 #27379 Fix #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
1 parent 2ffca50 commit 1950c4d

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

modules/core/include/opencv2/core/cuda.hpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,10 @@ class CV_EXPORTS_W GpuMat
240240

241241
//! converts GpuMat to another datatype (Blocking call)
242242
void convertTo(OutputArray dst, int rtype) const;
243+
//! bindings overload which converts GpuMat to another datatype (Blocking call)
244+
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype) const {
245+
convertTo(static_cast<OutputArray>(dst), rtype);
246+
}
243247

244248
//! converts GpuMat to another datatype (Non-Blocking call)
245249
void convertTo(OutputArray dst, int rtype, Stream& stream) const;
@@ -250,10 +254,13 @@ class CV_EXPORTS_W GpuMat
250254

251255
//! converts GpuMat to another datatype with scaling (Blocking call)
252256
void convertTo(OutputArray dst, int rtype, double alpha, double beta = 0.0) const;
257+
253258
//! bindings overload which converts GpuMat to another datatype with scaling(Blocking call)
254-
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype, double alpha = 1.0, double beta = 0.0) const {
259+
#ifdef OPENCV_BINDINGS_PARSER
260+
CV_WRAP void convertTo(CV_OUT GpuMat& dst, int rtype, double alpha=1.0, double beta = 0.0) const {
255261
convertTo(static_cast<OutputArray>(dst), rtype, alpha, beta);
256262
}
263+
#endif
257264

258265
//! converts GpuMat to another datatype with scaling (Non-Blocking call)
259266
void convertTo(OutputArray dst, int rtype, double alpha, Stream& stream) const;

modules/core/src/cuda/gpu_mat.cu

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, Stream& stream) co
546546
return;
547547
}
548548

549-
CV_DbgAssert( sdepth <= CV_64F && ddepth <= CV_64F );
549+
CV_Assert( sdepth <= CV_64F && ddepth <= CV_64F );
550550

551551
GpuMat src = *this;
552552

@@ -578,6 +578,8 @@ void cv::cuda::GpuMat::convertTo(OutputArray _dst, int rtype, double alpha, doub
578578
const int sdepth = depth();
579579
const int ddepth = CV_MAT_DEPTH(rtype);
580580

581+
CV_Assert(sdepth <= CV_64F && ddepth <= CV_64F);
582+
581583
GpuMat src = *this;
582584

583585
_dst.create(size(), rtype);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy