mirror of
https://github.com/opencv/opencv.git
synced 2025-01-18 22:44:02 +08:00
spatialGradient: Add asserts
This commit is contained in:
parent
9f1c641199
commit
11fb1f74cc
@ -45,12 +45,24 @@
|
||||
namespace cv
|
||||
{
|
||||
|
||||
void spatialGradient( InputArray src, OutputArray dx, OutputArray dy, int ksize )
|
||||
void spatialGradient( InputArray _src, OutputArray _dx, OutputArray _dy, int ksize )
|
||||
{
|
||||
|
||||
Mat src = _src.getMat();
|
||||
CV_Assert(!src.empty());
|
||||
CV_Assert(src.isContinuous());
|
||||
CV_Assert(src.type() == CV_8UC1);
|
||||
|
||||
_dx.create(src.size(), CV_16SC1);
|
||||
_dy.create(src.size(), CV_16SC1);
|
||||
Mat dx = _dx.getMat(),
|
||||
dy = _dy.getMat();
|
||||
CV_Assert(dx.isContinuous());
|
||||
CV_Assert(dy.isContinuous());
|
||||
|
||||
// TODO: Vectorize using hal intrinsics
|
||||
Sobel( src, dx, CV_16S, 1, 0, 3 );
|
||||
Sobel( src, dy, CV_16S, 0, 1, 3 );
|
||||
Sobel( src, dx, CV_16SC1, 1, 0, ksize );
|
||||
Sobel( src, dy, CV_16SC1, 0, 1, ksize );
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -582,9 +582,12 @@ void CV_SpatialGradientTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
|
||||
sizes[OUTPUT][1] = sizes[REF_OUTPUT][1] = sizes[OUTPUT][0];
|
||||
|
||||
// Only CV_16S1 for now
|
||||
types[INPUT][0] = types[OUTPUT][0] = types[OUTPUT][1] = types[REF_OUTPUT][0]
|
||||
= types[REF_OUTPUT][1] = CV_MAKETYPE(CV_16S, 1);
|
||||
// Inputs are only CV_8UC1 for now
|
||||
types[INPUT][0] = CV_8UC1;
|
||||
|
||||
// Outputs are only CV_16SC1 for now
|
||||
types[OUTPUT][0] = types[OUTPUT][1] = types[REF_OUTPUT][0]
|
||||
= types[REF_OUTPUT][1] = CV_16SC1;
|
||||
|
||||
ksize = 3;
|
||||
}
|
||||
@ -592,11 +595,11 @@ void CV_SpatialGradientTest::get_test_array_types_and_sizes( int test_case_idx,
|
||||
|
||||
void CV_SpatialGradientTest::run_func()
|
||||
{
|
||||
spatialGradient( cvarrToMat(test_array[INPUT][0]),
|
||||
cvarrToMat(test_array[OUTPUT][0]),
|
||||
cvarrToMat(test_array[OUTPUT][1]),
|
||||
ksize
|
||||
);
|
||||
Mat dx, dy;
|
||||
spatialGradient( test_mat[INPUT][0].clone(), dx, dy, ksize );
|
||||
|
||||
test_mat[OUTPUT][0] = dx;
|
||||
test_mat[OUTPUT][1] = dy;
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user