fixed ocl::cornerHarris, ocl::cornerMinEigenVal and their accuracy tests
This commit is contained in:
parent
dd942df08b
commit
a8426e1c12
@ -125,10 +125,12 @@ __kernel void calcHarris(__global const float *Dx, __global const float *Dy, __g
|
||||
int indexDx = (dx_startY+i)*(dx_step>>2)+(dx_startX+col);
|
||||
float dx_s = dx_con ? Dx[indexDx] : 0.0f;
|
||||
dx_data[i] = dx_s;
|
||||
|
||||
bool dy_con = dy_startX+col >= 0 && dy_startX+col < dy_whole_cols && dy_startY+i >= 0 && dy_startY+i < dy_whole_rows;
|
||||
int indexDy = (dy_startY+i)*(dy_step>>2)+(dy_startX+col);
|
||||
float dy_s = dx_con ? Dy[indexDy] : 0.0f;
|
||||
float dy_s = dy_con ? Dy[indexDy] : 0.0f;
|
||||
dy_data[i] = dy_s;
|
||||
|
||||
data[0][i] = dx_data[i] * dx_data[i];
|
||||
data[1][i] = dx_data[i] * dy_data[i];
|
||||
data[2][i] = dy_data[i] * dy_data[i];
|
||||
|
@ -124,10 +124,12 @@ __kernel void calcMinEigenVal(__global const float *Dx,__global const float *Dy,
|
||||
int indexDx = (dx_startY+i)*(dx_step>>2)+(dx_startX+col);
|
||||
float dx_s = dx_con ? Dx[indexDx] : 0.0f;
|
||||
dx_data[i] = dx_s;
|
||||
|
||||
bool dy_con = dy_startX+col >= 0 && dy_startX+col < dy_whole_cols && dy_startY+i >= 0 && dy_startY+i < dy_whole_rows;
|
||||
int indexDy = (dy_startY+i)*(dy_step>>2)+(dy_startX+col);
|
||||
float dy_s = dx_con ? Dy[indexDy] : 0.0f;
|
||||
float dy_s = dy_con ? Dy[indexDy] : 0.0f;
|
||||
dy_data[i] = dy_s;
|
||||
|
||||
data[0][i] = dx_data[i] * dx_data[i];
|
||||
data[1][i] = dx_data[i] * dy_data[i];
|
||||
data[2][i] = dy_data[i] * dy_data[i];
|
||||
|
@ -93,23 +93,15 @@ PARAM_TEST_CASE(ImgprocTestBase, MatType,
|
||||
generateOclMat(gdst_whole, gdst_roi, dst_whole, roiSize, dstBorder);
|
||||
}
|
||||
|
||||
void Near(double threshold = 0.0, bool relative = false)
|
||||
void Near(double threshold = 0.0)
|
||||
{
|
||||
Mat roi, whole;
|
||||
gdst_whole.download(whole);
|
||||
gdst_roi.download(roi);
|
||||
|
||||
if (relative)
|
||||
{
|
||||
EXPECT_MAT_NEAR_RELATIVE(dst_whole, whole, threshold);
|
||||
EXPECT_MAT_NEAR_RELATIVE(dst_roi, roi, threshold);
|
||||
}
|
||||
else
|
||||
{
|
||||
EXPECT_MAT_NEAR(dst_whole, whole, threshold);
|
||||
EXPECT_MAT_NEAR(dst_roi, roi, threshold);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
////////////////////////////////copyMakeBorder////////////////////////////////////////////
|
||||
@ -207,11 +199,19 @@ struct CornerTestBase :
|
||||
Mat image = readImageType("gpu/stereobm/aloe-L.png", type);
|
||||
ASSERT_FALSE(image.empty());
|
||||
|
||||
bool isFP = CV_MAT_DEPTH(type) >= CV_32F;
|
||||
float val = 255.0f;
|
||||
if (isFP)
|
||||
{
|
||||
image.convertTo(image, -1, 1.0 / 255);
|
||||
val /= 255.0f;
|
||||
}
|
||||
|
||||
Size roiSize = image.size();
|
||||
Border srcBorder = randomBorder(0, useRoi ? MAX_VALUE : 0);
|
||||
|
||||
Size wholeSize = Size(roiSize.width + srcBorder.lef + srcBorder.rig, roiSize.height + srcBorder.top + srcBorder.bot);
|
||||
src = randomMat(wholeSize, type, -255, 255, false);
|
||||
src = randomMat(wholeSize, type, -val, val, false);
|
||||
src_roi = src(Rect(srcBorder.lef, srcBorder.top, roiSize.width, roiSize.height));
|
||||
image.copyTo(src_roi);
|
||||
|
||||
@ -236,7 +236,7 @@ OCL_TEST_P(CornerMinEigenVal, Mat)
|
||||
cornerMinEigenVal(src_roi, dst_roi, blockSize, apertureSize, borderType);
|
||||
ocl::cornerMinEigenVal(gsrc_roi, gdst_roi, blockSize, apertureSize, borderType);
|
||||
|
||||
Near(1e-5, true);
|
||||
Near(1e-6);
|
||||
}
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ OCL_TEST_P(CornerHarris, Mat)
|
||||
cornerHarris(src_roi, dst_roi, blockSize, apertureSize, k, borderType);
|
||||
ocl::cornerHarris(gsrc_roi, gdst_roi, blockSize, apertureSize, k, borderType);
|
||||
|
||||
Near(1e-5, true);
|
||||
Near(1e-6);
|
||||
}
|
||||
}
|
||||
|
||||
@ -522,7 +522,7 @@ INSTANTIATE_TEST_CASE_P(Imgproc, CornerMinEigenVal, Combine(
|
||||
Bool()));
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(Imgproc, CornerHarris, Combine(
|
||||
Values((MatType)CV_8UC1), // TODO does not work properly with CV_32FC1
|
||||
Values((MatType)CV_8UC1, CV_32FC1),
|
||||
Values(3, 5),
|
||||
Values( (int)BORDER_CONSTANT, (int)BORDER_REPLICATE, (int)BORDER_REFLECT, (int)BORDER_REFLECT_101),
|
||||
Bool()));
|
||||
|
Loading…
Reference in New Issue
Block a user