switched to Input/Output Array in gpu::threshold
This commit is contained in:
@@ -131,6 +131,9 @@ static inline void scaleAdd(InputArray src1, double alpha, InputArray src2, Outp
|
|||||||
addWeighted(src1, alpha, src2, 1.0, 0.0, dst, -1, stream);
|
addWeighted(src1, alpha, src2, 1.0, 0.0, dst, -1, stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! applies fixed threshold to the image
|
||||||
|
CV_EXPORTS double threshold(InputArray src, OutputArray dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());
|
||||||
|
|
||||||
//! implements generalized matrix product algorithm GEMM from BLAS
|
//! implements generalized matrix product algorithm GEMM from BLAS
|
||||||
CV_EXPORTS void gemm(const GpuMat& src1, const GpuMat& src2, double alpha,
|
CV_EXPORTS void gemm(const GpuMat& src1, const GpuMat& src2, double alpha,
|
||||||
const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null());
|
const GpuMat& src3, double beta, GpuMat& dst, int flags = 0, Stream& stream = Stream::Null());
|
||||||
@@ -256,9 +259,6 @@ CV_EXPORTS void rectStdDev(const GpuMat& src, const GpuMat& sqr, GpuMat& dst, co
|
|||||||
CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType,
|
CV_EXPORTS void copyMakeBorder(const GpuMat& src, GpuMat& dst, int top, int bottom, int left, int right, int borderType,
|
||||||
const Scalar& value = Scalar(), Stream& stream = Stream::Null());
|
const Scalar& value = Scalar(), Stream& stream = Stream::Null());
|
||||||
|
|
||||||
//! applies fixed threshold to the image
|
|
||||||
CV_EXPORTS double threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxval, int type, Stream& stream = Stream::Null());
|
|
||||||
|
|
||||||
//! computes the integral image
|
//! computes the integral image
|
||||||
//! sum will have CV_32S type, but will contain unsigned int values
|
//! sum will have CV_32S type, but will contain unsigned int values
|
||||||
//! supports only CV_8UC1 source type
|
//! supports only CV_8UC1 source type
|
||||||
|
@@ -75,7 +75,7 @@ void cv::gpu::max(InputArray, InputArray, OutputArray, Stream&) { throw_no_cuda(
|
|||||||
|
|
||||||
void cv::gpu::addWeighted(InputArray, double, InputArray, double, double, OutputArray, int, Stream&) { throw_no_cuda(); }
|
void cv::gpu::addWeighted(InputArray, double, InputArray, double, double, OutputArray, int, Stream&) { throw_no_cuda(); }
|
||||||
|
|
||||||
double cv::gpu::threshold(const GpuMat&, GpuMat&, double, double, int, Stream&) {throw_no_cuda(); return 0.0;}
|
double cv::gpu::threshold(InputArray, OutputArray, double, double, int, Stream&) {throw_no_cuda(); return 0.0;}
|
||||||
|
|
||||||
void cv::gpu::magnitude(const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
void cv::gpu::magnitude(const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||||
void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
void cv::gpu::magnitude(const GpuMat&, const GpuMat&, GpuMat&, Stream&) { throw_no_cuda(); }
|
||||||
@@ -2938,8 +2938,10 @@ namespace arithm
|
|||||||
void threshold(PtrStepSzb src, PtrStepSzb dst, double thresh, double maxVal, int type, cudaStream_t stream);
|
void threshold(PtrStepSzb src, PtrStepSzb dst, double thresh, double maxVal, int type, cudaStream_t stream);
|
||||||
}
|
}
|
||||||
|
|
||||||
double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double maxVal, int type, Stream& s)
|
double cv::gpu::threshold(InputArray _src, OutputArray _dst, double thresh, double maxVal, int type, Stream& _stream)
|
||||||
{
|
{
|
||||||
|
GpuMat src = _src.getGpuMat();
|
||||||
|
|
||||||
const int depth = src.depth();
|
const int depth = src.depth();
|
||||||
|
|
||||||
CV_Assert( src.channels() == 1 && depth <= CV_64F );
|
CV_Assert( src.channels() == 1 && depth <= CV_64F );
|
||||||
@@ -2951,9 +2953,10 @@ double cv::gpu::threshold(const GpuMat& src, GpuMat& dst, double thresh, double
|
|||||||
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
CV_Error(cv::Error::StsUnsupportedFormat, "The device doesn't support double");
|
||||||
}
|
}
|
||||||
|
|
||||||
dst.create(src.size(), src.type());
|
_dst.create(src.size(), src.type());
|
||||||
|
GpuMat dst = _dst.getGpuMat();
|
||||||
|
|
||||||
cudaStream_t stream = StreamAccessor::getStream(s);
|
cudaStream_t stream = StreamAccessor::getStream(_stream);
|
||||||
|
|
||||||
if (src.type() == CV_32FC1 && type == 2/*THRESH_TRUNC*/)
|
if (src.type() == CV_32FC1 && type == 2/*THRESH_TRUNC*/)
|
||||||
{
|
{
|
||||||
|
@@ -2526,6 +2526,54 @@ INSTANTIATE_TEST_CASE_P(GPU_Arithm, AddWeighted, testing::Combine(
|
|||||||
ALL_DEPTH,
|
ALL_DEPTH,
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
|
// Threshold
|
||||||
|
|
||||||
|
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
|
||||||
|
#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV))
|
||||||
|
|
||||||
|
PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi)
|
||||||
|
{
|
||||||
|
cv::gpu::DeviceInfo devInfo;
|
||||||
|
cv::Size size;
|
||||||
|
int type;
|
||||||
|
int threshOp;
|
||||||
|
bool useRoi;
|
||||||
|
|
||||||
|
virtual void SetUp()
|
||||||
|
{
|
||||||
|
devInfo = GET_PARAM(0);
|
||||||
|
size = GET_PARAM(1);
|
||||||
|
type = GET_PARAM(2);
|
||||||
|
threshOp = GET_PARAM(3);
|
||||||
|
useRoi = GET_PARAM(4);
|
||||||
|
|
||||||
|
cv::gpu::setDevice(devInfo.deviceID());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
GPU_TEST_P(Threshold, Accuracy)
|
||||||
|
{
|
||||||
|
cv::Mat src = randomMat(size, type);
|
||||||
|
double maxVal = randomDouble(20.0, 127.0);
|
||||||
|
double thresh = randomDouble(0.0, maxVal);
|
||||||
|
|
||||||
|
cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi);
|
||||||
|
cv::gpu::threshold(loadMat(src, useRoi), dst, thresh, maxVal, threshOp);
|
||||||
|
|
||||||
|
cv::Mat dst_gold;
|
||||||
|
cv::threshold(src, dst_gold, thresh, maxVal, threshOp);
|
||||||
|
|
||||||
|
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
INSTANTIATE_TEST_CASE_P(GPU_Arithm, Threshold, testing::Combine(
|
||||||
|
ALL_DEVICES,
|
||||||
|
DIFFERENT_SIZES,
|
||||||
|
testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)),
|
||||||
|
ALL_THRESH_OPS,
|
||||||
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Magnitude
|
// Magnitude
|
||||||
|
|
||||||
@@ -2744,52 +2792,4 @@ INSTANTIATE_TEST_CASE_P(GPU_Arithm, PolarToCart, testing::Combine(
|
|||||||
testing::Values(AngleInDegrees(false), AngleInDegrees(true)),
|
testing::Values(AngleInDegrees(false), AngleInDegrees(true)),
|
||||||
WHOLE_SUBMAT));
|
WHOLE_SUBMAT));
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
|
||||||
// Threshold
|
|
||||||
|
|
||||||
CV_ENUM(ThreshOp, cv::THRESH_BINARY, cv::THRESH_BINARY_INV, cv::THRESH_TRUNC, cv::THRESH_TOZERO, cv::THRESH_TOZERO_INV)
|
|
||||||
#define ALL_THRESH_OPS testing::Values(ThreshOp(cv::THRESH_BINARY), ThreshOp(cv::THRESH_BINARY_INV), ThreshOp(cv::THRESH_TRUNC), ThreshOp(cv::THRESH_TOZERO), ThreshOp(cv::THRESH_TOZERO_INV))
|
|
||||||
|
|
||||||
PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, UseRoi)
|
|
||||||
{
|
|
||||||
cv::gpu::DeviceInfo devInfo;
|
|
||||||
cv::Size size;
|
|
||||||
int type;
|
|
||||||
int threshOp;
|
|
||||||
bool useRoi;
|
|
||||||
|
|
||||||
virtual void SetUp()
|
|
||||||
{
|
|
||||||
devInfo = GET_PARAM(0);
|
|
||||||
size = GET_PARAM(1);
|
|
||||||
type = GET_PARAM(2);
|
|
||||||
threshOp = GET_PARAM(3);
|
|
||||||
useRoi = GET_PARAM(4);
|
|
||||||
|
|
||||||
cv::gpu::setDevice(devInfo.deviceID());
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
GPU_TEST_P(Threshold, Accuracy)
|
|
||||||
{
|
|
||||||
cv::Mat src = randomMat(size, type);
|
|
||||||
double maxVal = randomDouble(20.0, 127.0);
|
|
||||||
double thresh = randomDouble(0.0, maxVal);
|
|
||||||
|
|
||||||
cv::gpu::GpuMat dst = createMat(src.size(), src.type(), useRoi);
|
|
||||||
cv::gpu::threshold(loadMat(src, useRoi), dst, thresh, maxVal, threshOp);
|
|
||||||
|
|
||||||
cv::Mat dst_gold;
|
|
||||||
cv::threshold(src, dst_gold, thresh, maxVal, threshOp);
|
|
||||||
|
|
||||||
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
INSTANTIATE_TEST_CASE_P(GPU_Arithm, Threshold, testing::Combine(
|
|
||||||
ALL_DEVICES,
|
|
||||||
DIFFERENT_SIZES,
|
|
||||||
testing::Values(MatType(CV_8UC1), MatType(CV_16SC1), MatType(CV_32FC1)),
|
|
||||||
ALL_THRESH_OPS,
|
|
||||||
WHOLE_SUBMAT));
|
|
||||||
|
|
||||||
#endif // HAVE_CUDA
|
#endif // HAVE_CUDA
|
||||||
|
Reference in New Issue
Block a user