This source file includes following definitions.
- PARAM_TEST_CASE
- OCL_TEST_P
- OCL_TEST_P
#include "../test_precomp.hpp"
#include "opencv2/ts/ocl_test.hpp"
#ifdef HAVE_OPENCL
namespace cvtest {
namespace ocl {
PARAM_TEST_CASE(GoodFeaturesToTrack, double, bool)
{
double minDistance;
bool useRoi;
static const int maxCorners;
static const double qualityLevel;
TEST_DECLARE_INPUT_PARAMETER(src);
UMat points, upoints;
virtual void SetUp()
{
minDistance = GET_PARAM(0);
useRoi = GET_PARAM(1);
}
void generateTestData()
{
Mat frame = readImage("../gpu/opticalflow/rubberwhale1.png", IMREAD_GRAYSCALE);
ASSERT_FALSE(frame.empty()) << "could not load gpu/opticalflow/rubberwhale1.png";
Size roiSize = frame.size();
Border srcBorder = randomBorder(0, useRoi ? 2 : 0);
randomSubMat(src, src_roi, roiSize, srcBorder, frame.type(), 5, 256);
src_roi.copyTo(frame);
UMAT_UPLOAD_INPUT_PARAMETER(src);
}
void UMatToVector(const UMat & um, std::vector<Point2f> & v) const
{
v.resize(um.size().area());
um.copyTo(Mat(um.size(), CV_32FC2, &v[0]));
}
};
const int GoodFeaturesToTrack::maxCorners = 1000;
const double GoodFeaturesToTrack::qualityLevel = 0.01;
OCL_TEST_P(GoodFeaturesToTrack, Accuracy)
{
for (int j = 0; j < test_loop_times; ++j)
{
generateTestData();
std::vector<Point2f> upts, pts;
OCL_OFF(cv::goodFeaturesToTrack(src_roi, points, maxCorners, qualityLevel, minDistance, noArray()));
ASSERT_FALSE(points.empty());
UMatToVector(points, pts);
OCL_ON(cv::goodFeaturesToTrack(usrc_roi, upoints, maxCorners, qualityLevel, minDistance));
ASSERT_FALSE(upoints.empty());
UMatToVector(upoints, upts);
ASSERT_EQ(upts.size(), pts.size());
int mistmatch = 0;
for (size_t i = 0; i < pts.size(); ++i)
{
Point2i a = upts[i], b = pts[i];
bool eq = std::abs(a.x - b.x) < 1 && std::abs(a.y - b.y) < 1;
if (!eq)
++mistmatch;
}
double bad_ratio = static_cast<double>(mistmatch) / pts.size();
ASSERT_GE(1e-2, bad_ratio);
}
}
OCL_TEST_P(GoodFeaturesToTrack, EmptyCorners)
{
generateTestData();
usrc_roi.setTo(Scalar::all(0));
OCL_ON(cv::goodFeaturesToTrack(usrc_roi, upoints, maxCorners, qualityLevel, minDistance));
ASSERT_TRUE(upoints.empty());
}
OCL_INSTANTIATE_TEST_CASE_P(Imgproc, GoodFeaturesToTrack,
::testing::Combine(testing::Values(0.0, 3.0), Bool()));
} }
#endif