call resetDevice if gpu test fails

This commit is contained in:
Vladislav Vinogradov 2012-12-18 16:59:00 +04:00
parent 0973e86d8a
commit ab25fe9e37
36 changed files with 9551 additions and 5795 deletions

View File

@ -92,15 +92,23 @@ PERF_TEST_P(Image, HoughLinesP,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_lines;
cv::gpu::HoughLinesBuf d_buf;
cv::gpu::HoughLinesP(d_image, d_lines, d_buf, rho, theta, minLineLenght, maxLineGap);
TEST_CYCLE()
try
{
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_lines;
cv::gpu::HoughLinesBuf d_buf;
cv::gpu::HoughLinesP(d_image, d_lines, d_buf, rho, theta, minLineLenght, maxLineGap);
TEST_CYCLE()
{
cv::gpu::HoughLinesP(d_image, d_lines, d_buf, rho, theta, minLineLenght, maxLineGap);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -155,17 +163,25 @@ PERF_TEST_P(Image_Depth, GoodFeaturesToTrack,
if (PERF_RUN_GPU())
{
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, k);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
cv::gpu::GpuMat d_pts;
d_detector(d_src, d_pts, d_mask);
TEST_CYCLE()
try
{
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(maxCorners, qualityLevel, minDistance, blockSize, useHarrisDetector, k);
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
cv::gpu::GpuMat d_pts;
d_detector(d_src, d_pts, d_mask);
TEST_CYCLE()
{
d_detector(d_src, d_pts, d_mask);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -244,23 +260,31 @@ PERF_TEST_P(ImagePair_Depth_GraySource, OpticalFlowPyrLKSparse,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
cv::gpu::GpuMat d_nextPts;
cv::gpu::GpuMat d_status;
cv::gpu::PyrLKOpticalFlow d_pyrLK;
d_pyrLK.winSize = winSize;
d_pyrLK.maxLevel = maxLevel;
d_pyrLK.iters = criteria.maxCount;
d_pyrLK.useInitialFlow = false;
d_pyrLK.sparse(d_src1, d_src2, d_pts, d_nextPts, d_status);
TEST_CYCLE()
try
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
cv::gpu::GpuMat d_nextPts;
cv::gpu::GpuMat d_status;
cv::gpu::PyrLKOpticalFlow d_pyrLK;
d_pyrLK.winSize = winSize;
d_pyrLK.maxLevel = maxLevel;
d_pyrLK.iters = criteria.maxCount;
d_pyrLK.useInitialFlow = false;
d_pyrLK.sparse(d_src1, d_src2, d_pts, d_nextPts, d_status);
TEST_CYCLE()
{
d_pyrLK.sparse(d_src1, d_src2, d_pts, d_nextPts, d_status);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -322,25 +346,33 @@ PERF_TEST_P(ImagePair_Depth, OpticalFlowFarneback,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_u(src1.size(), CV_32FC1, cv::Scalar::all(0));
cv::gpu::GpuMat d_v(src1.size(), CV_32FC1, cv::Scalar::all(0));
cv::gpu::FarnebackOpticalFlow d_farneback;
d_farneback.pyrScale = pyrScale;
d_farneback.numLevels = numLevels;
d_farneback.winSize = winSize;
d_farneback.numIters = numIters;
d_farneback.polyN = polyN;
d_farneback.polySigma = polySigma;
d_farneback.flags = flags;
d_farneback(d_src1, d_src2, d_u, d_v);
TEST_CYCLE_N(10)
try
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_u(src1.size(), CV_32FC1, cv::Scalar::all(0));
cv::gpu::GpuMat d_v(src1.size(), CV_32FC1, cv::Scalar::all(0));
cv::gpu::FarnebackOpticalFlow d_farneback;
d_farneback.pyrScale = pyrScale;
d_farneback.numLevels = numLevels;
d_farneback.winSize = winSize;
d_farneback.numIters = numIters;
d_farneback.polyN = polyN;
d_farneback.polySigma = polySigma;
d_farneback.flags = flags;
d_farneback(d_src1, d_src2, d_u, d_v);
TEST_CYCLE_N(10)
{
d_farneback(d_src1, d_src2, d_u, d_v);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -409,15 +441,23 @@ PERF_TEST_P(ImagePair_BlockSize_ShiftSize_MaxRange, OpticalFlowBM,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_velx, d_vely, buf;
cv::gpu::calcOpticalFlowBM(d_src1, d_src2, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
TEST_CYCLE_N(10)
try
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_velx, d_vely, buf;
cv::gpu::calcOpticalFlowBM(d_src1, d_src2, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
TEST_CYCLE_N(10)
{
cv::gpu::calcOpticalFlowBM(d_src1, d_src2, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -460,17 +500,25 @@ PERF_TEST_P(ImagePair_BlockSize_ShiftSize_MaxRange, FastOpticalFlowBM,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_velx, d_vely;
cv::gpu::FastOpticalFlowBM fastBM;
fastBM(d_src1, d_src2, d_velx, d_vely, max_range.width, block_size.width);
TEST_CYCLE_N(10)
try
{
cv::gpu::GpuMat d_src1(src1);
cv::gpu::GpuMat d_src2(src2);
cv::gpu::GpuMat d_velx, d_vely;
cv::gpu::FastOpticalFlowBM fastBM;
fastBM(d_src1, d_src2, d_velx, d_vely, max_range.width, block_size.width);
TEST_CYCLE_N(10)
{
fastBM(d_src1, d_src2, d_velx, d_vely, max_range.width, block_size.width);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else

View File

@ -26,20 +26,28 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBM, Values(pair_string("gpu/perf/aloe.png",
if (PERF_RUN_GPU())
{
cv::gpu::StereoBM_GPU d_bm(preset, ndisp);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_bm(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
try
{
d_bm(d_imgLeft, d_imgRight, d_dst);
}
cv::gpu::StereoBM_GPU d_bm(preset, ndisp);
GPU_SANITY_CHECK(d_dst);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_bm(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
{
d_bm(d_imgLeft, d_imgRight, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -75,20 +83,28 @@ PERF_TEST_P(ImagePair, Calib3D_StereoBeliefPropagation, Values(pair_string("gpu/
if (PERF_RUN_GPU())
{
cv::gpu::StereoBeliefPropagation d_bp(ndisp);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_bp(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
try
{
d_bp(d_imgLeft, d_imgRight, d_dst);
}
cv::gpu::StereoBeliefPropagation d_bp(ndisp);
GPU_SANITY_CHECK(d_dst);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_bp(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
{
d_bp(d_imgLeft, d_imgRight, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -113,20 +129,28 @@ PERF_TEST_P(ImagePair, Calib3D_StereoConstantSpaceBP, Values(pair_string("gpu/st
if (PERF_RUN_GPU())
{
cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_csbp(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
try
{
d_csbp(d_imgLeft, d_imgRight, d_dst);
}
cv::gpu::StereoConstantSpaceBP d_csbp(ndisp);
GPU_SANITY_CHECK(d_dst);
cv::gpu::GpuMat d_imgLeft(imgLeft);
cv::gpu::GpuMat d_imgRight(imgRight);
cv::gpu::GpuMat d_dst;
d_csbp(d_imgLeft, d_imgRight, d_dst);
TEST_CYCLE()
{
d_csbp(d_imgLeft, d_imgRight, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -149,20 +173,28 @@ PERF_TEST_P(ImagePair, Calib3D_DisparityBilateralFilter, Values(pair_string("gpu
if (PERF_RUN_GPU())
{
cv::gpu::DisparityBilateralFilter d_filter(ndisp);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_disp(disp);
cv::gpu::GpuMat d_dst;
d_filter(d_disp, d_img, d_dst);
TEST_CYCLE()
try
{
d_filter(d_disp, d_img, d_dst);
}
cv::gpu::DisparityBilateralFilter d_filter(ndisp);
GPU_SANITY_CHECK(d_dst);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_disp(disp);
cv::gpu::GpuMat d_dst;
d_filter(d_disp, d_img, d_dst);
TEST_CYCLE()
{
d_filter(d_disp, d_img, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -187,17 +219,25 @@ PERF_TEST_P(Count, Calib3D_TransformPoints, Values(5000, 10000, 20000))
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
TEST_CYCLE()
try
{
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
TEST_CYCLE()
{
cv::gpu::transformPoints(d_src, rvec, tvec, d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -221,17 +261,25 @@ PERF_TEST_P(Count, Calib3D_ProjectPoints, Values(5000, 10000, 20000))
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
TEST_CYCLE()
try
{
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
TEST_CYCLE()
{
cv::gpu::projectPoints(d_src, rvec, tvec, camera_mat, cv::Mat(), d_dst);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -283,11 +331,19 @@ PERF_TEST_P(Count, Calib3D_SolvePnPRansac, Values(5000, 10000, 20000))
if (PERF_RUN_GPU())
{
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
TEST_CYCLE()
try
{
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
TEST_CYCLE()
{
cv::gpu::solvePnPRansac(object, image, camera_mat, dist_coef, rvec, tvec);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -320,17 +376,25 @@ PERF_TEST_P(Sz_Depth, Calib3D_ReprojectImageTo3D, Combine(GPU_TYPICAL_MAT_SIZES,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
TEST_CYCLE()
try
{
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
TEST_CYCLE()
{
cv::gpu::reprojectImageTo3D(d_src, d_dst, Q);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -360,17 +424,25 @@ PERF_TEST_P(Sz_Depth, Calib3D_DrawColorDisp, Combine(GPU_TYPICAL_MAT_SIZES, Valu
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::drawColorDisp(d_src, d_dst, 255);
TEST_CYCLE()
try
{
cv::gpu::drawColorDisp(d_src, d_dst, 255);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::drawColorDisp(d_src, d_dst, 255);
TEST_CYCLE()
{
cv::gpu::drawColorDisp(d_src, d_dst, 255);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

File diff suppressed because it is too large Load Diff

View File

@ -30,19 +30,27 @@ PERF_TEST_P(Sz_Depth_Cn_KernelSz, Denoising_BilateralFilter,
cv::Mat src(size, type);
fillRandom(src);
if (PERF_RUN_GPU())
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
TEST_CYCLE()
try
{
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
TEST_CYCLE()
{
cv::gpu::bilateralFilter(d_src, d_dst, kernel_size, sigma_color, sigma_spatial, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -87,17 +95,25 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_NonLocalMeans,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
TEST_CYCLE()
try
{
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
TEST_CYCLE()
{
cv::gpu::nonLocalMeans(d_src, d_dst, h, search_widow_size, block_size, borderMode);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -130,18 +146,26 @@ PERF_TEST_P(Sz_Depth_Cn_WinSz_BlockSz, Denoising_FastNonLocalMeans,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
TEST_CYCLE()
try
{
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
GPU_SANITY_CHECK(d_dst);
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
TEST_CYCLE()
{
fnlmd.simpleMethod(d_src, d_dst, h, search_widow_size, block_size);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -181,18 +205,26 @@ PERF_TEST_P(Sz_Depth_WinSz_BlockSz, Denoising_FastNonLocalMeansColored,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
TEST_CYCLE()
try
{
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
GPU_SANITY_CHECK(d_dst);
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
TEST_CYCLE()
{
fnlmd.labMethod(d_src, d_dst, h, h, search_widow_size, block_size);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

View File

@ -19,20 +19,28 @@ PERF_TEST_P(Image, Features2D_SURF, Values<string>("gpu/perf/aloe.png"))
if (PERF_RUN_GPU())
{
cv::gpu::SURF_GPU d_surf;
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints, d_descriptors;
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
TEST_CYCLE()
try
{
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
cv::gpu::SURF_GPU d_surf;
GPU_SANITY_CHECK(d_descriptors, 1e-4);
GPU_SANITY_CHECK_KEYPOINTS(SURF, d_keypoints);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints, d_descriptors;
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
TEST_CYCLE()
{
d_surf(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
GPU_SANITY_CHECK(d_descriptors, 1e-4);
GPU_SANITY_CHECK_KEYPOINTS(SURF, d_keypoints);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -64,19 +72,27 @@ PERF_TEST_P(Image, Features2D_FAST, Values<string>("gpu/perf/aloe.png"))
if (PERF_RUN_GPU())
{
cv::gpu::FAST_GPU d_fast(20);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints;
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
TEST_CYCLE()
try
{
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
}
cv::gpu::FAST_GPU d_fast(20);
GPU_SANITY_CHECK_RESPONSE(FAST, d_keypoints);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints;
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
TEST_CYCLE()
{
d_fast(d_img, cv::gpu::GpuMat(), d_keypoints);
}
GPU_SANITY_CHECK_RESPONSE(FAST, d_keypoints);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -104,20 +120,28 @@ PERF_TEST_P(Image, Features2D_ORB, Values<string>("gpu/perf/aloe.png"))
if (PERF_RUN_GPU())
{
cv::gpu::ORB_GPU d_orb(4000);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints, d_descriptors;
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
TEST_CYCLE()
try
{
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
cv::gpu::ORB_GPU d_orb(4000);
GPU_SANITY_CHECK_KEYPOINTS(ORB, d_keypoints);
GPU_SANITY_CHECK(d_descriptors);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_keypoints, d_descriptors;
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
TEST_CYCLE()
{
d_orb(d_img, cv::gpu::GpuMat(), d_keypoints, d_descriptors);
}
GPU_SANITY_CHECK_KEYPOINTS(ORB, d_keypoints);
GPU_SANITY_CHECK(d_descriptors);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -161,21 +185,29 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFMatch, Combine(Values(64, 128, 256), Val
if (PERF_RUN_GPU())
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_distance;
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
TEST_CYCLE()
try
{
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
}
cv::gpu::BFMatcher_GPU d_matcher(normType);
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_distance;
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
TEST_CYCLE()
{
d_matcher.matchSingle(d_query, d_train, d_trainIdx, d_distance);
}
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -220,21 +252,29 @@ PERF_TEST_P(DescSize_K_Norm, Features2D_BFKnnMatch, Combine(
if (PERF_RUN_GPU())
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist;
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
TEST_CYCLE()
try
{
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
}
cv::gpu::BFMatcher_GPU d_matcher(normType);
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_distance, d_allDist;
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
TEST_CYCLE()
{
d_matcher.knnMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_allDist, k);
}
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -273,21 +313,29 @@ PERF_TEST_P(DescSize_Norm, Features2D_BFRadiusMatch, Combine(Values(64, 128, 256
if (PERF_RUN_GPU())
{
cv::gpu::BFMatcher_GPU d_matcher(normType);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance;
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
TEST_CYCLE()
try
{
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
}
cv::gpu::BFMatcher_GPU d_matcher(normType);
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
cv::gpu::GpuMat d_query(query);
cv::gpu::GpuMat d_train(train);
cv::gpu::GpuMat d_trainIdx, d_nMatches, d_distance;
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
TEST_CYCLE()
{
d_matcher.radiusMatchSingle(d_query, d_train, d_trainIdx, d_distance, d_nMatches, 2.0);
}
GPU_SANITY_CHECK(d_trainIdx);
GPU_SANITY_CHECK(d_distance);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

View File

@ -23,17 +23,25 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Blur, Combine(GPU_TYPICAL_MAT_SIZES, Value
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
TEST_CYCLE()
try
{
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
TEST_CYCLE()
{
cv::gpu::blur(d_src, d_dst, cv::Size(ksize, ksize));
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -66,18 +74,26 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Sobel, Combine(GPU_TYPICAL_MAT_SIZES, Valu
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
TEST_CYCLE()
try
{
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
GPU_SANITY_CHECK(d_dst);
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
TEST_CYCLE()
{
cv::gpu::Sobel(d_src, d_dst, -1, 1, 1, d_buf, ksize);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -109,18 +125,26 @@ PERF_TEST_P(Sz_Type, Filters_Scharr, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
TEST_CYCLE()
try
{
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
GPU_SANITY_CHECK(d_dst);
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
TEST_CYCLE()
{
cv::gpu::Scharr(d_src, d_dst, -1, 1, 0, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -153,18 +177,26 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_GaussianBlur, Combine(GPU_TYPICAL_MAT_SIZE
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
TEST_CYCLE()
try
{
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
GPU_SANITY_CHECK(d_dst);
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
TEST_CYCLE()
{
cv::gpu::GaussianBlur(d_src, d_dst, cv::Size(ksize, ksize), d_buf, 0.5);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -197,17 +229,25 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Laplacian, Combine(GPU_TYPICAL_MAT_SIZES,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
TEST_CYCLE()
try
{
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
TEST_CYCLE()
{
cv::gpu::Laplacian(d_src, d_dst, -1, ksize);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -241,18 +281,26 @@ PERF_TEST_P(Sz_Type, Filters_Erode, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8UC
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::erode(d_src, d_dst, ker, d_buf);
TEST_CYCLE()
try
{
cv::gpu::erode(d_src, d_dst, ker, d_buf);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
GPU_SANITY_CHECK(d_dst);
cv::gpu::erode(d_src, d_dst, ker, d_buf);
TEST_CYCLE()
{
cv::gpu::erode(d_src, d_dst, ker, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -286,18 +334,26 @@ PERF_TEST_P(Sz_Type, Filters_Dilate, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8U
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
TEST_CYCLE()
try
{
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf;
GPU_SANITY_CHECK(d_dst);
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
TEST_CYCLE()
{
cv::gpu::dilate(d_src, d_dst, ker, d_buf);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -337,19 +393,27 @@ PERF_TEST_P(Sz_Type_Op, Filters_MorphologyEx, Combine(GPU_TYPICAL_MAT_SIZES, Val
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf1;
cv::gpu::GpuMat d_buf2;
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
TEST_CYCLE()
try
{
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::GpuMat d_buf1;
cv::gpu::GpuMat d_buf2;
GPU_SANITY_CHECK(d_dst);
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
TEST_CYCLE()
{
cv::gpu::morphologyEx(d_src, d_dst, morphOp, ker, d_buf1, d_buf2);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -385,17 +449,25 @@ PERF_TEST_P(Sz_Type_KernelSz, Filters_Filter2D, Combine(GPU_TYPICAL_MAT_SIZES, V
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
TEST_CYCLE()
try
{
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
TEST_CYCLE()
{
cv::gpu::filter2D(d_src, d_dst, -1, kernel);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

File diff suppressed because it is too large Load Diff

View File

@ -108,22 +108,30 @@ PERF_TEST_P(Image, Labeling_ConnectedComponents, Values<string>("gpu/labeling/al
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
TEST_CYCLE()
try
{
cv::gpu::labelComponents(mask, components);
}
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
GPU_SANITY_CHECK(components);
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
TEST_CYCLE()
{
cv::gpu::labelComponents(mask, components);
}
GPU_SANITY_CHECK(components);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

View File

@ -20,16 +20,24 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV_8
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(size, type);
d_src.setTo(val);
TEST_CYCLE()
try
{
d_src.setTo(val);
}
cv::gpu::GpuMat d_src(size, type);
GPU_SANITY_CHECK(d_src);
d_src.setTo(val);
TEST_CYCLE()
{
d_src.setTo(val);
}
GPU_SANITY_CHECK(d_src);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -67,17 +75,25 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_SetToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Value
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
d_src.setTo(val, d_mask);
TEST_CYCLE()
try
{
d_src.setTo(val, d_mask);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
GPU_SANITY_CHECK(d_src);
d_src.setTo(val, d_mask);
TEST_CYCLE()
{
d_src.setTo(val, d_mask);
}
GPU_SANITY_CHECK(d_src);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -111,18 +127,26 @@ PERF_TEST_P(Sz_Depth_Cn, MatOp_CopyToMasked, Combine(GPU_TYPICAL_MAT_SIZES, Valu
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
cv::gpu::GpuMat d_dst;
d_src.copyTo(d_dst, d_mask);
TEST_CYCLE()
try
{
d_src.copyTo(d_dst, d_mask);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_mask(mask);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
d_src.copyTo(d_dst, d_mask);
TEST_CYCLE()
{
d_src.copyTo(d_dst, d_mask);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -155,17 +179,25 @@ PERF_TEST_P(Sz_2Depth, MatOp_ConvertTo, Combine(GPU_TYPICAL_MAT_SIZES, Values(CV
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
TEST_CYCLE()
try
{
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
}
cv::gpu::GpuMat d_src(src);
cv::gpu::GpuMat d_dst;
GPU_SANITY_CHECK(d_dst);
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
TEST_CYCLE()
{
d_src.convertTo(d_dst, depth2, 0.5, 1.0);
}
GPU_SANITY_CHECK(d_dst);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

View File

@ -19,16 +19,24 @@ PERF_TEST_P(Image, ObjDetect_HOG, Values<string>("gpu/hog/road.png"))
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img(img);
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.detectMultiScale(d_img, found_locations);
TEST_CYCLE()
try
{
cv::gpu::GpuMat d_img(img);
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.detectMultiScale(d_img, found_locations);
TEST_CYCLE()
{
d_hog.detectMultiScale(d_img, found_locations);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -61,16 +69,24 @@ PERF_TEST_P(HOG, CalTech, Values<string>("gpu/caltech/image_00000009_0.png", "gp
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_img(img);
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.detectMultiScale(d_img, found_locations);
TEST_CYCLE()
try
{
cv::gpu::GpuMat d_img(img);
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.detectMultiScale(d_img, found_locations);
TEST_CYCLE()
{
d_hog.detectMultiScale(d_img, found_locations);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -103,20 +119,28 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_HaarClassifier,
if (PERF_RUN_GPU())
{
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_objects_buffer;
d_cascade.detectMultiScale(d_img, d_objects_buffer);
TEST_CYCLE()
try
{
d_cascade.detectMultiScale(d_img, d_objects_buffer);
}
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
GPU_SANITY_CHECK(d_objects_buffer);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_objects_buffer;
d_cascade.detectMultiScale(d_img, d_objects_buffer);
TEST_CYCLE()
{
d_cascade.detectMultiScale(d_img, d_objects_buffer);
}
GPU_SANITY_CHECK(d_objects_buffer);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -147,20 +171,28 @@ PERF_TEST_P(ImageAndCascade, ObjDetect_LBPClassifier,
if (PERF_RUN_GPU())
{
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_gpu_rects;
d_cascade.detectMultiScale(d_img, d_gpu_rects);
TEST_CYCLE()
try
{
d_cascade.detectMultiScale(d_img, d_gpu_rects);
}
cv::gpu::CascadeClassifier_GPU d_cascade;
ASSERT_TRUE(d_cascade.load(perf::TestBase::getDataPath(GetParam().second)));
GPU_SANITY_CHECK(d_gpu_rects);
cv::gpu::GpuMat d_img(img);
cv::gpu::GpuMat d_gpu_rects;
d_cascade.detectMultiScale(d_img, d_gpu_rects);
TEST_CYCLE()
{
d_cascade.detectMultiScale(d_img, d_gpu_rects);
}
GPU_SANITY_CHECK(d_gpu_rects);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

View File

@ -60,28 +60,36 @@ GPU_PERF_TEST_P(SCascadeTest, detect,
RUN_GPU(SCascadeTest, detect)
{
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(1);
cascade.detect(colored, rois, objectBoxes);
TEST_CYCLE()
try
{
cascade.detect(colored, rois, objectBoxes);
}
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
SANITY_CHECK(sortDetections(objectBoxes));
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(1);
cascade.detect(colored, rois, objectBoxes);
TEST_CYCLE()
{
cascade.detect(colored, rois, objectBoxes);
}
SANITY_CHECK(sortDetections(objectBoxes));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
NO_CPU(SCascadeTest, detect)
@ -118,37 +126,45 @@ GPU_PERF_TEST_P(SCascadeTestRoi, detectInRoi,
RUN_GPU(SCascadeTestRoi, detectInRoi)
{
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 16384 * 20, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
int nroi = GET_PARAM(2);
cv::RNG rng;
for (int i = 0; i < nroi; ++i)
try
{
cv::Rect r = getFromTable(rng(10));
cv::gpu::GpuMat sub(rois, r);
sub.setTo(1);
}
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
cascade.detect(colored, rois, objectBoxes);
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 16384 * 20, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
int nroi = GET_PARAM(2);
cv::RNG rng;
for (int i = 0; i < nroi; ++i)
{
cv::Rect r = getFromTable(rng(10));
cv::gpu::GpuMat sub(rois, r);
sub.setTo(1);
}
TEST_CYCLE()
{
cascade.detect(colored, rois, objectBoxes);
}
SANITY_CHECK(sortDetections(objectBoxes));
TEST_CYCLE()
{
cascade.detect(colored, rois, objectBoxes);
}
SANITY_CHECK(sortDetections(objectBoxes));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
NO_CPU(SCascadeTestRoi, detectInRoi)
@ -163,33 +179,41 @@ GPU_PERF_TEST_P(SCascadeTestRoi, detectEachRoi,
RUN_GPU(SCascadeTestRoi, detectEachRoi)
{
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 16384 * 20, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
int idx = GET_PARAM(2);
cv::Rect r = getFromTable(idx);
cv::gpu::GpuMat sub(rois, r);
sub.setTo(1);
cascade.detect(colored, rois, objectBoxes);
TEST_CYCLE()
try
{
cascade.detect(colored, rois, objectBoxes);
}
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
SANITY_CHECK(sortDetections(objectBoxes));
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 16384 * 20, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
int idx = GET_PARAM(2);
cv::Rect r = getFromTable(idx);
cv::gpu::GpuMat sub(rois, r);
sub.setTo(1);
cascade.detect(colored, rois, objectBoxes);
TEST_CYCLE()
{
cascade.detect(colored, rois, objectBoxes);
}
SANITY_CHECK(sortDetections(objectBoxes));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
NO_CPU(SCascadeTestRoi, detectEachRoi)
@ -209,36 +233,44 @@ GPU_PERF_TEST_P(SCascadeTest, detectOnIntegral,
RUN_GPU(SCascadeTest, detectOnIntegral)
{
cv::FileStorage fsi(perf::TestBase::getDataPath(GET_PARAM(1)), cv::FileStorage::READ);
ASSERT_TRUE(fsi.isOpened());
cv::gpu::GpuMat hogluv(121 * 10, 161, CV_32SC1);
for (int i = 0; i < 10; ++i)
try
{
cv::Mat channel;
fsi[std::string("channel") + itoa(i)] >> channel;
cv::gpu::GpuMat gchannel(hogluv, cv::Rect(0, 121 * i, 161, 121));
gchannel.upload(channel);
}
cv::FileStorage fsi(perf::TestBase::getDataPath(GET_PARAM(1)), cv::FileStorage::READ);
ASSERT_TRUE(fsi.isOpened());
cv::gpu::SCascade cascade;
cv::gpu::GpuMat hogluv(121 * 10, 161, CV_32SC1);
for (int i = 0; i < 10; ++i)
{
cv::Mat channel;
fsi[std::string("channel") + itoa(i)] >> channel;
cv::gpu::GpuMat gchannel(hogluv, cv::Rect(0, 121 * i, 161, 121));
gchannel.upload(channel);
}
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
cv::gpu::SCascade cascade;
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(cv::Size(640, 480), CV_8UC1);
rois.setTo(1);
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cascade.detect(hogluv, rois, objectBoxes);
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(cv::Size(640, 480), CV_8UC1);
rois.setTo(1);
TEST_CYCLE()
{
cascade.detect(hogluv, rois, objectBoxes);
}
SANITY_CHECK(sortDetections(objectBoxes));
TEST_CYCLE()
{
cascade.detect(hogluv, rois, objectBoxes);
}
SANITY_CHECK(sortDetections(objectBoxes));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
NO_CPU(SCascadeTest, detectOnIntegral)
@ -251,34 +283,42 @@ GPU_PERF_TEST_P(SCascadeTest, detectStream,
RUN_GPU(SCascadeTest, detectStream)
{
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(1);
cv::gpu::Stream s;
cascade.detect(colored, rois, objectBoxes, s);
TEST_CYCLE()
try
{
cv::Mat cpu = readImage (GET_PARAM(1));
ASSERT_FALSE(cpu.empty());
cv::gpu::GpuMat colored(cpu);
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(0)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::gpu::GpuMat objectBoxes(1, 10000 * sizeof(cv::gpu::SCascade::Detection), CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(1);
cv::gpu::Stream s;
cascade.detect(colored, rois, objectBoxes, s);
TEST_CYCLE()
{
cascade.detect(colored, rois, objectBoxes, s);
}
#ifdef HAVE_CUDA
cudaDeviceSynchronize();
#endif
SANITY_CHECK(sortDetections(objectBoxes));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
#ifdef HAVE_CUDA
cudaDeviceSynchronize();
#endif
SANITY_CHECK(sortDetections(objectBoxes));
}
NO_CPU(SCascadeTest, detectStream)

View File

@ -36,23 +36,31 @@ PERF_TEST_P(ImagePair, Video_BroxOpticalFlow,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(d_frame0, d_frame1, d_u, d_v);
TEST_CYCLE()
try
{
d_flow(d_frame0, d_frame1, d_u, d_v);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(d_frame0, d_frame1, d_u, d_v);
TEST_CYCLE()
{
d_flow(d_frame0, d_frame1, d_u, d_v);
}
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -77,31 +85,39 @@ PERF_TEST_P(ImagePair, Video_InterpolateFrames,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_fu, d_fv;
cv::gpu::GpuMat d_bu, d_bv;
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(d_frame0, d_frame1, d_fu, d_fv);
d_flow(d_frame1, d_frame0, d_bu, d_bv);
cv::gpu::GpuMat d_newFrame;
cv::gpu::GpuMat d_buf;
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
TEST_CYCLE()
try
{
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_fu, d_fv;
cv::gpu::GpuMat d_bu, d_bv;
GPU_SANITY_CHECK(d_fu);
GPU_SANITY_CHECK(d_fv);
GPU_SANITY_CHECK(d_bu);
GPU_SANITY_CHECK(d_bv);
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(d_frame0, d_frame1, d_fu, d_fv);
d_flow(d_frame1, d_frame0, d_bu, d_bv);
cv::gpu::GpuMat d_newFrame;
cv::gpu::GpuMat d_buf;
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
TEST_CYCLE()
{
cv::gpu::interpolateFrames(d_frame0, d_frame1, d_fu, d_fv, d_bu, d_bv, 0.5f, d_newFrame, d_buf);
}
GPU_SANITY_CHECK(d_fu);
GPU_SANITY_CHECK(d_fv);
GPU_SANITY_CHECK(d_bu);
GPU_SANITY_CHECK(d_bv);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -126,27 +142,35 @@ PERF_TEST_P(ImagePair, Video_CreateOpticalFlowNeedleMap,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(d_frame0, d_frame1, d_u, d_v);
cv::gpu::GpuMat d_vertex, d_colors;
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
TEST_CYCLE()
try
{
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
GPU_SANITY_CHECK(d_vertex);
GPU_SANITY_CHECK(d_colors);
cv::gpu::BroxOpticalFlow d_flow(0.197f /*alpha*/, 50.0f /*gamma*/, 0.8f /*scale_factor*/,
10 /*inner_iterations*/, 77 /*outer_iterations*/, 10 /*solver_iterations*/);
d_flow(d_frame0, d_frame1, d_u, d_v);
cv::gpu::GpuMat d_vertex, d_colors;
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
TEST_CYCLE()
{
cv::gpu::createOpticalFlowNeedleMap(d_u, d_v, d_vertex, d_colors);
}
GPU_SANITY_CHECK(d_vertex);
GPU_SANITY_CHECK(d_colors);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -170,19 +194,27 @@ PERF_TEST_P(Image_MinDistance, Video_GoodFeaturesToTrack,
if (PERF_RUN_GPU())
{
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_pts;
d_detector(d_image, d_pts);
TEST_CYCLE()
try
{
d_detector(d_image, d_pts);
}
cv::gpu::GoodFeaturesToTrackDetector_GPU d_detector(8000, 0.01, minDistance);
GPU_SANITY_CHECK(d_pts);
cv::gpu::GpuMat d_image(image);
cv::gpu::GpuMat d_pts;
d_detector(d_image, d_pts);
TEST_CYCLE()
{
d_detector(d_image, d_pts);
}
GPU_SANITY_CHECK(d_pts);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -238,26 +270,34 @@ PERF_TEST_P(ImagePair_Gray_NPts_WinSz_Levels_Iters, Video_PyrLKOpticalFlowSparse
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
cv::gpu::PyrLKOpticalFlow d_pyrLK;
d_pyrLK.winSize = cv::Size(winSize, winSize);
d_pyrLK.maxLevel = levels - 1;
d_pyrLK.iters = iters;
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_nextPts;
cv::gpu::GpuMat d_status;
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
TEST_CYCLE()
try
{
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
}
cv::gpu::GpuMat d_pts(pts.reshape(2, 1));
GPU_SANITY_CHECK(d_status);
cv::gpu::PyrLKOpticalFlow d_pyrLK;
d_pyrLK.winSize = cv::Size(winSize, winSize);
d_pyrLK.maxLevel = levels - 1;
d_pyrLK.iters = iters;
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_nextPts;
cv::gpu::GpuMat d_status;
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
TEST_CYCLE()
{
d_pyrLK.sparse(d_frame0, d_frame1, d_pts, d_nextPts, d_status);
}
GPU_SANITY_CHECK(d_status);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -305,25 +345,33 @@ PERF_TEST_P(ImagePair_WinSz_Levels_Iters, Video_PyrLKOpticalFlowDense, Combine(
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
cv::gpu::PyrLKOpticalFlow d_pyrLK;
d_pyrLK.winSize = cv::Size(winSize, winSize);
d_pyrLK.maxLevel = levels - 1;
d_pyrLK.iters = iters;
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
TEST_CYCLE()
try
{
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
cv::gpu::PyrLKOpticalFlow d_pyrLK;
d_pyrLK.winSize = cv::Size(winSize, winSize);
d_pyrLK.maxLevel = levels - 1;
d_pyrLK.iters = iters;
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
TEST_CYCLE()
{
d_pyrLK.dense(d_frame0, d_frame1, d_u, d_v);
}
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -355,29 +403,37 @@ PERF_TEST_P(ImagePair, Video_FarnebackOpticalFlow,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
cv::gpu::FarnebackOpticalFlow d_farneback;
d_farneback.numLevels = numLevels;
d_farneback.pyrScale = pyrScale;
d_farneback.winSize = winSize;
d_farneback.numIters = numIters;
d_farneback.polyN = polyN;
d_farneback.polySigma = polySigma;
d_farneback.flags = flags;
d_farneback(d_frame0, d_frame1, d_u, d_v);
TEST_CYCLE()
try
{
d_farneback(d_frame0, d_frame1, d_u, d_v);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_u;
cv::gpu::GpuMat d_v;
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
cv::gpu::FarnebackOpticalFlow d_farneback;
d_farneback.numLevels = numLevels;
d_farneback.pyrScale = pyrScale;
d_farneback.winSize = winSize;
d_farneback.numIters = numIters;
d_farneback.polyN = polyN;
d_farneback.polySigma = polySigma;
d_farneback.flags = flags;
d_farneback(d_frame0, d_frame1, d_u, d_v);
TEST_CYCLE()
{
d_farneback(d_frame0, d_frame1, d_u, d_v);
}
GPU_SANITY_CHECK(d_u);
GPU_SANITY_CHECK(d_v);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -410,22 +466,30 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowDual_TVL1,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_flowx;
cv::gpu::GpuMat d_flowy;
cv::gpu::OpticalFlowDual_TVL1_GPU d_alg;
d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
TEST_CYCLE()
try
{
d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_flowx;
cv::gpu::GpuMat d_flowy;
GPU_SANITY_CHECK(d_flowx);
GPU_SANITY_CHECK(d_flowy);
cv::gpu::OpticalFlowDual_TVL1_GPU d_alg;
d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
TEST_CYCLE()
{
d_alg(d_frame0, d_frame1, d_flowx, d_flowy);
}
GPU_SANITY_CHECK(d_flowx);
GPU_SANITY_CHECK(d_flowy);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -482,19 +546,27 @@ PERF_TEST_P(ImagePair, Video_OpticalFlowBM,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_velx, d_vely, buf;
cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
TEST_CYCLE()
try
{
cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_velx, d_vely, buf;
GPU_SANITY_CHECK(d_velx);
GPU_SANITY_CHECK(d_vely);
cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
TEST_CYCLE()
{
cv::gpu::calcOpticalFlowBM(d_frame0, d_frame1, block_size, shift_size, max_range, false, d_velx, d_vely, buf);
}
GPU_SANITY_CHECK(d_velx);
GPU_SANITY_CHECK(d_vely);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -529,21 +601,29 @@ PERF_TEST_P(ImagePair, Video_FastOpticalFlowBM,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_velx, d_vely;
cv::gpu::FastOpticalFlowBM fastBM;
fastBM(d_frame0, d_frame1, d_velx, d_vely, max_range.width, block_size.width);
TEST_CYCLE()
try
{
fastBM(d_frame0, d_frame1, d_velx, d_vely, max_range.width, block_size.width);
}
cv::gpu::GpuMat d_frame0(frame0);
cv::gpu::GpuMat d_frame1(frame1);
cv::gpu::GpuMat d_velx, d_vely;
GPU_SANITY_CHECK(d_velx);
GPU_SANITY_CHECK(d_vely);
cv::gpu::FastOpticalFlowBM fastBM;
fastBM(d_frame0, d_frame1, d_velx, d_vely, max_range.width, block_size.width);
TEST_CYCLE()
{
fastBM(d_frame0, d_frame1, d_velx, d_vely, max_range.width, block_size.width);
}
GPU_SANITY_CHECK(d_velx);
GPU_SANITY_CHECK(d_vely);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -581,21 +661,29 @@ PERF_TEST_P(Video, DISABLED_Video_FGDStatModel, Values("gpu/video/768x576.avi",
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::FGDStatModel d_model(4);
d_model.create(d_frame);
for (int i = 0; i < 10; ++i)
try
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::gpu::GpuMat d_frame(frame);
d_frame.upload(frame);
cv::gpu::FGDStatModel d_model(4);
d_model.create(d_frame);
startTimer(); next();
d_model.update(d_frame);
stopTimer();
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
d_frame.upload(frame);
startTimer(); next();
d_model.update(d_frame);
stopTimer();
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -649,32 +737,40 @@ PERF_TEST_P(Video_Cn_LearningRate, DISABLED_Video_MOG,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG_GPU d_mog;
cv::gpu::GpuMat d_foreground;
d_mog(d_frame, d_foreground, learningRate);
for (int i = 0; i < 10; ++i)
try
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG_GPU d_mog;
cv::gpu::GpuMat d_foreground;
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_mog(d_frame, d_foreground, learningRate);
stopTimer();
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_mog(d_frame, d_foreground, learningRate);
stopTimer();
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -737,32 +833,40 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_MOG2,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG2_GPU d_mog2;
cv::gpu::GpuMat d_foreground;
d_mog2(d_frame, d_foreground);
for (int i = 0; i < 10; ++i)
try
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::gpu::GpuMat d_frame(frame);
cv::gpu::MOG2_GPU d_mog2;
cv::gpu::GpuMat d_foreground;
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_mog2(d_frame, d_foreground);
stopTimer();
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_mog2(d_frame, d_foreground);
stopTimer();
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -810,39 +914,47 @@ PERF_TEST_P(Video_Cn, Video_MOG2GetBackgroundImage,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame;
cv::gpu::MOG2_GPU d_mog2;
cv::gpu::GpuMat d_foreground;
for (int i = 0; i < 10; ++i)
try
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::gpu::GpuMat d_frame;
cv::gpu::MOG2_GPU d_mog2;
cv::gpu::GpuMat d_foreground;
if (cn != 3)
for (int i = 0; i < 10; ++i)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
d_mog2(d_frame, d_foreground);
}
d_frame.upload(frame);
d_mog2(d_frame, d_foreground);
}
cv::gpu::GpuMat d_background;
d_mog2.getBackgroundImage(d_background);
TEST_CYCLE()
{
cv::gpu::GpuMat d_background;
d_mog2.getBackgroundImage(d_background);
}
GPU_SANITY_CHECK(d_background);
TEST_CYCLE()
{
d_mog2.getBackgroundImage(d_background);
}
GPU_SANITY_CHECK(d_background);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{
@ -907,32 +1019,40 @@ PERF_TEST_P(Video_Cn, DISABLED_Video_VIBE,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::VIBE_GPU d_vibe;
cv::gpu::GpuMat d_foreground;
d_vibe(d_frame, d_foreground);
for (int i = 0; i < 10; ++i)
try
{
cap >> frame;
ASSERT_FALSE(frame.empty());
cv::gpu::GpuMat d_frame(frame);
cv::gpu::VIBE_GPU d_vibe;
cv::gpu::GpuMat d_foreground;
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_vibe(d_frame, d_foreground);
stopTimer();
for (int i = 0; i < 10; ++i)
{
cap >> frame;
ASSERT_FALSE(frame.empty());
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_vibe(d_frame, d_foreground);
stopTimer();
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -972,39 +1092,47 @@ PERF_TEST_P(Video_Cn_MaxFeatures, DISABLED_Video_GMG,
if (PERF_RUN_GPU())
{
cv::gpu::GpuMat d_frame(frame);
cv::gpu::GpuMat d_fgmask;
cv::gpu::GMG_GPU d_gmg;
d_gmg.maxFeatures = maxFeatures;
d_gmg(d_frame, d_fgmask);
for (int i = 0; i < 150; ++i)
try
{
cap >> frame;
if (frame.empty())
{
cap.release();
cap.open(inputFile);
cap >> frame;
}
cv::gpu::GpuMat d_frame(frame);
cv::gpu::GpuMat d_fgmask;
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
cv::gpu::GMG_GPU d_gmg;
d_gmg.maxFeatures = maxFeatures;
d_frame.upload(frame);
startTimer(); next();
d_gmg(d_frame, d_fgmask);
stopTimer();
for (int i = 0; i < 150; ++i)
{
cap >> frame;
if (frame.empty())
{
cap.release();
cap.open(inputFile);
cap >> frame;
}
if (cn != 3)
{
cv::Mat temp;
if (cn == 1)
cv::cvtColor(frame, temp, cv::COLOR_BGR2GRAY);
else
cv::cvtColor(frame, temp, cv::COLOR_BGR2BGRA);
cv::swap(temp, frame);
}
d_frame.upload(frame);
startTimer(); next();
d_gmg(d_frame, d_fgmask);
stopTimer();
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -1066,23 +1194,31 @@ PERF_TEST_P(Video, Video_VideoWriter, Values("gpu/video/768x576.avi", "gpu/video
if (PERF_RUN_GPU())
{
cv::gpu::VideoWriter_GPU d_writer;
cv::gpu::GpuMat d_frame;
for (int i = 0; i < 10; ++i)
try
{
reader >> frame;
ASSERT_FALSE(frame.empty());
cv::gpu::VideoWriter_GPU d_writer;
d_frame.upload(frame);
cv::gpu::GpuMat d_frame;
if (!d_writer.isOpened())
d_writer.open(outputFile, frame.size(), FPS);
for (int i = 0; i < 10; ++i)
{
reader >> frame;
ASSERT_FALSE(frame.empty());
startTimer(); next();
d_writer.write(d_frame);
stopTimer();
d_frame.upload(frame);
if (!d_writer.isOpened())
d_writer.open(outputFile, frame.size(), FPS);
startTimer(); next();
d_writer.write(d_frame);
stopTimer();
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
@ -1115,19 +1251,27 @@ PERF_TEST_P(Video, Video_VideoReader, Values("gpu/video/768x576.avi", "gpu/video
if (PERF_RUN_GPU())
{
cv::gpu::VideoReader_GPU d_reader(inputFile);
ASSERT_TRUE( d_reader.isOpened() );
cv::gpu::GpuMat d_frame;
d_reader.read(d_frame);
TEST_CYCLE_N(10)
try
{
d_reader.read(d_frame);
}
cv::gpu::VideoReader_GPU d_reader(inputFile);
ASSERT_TRUE( d_reader.isOpened() );
GPU_SANITY_CHECK(d_frame);
cv::gpu::GpuMat d_frame;
d_reader.read(d_frame);
TEST_CYCLE_N(10)
{
d_reader.read(d_frame);
}
GPU_SANITY_CHECK(d_frame);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
else
{

View File

@ -276,6 +276,8 @@ static void devNullOutput(const std::string& msg)
(void)msg;
}
}
bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)
{
path = test_data_path.c_str();
@ -292,8 +294,6 @@ bool nvidia_NPPST_Integral_Image(const std::string& test_data_path, OutputLevel
return testListerII.invoke();
}
}
bool nvidia_NPPST_Squared_Integral_Image(const std::string& test_data_path, OutputLevel outputLevel)
{
path = test_data_path;

View File

@ -62,20 +62,28 @@ struct StereoBM : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(StereoBM, Regression)
{
cv::Mat left_image = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
cv::Mat right_image = readImage("stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
cv::Mat disp_gold = readImage("stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
try
{
cv::Mat left_image = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
cv::Mat right_image = readImage("stereobm/aloe-R.png", cv::IMREAD_GRAYSCALE);
cv::Mat disp_gold = readImage("stereobm/aloe-disp.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(left_image.empty());
ASSERT_FALSE(right_image.empty());
ASSERT_FALSE(disp_gold.empty());
ASSERT_FALSE(left_image.empty());
ASSERT_FALSE(right_image.empty());
ASSERT_FALSE(disp_gold.empty());
cv::gpu::StereoBM_GPU bm(0, 128, 19);
cv::gpu::GpuMat disp;
cv::gpu::StereoBM_GPU bm(0, 128, 19);
cv::gpu::GpuMat disp;
bm(loadMat(left_image), loadMat(right_image), disp);
bm(loadMat(left_image), loadMat(right_image), disp);
EXPECT_MAT_NEAR(disp_gold, disp, 0.0);
EXPECT_MAT_NEAR(disp_gold, disp, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBM, ALL_DEVICES);
@ -97,23 +105,31 @@ struct StereoBeliefPropagation : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(StereoBeliefPropagation, Regression)
{
cv::Mat left_image = readImage("stereobp/aloe-L.png");
cv::Mat right_image = readImage("stereobp/aloe-R.png");
cv::Mat disp_gold = readImage("stereobp/aloe-disp.png", cv::IMREAD_GRAYSCALE);
try
{
cv::Mat left_image = readImage("stereobp/aloe-L.png");
cv::Mat right_image = readImage("stereobp/aloe-R.png");
cv::Mat disp_gold = readImage("stereobp/aloe-disp.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(left_image.empty());
ASSERT_FALSE(right_image.empty());
ASSERT_FALSE(disp_gold.empty());
ASSERT_FALSE(left_image.empty());
ASSERT_FALSE(right_image.empty());
ASSERT_FALSE(disp_gold.empty());
cv::gpu::StereoBeliefPropagation bp(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
cv::gpu::GpuMat disp;
cv::gpu::StereoBeliefPropagation bp(64, 8, 2, 25, 0.1f, 15, 1, CV_16S);
cv::gpu::GpuMat disp;
bp(loadMat(left_image), loadMat(right_image), disp);
bp(loadMat(left_image), loadMat(right_image), disp);
cv::Mat h_disp(disp);
h_disp.convertTo(h_disp, disp_gold.depth());
cv::Mat h_disp(disp);
h_disp.convertTo(h_disp, disp_gold.depth());
EXPECT_MAT_NEAR(disp_gold, h_disp, 0.0);
EXPECT_MAT_NEAR(disp_gold, h_disp, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoBeliefPropagation, ALL_DEVICES);
@ -135,29 +151,37 @@ struct StereoConstantSpaceBP : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(StereoConstantSpaceBP, Regression)
{
cv::Mat left_image = readImage("csstereobp/aloe-L.png");
cv::Mat right_image = readImage("csstereobp/aloe-R.png");
try
{
cv::Mat left_image = readImage("csstereobp/aloe-L.png");
cv::Mat right_image = readImage("csstereobp/aloe-R.png");
cv::Mat disp_gold;
cv::Mat disp_gold;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
disp_gold = readImage("csstereobp/aloe-disp.png", cv::IMREAD_GRAYSCALE);
else
disp_gold = readImage("csstereobp/aloe-disp_CC1X.png", cv::IMREAD_GRAYSCALE);
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
disp_gold = readImage("csstereobp/aloe-disp.png", cv::IMREAD_GRAYSCALE);
else
disp_gold = readImage("csstereobp/aloe-disp_CC1X.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(left_image.empty());
ASSERT_FALSE(right_image.empty());
ASSERT_FALSE(disp_gold.empty());
ASSERT_FALSE(left_image.empty());
ASSERT_FALSE(right_image.empty());
ASSERT_FALSE(disp_gold.empty());
cv::gpu::StereoConstantSpaceBP csbp(128, 16, 4, 4);
cv::gpu::GpuMat disp;
cv::gpu::StereoConstantSpaceBP csbp(128, 16, 4, 4);
cv::gpu::GpuMat disp;
csbp(loadMat(left_image), loadMat(right_image), disp);
csbp(loadMat(left_image), loadMat(right_image), disp);
cv::Mat h_disp(disp);
h_disp.convertTo(h_disp, disp_gold.depth());
cv::Mat h_disp(disp);
h_disp.convertTo(h_disp, disp_gold.depth());
EXPECT_MAT_NEAR(disp_gold, h_disp, 1.0);
EXPECT_MAT_NEAR(disp_gold, h_disp, 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, StereoConstantSpaceBP, ALL_DEVICES);
@ -179,32 +203,40 @@ struct TransformPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(TransformPoints, Accuracy)
{
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
cv::Mat rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Mat tvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::gpu::GpuMat dst;
cv::gpu::transformPoints(loadMat(src), rvec, tvec, dst);
ASSERT_EQ(src.size(), dst.size());
ASSERT_EQ(src.type(), dst.type());
cv::Mat h_dst(dst);
cv::Mat rot;
cv::Rodrigues(rvec, rot);
for (int i = 0; i < h_dst.cols; ++i)
try
{
cv::Point3f res = h_dst.at<cv::Point3f>(0, i);
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
cv::Mat rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Mat tvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Point3f p = src.at<cv::Point3f>(0, i);
cv::Point3f res_gold(
rot.at<float>(0, 0) * p.x + rot.at<float>(0, 1) * p.y + rot.at<float>(0, 2) * p.z + tvec.at<float>(0, 0),
rot.at<float>(1, 0) * p.x + rot.at<float>(1, 1) * p.y + rot.at<float>(1, 2) * p.z + tvec.at<float>(0, 1),
rot.at<float>(2, 0) * p.x + rot.at<float>(2, 1) * p.y + rot.at<float>(2, 2) * p.z + tvec.at<float>(0, 2));
cv::gpu::GpuMat dst;
cv::gpu::transformPoints(loadMat(src), rvec, tvec, dst);
ASSERT_POINT3_NEAR(res_gold, res, 1e-5);
ASSERT_EQ(src.size(), dst.size());
ASSERT_EQ(src.type(), dst.type());
cv::Mat h_dst(dst);
cv::Mat rot;
cv::Rodrigues(rvec, rot);
for (int i = 0; i < h_dst.cols; ++i)
{
cv::Point3f res = h_dst.at<cv::Point3f>(0, i);
cv::Point3f p = src.at<cv::Point3f>(0, i);
cv::Point3f res_gold(
rot.at<float>(0, 0) * p.x + rot.at<float>(0, 1) * p.y + rot.at<float>(0, 2) * p.z + tvec.at<float>(0, 0),
rot.at<float>(1, 0) * p.x + rot.at<float>(1, 1) * p.y + rot.at<float>(1, 2) * p.z + tvec.at<float>(0, 1),
rot.at<float>(2, 0) * p.x + rot.at<float>(2, 1) * p.y + rot.at<float>(2, 2) * p.z + tvec.at<float>(0, 2));
ASSERT_POINT3_NEAR(res_gold, res, 1e-5);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
@ -227,34 +259,42 @@ struct ProjectPoints : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(ProjectPoints, Accuracy)
{
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
cv::Mat rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Mat tvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
camera_mat.at<float>(0, 1) = 0.f;
camera_mat.at<float>(1, 0) = 0.f;
camera_mat.at<float>(2, 0) = 0.f;
camera_mat.at<float>(2, 1) = 0.f;
cv::gpu::GpuMat dst;
cv::gpu::projectPoints(loadMat(src), rvec, tvec, camera_mat, cv::Mat(), dst);
ASSERT_EQ(1, dst.rows);
ASSERT_EQ(MatType(CV_32FC2), MatType(dst.type()));
std::vector<cv::Point2f> dst_gold;
cv::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), dst_gold);
ASSERT_EQ(dst_gold.size(), static_cast<size_t>(dst.cols));
cv::Mat h_dst(dst);
for (size_t i = 0; i < dst_gold.size(); ++i)
try
{
cv::Point2f res = h_dst.at<cv::Point2f>(0, (int)i);
cv::Point2f res_gold = dst_gold[i];
cv::Mat src = randomMat(cv::Size(1000, 1), CV_32FC3, 0, 10);
cv::Mat rvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Mat tvec = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
camera_mat.at<float>(0, 1) = 0.f;
camera_mat.at<float>(1, 0) = 0.f;
camera_mat.at<float>(2, 0) = 0.f;
camera_mat.at<float>(2, 1) = 0.f;
ASSERT_LE(cv::norm(res_gold - res) / cv::norm(res_gold), 1e-3f);
cv::gpu::GpuMat dst;
cv::gpu::projectPoints(loadMat(src), rvec, tvec, camera_mat, cv::Mat(), dst);
ASSERT_EQ(1, dst.rows);
ASSERT_EQ(MatType(CV_32FC2), MatType(dst.type()));
std::vector<cv::Point2f> dst_gold;
cv::projectPoints(src, rvec, tvec, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), dst_gold);
ASSERT_EQ(dst_gold.size(), static_cast<size_t>(dst.cols));
cv::Mat h_dst(dst);
for (size_t i = 0; i < dst_gold.size(); ++i)
{
cv::Point2f res = h_dst.at<cv::Point2f>(0, (int)i);
cv::Point2f res_gold = dst_gold[i];
ASSERT_LE(cv::norm(res_gold - res) / cv::norm(res_gold), 1e-3f);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
@ -277,28 +317,36 @@ struct SolvePnPRansac : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(SolvePnPRansac, Accuracy)
{
cv::Mat object = randomMat(cv::Size(5000, 1), CV_32FC3, 0, 100);
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
camera_mat.at<float>(0, 1) = 0.f;
camera_mat.at<float>(1, 0) = 0.f;
camera_mat.at<float>(2, 0) = 0.f;
camera_mat.at<float>(2, 1) = 0.f;
try
{
cv::Mat object = randomMat(cv::Size(5000, 1), CV_32FC3, 0, 100);
cv::Mat camera_mat = randomMat(cv::Size(3, 3), CV_32F, 0.5, 1);
camera_mat.at<float>(0, 1) = 0.f;
camera_mat.at<float>(1, 0) = 0.f;
camera_mat.at<float>(2, 0) = 0.f;
camera_mat.at<float>(2, 1) = 0.f;
std::vector<cv::Point2f> image_vec;
cv::Mat rvec_gold;
cv::Mat tvec_gold;
rvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
tvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), image_vec);
std::vector<cv::Point2f> image_vec;
cv::Mat rvec_gold;
cv::Mat tvec_gold;
rvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
tvec_gold = randomMat(cv::Size(3, 1), CV_32F, 0, 1);
cv::projectPoints(object, rvec_gold, tvec_gold, camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)), image_vec);
cv::Mat rvec, tvec;
std::vector<int> inliers;
cv::gpu::solvePnPRansac(object, cv::Mat(1, (int)image_vec.size(), CV_32FC2, &image_vec[0]),
camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)),
rvec, tvec, false, 200, 2.f, 100, &inliers);
cv::Mat rvec, tvec;
std::vector<int> inliers;
cv::gpu::solvePnPRansac(object, cv::Mat(1, (int)image_vec.size(), CV_32FC2, &image_vec[0]),
camera_mat, cv::Mat(1, 8, CV_32F, cv::Scalar::all(0)),
rvec, tvec, false, 200, 2.f, 100, &inliers);
ASSERT_LE(cv::norm(rvec - rvec_gold), 1e-3);
ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3);
ASSERT_LE(cv::norm(rvec - rvec_gold), 1e-3);
ASSERT_LE(cv::norm(tvec - tvec_gold), 1e-3);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, SolvePnPRansac, ALL_DEVICES);
@ -326,16 +374,24 @@ PARAM_TEST_CASE(ReprojectImageTo3D, cv::gpu::DeviceInfo, cv::Size, MatDepth, Use
TEST_P(ReprojectImageTo3D, Accuracy)
{
cv::Mat disp = randomMat(size, depth, 5.0, 30.0);
cv::Mat Q = randomMat(cv::Size(4, 4), CV_32FC1, 0.1, 1.0);
try
{
cv::Mat disp = randomMat(size, depth, 5.0, 30.0);
cv::Mat Q = randomMat(cv::Size(4, 4), CV_32FC1, 0.1, 1.0);
cv::gpu::GpuMat dst;
cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), dst, Q, 3);
cv::gpu::GpuMat dst;
cv::gpu::reprojectImageTo3D(loadMat(disp, useRoi), dst, Q, 3);
cv::Mat dst_gold;
cv::reprojectImageTo3D(disp, dst_gold, Q, false);
cv::Mat dst_gold;
cv::reprojectImageTo3D(disp, dst_gold, Q, false);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
EXPECT_MAT_NEAR(dst_gold, dst, 1e-5);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Calib3D, ReprojectImageTo3D, testing::Combine(

File diff suppressed because it is too large Load Diff

View File

@ -71,16 +71,24 @@ PARAM_TEST_CASE(CopyMakeBorder, cv::gpu::DeviceInfo, cv::Size, MatType, Border,
TEST_P(CopyMakeBorder, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Scalar val = randomScalar(0, 255);
try
{
cv::Mat src = randomMat(size, type);
cv::Scalar val = randomScalar(0, 255);
cv::gpu::GpuMat dst = createMat(cv::Size(size.width + 2 * border, size.height + 2 * border), type, useRoi);
cv::gpu::copyMakeBorder(loadMat(src, useRoi), dst, border, border, border, border, borderType, val);
cv::gpu::GpuMat dst = createMat(cv::Size(size.width + 2 * border, size.height + 2 * border), type, useRoi);
cv::gpu::copyMakeBorder(loadMat(src, useRoi), dst, border, border, border, border, borderType, val);
cv::Mat dst_gold;
cv::copyMakeBorder(src, dst_gold, border, border, border, border, borderType, val);
cv::Mat dst_gold;
cv::copyMakeBorder(src, dst_gold, border, border, border, border, borderType, val);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CopyMakeBorder, testing::Combine(

File diff suppressed because it is too large Load Diff

View File

@ -71,17 +71,25 @@ PARAM_TEST_CASE(BilateralFilter, cv::gpu::DeviceInfo, cv::Size, MatType)
TEST_P(BilateralFilter, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
src.convertTo(src, type);
cv::gpu::GpuMat dst;
src.convertTo(src, type);
cv::gpu::GpuMat dst;
cv::gpu::bilateralFilter(loadMat(src), dst, kernel_size, sigma_color, sigma_spatial);
cv::gpu::bilateralFilter(loadMat(src), dst, kernel_size, sigma_color, sigma_spatial);
cv::Mat dst_gold;
cv::bilateralFilter(src, dst_gold, kernel_size, sigma_color, sigma_spatial);
cv::Mat dst_gold;
cv::bilateralFilter(src, dst_gold, kernel_size, sigma_color, sigma_spatial);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-3 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-3 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Denoising, BilateralFilter, testing::Combine(
@ -107,35 +115,41 @@ struct BruteForceNonLocalMeans: testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(BruteForceNonLocalMeans, Regression)
{
using cv::gpu::GpuMat;
try
{
using cv::gpu::GpuMat;
cv::Mat bgr = readImage("denoising/lena_noised_gaussian_sigma=20_multi_0.png", cv::IMREAD_COLOR);
ASSERT_FALSE(bgr.empty());
cv::Mat bgr = readImage("denoising/lena_noised_gaussian_sigma=20_multi_0.png", cv::IMREAD_COLOR);
ASSERT_FALSE(bgr.empty());
cv::Mat gray;
cv::cvtColor(bgr, gray, CV_BGR2GRAY);
cv::Mat gray;
cv::cvtColor(bgr, gray, CV_BGR2GRAY);
GpuMat dbgr, dgray;
cv::gpu::nonLocalMeans(GpuMat(bgr), dbgr, 20);
cv::gpu::nonLocalMeans(GpuMat(gray), dgray, 20);
GpuMat dbgr, dgray;
cv::gpu::nonLocalMeans(GpuMat(bgr), dbgr, 20);
cv::gpu::nonLocalMeans(GpuMat(gray), dgray, 20);
#if 0
dumpImage("denoising/nlm_denoised_lena_bgr.png", cv::Mat(dbgr));
dumpImage("denoising/nlm_denoised_lena_gray.png", cv::Mat(dgray));
#endif
#if 0
dumpImage("denoising/nlm_denoised_lena_bgr.png", cv::Mat(dbgr));
dumpImage("denoising/nlm_denoised_lena_gray.png", cv::Mat(dgray));
#endif
cv::Mat bgr_gold = readImage("denoising/nlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
cv::Mat gray_gold = readImage("denoising/nlm_denoised_lena_gray.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(bgr_gold.empty() || gray_gold.empty());
cv::Mat bgr_gold = readImage("denoising/nlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
cv::Mat gray_gold = readImage("denoising/nlm_denoised_lena_gray.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(bgr_gold.empty() || gray_gold.empty());
EXPECT_MAT_NEAR(bgr_gold, dbgr, 1e-4);
EXPECT_MAT_NEAR(gray_gold, dgray, 1e-4);
EXPECT_MAT_NEAR(bgr_gold, dbgr, 1e-4);
EXPECT_MAT_NEAR(gray_gold, dgray, 1e-4);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Denoising, BruteForceNonLocalMeans, ALL_DEVICES);
////////////////////////////////////////////////////////
// Fast Force Non local means
@ -152,34 +166,41 @@ struct FastNonLocalMeans: testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(FastNonLocalMeans, Regression)
{
using cv::gpu::GpuMat;
try
{
using cv::gpu::GpuMat;
cv::Mat bgr = readImage("denoising/lena_noised_gaussian_sigma=20_multi_0.png", cv::IMREAD_COLOR);
ASSERT_FALSE(bgr.empty());
cv::Mat bgr = readImage("denoising/lena_noised_gaussian_sigma=20_multi_0.png", cv::IMREAD_COLOR);
ASSERT_FALSE(bgr.empty());
cv::Mat gray;
cv::cvtColor(bgr, gray, CV_BGR2GRAY);
cv::Mat gray;
cv::cvtColor(bgr, gray, CV_BGR2GRAY);
GpuMat dbgr, dgray;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
GpuMat dbgr, dgray;
cv::gpu::FastNonLocalMeansDenoising fnlmd;
fnlmd.simpleMethod(GpuMat(gray), dgray, 20);
fnlmd.labMethod(GpuMat(bgr), dbgr, 20, 10);
fnlmd.simpleMethod(GpuMat(gray), dgray, 20);
fnlmd.labMethod(GpuMat(bgr), dbgr, 20, 10);
#if 0
//dumpImage("denoising/fnlm_denoised_lena_bgr.png", cv::Mat(dbgr));
//dumpImage("denoising/fnlm_denoised_lena_gray.png", cv::Mat(dgray));
#endif
#if 0
//dumpImage("denoising/fnlm_denoised_lena_bgr.png", cv::Mat(dbgr));
//dumpImage("denoising/fnlm_denoised_lena_gray.png", cv::Mat(dgray));
#endif
cv::Mat bgr_gold = readImage("denoising/fnlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
cv::Mat gray_gold = readImage("denoising/fnlm_denoised_lena_gray.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(bgr_gold.empty() || gray_gold.empty());
cv::Mat bgr_gold = readImage("denoising/fnlm_denoised_lena_bgr.png", cv::IMREAD_COLOR);
cv::Mat gray_gold = readImage("denoising/fnlm_denoised_lena_gray.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(bgr_gold.empty() || gray_gold.empty());
EXPECT_MAT_NEAR(bgr_gold, dbgr, 1);
EXPECT_MAT_NEAR(gray_gold, dgray, 1);
EXPECT_MAT_NEAR(bgr_gold, dbgr, 1);
EXPECT_MAT_NEAR(gray_gold, dgray, 1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Denoising, FastNonLocalMeans, ALL_DEVICES);
#endif // HAVE_CUDA

File diff suppressed because it is too large Load Diff

View File

@ -88,15 +88,23 @@ PARAM_TEST_CASE(Blur, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor, Use
TEST_P(Blur, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::blur(loadMat(src, useRoi), dst, ksize, anchor);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::blur(loadMat(src, useRoi), dst, ksize, anchor);
cv::Mat dst_gold;
cv::blur(src, dst_gold, ksize, anchor);
cv::Mat dst_gold;
cv::blur(src, dst_gold, ksize, anchor);
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 1.0);
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Blur, testing::Combine(
@ -150,15 +158,23 @@ TEST_P(Sobel, Accuracy)
if (dx == 0 && dy == 0)
return;
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::Sobel(loadMat(src, useRoi), dst, -1, dx, dy, ksize.width, 1.0, borderType);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::Sobel(loadMat(src, useRoi), dst, -1, dx, dy, ksize.width, 1.0, borderType);
cv::Mat dst_gold;
cv::Sobel(src, dst_gold, -1, dx, dy, ksize.width, 1.0, 0.0, borderType);
cv::Mat dst_gold;
cv::Sobel(src, dst_gold, -1, dx, dy, ksize.width, 1.0, 0.0, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, CV_MAT_DEPTH(type) < CV_32F ? 0.0 : 0.1);
EXPECT_MAT_NEAR(dst_gold, dst, CV_MAT_DEPTH(type) < CV_32F ? 0.0 : 0.1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Sobel, testing::Combine(
@ -213,15 +229,23 @@ TEST_P(Scharr, Accuracy)
if (dx + dy != 1)
return;
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::Scharr(loadMat(src, useRoi), dst, -1, dx, dy, 1.0, borderType);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::Scharr(loadMat(src, useRoi), dst, -1, dx, dy, 1.0, borderType);
cv::Mat dst_gold;
cv::Scharr(src, dst_gold, -1, dx, dy, 1.0, 0.0, borderType);
cv::Mat dst_gold;
cv::Scharr(src, dst_gold, -1, dx, dy, 1.0, 0.0, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, CV_MAT_DEPTH(type) < CV_32F ? 0.0 : 0.1);
EXPECT_MAT_NEAR(dst_gold, dst, CV_MAT_DEPTH(type) < CV_32F ? 0.0 : 0.1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Scharr, testing::Combine(
@ -270,31 +294,39 @@ PARAM_TEST_CASE(GaussianBlur, cv::gpu::DeviceInfo, cv::Size, MatDepth, Channels,
TEST_P(GaussianBlur, Accuracy)
{
cv::Mat src = randomMat(size, type);
double sigma1 = randomDouble(0.1, 1.0);
double sigma2 = randomDouble(0.1, 1.0);
if (ksize.height > 16 && !supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
try
{
try
cv::Mat src = randomMat(size, type);
double sigma1 = randomDouble(0.1, 1.0);
double sigma2 = randomDouble(0.1, 1.0);
if (ksize.height > 16 && !supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
{
cv::gpu::GpuMat dst;
cv::gpu::GaussianBlur(loadMat(src), dst, ksize, sigma1, sigma2, borderType);
try
{
cv::gpu::GpuMat dst;
cv::gpu::GaussianBlur(loadMat(src), dst, ksize, sigma1, sigma2, borderType);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsNotImplemented, e.code);
}
}
catch (const cv::Exception& e)
else
{
ASSERT_EQ(CV_StsNotImplemented, e.code);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::GaussianBlur(loadMat(src, useRoi), dst, ksize, sigma1, sigma2, borderType);
cv::Mat dst_gold;
cv::GaussianBlur(src, dst_gold, ksize, sigma1, sigma2, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, 4.0);
}
}
else
catch (...)
{
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::GaussianBlur(loadMat(src, useRoi), dst, ksize, sigma1, sigma2, borderType);
cv::Mat dst_gold;
cv::GaussianBlur(src, dst_gold, ksize, sigma1, sigma2, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, 4.0);
cv::gpu::resetDevice();
throw;
}
}
@ -349,15 +381,23 @@ PARAM_TEST_CASE(Laplacian, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, UseRoi
TEST_P(Laplacian, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::Laplacian(loadMat(src, useRoi), dst, -1, ksize.width);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::Laplacian(loadMat(src, useRoi), dst, -1, ksize.width);
cv::Mat dst_gold;
cv::Laplacian(src, dst_gold, -1, ksize.width);
cv::Mat dst_gold;
cv::Laplacian(src, dst_gold, -1, ksize.width);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() < CV_32F ? 0.0 : 1e-3);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() < CV_32F ? 0.0 : 1e-3);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Laplacian, testing::Combine(
@ -396,18 +436,26 @@ PARAM_TEST_CASE(Erode, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iteration
TEST_P(Erode, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
try
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::erode(loadMat(src, useRoi), dst, kernel, anchor, iterations);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::erode(loadMat(src, useRoi), dst, kernel, anchor, iterations);
cv::Mat dst_gold;
cv::erode(src, dst_gold, kernel, anchor, iterations);
cv::Mat dst_gold;
cv::erode(src, dst_gold, kernel, anchor, iterations);
cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));
cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Erode, testing::Combine(
@ -445,18 +493,26 @@ PARAM_TEST_CASE(Dilate, cv::gpu::DeviceInfo, cv::Size, MatType, Anchor, Iteratio
TEST_P(Dilate, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
try
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::dilate(loadMat(src, useRoi), dst, kernel, anchor, iterations);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::dilate(loadMat(src, useRoi), dst, kernel, anchor, iterations);
cv::Mat dst_gold;
cv::dilate(src, dst_gold, kernel, anchor, iterations);
cv::Mat dst_gold;
cv::dilate(src, dst_gold, kernel, anchor, iterations);
cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));
cv::Size ksize = cv::Size(kernel.cols + iterations * (kernel.cols - 1), kernel.rows + iterations * (kernel.rows - 1));
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);
EXPECT_MAT_NEAR(getInnerROI(dst_gold, ksize), getInnerROI(dst, ksize), 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Dilate, testing::Combine(
@ -499,18 +555,26 @@ PARAM_TEST_CASE(MorphEx, cv::gpu::DeviceInfo, cv::Size, MatType, MorphOp, Anchor
TEST_P(MorphEx, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
try
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = cv::Mat::ones(3, 3, CV_8U);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::morphologyEx(loadMat(src, useRoi), dst, morphOp, kernel, anchor, iterations);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::morphologyEx(loadMat(src, useRoi), dst, morphOp, kernel, anchor, iterations);
cv::Mat dst_gold;
cv::morphologyEx(src, dst_gold, morphOp, kernel, anchor, iterations);
cv::Mat dst_gold;
cv::morphologyEx(src, dst_gold, morphOp, kernel, anchor, iterations);
cv::Size border = cv::Size(kernel.cols + (iterations + 1) * kernel.cols + 2, kernel.rows + (iterations + 1) * kernel.rows + 2);
cv::Size border = cv::Size(kernel.cols + (iterations + 1) * kernel.cols + 2, kernel.rows + (iterations + 1) * kernel.rows + 2);
EXPECT_MAT_NEAR(getInnerROI(dst_gold, border), getInnerROI(dst, border), 0.0);
EXPECT_MAT_NEAR(getInnerROI(dst_gold, border), getInnerROI(dst, border), 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, MorphEx, testing::Combine(
@ -553,16 +617,24 @@ PARAM_TEST_CASE(Filter2D, cv::gpu::DeviceInfo, cv::Size, MatType, KSize, Anchor,
TEST_P(Filter2D, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = randomMat(cv::Size(ksize.width, ksize.height), CV_32FC1, 0.0, 1.0);
try
{
cv::Mat src = randomMat(size, type);
cv::Mat kernel = randomMat(cv::Size(ksize.width, ksize.height), CV_32FC1, 0.0, 1.0);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::filter2D(loadMat(src, useRoi), dst, -1, kernel, anchor, borderType);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::filter2D(loadMat(src, useRoi), dst, -1, kernel, anchor, borderType);
cv::Mat dst_gold;
cv::filter2D(src, dst_gold, -1, kernel, anchor, 0, borderType);
cv::Mat dst_gold;
cv::filter2D(src, dst_gold, -1, kernel, anchor, 0, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, CV_MAT_DEPTH(type) == CV_32F ? 1e-1 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, CV_MAT_DEPTH(type) == CV_32F ? 1e-1 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_Filter, Filter2D, testing::Combine(

View File

@ -53,35 +53,43 @@ struct CompactPoints : testing::TestWithParam<gpu::DeviceInfo>
TEST_P(CompactPoints, CanCompactizeSmallInput)
{
Mat src0(1, 3, CV_32FC2);
src0.at<Point2f>(0,0) = Point2f(0,0);
src0.at<Point2f>(0,1) = Point2f(0,1);
src0.at<Point2f>(0,2) = Point2f(0,2);
try
{
Mat src0(1, 3, CV_32FC2);
src0.at<Point2f>(0,0) = Point2f(0,0);
src0.at<Point2f>(0,1) = Point2f(0,1);
src0.at<Point2f>(0,2) = Point2f(0,2);
Mat src1(1, 3, CV_32FC2);
src1.at<Point2f>(0,0) = Point2f(1,0);
src1.at<Point2f>(0,1) = Point2f(1,1);
src1.at<Point2f>(0,2) = Point2f(1,2);
Mat src1(1, 3, CV_32FC2);
src1.at<Point2f>(0,0) = Point2f(1,0);
src1.at<Point2f>(0,1) = Point2f(1,1);
src1.at<Point2f>(0,2) = Point2f(1,2);
Mat mask(1, 3, CV_8U);
mask.at<uchar>(0,0) = 1;
mask.at<uchar>(0,1) = 0;
mask.at<uchar>(0,2) = 1;
Mat mask(1, 3, CV_8U);
mask.at<uchar>(0,0) = 1;
mask.at<uchar>(0,1) = 0;
mask.at<uchar>(0,2) = 1;
gpu::GpuMat dsrc0(src0), dsrc1(src1), dmask(mask);
gpu::compactPoints(dsrc0, dsrc1, dmask);
gpu::GpuMat dsrc0(src0), dsrc1(src1), dmask(mask);
gpu::compactPoints(dsrc0, dsrc1, dmask);
dsrc0.download(src0);
dsrc1.download(src1);
dsrc0.download(src0);
dsrc1.download(src1);
ASSERT_EQ(2, src0.cols);
ASSERT_EQ(2, src1.cols);
ASSERT_EQ(2, src0.cols);
ASSERT_EQ(2, src1.cols);
ASSERT_TRUE(src0.at<Point2f>(0,0) == Point2f(0,0));
ASSERT_TRUE(src0.at<Point2f>(0,1) == Point2f(0,2));
ASSERT_TRUE(src0.at<Point2f>(0,0) == Point2f(0,0));
ASSERT_TRUE(src0.at<Point2f>(0,1) == Point2f(0,2));
ASSERT_TRUE(src1.at<Point2f>(0,0) == Point2f(1,0));
ASSERT_TRUE(src1.at<Point2f>(0,1) == Point2f(1,2));
ASSERT_TRUE(src1.at<Point2f>(0,0) == Point2f(1,0));
ASSERT_TRUE(src1.at<Point2f>(0,1) == Point2f(1,2));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_GlobalMotion, CompactPoints, ALL_DEVICES);

View File

@ -69,90 +69,122 @@ PARAM_TEST_CASE(SetTo, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
TEST_P(SetTo, Zero)
{
cv::Scalar zero = cv::Scalar::all(0);
try
{
cv::Scalar zero = cv::Scalar::all(0);
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(zero);
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(zero);
EXPECT_MAT_NEAR(cv::Mat::zeros(size, type), mat, 0.0);
EXPECT_MAT_NEAR(cv::Mat::zeros(size, type), mat, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(SetTo, SameVal)
{
cv::Scalar val = cv::Scalar::all(randomDouble(0.0, 255.0));
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
try
{
try
cv::Scalar val = cv::Scalar::all(randomDouble(0.0, 255.0));
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
{
try
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
}
}
else
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
EXPECT_MAT_NEAR(cv::Mat(size, type, val), mat, 0.0);
}
}
else
catch (...)
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val);
EXPECT_MAT_NEAR(cv::Mat(size, type, val), mat, 0.0);
cv::gpu::resetDevice();
throw;
}
}
TEST_P(SetTo, DifferentVal)
{
cv::Scalar val = randomScalar(0.0, 255.0);
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
try
{
try
cv::Scalar val = randomScalar(0.0, 255.0);
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
{
try
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
}
}
else
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
EXPECT_MAT_NEAR(cv::Mat(size, type, val), mat, 0.0);
}
}
else
catch (...)
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val);
EXPECT_MAT_NEAR(cv::Mat(size, type, val), mat, 0.0);
cv::gpu::resetDevice();
throw;
}
}
TEST_P(SetTo, Masked)
{
cv::Scalar val = randomScalar(0.0, 255.0);
cv::Mat mat_gold = randomMat(size, type);
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
try
{
try
cv::Scalar val = randomScalar(0.0, 255.0);
cv::Mat mat_gold = randomMat(size, type);
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val, loadMat(mask));
try
{
cv::gpu::GpuMat mat = createMat(size, type, useRoi);
mat.setTo(val, loadMat(mask));
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
}
}
catch (const cv::Exception& e)
else
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
cv::gpu::GpuMat mat = loadMat(mat_gold, useRoi);
mat.setTo(val, loadMat(mask, useRoi));
mat_gold.setTo(val, mask);
EXPECT_MAT_NEAR(mat_gold, mat, 0.0);
}
}
else
catch (...)
{
cv::gpu::GpuMat mat = loadMat(mat_gold, useRoi);
mat.setTo(val, loadMat(mask, useRoi));
mat_gold.setTo(val, mask);
EXPECT_MAT_NEAR(mat_gold, mat, 0.0);
cv::gpu::resetDevice();
throw;
}
}
@ -186,43 +218,59 @@ PARAM_TEST_CASE(CopyTo, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
TEST_P(CopyTo, WithOutMask)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
d_src.copyTo(dst);
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
d_src.copyTo(dst);
EXPECT_MAT_NEAR(src, dst, 0.0);
EXPECT_MAT_NEAR(src, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(CopyTo, Masked)
{
cv::Mat src = randomMat(size, type);
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
try
{
try
cv::Mat src = randomMat(size, type);
cv::Mat mask = randomMat(size, CV_8UC1, 0.0, 2.0);
if (CV_MAT_DEPTH(type) == CV_64F && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
{
cv::gpu::GpuMat d_src = loadMat(src);
cv::gpu::GpuMat dst;
d_src.copyTo(dst, loadMat(mask, useRoi));
try
{
cv::gpu::GpuMat d_src = loadMat(src);
cv::gpu::GpuMat dst;
d_src.copyTo(dst, loadMat(mask, useRoi));
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
}
}
catch (const cv::Exception& e)
else
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = loadMat(cv::Mat::zeros(size, type), useRoi);
d_src.copyTo(dst, loadMat(mask, useRoi));
cv::Mat dst_gold = cv::Mat::zeros(size, type);
src.copyTo(dst_gold, mask);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
}
else
catch (...)
{
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = loadMat(cv::Mat::zeros(size, type), useRoi);
d_src.copyTo(dst, loadMat(mask, useRoi));
cv::Mat dst_gold = cv::Mat::zeros(size, type);
src.copyTo(dst_gold, mask);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
cv::gpu::resetDevice();
throw;
}
}
@ -257,63 +305,79 @@ PARAM_TEST_CASE(ConvertTo, cv::gpu::DeviceInfo, cv::Size, MatDepth, MatDepth, Us
TEST_P(ConvertTo, WithOutScaling)
{
cv::Mat src = randomMat(size, depth1);
if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
try
{
try
cv::Mat src = randomMat(size, depth1);
if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
{
cv::gpu::GpuMat d_src = loadMat(src);
cv::gpu::GpuMat dst;
d_src.convertTo(dst, depth2);
try
{
cv::gpu::GpuMat d_src = loadMat(src);
cv::gpu::GpuMat dst;
d_src.convertTo(dst, depth2);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
}
}
catch (const cv::Exception& e)
else
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = createMat(size, depth2, useRoi);
d_src.convertTo(dst, depth2);
cv::Mat dst_gold;
src.convertTo(dst_gold, depth2);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
}
else
catch (...)
{
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = createMat(size, depth2, useRoi);
d_src.convertTo(dst, depth2);
cv::Mat dst_gold;
src.convertTo(dst_gold, depth2);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
cv::gpu::resetDevice();
throw;
}
}
TEST_P(ConvertTo, WithScaling)
{
cv::Mat src = randomMat(size, depth1);
double a = randomDouble(0.0, 1.0);
double b = randomDouble(-10.0, 10.0);
if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
try
{
try
cv::Mat src = randomMat(size, depth1);
double a = randomDouble(0.0, 1.0);
double b = randomDouble(-10.0, 10.0);
if ((depth1 == CV_64F || depth2 == CV_64F) && !supportFeature(devInfo, cv::gpu::NATIVE_DOUBLE))
{
cv::gpu::GpuMat d_src = loadMat(src);
cv::gpu::GpuMat dst;
d_src.convertTo(dst, depth2, a, b);
try
{
cv::gpu::GpuMat d_src = loadMat(src);
cv::gpu::GpuMat dst;
d_src.convertTo(dst, depth2, a, b);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
}
}
catch (const cv::Exception& e)
else
{
ASSERT_EQ(CV_StsUnsupportedFormat, e.code);
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = createMat(size, depth2, useRoi);
d_src.convertTo(dst, depth2, a, b);
cv::Mat dst_gold;
src.convertTo(dst_gold, depth2, a, b);
EXPECT_MAT_NEAR(dst_gold, dst, depth2 < CV_32F ? 1.0 : 1e-4);
}
}
else
catch (...)
{
cv::gpu::GpuMat d_src = loadMat(src, useRoi);
cv::gpu::GpuMat dst = createMat(size, depth2, useRoi);
d_src.convertTo(dst, depth2, a, b);
cv::Mat dst_gold;
src.convertTo(dst_gold, depth2, a, b);
EXPECT_MAT_NEAR(dst_gold, dst, depth2 < CV_32F ? 1.0 : 1e-4);
cv::gpu::resetDevice();
throw;
}
}
@ -338,22 +402,30 @@ struct EnsureSizeIsEnough : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(EnsureSizeIsEnough, BufferReuse)
{
cv::gpu::GpuMat buffer(100, 100, CV_8U);
cv::gpu::GpuMat old = buffer;
try
{
cv::gpu::GpuMat buffer(100, 100, CV_8U);
cv::gpu::GpuMat old = buffer;
// don't reallocate memory
cv::gpu::ensureSizeIsEnough(10, 20, CV_8U, buffer);
EXPECT_EQ(10, buffer.rows);
EXPECT_EQ(20, buffer.cols);
EXPECT_EQ(CV_8UC1, buffer.type());
EXPECT_EQ(reinterpret_cast<intptr_t>(old.data), reinterpret_cast<intptr_t>(buffer.data));
// don't reallocate memory
cv::gpu::ensureSizeIsEnough(10, 20, CV_8U, buffer);
EXPECT_EQ(10, buffer.rows);
EXPECT_EQ(20, buffer.cols);
EXPECT_EQ(CV_8UC1, buffer.type());
EXPECT_EQ(reinterpret_cast<intptr_t>(old.data), reinterpret_cast<intptr_t>(buffer.data));
// don't reallocate memory
cv::gpu::ensureSizeIsEnough(20, 30, CV_8U, buffer);
EXPECT_EQ(20, buffer.rows);
EXPECT_EQ(30, buffer.cols);
EXPECT_EQ(CV_8UC1, buffer.type());
EXPECT_EQ(reinterpret_cast<intptr_t>(old.data), reinterpret_cast<intptr_t>(buffer.data));
// don't reallocate memory
cv::gpu::ensureSizeIsEnough(20, 30, CV_8U, buffer);
EXPECT_EQ(20, buffer.rows);
EXPECT_EQ(30, buffer.cols);
EXPECT_EQ(CV_8UC1, buffer.type());
EXPECT_EQ(reinterpret_cast<intptr_t>(old.data), reinterpret_cast<intptr_t>(buffer.data));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_GpuMat, EnsureSizeIsEnough, ALL_DEVICES);

View File

@ -81,28 +81,36 @@ PARAM_TEST_CASE(HoughLines, cv::gpu::DeviceInfo, cv::Size, UseRoi)
TEST_P(HoughLines, Accuracy)
{
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const cv::Size size = GET_PARAM(1);
const bool useRoi = GET_PARAM(2);
try
{
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const cv::Size size = GET_PARAM(1);
const bool useRoi = GET_PARAM(2);
const float rho = 1.0f;
const float theta = 1.5f * CV_PI / 180.0f;
const int threshold = 100;
const float rho = 1.0f;
const float theta = 1.5f * CV_PI / 180.0f;
const int threshold = 100;
cv::Mat src(size, CV_8UC1);
generateLines(src);
cv::Mat src(size, CV_8UC1);
generateLines(src);
cv::gpu::GpuMat d_lines;
cv::gpu::HoughLines(loadMat(src, useRoi), d_lines, rho, theta, threshold);
cv::gpu::GpuMat d_lines;
cv::gpu::HoughLines(loadMat(src, useRoi), d_lines, rho, theta, threshold);
std::vector<cv::Vec2f> lines;
cv::gpu::HoughLinesDownload(d_lines, lines);
std::vector<cv::Vec2f> lines;
cv::gpu::HoughLinesDownload(d_lines, lines);
cv::Mat dst(size, CV_8UC1);
drawLines(dst, lines);
cv::Mat dst(size, CV_8UC1);
drawLines(dst, lines);
ASSERT_MAT_NEAR(src, dst, 0.0);
ASSERT_MAT_NEAR(src, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HoughLines, testing::Combine(
@ -126,53 +134,61 @@ PARAM_TEST_CASE(HoughCircles, cv::gpu::DeviceInfo, cv::Size, UseRoi)
TEST_P(HoughCircles, Accuracy)
{
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const cv::Size size = GET_PARAM(1);
const bool useRoi = GET_PARAM(2);
const float dp = 2.0f;
const float minDist = 10.0f;
const int minRadius = 10;
const int maxRadius = 20;
const int cannyThreshold = 100;
const int votesThreshold = 20;
std::vector<cv::Vec3f> circles_gold(4);
circles_gold[0] = cv::Vec3i(20, 20, minRadius);
circles_gold[1] = cv::Vec3i(90, 87, minRadius + 3);
circles_gold[2] = cv::Vec3i(30, 70, minRadius + 8);
circles_gold[3] = cv::Vec3i(80, 10, maxRadius);
cv::Mat src(size, CV_8UC1);
drawCircles(src, circles_gold, true);
cv::gpu::GpuMat d_circles;
cv::gpu::HoughCircles(loadMat(src, useRoi), d_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
std::vector<cv::Vec3f> circles;
cv::gpu::HoughCirclesDownload(d_circles, circles);
ASSERT_FALSE(circles.empty());
for (size_t i = 0; i < circles.size(); ++i)
try
{
cv::Vec3f cur = circles[i];
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const cv::Size size = GET_PARAM(1);
const bool useRoi = GET_PARAM(2);
bool found = false;
const float dp = 2.0f;
const float minDist = 10.0f;
const int minRadius = 10;
const int maxRadius = 20;
const int cannyThreshold = 100;
const int votesThreshold = 20;
for (size_t j = 0; j < circles_gold.size(); ++j)
std::vector<cv::Vec3f> circles_gold(4);
circles_gold[0] = cv::Vec3i(20, 20, minRadius);
circles_gold[1] = cv::Vec3i(90, 87, minRadius + 3);
circles_gold[2] = cv::Vec3i(30, 70, minRadius + 8);
circles_gold[3] = cv::Vec3i(80, 10, maxRadius);
cv::Mat src(size, CV_8UC1);
drawCircles(src, circles_gold, true);
cv::gpu::GpuMat d_circles;
cv::gpu::HoughCircles(loadMat(src, useRoi), d_circles, CV_HOUGH_GRADIENT, dp, minDist, cannyThreshold, votesThreshold, minRadius, maxRadius);
std::vector<cv::Vec3f> circles;
cv::gpu::HoughCirclesDownload(d_circles, circles);
ASSERT_FALSE(circles.empty());
for (size_t i = 0; i < circles.size(); ++i)
{
cv::Vec3f gold = circles_gold[j];
cv::Vec3f cur = circles[i];
if (std::fabs(cur[0] - gold[0]) < minDist && std::fabs(cur[1] - gold[1]) < minDist && std::fabs(cur[2] - gold[2]) < minDist)
bool found = false;
for (size_t j = 0; j < circles_gold.size(); ++j)
{
found = true;
break;
}
}
cv::Vec3f gold = circles_gold[j];
ASSERT_TRUE(found);
if (std::fabs(cur[0] - gold[0]) < minDist && std::fabs(cur[1] - gold[1]) < minDist && std::fabs(cur[2] - gold[2]) < minDist)
{
found = true;
break;
}
}
ASSERT_TRUE(found);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
@ -190,60 +206,68 @@ PARAM_TEST_CASE(GeneralizedHough, cv::gpu::DeviceInfo, UseRoi)
TEST_P(GeneralizedHough, POSITION)
{
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const bool useRoi = GET_PARAM(1);
cv::Mat templ = readImage("../cv/shared/templ.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(templ.empty());
cv::Point templCenter(templ.cols / 2, templ.rows / 2);
const size_t gold_count = 3;
cv::Point pos_gold[gold_count];
pos_gold[0] = cv::Point(templCenter.x + 10, templCenter.y + 10);
pos_gold[1] = cv::Point(2 * templCenter.x + 40, templCenter.y + 10);
pos_gold[2] = cv::Point(2 * templCenter.x + 40, 2 * templCenter.y + 40);
cv::Mat image(templ.rows * 3, templ.cols * 3, CV_8UC1, cv::Scalar::all(0));
for (size_t i = 0; i < gold_count; ++i)
try
{
cv::Rect rec(pos_gold[i].x - templCenter.x, pos_gold[i].y - templCenter.y, templ.cols, templ.rows);
cv::Mat imageROI = image(rec);
templ.copyTo(imageROI);
}
const cv::gpu::DeviceInfo devInfo = GET_PARAM(0);
cv::gpu::setDevice(devInfo.deviceID());
const bool useRoi = GET_PARAM(1);
cv::Ptr<cv::gpu::GeneralizedHough_GPU> hough = cv::gpu::GeneralizedHough_GPU::create(cv::GHT_POSITION);
hough->set("votesThreshold", 200);
cv::Mat templ = readImage("../cv/shared/templ.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(templ.empty());
hough->setTemplate(loadMat(templ, useRoi));
cv::Point templCenter(templ.cols / 2, templ.rows / 2);
cv::gpu::GpuMat d_pos;
hough->detect(loadMat(image, useRoi), d_pos);
const size_t gold_count = 3;
cv::Point pos_gold[gold_count];
pos_gold[0] = cv::Point(templCenter.x + 10, templCenter.y + 10);
pos_gold[1] = cv::Point(2 * templCenter.x + 40, templCenter.y + 10);
pos_gold[2] = cv::Point(2 * templCenter.x + 40, 2 * templCenter.y + 40);
std::vector<cv::Vec4f> pos;
hough->download(d_pos, pos);
ASSERT_EQ(gold_count, pos.size());
for (size_t i = 0; i < gold_count; ++i)
{
cv::Point gold = pos_gold[i];
bool found = false;
for (size_t j = 0; j < pos.size(); ++j)
cv::Mat image(templ.rows * 3, templ.cols * 3, CV_8UC1, cv::Scalar::all(0));
for (size_t i = 0; i < gold_count; ++i)
{
cv::Point2f p(pos[j][0], pos[j][1]);
if (::fabs(p.x - gold.x) < 2 && ::fabs(p.y - gold.y) < 2)
{
found = true;
break;
}
cv::Rect rec(pos_gold[i].x - templCenter.x, pos_gold[i].y - templCenter.y, templ.cols, templ.rows);
cv::Mat imageROI = image(rec);
templ.copyTo(imageROI);
}
ASSERT_TRUE(found);
cv::Ptr<cv::gpu::GeneralizedHough_GPU> hough = cv::gpu::GeneralizedHough_GPU::create(cv::GHT_POSITION);
hough->set("votesThreshold", 200);
hough->setTemplate(loadMat(templ, useRoi));
cv::gpu::GpuMat d_pos;
hough->detect(loadMat(image, useRoi), d_pos);
std::vector<cv::Vec4f> pos;
hough->download(d_pos, pos);
ASSERT_EQ(gold_count, pos.size());
for (size_t i = 0; i < gold_count; ++i)
{
cv::Point gold = pos_gold[i];
bool found = false;
for (size_t j = 0; j < pos.size(); ++j)
{
cv::Point2f p(pos[j][0], pos[j][1]);
if (::fabs(p.x - gold.x) < 2 && ::fabs(p.y - gold.y) < 2)
{
found = true;
break;
}
}
ASSERT_TRUE(found);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}

View File

@ -66,15 +66,23 @@ PARAM_TEST_CASE(Integral, cv::gpu::DeviceInfo, cv::Size, UseRoi)
TEST_P(Integral, Accuracy)
{
cv::Mat src = randomMat(size, CV_8UC1);
try
{
cv::Mat src = randomMat(size, CV_8UC1);
cv::gpu::GpuMat dst = createMat(cv::Size(src.cols + 1, src.rows + 1), CV_32SC1, useRoi);
cv::gpu::integral(loadMat(src, useRoi), dst);
cv::gpu::GpuMat dst = createMat(cv::Size(src.cols + 1, src.rows + 1), CV_32SC1, useRoi);
cv::gpu::integral(loadMat(src, useRoi), dst);
cv::Mat dst_gold;
cv::integral(src, dst_gold, CV_32S);
cv::Mat dst_gold;
cv::integral(src, dst_gold, CV_32S);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Integral, testing::Combine(
@ -99,32 +107,40 @@ struct HistEven : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(HistEven, Accuracy)
{
cv::Mat img = readImage("stereobm/aloe-L.png");
ASSERT_FALSE(img.empty());
try
{
cv::Mat img = readImage("stereobm/aloe-L.png");
ASSERT_FALSE(img.empty());
cv::Mat hsv;
cv::cvtColor(img, hsv, CV_BGR2HSV);
cv::Mat hsv;
cv::cvtColor(img, hsv, CV_BGR2HSV);
int hbins = 30;
float hranges[] = {0.0f, 180.0f};
int hbins = 30;
float hranges[] = {0.0f, 180.0f};
std::vector<cv::gpu::GpuMat> srcs;
cv::gpu::split(loadMat(hsv), srcs);
std::vector<cv::gpu::GpuMat> srcs;
cv::gpu::split(loadMat(hsv), srcs);
cv::gpu::GpuMat hist;
cv::gpu::histEven(srcs[0], hist, hbins, (int)hranges[0], (int)hranges[1]);
cv::gpu::GpuMat hist;
cv::gpu::histEven(srcs[0], hist, hbins, (int)hranges[0], (int)hranges[1]);
cv::MatND histnd;
int histSize[] = {hbins};
const float* ranges[] = {hranges};
int channels[] = {0};
cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);
cv::MatND histnd;
int histSize[] = {hbins};
const float* ranges[] = {hranges};
int channels[] = {0};
cv::calcHist(&hsv, 1, channels, cv::Mat(), histnd, 1, histSize, ranges);
cv::Mat hist_gold = histnd;
hist_gold = hist_gold.t();
hist_gold.convertTo(hist_gold, CV_32S);
cv::Mat hist_gold = histnd;
hist_gold = hist_gold.t();
hist_gold.convertTo(hist_gold, CV_32S);
EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, HistEven, ALL_DEVICES);
@ -164,15 +180,23 @@ PARAM_TEST_CASE(CalcHist, cv::gpu::DeviceInfo, cv::Size)
TEST_P(CalcHist, Accuracy)
{
cv::Mat src = randomMat(size, CV_8UC1);
try
{
cv::Mat src = randomMat(size, CV_8UC1);
cv::gpu::GpuMat hist;
cv::gpu::calcHist(loadMat(src), hist);
cv::gpu::GpuMat hist;
cv::gpu::calcHist(loadMat(src), hist);
cv::Mat hist_gold;
calcHistGold(src, hist_gold);
cv::Mat hist_gold;
calcHistGold(src, hist_gold);
EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
EXPECT_MAT_NEAR(hist_gold, hist, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CalcHist, testing::Combine(
@ -198,15 +222,23 @@ PARAM_TEST_CASE(EqualizeHist, cv::gpu::DeviceInfo, cv::Size)
TEST_P(EqualizeHist, Accuracy)
{
cv::Mat src = randomMat(size, CV_8UC1);
try
{
cv::Mat src = randomMat(size, CV_8UC1);
cv::gpu::GpuMat dst;
cv::gpu::equalizeHist(loadMat(src), dst);
cv::gpu::GpuMat dst;
cv::gpu::equalizeHist(loadMat(src), dst);
cv::Mat dst_gold;
cv::equalizeHist(src, dst_gold);
cv::Mat dst_gold;
cv::equalizeHist(src, dst_gold);
EXPECT_MAT_NEAR(dst_gold, dst, 3.0);
EXPECT_MAT_NEAR(dst_gold, dst, 3.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, EqualizeHist, testing::Combine(
@ -232,28 +264,36 @@ PARAM_TEST_CASE(ColumnSum, cv::gpu::DeviceInfo, cv::Size)
TEST_P(ColumnSum, Accuracy)
{
cv::Mat src = randomMat(size, CV_32FC1);
cv::gpu::GpuMat d_dst;
cv::gpu::columnSum(loadMat(src), d_dst);
cv::Mat dst(d_dst);
for (int j = 0; j < src.cols; ++j)
try
{
float gold = src.at<float>(0, j);
float res = dst.at<float>(0, j);
ASSERT_NEAR(res, gold, 1e-5);
}
cv::Mat src = randomMat(size, CV_32FC1);
cv::gpu::GpuMat d_dst;
cv::gpu::columnSum(loadMat(src), d_dst);
cv::Mat dst(d_dst);
for (int i = 1; i < src.rows; ++i)
{
for (int j = 0; j < src.cols; ++j)
{
float gold = src.at<float>(i, j) += src.at<float>(i - 1, j);
float res = dst.at<float>(i, j);
float gold = src.at<float>(0, j);
float res = dst.at<float>(0, j);
ASSERT_NEAR(res, gold, 1e-5);
}
for (int i = 1; i < src.rows; ++i)
{
for (int j = 0; j < src.cols; ++j)
{
float gold = src.at<float>(i, j) += src.at<float>(i - 1, j);
float res = dst.at<float>(i, j);
ASSERT_NEAR(res, gold, 1e-5);
}
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
@ -287,33 +327,41 @@ PARAM_TEST_CASE(Canny, cv::gpu::DeviceInfo, AppertureSize, L2gradient, UseRoi)
TEST_P(Canny, Accuracy)
{
cv::Mat img = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
double low_thresh = 50.0;
double high_thresh = 100.0;
if (!supportFeature(devInfo, cv::gpu::SHARED_ATOMICS))
try
{
try
cv::Mat img = readImage("stereobm/aloe-L.png", cv::IMREAD_GRAYSCALE);
ASSERT_FALSE(img.empty());
double low_thresh = 50.0;
double high_thresh = 100.0;
if (!supportFeature(devInfo, cv::gpu::SHARED_ATOMICS))
{
cv::gpu::GpuMat edges;
cv::gpu::Canny(loadMat(img), edges, low_thresh, high_thresh, apperture_size, useL2gradient);
try
{
cv::gpu::GpuMat edges;
cv::gpu::Canny(loadMat(img), edges, low_thresh, high_thresh, apperture_size, useL2gradient);
}
catch (const cv::Exception& e)
{
ASSERT_EQ(CV_StsNotImplemented, e.code);
}
}
catch (const cv::Exception& e)
else
{
ASSERT_EQ(CV_StsNotImplemented, e.code);
cv::gpu::GpuMat edges;
cv::gpu::Canny(loadMat(img, useRoi), edges, low_thresh, high_thresh, apperture_size, useL2gradient);
cv::Mat edges_gold;
cv::Canny(img, edges_gold, low_thresh, high_thresh, apperture_size, useL2gradient);
EXPECT_MAT_SIMILAR(edges_gold, edges, 2e-2);
}
}
else
catch (...)
{
cv::gpu::GpuMat edges;
cv::gpu::Canny(loadMat(img, useRoi), edges, low_thresh, high_thresh, apperture_size, useL2gradient);
cv::Mat edges_gold;
cv::Canny(img, edges_gold, low_thresh, high_thresh, apperture_size, useL2gradient);
EXPECT_MAT_SIMILAR(edges_gold, edges, 2e-2);
cv::gpu::resetDevice();
throw;
}
}
@ -351,50 +399,66 @@ struct MeanShift : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(MeanShift, Filtering)
{
cv::Mat img_template;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
img_template = readImage("meanshift/con_result.png");
else
img_template = readImage("meanshift/con_result_CC1X.png");
ASSERT_FALSE(img_template.empty());
try
{
cv::Mat img_template;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
img_template = readImage("meanshift/con_result.png");
else
img_template = readImage("meanshift/con_result_CC1X.png");
ASSERT_FALSE(img_template.empty());
cv::gpu::GpuMat d_dst;
cv::gpu::meanShiftFiltering(loadMat(img), d_dst, spatialRad, colorRad);
cv::gpu::GpuMat d_dst;
cv::gpu::meanShiftFiltering(loadMat(img), d_dst, spatialRad, colorRad);
ASSERT_EQ(CV_8UC4, d_dst.type());
ASSERT_EQ(CV_8UC4, d_dst.type());
cv::Mat dst(d_dst);
cv::Mat dst(d_dst);
cv::Mat result;
cv::cvtColor(dst, result, CV_BGRA2BGR);
cv::Mat result;
cv::cvtColor(dst, result, CV_BGRA2BGR);
EXPECT_MAT_NEAR(img_template, result, 0.0);
EXPECT_MAT_NEAR(img_template, result, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(MeanShift, Proc)
{
cv::FileStorage fs;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);
else
fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
try
{
cv::FileStorage fs;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap.yaml", cv::FileStorage::READ);
else
fs.open(std::string(cvtest::TS::ptr()->get_data_path()) + "meanshift/spmap_CC1X.yaml", cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
cv::Mat spmap_template;
fs["spmap"] >> spmap_template;
ASSERT_FALSE(spmap_template.empty());
cv::Mat spmap_template;
fs["spmap"] >> spmap_template;
ASSERT_FALSE(spmap_template.empty());
cv::gpu::GpuMat rmap_filtered;
cv::gpu::meanShiftFiltering(loadMat(img), rmap_filtered, spatialRad, colorRad);
cv::gpu::GpuMat rmap_filtered;
cv::gpu::meanShiftFiltering(loadMat(img), rmap_filtered, spatialRad, colorRad);
cv::gpu::GpuMat rmap;
cv::gpu::GpuMat spmap;
cv::gpu::meanShiftProc(loadMat(img), rmap, spmap, spatialRad, colorRad);
cv::gpu::GpuMat rmap;
cv::gpu::GpuMat spmap;
cv::gpu::meanShiftProc(loadMat(img), rmap, spmap, spatialRad, colorRad);
ASSERT_EQ(CV_8UC4, rmap.type());
ASSERT_EQ(CV_8UC4, rmap.type());
EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);
EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);
EXPECT_MAT_NEAR(rmap_filtered, rmap, 0.0);
EXPECT_MAT_NEAR(spmap_template, spmap, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MeanShift, ALL_DEVICES);
@ -420,25 +484,33 @@ PARAM_TEST_CASE(MeanShiftSegmentation, cv::gpu::DeviceInfo, MinSize)
TEST_P(MeanShiftSegmentation, Regression)
{
cv::Mat img = readImageType("meanshift/cones.png", CV_8UC4);
ASSERT_FALSE(img.empty());
try
{
cv::Mat img = readImageType("meanshift/cones.png", CV_8UC4);
ASSERT_FALSE(img.empty());
std::ostringstream path;
path << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
path << ".png";
else
path << "_CC1X.png";
cv::Mat dst_gold = readImage(path.str());
ASSERT_FALSE(dst_gold.empty());
std::ostringstream path;
path << "meanshift/cones_segmented_sp10_sr10_minsize" << minsize;
if (supportFeature(devInfo, cv::gpu::FEATURE_SET_COMPUTE_20))
path << ".png";
else
path << "_CC1X.png";
cv::Mat dst_gold = readImage(path.str());
ASSERT_FALSE(dst_gold.empty());
cv::Mat dst;
cv::gpu::meanShiftSegmentation(loadMat(img), dst, 10, 10, minsize);
cv::Mat dst;
cv::gpu::meanShiftSegmentation(loadMat(img), dst, 10, 10, minsize);
cv::Mat dst_rgb;
cv::cvtColor(dst, dst_rgb, CV_BGRA2BGR);
cv::Mat dst_rgb;
cv::cvtColor(dst, dst_rgb, CV_BGRA2BGR);
EXPECT_MAT_SIMILAR(dst_gold, dst_rgb, 1e-3);
EXPECT_MAT_SIMILAR(dst_gold, dst_rgb, 1e-3);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MeanShiftSegmentation, testing::Combine(
@ -492,23 +564,31 @@ PARAM_TEST_CASE(Blend, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
TEST_P(Blend, Accuracy)
{
int depth = CV_MAT_DEPTH(type);
try
{
int depth = CV_MAT_DEPTH(type);
cv::Mat img1 = randomMat(size, type, 0.0, depth == CV_8U ? 255.0 : 1.0);
cv::Mat img2 = randomMat(size, type, 0.0, depth == CV_8U ? 255.0 : 1.0);
cv::Mat weights1 = randomMat(size, CV_32F, 0, 1);
cv::Mat weights2 = randomMat(size, CV_32F, 0, 1);
cv::Mat img1 = randomMat(size, type, 0.0, depth == CV_8U ? 255.0 : 1.0);
cv::Mat img2 = randomMat(size, type, 0.0, depth == CV_8U ? 255.0 : 1.0);
cv::Mat weights1 = randomMat(size, CV_32F, 0, 1);
cv::Mat weights2 = randomMat(size, CV_32F, 0, 1);
cv::gpu::GpuMat result;
cv::gpu::blendLinear(loadMat(img1, useRoi), loadMat(img2, useRoi), loadMat(weights1, useRoi), loadMat(weights2, useRoi), result);
cv::gpu::GpuMat result;
cv::gpu::blendLinear(loadMat(img1, useRoi), loadMat(img2, useRoi), loadMat(weights1, useRoi), loadMat(weights2, useRoi), result);
cv::Mat result_gold;
if (depth == CV_8U)
blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);
else
blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);
cv::Mat result_gold;
if (depth == CV_8U)
blendLinearGold<uchar>(img1, img2, weights1, weights2, result_gold);
else
blendLinearGold<float>(img1, img2, weights1, weights2, result_gold);
EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.0 : 1e-5);
EXPECT_MAT_NEAR(result_gold, result, CV_MAT_DEPTH(type) == CV_8U ? 1.0 : 1e-5);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Blend, testing::Combine(
@ -582,16 +662,24 @@ PARAM_TEST_CASE(Convolve, cv::gpu::DeviceInfo, cv::Size, KSize, Ccorr)
TEST_P(Convolve, Accuracy)
{
cv::Mat src = randomMat(size, CV_32FC1, 0.0, 100.0);
cv::Mat kernel = randomMat(cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0);
try
{
cv::Mat src = randomMat(size, CV_32FC1, 0.0, 100.0);
cv::Mat kernel = randomMat(cv::Size(ksize, ksize), CV_32FC1, 0.0, 1.0);
cv::gpu::GpuMat dst;
cv::gpu::convolve(loadMat(src), loadMat(kernel), dst, ccorr);
cv::gpu::GpuMat dst;
cv::gpu::convolve(loadMat(src), loadMat(kernel), dst, ccorr);
cv::Mat dst_gold;
convolveDFT(src, kernel, dst_gold, ccorr);
cv::Mat dst_gold;
convolveDFT(src, kernel, dst_gold, ccorr);
EXPECT_MAT_NEAR(dst, dst_gold, 1e-1);
EXPECT_MAT_NEAR(dst, dst_gold, 1e-1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Convolve, testing::Combine(
@ -630,16 +718,24 @@ PARAM_TEST_CASE(MatchTemplate8U, cv::gpu::DeviceInfo, cv::Size, TemplateSize, Ch
TEST_P(MatchTemplate8U, Accuracy)
{
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
try
{
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_8U, cn));
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_8U, cn));
cv::gpu::GpuMat dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dst, method);
cv::gpu::GpuMat dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dst, method);
cv::Mat dst_gold;
cv::matchTemplate(image, templ, dst_gold, method);
cv::Mat dst_gold;
cv::matchTemplate(image, templ, dst_gold, method);
EXPECT_MAT_NEAR(dst_gold, dst, templ_size.area() * 1e-1);
EXPECT_MAT_NEAR(dst_gold, dst, templ_size.area() * 1e-1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate8U, testing::Combine(
@ -676,16 +772,24 @@ PARAM_TEST_CASE(MatchTemplate32F, cv::gpu::DeviceInfo, cv::Size, TemplateSize, C
TEST_P(MatchTemplate32F, Regression)
{
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
try
{
cv::Mat image = randomMat(size, CV_MAKETYPE(CV_32F, cn));
cv::Mat templ = randomMat(templ_size, CV_MAKETYPE(CV_32F, cn));
cv::gpu::GpuMat dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dst, method);
cv::gpu::GpuMat dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(templ), dst, method);
cv::Mat dst_gold;
cv::matchTemplate(image, templ, dst_gold, method);
cv::Mat dst_gold;
cv::matchTemplate(image, templ, dst_gold, method);
EXPECT_MAT_NEAR(dst_gold, dst, templ_size.area() * 1e-1);
EXPECT_MAT_NEAR(dst_gold, dst, templ_size.area() * 1e-1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate32F, testing::Combine(
@ -714,24 +818,32 @@ PARAM_TEST_CASE(MatchTemplateBlackSource, cv::gpu::DeviceInfo, TemplateMethod)
TEST_P(MatchTemplateBlackSource, Accuracy)
{
cv::Mat image = readImage("matchtemplate/black.png");
ASSERT_FALSE(image.empty());
try
{
cv::Mat image = readImage("matchtemplate/black.png");
ASSERT_FALSE(image.empty());
cv::Mat pattern = readImage("matchtemplate/cat.png");
ASSERT_FALSE(pattern.empty());
cv::Mat pattern = readImage("matchtemplate/cat.png");
ASSERT_FALSE(pattern.empty());
cv::gpu::GpuMat d_dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), d_dst, method);
cv::gpu::GpuMat d_dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), d_dst, method);
cv::Mat dst(d_dst);
cv::Mat dst(d_dst);
double maxValue;
cv::Point maxLoc;
cv::minMaxLoc(dst, NULL, &maxValue, NULL, &maxLoc);
double maxValue;
cv::Point maxLoc;
cv::minMaxLoc(dst, NULL, &maxValue, NULL, &maxLoc);
cv::Point maxLocGold = cv::Point(284, 12);
cv::Point maxLocGold = cv::Point(284, 12);
ASSERT_EQ(maxLocGold, maxLoc);
ASSERT_EQ(maxLocGold, maxLoc);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplateBlackSource, testing::Combine(
@ -759,32 +871,40 @@ PARAM_TEST_CASE(MatchTemplate_CCOEF_NORMED, cv::gpu::DeviceInfo, std::pair<std::
TEST_P(MatchTemplate_CCOEF_NORMED, Accuracy)
{
cv::Mat image = readImage(imageName);
ASSERT_FALSE(image.empty());
try
{
cv::Mat image = readImage(imageName);
ASSERT_FALSE(image.empty());
cv::Mat pattern = readImage(patternName);
ASSERT_FALSE(pattern.empty());
cv::Mat pattern = readImage(patternName);
ASSERT_FALSE(pattern.empty());
cv::gpu::GpuMat d_dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), d_dst, CV_TM_CCOEFF_NORMED);
cv::gpu::GpuMat d_dst;
cv::gpu::matchTemplate(loadMat(image), loadMat(pattern), d_dst, CV_TM_CCOEFF_NORMED);
cv::Mat dst(d_dst);
cv::Mat dst(d_dst);
cv::Point minLoc, maxLoc;
double minVal, maxVal;
cv::minMaxLoc(dst, &minVal, &maxVal, &minLoc, &maxLoc);
cv::Point minLoc, maxLoc;
double minVal, maxVal;
cv::minMaxLoc(dst, &minVal, &maxVal, &minLoc, &maxLoc);
cv::Mat dstGold;
cv::matchTemplate(image, pattern, dstGold, CV_TM_CCOEFF_NORMED);
cv::Mat dstGold;
cv::matchTemplate(image, pattern, dstGold, CV_TM_CCOEFF_NORMED);
double minValGold, maxValGold;
cv::Point minLocGold, maxLocGold;
cv::minMaxLoc(dstGold, &minValGold, &maxValGold, &minLocGold, &maxLocGold);
double minValGold, maxValGold;
cv::Point minLocGold, maxLocGold;
cv::minMaxLoc(dstGold, &minValGold, &maxValGold, &minLocGold, &maxLocGold);
ASSERT_EQ(minLocGold, minLoc);
ASSERT_EQ(maxLocGold, maxLoc);
ASSERT_LE(maxVal, 1.0);
ASSERT_GE(minVal, -1.0);
ASSERT_EQ(minLocGold, minLoc);
ASSERT_EQ(maxLocGold, maxLoc);
ASSERT_LE(maxVal, 1.0);
ASSERT_GE(minVal, -1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate_CCOEF_NORMED, testing::Combine(
@ -808,47 +928,63 @@ struct MatchTemplate_CanFindBigTemplate : testing::TestWithParam<cv::gpu::Device
TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF_NORMED)
{
cv::Mat scene = readImage("matchtemplate/scene.png");
ASSERT_FALSE(scene.empty());
try
{
cv::Mat scene = readImage("matchtemplate/scene.png");
ASSERT_FALSE(scene.empty());
cv::Mat templ = readImage("matchtemplate/template.png");
ASSERT_FALSE(templ.empty());
cv::Mat templ = readImage("matchtemplate/template.png");
ASSERT_FALSE(templ.empty());
cv::gpu::GpuMat d_result;
cv::gpu::matchTemplate(loadMat(scene), loadMat(templ), d_result, CV_TM_SQDIFF_NORMED);
cv::gpu::GpuMat d_result;
cv::gpu::matchTemplate(loadMat(scene), loadMat(templ), d_result, CV_TM_SQDIFF_NORMED);
cv::Mat result(d_result);
cv::Mat result(d_result);
double minVal;
cv::Point minLoc;
cv::minMaxLoc(result, &minVal, 0, &minLoc, 0);
double minVal;
cv::Point minLoc;
cv::minMaxLoc(result, &minVal, 0, &minLoc, 0);
ASSERT_GE(minVal, 0);
ASSERT_LT(minVal, 1e-3);
ASSERT_EQ(344, minLoc.x);
ASSERT_EQ(0, minLoc.y);
ASSERT_GE(minVal, 0);
ASSERT_LT(minVal, 1e-3);
ASSERT_EQ(344, minLoc.x);
ASSERT_EQ(0, minLoc.y);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(MatchTemplate_CanFindBigTemplate, SQDIFF)
{
cv::Mat scene = readImage("matchtemplate/scene.png");
ASSERT_FALSE(scene.empty());
try
{
cv::Mat scene = readImage("matchtemplate/scene.png");
ASSERT_FALSE(scene.empty());
cv::Mat templ = readImage("matchtemplate/template.png");
ASSERT_FALSE(templ.empty());
cv::Mat templ = readImage("matchtemplate/template.png");
ASSERT_FALSE(templ.empty());
cv::gpu::GpuMat d_result;
cv::gpu::matchTemplate(loadMat(scene), loadMat(templ), d_result, CV_TM_SQDIFF);
cv::gpu::GpuMat d_result;
cv::gpu::matchTemplate(loadMat(scene), loadMat(templ), d_result, CV_TM_SQDIFF);
cv::Mat result(d_result);
cv::Mat result(d_result);
double minVal;
cv::Point minLoc;
cv::minMaxLoc(result, &minVal, 0, &minLoc, 0);
double minVal;
cv::Point minLoc;
cv::minMaxLoc(result, &minVal, 0, &minLoc, 0);
ASSERT_GE(minVal, 0);
ASSERT_EQ(344, minLoc.x);
ASSERT_EQ(0, minLoc.y);
ASSERT_GE(minVal, 0);
ASSERT_EQ(344, minLoc.x);
ASSERT_EQ(0, minLoc.y);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MatchTemplate_CanFindBigTemplate, ALL_DEVICES);
@ -881,27 +1017,43 @@ PARAM_TEST_CASE(MulSpectrums, cv::gpu::DeviceInfo, cv::Size, DftFlags)
TEST_P(MulSpectrums, Simple)
{
cv::gpu::GpuMat c;
cv::gpu::mulSpectrums(loadMat(a), loadMat(b), c, flag, false);
try
{
cv::gpu::GpuMat c;
cv::gpu::mulSpectrums(loadMat(a), loadMat(b), c, flag, false);
cv::Mat c_gold;
cv::mulSpectrums(a, b, c_gold, flag, false);
cv::Mat c_gold;
cv::mulSpectrums(a, b, c_gold, flag, false);
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(MulSpectrums, Scaled)
{
float scale = 1.f / size.area();
try
{
float scale = 1.f / size.area();
cv::gpu::GpuMat c;
cv::gpu::mulAndScaleSpectrums(loadMat(a), loadMat(b), c, flag, scale, false);
cv::gpu::GpuMat c;
cv::gpu::mulAndScaleSpectrums(loadMat(a), loadMat(b), c, flag, scale, false);
cv::Mat c_gold;
cv::mulSpectrums(a, b, c_gold, flag, false);
c_gold.convertTo(c_gold, c_gold.type(), scale);
cv::Mat c_gold;
cv::mulSpectrums(a, b, c_gold, flag, false);
c_gold.convertTo(c_gold, c_gold.type(), scale);
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
EXPECT_MAT_NEAR(c_gold, c, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, MulSpectrums, testing::Combine(
@ -950,26 +1102,34 @@ void testC2C(const std::string& hint, int cols, int rows, int flags, bool inplac
TEST_P(Dft, C2C)
{
int cols = randomInt(2, 100);
int rows = randomInt(2, 100);
for (int i = 0; i < 2; ++i)
try
{
bool inplace = i != 0;
int cols = randomInt(2, 100);
int rows = randomInt(2, 100);
testC2C("no flags", cols, rows, 0, inplace);
testC2C("no flags 0 1", cols, rows + 1, 0, inplace);
testC2C("no flags 1 0", cols, rows + 1, 0, inplace);
testC2C("no flags 1 1", cols + 1, rows, 0, inplace);
testC2C("DFT_INVERSE", cols, rows, cv::DFT_INVERSE, inplace);
testC2C("DFT_ROWS", cols, rows, cv::DFT_ROWS, inplace);
testC2C("single col", 1, rows, 0, inplace);
testC2C("single row", cols, 1, 0, inplace);
testC2C("single col inversed", 1, rows, cv::DFT_INVERSE, inplace);
testC2C("single row inversed", cols, 1, cv::DFT_INVERSE, inplace);
testC2C("single row DFT_ROWS", cols, 1, cv::DFT_ROWS, inplace);
testC2C("size 1 2", 1, 2, 0, inplace);
testC2C("size 2 1", 2, 1, 0, inplace);
for (int i = 0; i < 2; ++i)
{
bool inplace = i != 0;
testC2C("no flags", cols, rows, 0, inplace);
testC2C("no flags 0 1", cols, rows + 1, 0, inplace);
testC2C("no flags 1 0", cols, rows + 1, 0, inplace);
testC2C("no flags 1 1", cols + 1, rows, 0, inplace);
testC2C("DFT_INVERSE", cols, rows, cv::DFT_INVERSE, inplace);
testC2C("DFT_ROWS", cols, rows, cv::DFT_ROWS, inplace);
testC2C("single col", 1, rows, 0, inplace);
testC2C("single row", cols, 1, 0, inplace);
testC2C("single col inversed", 1, rows, cv::DFT_INVERSE, inplace);
testC2C("single row inversed", cols, 1, cv::DFT_INVERSE, inplace);
testC2C("single row DFT_ROWS", cols, 1, cv::DFT_ROWS, inplace);
testC2C("size 1 2", 1, 2, 0, inplace);
testC2C("size 2 1", 2, 1, 0, inplace);
}
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
@ -1011,24 +1171,32 @@ void testR2CThenC2R(const std::string& hint, int cols, int rows, bool inplace)
TEST_P(Dft, R2CThenC2R)
{
int cols = randomInt(2, 100);
int rows = randomInt(2, 100);
try
{
int cols = randomInt(2, 100);
int rows = randomInt(2, 100);
testR2CThenC2R("sanity", cols, rows, false);
testR2CThenC2R("sanity 0 1", cols, rows + 1, false);
testR2CThenC2R("sanity 1 0", cols + 1, rows, false);
testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, false);
testR2CThenC2R("single col", 1, rows, false);
testR2CThenC2R("single col 1", 1, rows + 1, false);
testR2CThenC2R("single row", cols, 1, false);
testR2CThenC2R("single row 1", cols + 1, 1, false);
testR2CThenC2R("sanity", cols, rows, false);
testR2CThenC2R("sanity 0 1", cols, rows + 1, false);
testR2CThenC2R("sanity 1 0", cols + 1, rows, false);
testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, false);
testR2CThenC2R("single col", 1, rows, false);
testR2CThenC2R("single col 1", 1, rows + 1, false);
testR2CThenC2R("single row", cols, 1, false);
testR2CThenC2R("single row 1", cols + 1, 1, false);
testR2CThenC2R("sanity", cols, rows, true);
testR2CThenC2R("sanity 0 1", cols, rows + 1, true);
testR2CThenC2R("sanity 1 0", cols + 1, rows, true);
testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);
testR2CThenC2R("single row", cols, 1, true);
testR2CThenC2R("single row 1", cols + 1, 1, true);
testR2CThenC2R("sanity", cols, rows, true);
testR2CThenC2R("sanity 0 1", cols, rows + 1, true);
testR2CThenC2R("sanity 1 0", cols + 1, rows, true);
testR2CThenC2R("sanity 1 1", cols + 1, rows + 1, true);
testR2CThenC2R("single row", cols, 1, true);
testR2CThenC2R("single row 1", cols + 1, 1, true);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Dft, ALL_DEVICES);
@ -1061,18 +1229,26 @@ PARAM_TEST_CASE(CornerHarris, cv::gpu::DeviceInfo, MatType, BorderType, BlockSiz
TEST_P(CornerHarris, Accuracy)
{
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
ASSERT_FALSE(src.empty());
try
{
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
ASSERT_FALSE(src.empty());
double k = randomDouble(0.1, 0.9);
double k = randomDouble(0.1, 0.9);
cv::gpu::GpuMat dst;
cv::gpu::cornerHarris(loadMat(src), dst, blockSize, apertureSize, k, borderType);
cv::gpu::GpuMat dst;
cv::gpu::cornerHarris(loadMat(src), dst, blockSize, apertureSize, k, borderType);
cv::Mat dst_gold;
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
cv::Mat dst_gold;
cv::cornerHarris(src, dst_gold, blockSize, apertureSize, k, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CornerHarris, testing::Combine(
@ -1107,16 +1283,24 @@ PARAM_TEST_CASE(CornerMinEigen, cv::gpu::DeviceInfo, MatType, BorderType, BlockS
TEST_P(CornerMinEigen, Accuracy)
{
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
ASSERT_FALSE(src.empty());
try
{
cv::Mat src = readImageType("stereobm/aloe-L.png", type);
ASSERT_FALSE(src.empty());
cv::gpu::GpuMat dst;
cv::gpu::cornerMinEigenVal(loadMat(src), dst, blockSize, apertureSize, borderType);
cv::gpu::GpuMat dst;
cv::gpu::cornerMinEigenVal(loadMat(src), dst, blockSize, apertureSize, borderType);
cv::Mat dst_gold;
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
cv::Mat dst_gold;
cv::cornerMinEigenVal(src, dst_gold, blockSize, apertureSize, borderType);
EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
EXPECT_MAT_NEAR(dst_gold, dst, 0.02);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, CornerMinEigen, testing::Combine(

View File

@ -168,27 +168,35 @@ struct Labeling : testing::TestWithParam<cv::gpu::DeviceInfo>
TEST_P(Labeling, ConnectedComponents)
{
cv::Mat image;
cvtColor(loat_image(), image, CV_BGR2GRAY);
try
{
cv::Mat image;
cvtColor(loat_image(), image, CV_BGR2GRAY);
cv::threshold(image, image, 150, 255, CV_THRESH_BINARY);
cv::threshold(image, image, 150, 255, CV_THRESH_BINARY);
ASSERT_TRUE(image.type() == CV_8UC1);
ASSERT_TRUE(image.type() == CV_8UC1);
GreedyLabeling host(image);
host(host._labels);
GreedyLabeling host(image);
host(host._labels);
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
cv::gpu::GpuMat mask;
mask.create(image.rows, image.cols, CV_8UC1);
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
cv::gpu::GpuMat components;
components.create(image.rows, image.cols, CV_32SC1);
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
cv::gpu::connectivityMask(cv::gpu::GpuMat(image), mask, cv::Scalar::all(0), cv::Scalar::all(2));
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
ASSERT_NO_THROW(cv::gpu::labelComponents(mask, components));
host.checkCorrectness(cv::Mat(components));
host.checkCorrectness(cv::Mat(components));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(ConnectedComponents, Labeling, ALL_DEVICES);

View File

@ -69,82 +69,169 @@ struct NVidiaTest : TestWithParam<cv::gpu::DeviceInfo>
struct NPPST : NVidiaTest {};
struct NCV : NVidiaTest {};
//TEST_P(NPPST, Integral)
//{
// bool res = nvidia_NPPST_Integral_Image(path, nvidiaTestOutputLevel);
TEST_P(NPPST, Integral)
{
try
{
bool res = nvidia_NPPST_Integral_Image(_path, nvidiaTestOutputLevel);
// ASSERT_TRUE(res);
//}
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NPPST, SquaredIntegral)
{
bool res = nvidia_NPPST_Squared_Integral_Image(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NPPST_Squared_Integral_Image(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NPPST, RectStdDev)
{
bool res = nvidia_NPPST_RectStdDev(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NPPST_RectStdDev(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NPPST, Resize)
{
bool res = nvidia_NPPST_Resize(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NPPST_Resize(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NPPST, VectorOperations)
{
bool res = nvidia_NPPST_Vector_Operations(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NPPST_Vector_Operations(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NPPST, Transpose)
{
bool res = nvidia_NPPST_Transpose(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NPPST_Transpose(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NCV, VectorOperations)
{
bool res = nvidia_NCV_Vector_Operations(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NCV_Vector_Operations(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NCV, HaarCascadeLoader)
{
bool res = nvidia_NCV_Haar_Cascade_Loader(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NCV_Haar_Cascade_Loader(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NCV, HaarCascadeApplication)
{
bool res = nvidia_NCV_Haar_Cascade_Application(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NCV_Haar_Cascade_Application(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NCV, HypothesesFiltration)
{
bool res = nvidia_NCV_Hypotheses_Filtration(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NCV_Hypotheses_Filtration(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(NCV, Visualization)
{
// this functionality doesn't used in gpu module
bool res = nvidia_NCV_Visualization(_path, nvidiaTestOutputLevel);
try
{
bool res = nvidia_NCV_Visualization(_path, nvidiaTestOutputLevel);
ASSERT_TRUE(res);
ASSERT_TRUE(res);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_NVidia, NPPST, ALL_DEVICES);

View File

@ -175,114 +175,129 @@ struct HOG : testing::TestWithParam<cv::gpu::DeviceInfo>, cv::gpu::HOGDescriptor
}
};
// desabled while resize does not fixed
TEST_P(HOG, DISABLED_Detect)
TEST_P(HOG, Detect)
{
cv::Mat img_rgb = readImage("hog/road.png");
ASSERT_FALSE(img_rgb.empty());
try
{
cv::Mat img_rgb = readImage("hog/road.png");
ASSERT_FALSE(img_rgb.empty());
#ifdef DUMP
f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);
ASSERT_TRUE(f.is_open());
#else
f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);
ASSERT_TRUE(f.is_open());
#endif
#ifdef DUMP
f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);
ASSERT_TRUE(f.is_open());
#else
f.open((std::string(cvtest::TS::ptr()->get_data_path()) + "hog/expected_output.bin").c_str(), std::ios_base::binary);
ASSERT_TRUE(f.is_open());
#endif
// Test on color image
cv::Mat img;
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
testDetect(img);
// Test on color image
cv::Mat img;
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
testDetect(img);
// Test on gray image
cv::cvtColor(img_rgb, img, CV_BGR2GRAY);
testDetect(img);
// Test on gray image
cv::cvtColor(img_rgb, img, CV_BGR2GRAY);
testDetect(img);
f.close();
f.close();
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(HOG, GetDescriptors)
{
// Load image (e.g. train data, composed from windows)
cv::Mat img_rgb = readImage("hog/train_data.png");
ASSERT_FALSE(img_rgb.empty());
// Convert to C4
cv::Mat img;
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
cv::gpu::GpuMat d_img(img);
// Convert train images into feature vectors (train table)
cv::gpu::GpuMat descriptors, descriptors_by_cols;
getDescriptors(d_img, win_size, descriptors, DESCR_FORMAT_ROW_BY_ROW);
getDescriptors(d_img, win_size, descriptors_by_cols, DESCR_FORMAT_COL_BY_COL);
// Check size of the result train table
wins_per_img_x = 3;
wins_per_img_y = 2;
blocks_per_win_x = 7;
blocks_per_win_y = 15;
block_hist_size = 36;
cv::Size descr_size_expected = cv::Size(blocks_per_win_x * blocks_per_win_y * block_hist_size,
wins_per_img_x * wins_per_img_y);
ASSERT_EQ(descr_size_expected, descriptors.size());
// Check both formats of output descriptors are handled correctly
cv::Mat dr(descriptors);
cv::Mat dc(descriptors_by_cols);
for (int i = 0; i < wins_per_img_x * wins_per_img_y; ++i)
try
{
const float* l = dr.rowRange(i, i + 1).ptr<float>();
const float* r = dc.rowRange(i, i + 1).ptr<float>();
for (int y = 0; y < blocks_per_win_y; ++y)
for (int x = 0; x < blocks_per_win_x; ++x)
for (int k = 0; k < block_hist_size; ++k)
ASSERT_EQ(l[(y * blocks_per_win_x + x) * block_hist_size + k],
r[(x * blocks_per_win_y + y) * block_hist_size + k]);
// Load image (e.g. train data, composed from windows)
cv::Mat img_rgb = readImage("hog/train_data.png");
ASSERT_FALSE(img_rgb.empty());
// Convert to C4
cv::Mat img;
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
cv::gpu::GpuMat d_img(img);
// Convert train images into feature vectors (train table)
cv::gpu::GpuMat descriptors, descriptors_by_cols;
getDescriptors(d_img, win_size, descriptors, DESCR_FORMAT_ROW_BY_ROW);
getDescriptors(d_img, win_size, descriptors_by_cols, DESCR_FORMAT_COL_BY_COL);
// Check size of the result train table
wins_per_img_x = 3;
wins_per_img_y = 2;
blocks_per_win_x = 7;
blocks_per_win_y = 15;
block_hist_size = 36;
cv::Size descr_size_expected = cv::Size(blocks_per_win_x * blocks_per_win_y * block_hist_size,
wins_per_img_x * wins_per_img_y);
ASSERT_EQ(descr_size_expected, descriptors.size());
// Check both formats of output descriptors are handled correctly
cv::Mat dr(descriptors);
cv::Mat dc(descriptors_by_cols);
for (int i = 0; i < wins_per_img_x * wins_per_img_y; ++i)
{
const float* l = dr.rowRange(i, i + 1).ptr<float>();
const float* r = dc.rowRange(i, i + 1).ptr<float>();
for (int y = 0; y < blocks_per_win_y; ++y)
for (int x = 0; x < blocks_per_win_x; ++x)
for (int k = 0; k < block_hist_size; ++k)
ASSERT_EQ(l[(y * blocks_per_win_x + x) * block_hist_size + k],
r[(x * blocks_per_win_y + y) * block_hist_size + k]);
}
/* Now we want to extract the same feature vectors, but from single images. NOTE: results will
be defferent, due to border values interpolation. Using of many small images is slower, however we
wont't call getDescriptors and will use computeBlockHistograms instead of. computeBlockHistograms
works good, it can be checked in the gpu_hog sample */
img_rgb = readImage("hog/positive1.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
// Everything is fine with interpolation for left top subimage
ASSERT_EQ(0.0, cv::norm((cv::Mat)block_hists, (cv::Mat)descriptors.rowRange(0, 1)));
img_rgb = readImage("hog/positive2.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(1, 2)));
img_rgb = readImage("hog/negative1.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(2, 3)));
img_rgb = readImage("hog/negative2.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(3, 4)));
img_rgb = readImage("hog/positive3.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(4, 5)));
img_rgb = readImage("hog/negative3.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(5, 6)));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
/* Now we want to extract the same feature vectors, but from single images. NOTE: results will
be defferent, due to border values interpolation. Using of many small images is slower, however we
wont't call getDescriptors and will use computeBlockHistograms instead of. computeBlockHistograms
works good, it can be checked in the gpu_hog sample */
img_rgb = readImage("hog/positive1.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
// Everything is fine with interpolation for left top subimage
ASSERT_EQ(0.0, cv::norm((cv::Mat)block_hists, (cv::Mat)descriptors.rowRange(0, 1)));
img_rgb = readImage("hog/positive2.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(1, 2)));
img_rgb = readImage("hog/negative1.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(2, 3)));
img_rgb = readImage("hog/negative2.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(3, 4)));
img_rgb = readImage("hog/positive3.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(4, 5)));
img_rgb = readImage("hog/negative3.png");
ASSERT_TRUE(!img_rgb.empty());
cv::cvtColor(img_rgb, img, CV_BGR2BGRA);
computeBlockHistograms(cv::gpu::GpuMat(img));
compare_inner_parts(cv::Mat(block_hists), cv::Mat(descriptors.rowRange(5, 6)));
}
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, HOG, ALL_DEVICES);
@ -305,27 +320,35 @@ struct CalTech : public ::testing::TestWithParam<std::tr1::tuple<cv::gpu::Device
TEST_P(CalTech, HOG)
{
cv::gpu::GpuMat d_img(img);
cv::Mat markedImage(img.clone());
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.nlevels = d_hog.nlevels + 32;
std::vector<cv::Rect> found_locations;
d_hog.detectMultiScale(d_img, found_locations);
#if defined (LOG_CASCADE_STATISTIC)
for (int i = 0; i < (int)found_locations.size(); i++)
try
{
cv::Rect r = found_locations[i];
cv::gpu::GpuMat d_img(img);
cv::Mat markedImage(img.clone());
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
cv::gpu::HOGDescriptor d_hog;
d_hog.setSVMDetector(cv::gpu::HOGDescriptor::getDefaultPeopleDetector());
d_hog.nlevels = d_hog.nlevels + 32;
std::vector<cv::Rect> found_locations;
d_hog.detectMultiScale(d_img, found_locations);
#if defined (LOG_CASCADE_STATISTIC)
for (int i = 0; i < (int)found_locations.size(); i++)
{
cv::Rect r = found_locations[i];
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
}
cv::imshow("Res", markedImage); cv::waitKey();
#endif
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
cv::imshow("Res", markedImage); cv::waitKey();
#endif
}
INSTANTIATE_TEST_CASE_P(detect, CalTech, testing::Combine(ALL_DEVICES,
@ -352,9 +375,17 @@ PARAM_TEST_CASE(LBP_Read_classifier, cv::gpu::DeviceInfo, int)
TEST_P(LBP_Read_classifier, Accuracy)
{
cv::gpu::CascadeClassifier_GPU classifier;
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
ASSERT_TRUE(classifier.load(classifierXmlPath));
try
{
cv::gpu::CascadeClassifier_GPU classifier;
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
ASSERT_TRUE(classifier.load(classifierXmlPath));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_Read_classifier,
@ -374,49 +405,57 @@ PARAM_TEST_CASE(LBP_classify, cv::gpu::DeviceInfo, int)
TEST_P(LBP_classify, Accuracy)
{
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
std::string imagePath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/er.png";
cv::CascadeClassifier cpuClassifier(classifierXmlPath);
ASSERT_FALSE(cpuClassifier.empty());
cv::Mat image = cv::imread(imagePath);
image = image.colRange(0, image.cols/2);
cv::Mat grey;
cvtColor(image, grey, CV_BGR2GRAY);
ASSERT_FALSE(image.empty());
std::vector<cv::Rect> rects;
cpuClassifier.detectMultiScale(grey, rects);
cv::Mat markedImage = image.clone();
std::vector<cv::Rect>::iterator it = rects.begin();
for (; it != rects.end(); ++it)
cv::rectangle(markedImage, *it, CV_RGB(0, 0, 255));
cv::gpu::CascadeClassifier_GPU gpuClassifier;
ASSERT_TRUE(gpuClassifier.load(classifierXmlPath));
cv::gpu::GpuMat gpu_rects;
cv::gpu::GpuMat tested(grey);
int count = gpuClassifier.detectMultiScale(tested, gpu_rects);
#if defined (LOG_CASCADE_STATISTIC)
cv::Mat downloaded(gpu_rects);
const cv::Rect* faces = downloaded.ptr<cv::Rect>();
for (int i = 0; i < count; i++)
try
{
cv::Rect r = faces[i];
std::string classifierXmlPath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/lbpcascade_frontalface.xml";
std::string imagePath = std::string(cvtest::TS::ptr()->get_data_path()) + "lbpcascade/er.png";
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
cv::CascadeClassifier cpuClassifier(classifierXmlPath);
ASSERT_FALSE(cpuClassifier.empty());
cv::Mat image = cv::imread(imagePath);
image = image.colRange(0, image.cols/2);
cv::Mat grey;
cvtColor(image, grey, CV_BGR2GRAY);
ASSERT_FALSE(image.empty());
std::vector<cv::Rect> rects;
cpuClassifier.detectMultiScale(grey, rects);
cv::Mat markedImage = image.clone();
std::vector<cv::Rect>::iterator it = rects.begin();
for (; it != rects.end(); ++it)
cv::rectangle(markedImage, *it, CV_RGB(0, 0, 255));
cv::gpu::CascadeClassifier_GPU gpuClassifier;
ASSERT_TRUE(gpuClassifier.load(classifierXmlPath));
cv::gpu::GpuMat gpu_rects;
cv::gpu::GpuMat tested(grey);
int count = gpuClassifier.detectMultiScale(tested, gpu_rects);
#if defined (LOG_CASCADE_STATISTIC)
cv::Mat downloaded(gpu_rects);
const cv::Rect* faces = downloaded.ptr<cv::Rect>();
for (int i = 0; i < count; i++)
{
cv::Rect r = faces[i];
std::cout << r.x << " " << r.y << " " << r.width << " " << r.height << std::endl;
cv::rectangle(markedImage, r , CV_RGB(255, 0, 0));
}
#endif
#if defined (LOG_CASCADE_STATISTIC)
cv::imshow("Res", markedImage); cv::waitKey();
#endif
(void)count;
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
#endif
#if defined (LOG_CASCADE_STATISTIC)
cv::imshow("Res", markedImage); cv::waitKey();
#endif
(void)count;
}
INSTANTIATE_TEST_CASE_P(GPU_ObjDetect, LBP_classify,

View File

@ -70,258 +70,402 @@ PARAM_TEST_CASE(GlBuffer, cv::Size, MatType)
TEST_P(GlBuffer, Constructor1)
{
cv::GlBuffer buf(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
try
{
cv::GlBuffer buf(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, Constructor2)
{
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
try
{
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, ConstructorFromMat)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, ConstructorFromGpuMat)
{
cv::Mat gold = randomMat(size, type);
cv::gpu::GpuMat d_gold(gold);
try
{
cv::Mat gold = randomMat(size, type);
cv::gpu::GpuMat d_gold(gold);
cv::GlBuffer buf(d_gold, cv::GlBuffer::ARRAY_BUFFER);
cv::GlBuffer buf(d_gold, cv::GlBuffer::ARRAY_BUFFER);
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, ConstructorFromGlBuffer)
{
cv::GlBuffer buf_gold(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
try
{
cv::GlBuffer buf_gold(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(buf_gold);
cv::GlBuffer buf(buf_gold);
EXPECT_EQ(buf_gold.bufId(), buf.bufId());
EXPECT_EQ(buf_gold.rows(), buf.rows());
EXPECT_EQ(buf_gold.cols(), buf.cols());
EXPECT_EQ(buf_gold.type(), buf.type());
EXPECT_EQ(buf_gold.bufId(), buf.bufId());
EXPECT_EQ(buf_gold.rows(), buf.rows());
EXPECT_EQ(buf_gold.cols(), buf.cols());
EXPECT_EQ(buf_gold.type(), buf.type());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, ConstructorFromGlTexture2D)
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
try
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
if (depth != CV_32F || cn == 2)
return;
if (depth != CV_32F || cn == 2)
return;
cv::Mat gold = randomMat(size, type, 0, 1.0);
cv::GlTexture2D tex_gold(gold, true);
cv::Mat gold = randomMat(size, type, 0, 1.0);
cv::GlTexture2D tex_gold(gold, true);
cv::GlBuffer buf(tex_gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
cv::GlBuffer buf(tex_gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, Create)
{
cv::GlBuffer buf;
buf.create(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
try
{
cv::GlBuffer buf;
buf.create(size.height, size.width, type, cv::GlBuffer::ARRAY_BUFFER, true);
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
EXPECT_EQ(size.height, buf.rows());
EXPECT_EQ(size.width, buf.cols());
EXPECT_EQ(type, buf.type());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyFromMat)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf;
buf.copyFrom(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf;
buf.copyFrom(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyFromGpuMat)
{
cv::Mat gold = randomMat(size, type);
cv::gpu::GpuMat d_gold(gold);
try
{
cv::Mat gold = randomMat(size, type);
cv::gpu::GpuMat d_gold(gold);
cv::GlBuffer buf;
buf.copyFrom(d_gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf;
buf.copyFrom(d_gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyFromGlBuffer)
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf_gold(gold, cv::GlBuffer::ARRAY_BUFFER, true);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf_gold(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf;
buf.copyFrom(buf_gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf;
buf.copyFrom(buf_gold, cv::GlBuffer::ARRAY_BUFFER, true);
EXPECT_NE(buf_gold.bufId(), buf.bufId());
EXPECT_NE(buf_gold.bufId(), buf.bufId());
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyFromGlTexture2D)
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
try
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
if (depth != CV_32F || cn == 2)
return;
if (depth != CV_32F || cn == 2)
return;
cv::Mat gold = randomMat(size, type, 0, 1.0);
cv::GlTexture2D tex_gold(gold, true);
cv::Mat gold = randomMat(size, type, 0, 1.0);
cv::GlTexture2D tex_gold(gold, true);
cv::GlBuffer buf;
buf.copyFrom(tex_gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf;
buf.copyFrom(tex_gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyToGpuMat)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::gpu::GpuMat dst;
buf.copyTo(dst);
cv::gpu::GpuMat dst;
buf.copyTo(dst);
EXPECT_MAT_NEAR(gold, dst, 0);
EXPECT_MAT_NEAR(gold, dst, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyToGlBuffer)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer dst;
buf.copyTo(dst, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer dst;
buf.copyTo(dst, cv::GlBuffer::ARRAY_BUFFER, true);
EXPECT_NE(buf.bufId(), dst.bufId());
EXPECT_NE(buf.bufId(), dst.bufId());
cv::Mat bufData;
dst.copyTo(bufData);
cv::Mat bufData;
dst.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, CopyToGlTexture2D)
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
try
{
const int depth = CV_MAT_DEPTH(type);
const int cn = CV_MAT_CN(type);
if (depth != CV_32F || cn == 2)
return;
if (depth != CV_32F || cn == 2)
return;
cv::Mat gold = randomMat(size, type, 0, 1.0);
cv::Mat gold = randomMat(size, type, 0, 1.0);
cv::GlBuffer buf(gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
cv::GlTexture2D tex;
buf.copyTo(tex, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
cv::GlTexture2D tex;
buf.copyTo(tex, cv::GlBuffer::PIXEL_PACK_BUFFER, true);
cv::Mat texData;
tex.copyTo(texData);
cv::Mat texData;
tex.copyTo(texData);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, Clone)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer dst = buf.clone(cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer dst = buf.clone(cv::GlBuffer::ARRAY_BUFFER, true);
EXPECT_NE(buf.bufId(), dst.bufId());
EXPECT_NE(buf.bufId(), dst.bufId());
cv::Mat bufData;
dst.copyTo(bufData);
cv::Mat bufData;
dst.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, MapHostRead)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::Mat dst = buf.mapHost(cv::GlBuffer::READ_ONLY);
cv::Mat dst = buf.mapHost(cv::GlBuffer::READ_ONLY);
EXPECT_MAT_NEAR(gold, dst, 0);
EXPECT_MAT_NEAR(gold, dst, 0);
buf.unmapHost();
buf.unmapHost();
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, MapHostWrite)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(size, type, cv::GlBuffer::ARRAY_BUFFER, true);
cv::Mat dst = buf.mapHost(cv::GlBuffer::WRITE_ONLY);
gold.copyTo(dst);
buf.unmapHost();
dst.release();
cv::Mat dst = buf.mapHost(cv::GlBuffer::WRITE_ONLY);
gold.copyTo(dst);
buf.unmapHost();
dst.release();
cv::Mat bufData;
buf.copyTo(bufData);
cv::Mat bufData;
buf.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 0);
EXPECT_MAT_NEAR(gold, bufData, 0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlBuffer, MapDevice)
{
cv::Mat gold = randomMat(size, type);
try
{
cv::Mat gold = randomMat(size, type);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::GlBuffer buf(gold, cv::GlBuffer::ARRAY_BUFFER, true);
cv::gpu::GpuMat dst = buf.mapDevice();
cv::gpu::GpuMat dst = buf.mapDevice();
EXPECT_MAT_NEAR(gold, dst, 0);
EXPECT_MAT_NEAR(gold, dst, 0);
buf.unmapDevice();
buf.unmapDevice();
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(OpenGL, GlBuffer, testing::Combine(DIFFERENT_SIZES, ALL_TYPES));
@ -360,147 +504,243 @@ PARAM_TEST_CASE(GlTexture2D, cv::Size, MatType)
TEST_P(GlTexture2D, Constructor1)
{
cv::GlTexture2D tex(size.height, size.width, format, true);
try
{
cv::GlTexture2D tex(size.height, size.width, format, true);
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, Constructor2)
{
cv::GlTexture2D tex(size, format, true);
try
{
cv::GlTexture2D tex(size, format, true);
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, ConstructorFromMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlTexture2D tex(gold, true);
cv::GlTexture2D tex(gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, ConstructorFromGpuMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::gpu::GpuMat d_gold(gold);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::gpu::GpuMat d_gold(gold);
cv::GlTexture2D tex(d_gold, true);
cv::GlTexture2D tex(d_gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, ConstructorFromGlBuffer)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
cv::GlTexture2D tex(buf_gold, true);
cv::GlTexture2D tex(buf_gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, ConstructorFromGlTexture2D)
{
cv::GlTexture2D tex_gold(size, format, true);
cv::GlTexture2D tex(tex_gold);
try
{
cv::GlTexture2D tex_gold(size, format, true);
cv::GlTexture2D tex(tex_gold);
EXPECT_EQ(tex_gold.texId(), tex.texId());
EXPECT_EQ(tex_gold.rows(), tex.rows());
EXPECT_EQ(tex_gold.cols(), tex.cols());
EXPECT_EQ(tex_gold.format(), tex.format());
EXPECT_EQ(tex_gold.texId(), tex.texId());
EXPECT_EQ(tex_gold.rows(), tex.rows());
EXPECT_EQ(tex_gold.cols(), tex.cols());
EXPECT_EQ(tex_gold.format(), tex.format());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, Create)
{
cv::GlTexture2D tex;
tex.create(size.height, size.width, format, true);
try
{
cv::GlTexture2D tex;
tex.create(size.height, size.width, format, true);
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
EXPECT_EQ(size.height, tex.rows());
EXPECT_EQ(size.width, tex.cols());
EXPECT_EQ(format, tex.format());
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, CopyFromMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlTexture2D tex;
tex.copyFrom(gold, true);
cv::GlTexture2D tex;
tex.copyFrom(gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, CopyFromGpuMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::gpu::GpuMat d_gold(gold);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::gpu::GpuMat d_gold(gold);
cv::GlTexture2D tex;
tex.copyFrom(d_gold, true);
cv::GlTexture2D tex;
tex.copyFrom(d_gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, CopyFromGlBuffer)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlBuffer buf_gold(gold, cv::GlBuffer::PIXEL_UNPACK_BUFFER, true);
cv::GlTexture2D tex;
tex.copyFrom(buf_gold, true);
cv::GlTexture2D tex;
tex.copyFrom(buf_gold, true);
cv::Mat texData;
tex.copyTo(texData, depth);
cv::Mat texData;
tex.copyTo(texData, depth);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
EXPECT_MAT_NEAR(gold, texData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, CopyToGpuMat)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlTexture2D tex(gold, true);
cv::GlTexture2D tex(gold, true);
cv::gpu::GpuMat dst;
tex.copyTo(dst, depth);
cv::gpu::GpuMat dst;
tex.copyTo(dst, depth);
EXPECT_MAT_NEAR(gold, dst, 1e-2);
EXPECT_MAT_NEAR(gold, dst, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
TEST_P(GlTexture2D, CopyToGlBuffer)
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
try
{
cv::Mat gold = randomMat(size, type, 0, depth == CV_8U ? 255 : 1);
cv::GlTexture2D tex(gold, true);
cv::GlTexture2D tex(gold, true);
cv::GlBuffer dst;
tex.copyTo(dst, depth, true);
cv::GlBuffer dst;
tex.copyTo(dst, depth, true);
cv::Mat bufData;
dst.copyTo(bufData);
cv::Mat bufData;
dst.copyTo(bufData);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
EXPECT_MAT_NEAR(gold, bufData, 1e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(OpenGL, GlTexture2D, testing::Combine(DIFFERENT_SIZES, testing::Values(CV_8UC1, CV_8UC3, CV_8UC4, CV_32FC1, CV_32FC3, CV_32FC4)));

View File

@ -66,15 +66,23 @@ PARAM_TEST_CASE(PyrDown, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
TEST_P(PyrDown, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(cv::Size((size.width + 1) / 2, (size.height + 1) / 2), type, useRoi);
cv::gpu::pyrDown(loadMat(src, useRoi), dst);
cv::gpu::GpuMat dst = createMat(cv::Size((size.width + 1) / 2, (size.height + 1) / 2), type, useRoi);
cv::gpu::pyrDown(loadMat(src, useRoi), dst);
cv::Mat dst_gold;
cv::pyrDown(src, dst_gold);
cv::Mat dst_gold;
cv::pyrDown(src, dst_gold);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrDown, testing::Combine(
@ -106,15 +114,23 @@ PARAM_TEST_CASE(PyrUp, cv::gpu::DeviceInfo, cv::Size, MatType, UseRoi)
TEST_P(PyrUp, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(cv::Size(size.width * 2, size.height * 2), type, useRoi);
cv::gpu::pyrUp(loadMat(src, useRoi), dst);
cv::gpu::GpuMat dst = createMat(cv::Size(size.width * 2, size.height * 2), type, useRoi);
cv::gpu::pyrUp(loadMat(src, useRoi), dst);
cv::Mat dst_gold;
cv::pyrUp(src, dst_gold);
cv::Mat dst_gold;
cv::pyrUp(src, dst_gold);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-4 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, PyrUp, testing::Combine(

View File

@ -154,16 +154,24 @@ PARAM_TEST_CASE(Remap, cv::gpu::DeviceInfo, cv::Size, MatType, Interpolation, Bo
TEST_P(Remap, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Scalar val = randomScalar(0.0, 255.0);
try
{
cv::Mat src = randomMat(size, type);
cv::Scalar val = randomScalar(0.0, 255.0);
cv::gpu::GpuMat dst = createMat(xmap.size(), type, useRoi);
cv::gpu::remap(loadMat(src, useRoi), dst, loadMat(xmap, useRoi), loadMat(ymap, useRoi), interpolation, borderType, val);
cv::gpu::GpuMat dst = createMat(xmap.size(), type, useRoi);
cv::gpu::remap(loadMat(src, useRoi), dst, loadMat(xmap, useRoi), loadMat(ymap, useRoi), interpolation, borderType, val);
cv::Mat dst_gold;
remapGold(src, xmap, ymap, dst_gold, interpolation, borderType, val);
cv::Mat dst_gold;
remapGold(src, xmap, ymap, dst_gold, interpolation, borderType, val);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-3 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-3 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Remap, testing::Combine(

View File

@ -138,15 +138,23 @@ PARAM_TEST_CASE(Resize, cv::gpu::DeviceInfo, cv::Size, MatType, double, Interpol
TEST_P(Resize, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(cv::Size(cv::saturate_cast<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff)), type, useRoi);
cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation);
cv::gpu::GpuMat dst = createMat(cv::Size(cv::saturate_cast<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff)), type, useRoi);
cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation);
cv::Mat dst_gold;
resizeGold(src, dst_gold, coeff, coeff, interpolation);
cv::Mat dst_gold;
resizeGold(src, dst_gold, coeff, coeff, interpolation);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Resize, testing::Combine(
@ -184,15 +192,23 @@ PARAM_TEST_CASE(ResizeSameAsHost, cv::gpu::DeviceInfo, cv::Size, MatType, double
// downscaling only: used for classifiers
TEST_P(ResizeSameAsHost, Accuracy)
{
cv::Mat src = randomMat(size, type);
try
{
cv::Mat src = randomMat(size, type);
cv::gpu::GpuMat dst = createMat(cv::Size(cv::saturate_cast<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff)), type, useRoi);
cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation);
cv::gpu::GpuMat dst = createMat(cv::Size(cv::saturate_cast<int>(src.cols * coeff), cv::saturate_cast<int>(src.rows * coeff)), type, useRoi);
cv::gpu::resize(loadMat(src, useRoi), dst, cv::Size(), coeff, coeff, interpolation);
cv::Mat dst_gold;
cv::resize(src, dst_gold, cv::Size(), coeff, coeff, interpolation);
cv::Mat dst_gold;
cv::resize(src, dst_gold, cv::Size(), coeff, coeff, interpolation);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-2 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeSameAsHost, testing::Combine(
@ -226,16 +242,24 @@ PARAM_TEST_CASE(ResizeNPP, cv::gpu::DeviceInfo, MatType, double, Interpolation)
TEST_P(ResizeNPP, Accuracy)
{
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
ASSERT_FALSE(src.empty());
try
{
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
ASSERT_FALSE(src.empty());
cv::gpu::GpuMat dst;
cv::gpu::resize(loadMat(src), dst, cv::Size(), coeff, coeff, interpolation);
cv::gpu::GpuMat dst;
cv::gpu::resize(loadMat(src), dst, cv::Size(), coeff, coeff, interpolation);
cv::Mat dst_gold;
resizeGold(src, dst_gold, coeff, coeff, interpolation);
cv::Mat dst_gold;
resizeGold(src, dst_gold, coeff, coeff, interpolation);
EXPECT_MAT_SIMILAR(dst_gold, dst, 1e-1);
EXPECT_MAT_SIMILAR(dst_gold, dst, 1e-1);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, ResizeNPP, testing::Combine(

View File

@ -40,7 +40,7 @@
//
//M*/
#include <test_precomp.hpp>
#include "test_precomp.hpp"
#include <time.h>
#ifdef HAVE_CUDA
@ -158,62 +158,77 @@ GPU_TEST_P(SCascadeTestRoi, detect,
testing::Values(std::string("../cv/cascadeandhog/bahnhof/image_00000000_0.png")),
testing::Range(0, 5)))
{
cv::gpu::setDevice(GET_PARAM(0).deviceID());
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path() + GET_PARAM(2));
ASSERT_FALSE(coloredCpu.empty());
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(1)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
GpuMat colored(coloredCpu), objectBoxes(1, 16384, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
int nroi = GET_PARAM(3);
cv::Mat result(coloredCpu);
cv::RNG rng;
for (int i = 0; i < nroi; ++i)
try
{
cv::Rect r = getFromTable(rng(10));
GpuMat sub(rois, r);
sub.setTo(1);
cv::rectangle(result, r, cv::Scalar(0, 0, 255, 255), 1);
cv::gpu::setDevice(GET_PARAM(0).deviceID());
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path() + GET_PARAM(2));
ASSERT_FALSE(coloredCpu.empty());
cv::gpu::SCascade cascade;
cv::FileStorage fs(perf::TestBase::getDataPath(GET_PARAM(1)), cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
GpuMat colored(coloredCpu), objectBoxes(1, 16384, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
int nroi = GET_PARAM(3);
cv::Mat result(coloredCpu);
cv::RNG rng;
for (int i = 0; i < nroi; ++i)
{
cv::Rect r = getFromTable(rng(10));
GpuMat sub(rois, r);
sub.setTo(1);
cv::rectangle(result, r, cv::Scalar(0, 0, 255, 255), 1);
}
objectBoxes.setTo(0);
cascade.detect(colored, rois, objectBoxes);
cv::Mat dt(objectBoxes);
typedef cv::gpu::SCascade::Detection Detection;
Detection* dts = ((Detection*)dt.data) + 1;
int* count = dt.ptr<int>(0);
printTotal(std::cout, *count);
for (int i = 0; i < *count; ++i)
{
Detection d = dts[i];
print(std::cout, d);
cv::rectangle(result, cv::Rect(d.x, d.y, d.w, d.h), cv::Scalar(255, 0, 0, 255), 1);
}
SHOW(result);
}
objectBoxes.setTo(0);
cascade.detect(colored, rois, objectBoxes);
cv::Mat dt(objectBoxes);
typedef cv::gpu::SCascade::Detection Detection;
Detection* dts = ((Detection*)dt.data) + 1;
int* count = dt.ptr<int>(0);
printTotal(std::cout, *count);
for (int i = 0; i < *count; ++i)
catch (...)
{
Detection d = dts[i];
print(std::cout, d);
cv::rectangle(result, cv::Rect(d.x, d.y, d.w, d.h), cv::Scalar(255, 0, 0, 255), 1);
cv::gpu::resetDevice();
throw;
}
SHOW(result);
}
TEST(SCascadeTest, readCascade)
{
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/icf-template.xml";
cv::gpu::SCascade cascade;
try
{
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/icf-template.xml";
cv::gpu::SCascade cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
typedef ::testing::TestWithParam<cv::gpu::DeviceInfo > SCascadeTestAll;
@ -221,104 +236,128 @@ GPU_TEST_P(SCascadeTestAll, detect,
ALL_DEVICES
)
{
cv::gpu::setDevice(GetParam().deviceID());
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::gpu::SCascade cascade;
try
{
cv::gpu::setDevice(GetParam().deviceID());
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::gpu::SCascade cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path()
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
ASSERT_FALSE(coloredCpu.empty());
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path()
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
ASSERT_FALSE(coloredCpu.empty());
GpuMat colored(coloredCpu), objectBoxes, rois(colored.size(), CV_8UC1);
rois.setTo(0);
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
sub.setTo(cv::Scalar::all(1));
GpuMat colored(coloredCpu), objectBoxes, rois(colored.size(), CV_8UC1);
rois.setTo(0);
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
sub.setTo(cv::Scalar::all(1));
objectBoxes.setTo(0);
cascade.detect(colored, rois, objectBoxes);
objectBoxes.setTo(0);
cascade.detect(colored, rois, objectBoxes);
typedef cv::gpu::SCascade::Detection Detection;
cv::Mat detections(objectBoxes);
int a = *(detections.ptr<int>(0));
ASSERT_EQ(a ,2448);
typedef cv::gpu::SCascade::Detection Detection;
cv::Mat detections(objectBoxes);
int a = *(detections.ptr<int>(0));
ASSERT_EQ(a, 2448);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
GPU_TEST_P(SCascadeTestAll, detectOnIntegral,
ALL_DEVICES
)
{
cv::gpu::setDevice(GetParam().deviceID());
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::gpu::SCascade cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
std::string intPath = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/integrals.xml";
cv::FileStorage fsi(intPath, cv::FileStorage::READ);
ASSERT_TRUE(fsi.isOpened());
GpuMat hogluv(121 * 10, 161, CV_32SC1);
for (int i = 0; i < 10; ++i)
try
{
cv::Mat channel;
fsi[std::string("channel") + itoa(i)] >> channel;
GpuMat gchannel(hogluv, cv::Rect(0, 121 * i, 161, 121));
gchannel.upload(channel);
cv::gpu::setDevice(GetParam().deviceID());
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::gpu::SCascade cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
std::string intPath = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/integrals.xml";
cv::FileStorage fsi(intPath, cv::FileStorage::READ);
ASSERT_TRUE(fsi.isOpened());
GpuMat hogluv(121 * 10, 161, CV_32SC1);
for (int i = 0; i < 10; ++i)
{
cv::Mat channel;
fsi[std::string("channel") + itoa(i)] >> channel;
GpuMat gchannel(hogluv, cv::Rect(0, 121 * i, 161, 121));
gchannel.upload(channel);
}
GpuMat objectBoxes(1, 100000, CV_8UC1), rois(cv::Size(640, 480), CV_8UC1);
rois.setTo(1);
objectBoxes.setTo(0);
cascade.detect(hogluv, rois, objectBoxes);
typedef cv::gpu::SCascade::Detection Detection;
cv::Mat detections(objectBoxes);
int a = *(detections.ptr<int>(0));
ASSERT_EQ(a, 1024);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
GpuMat objectBoxes(1, 100000, CV_8UC1), rois(cv::Size(640, 480), CV_8UC1);
rois.setTo(1);
objectBoxes.setTo(0);
cascade.detect(hogluv, rois, objectBoxes);
typedef cv::gpu::SCascade::Detection Detection;
cv::Mat detections(objectBoxes);
int a = *(detections.ptr<int>(0));
ASSERT_EQ( a ,1024);
}
GPU_TEST_P(SCascadeTestAll, detectStream,
ALL_DEVICES
)
{
cv::gpu::setDevice(GetParam().deviceID());
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::gpu::SCascade cascade;
try
{
cv::gpu::setDevice(GetParam().deviceID());
std::string xml = cvtest::TS::ptr()->get_data_path() + "../cv/cascadeandhog/sc_cvpr_2012_to_opencv.xml";
cv::gpu::SCascade cascade;
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
cv::FileStorage fs(xml, cv::FileStorage::READ);
ASSERT_TRUE(fs.isOpened());
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
ASSERT_TRUE(cascade.load(fs.getFirstTopLevelNode()));
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path()
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
ASSERT_FALSE(coloredCpu.empty());
cv::Mat coloredCpu = cv::imread(cvtest::TS::ptr()->get_data_path()
+ "../cv/cascadeandhog/bahnhof/image_00000000_0.png");
ASSERT_FALSE(coloredCpu.empty());
GpuMat colored(coloredCpu), objectBoxes(1, 100000, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
sub.setTo(cv::Scalar::all(1));
GpuMat colored(coloredCpu), objectBoxes(1, 100000, CV_8UC1), rois(colored.size(), CV_8UC1);
rois.setTo(0);
GpuMat sub(rois, cv::Rect(rois.cols / 4, rois.rows / 4,rois.cols / 2, rois.rows / 2));
sub.setTo(cv::Scalar::all(1));
cv::gpu::Stream s;
cv::gpu::Stream s;
objectBoxes.setTo(0);
cascade.detect(colored, rois, objectBoxes, s);
s.waitForCompletion();
objectBoxes.setTo(0);
cascade.detect(colored, rois, objectBoxes, s);
s.waitForCompletion();
typedef cv::gpu::SCascade::Detection Detection;
cv::Mat detections(objectBoxes);
int a = *(detections.ptr<int>(0));
ASSERT_EQ(a ,2448);
typedef cv::gpu::SCascade::Detection Detection;
cv::Mat detections(objectBoxes);
int a = *(detections.ptr<int>(0));
ASSERT_EQ(a, 2448);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}

View File

@ -68,17 +68,25 @@ PARAM_TEST_CASE(Threshold, cv::gpu::DeviceInfo, cv::Size, MatType, ThreshOp, Use
TEST_P(Threshold, Accuracy)
{
cv::Mat src = randomMat(size, type);
double maxVal = randomDouble(20.0, 127.0);
double thresh = randomDouble(0.0, maxVal);
try
{
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::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);
cv::Mat dst_gold;
cv::threshold(src, dst_gold, thresh, maxVal, threshOp);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, Threshold, testing::Combine(

File diff suppressed because it is too large Load Diff

View File

@ -76,24 +76,32 @@ PARAM_TEST_CASE(BuildWarpAffineMaps, cv::gpu::DeviceInfo, cv::Size, Inverse)
TEST_P(BuildWarpAffineMaps, Accuracy)
{
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
cv::gpu::GpuMat xmap, ymap;
cv::gpu::buildWarpAffineMaps(M, inverse, size, xmap, ymap);
try
{
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
cv::gpu::GpuMat xmap, ymap;
cv::gpu::buildWarpAffineMaps(M, inverse, size, xmap, ymap);
int interpolation = cv::INTER_NEAREST;
int borderMode = cv::BORDER_CONSTANT;
int interpolation = cv::INTER_NEAREST;
int borderMode = cv::BORDER_CONSTANT;
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
cv::Mat dst;
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), interpolation, borderMode);
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
cv::Mat dst;
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), interpolation, borderMode);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Mat dst_gold;
cv::warpAffine(src, dst_gold, M, size, flags, borderMode);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Mat dst_gold;
cv::warpAffine(src, dst_gold, M, size, flags, borderMode);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, BuildWarpAffineMaps, testing::Combine(
@ -201,20 +209,28 @@ PARAM_TEST_CASE(WarpAffine, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse, Int
TEST_P(WarpAffine, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Scalar val = randomScalar(0.0, 255.0);
try
{
cv::Mat src = randomMat(size, type);
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Scalar val = randomScalar(0.0, 255.0);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::warpAffine(loadMat(src, useRoi), dst, M, size, flags, borderType, val);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::warpAffine(loadMat(src, useRoi), dst, M, size, flags, borderType, val);
cv::Mat dst_gold;
warpAffineGold(src, M, inverse, size, dst_gold, interpolation, borderType, val);
cv::Mat dst_gold;
warpAffineGold(src, M, inverse, size, dst_gold, interpolation, borderType, val);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-1 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-1 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpAffine, testing::Combine(
@ -249,19 +265,27 @@ PARAM_TEST_CASE(WarpAffineNPP, cv::gpu::DeviceInfo, MatType, Inverse, Interpolat
TEST_P(WarpAffineNPP, Accuracy)
{
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
try
{
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::gpu::GpuMat dst;
cv::gpu::warpAffine(loadMat(src), dst, M, src.size(), flags);
cv::gpu::GpuMat dst;
cv::gpu::warpAffine(loadMat(src), dst, M, src.size(), flags);
cv::Mat dst_gold;
warpAffineGold(src, M, inverse, src.size(), dst_gold, interpolation, cv::BORDER_CONSTANT, cv::Scalar::all(0));
cv::Mat dst_gold;
warpAffineGold(src, M, inverse, src.size(), dst_gold, interpolation, cv::BORDER_CONSTANT, cv::Scalar::all(0));
EXPECT_MAT_SIMILAR(dst_gold, dst, 2e-2);
EXPECT_MAT_SIMILAR(dst_gold, dst, 2e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpAffineNPP, testing::Combine(

View File

@ -77,21 +77,29 @@ PARAM_TEST_CASE(BuildWarpPerspectiveMaps, cv::gpu::DeviceInfo, cv::Size, Inverse
TEST_P(BuildWarpPerspectiveMaps, Accuracy)
{
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
cv::gpu::GpuMat xmap, ymap;
cv::gpu::buildWarpPerspectiveMaps(M, inverse, size, xmap, ymap);
try
{
cv::Mat M = createTransfomMatrix(size, CV_PI / 4);
cv::gpu::GpuMat xmap, ymap;
cv::gpu::buildWarpPerspectiveMaps(M, inverse, size, xmap, ymap);
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
cv::Mat dst;
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), cv::INTER_NEAREST, cv::BORDER_CONSTANT);
cv::Mat src = randomMat(randomSize(200, 400), CV_8UC1);
cv::Mat dst;
cv::remap(src, dst, cv::Mat(xmap), cv::Mat(ymap), cv::INTER_NEAREST, cv::BORDER_CONSTANT);
int flags = cv::INTER_NEAREST;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Mat dst_gold;
cv::warpPerspective(src, dst_gold, M, size, flags, cv::BORDER_CONSTANT);
int flags = cv::INTER_NEAREST;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Mat dst_gold;
cv::warpPerspective(src, dst_gold, M, size, flags, cv::BORDER_CONSTANT);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
EXPECT_MAT_NEAR(dst_gold, dst, 0.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, BuildWarpPerspectiveMaps, testing::Combine(
@ -201,20 +209,28 @@ PARAM_TEST_CASE(WarpPerspective, cv::gpu::DeviceInfo, cv::Size, MatType, Inverse
TEST_P(WarpPerspective, Accuracy)
{
cv::Mat src = randomMat(size, type);
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Scalar val = randomScalar(0.0, 255.0);
try
{
cv::Mat src = randomMat(size, type);
cv::Mat M = createTransfomMatrix(size, CV_PI / 3);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::Scalar val = randomScalar(0.0, 255.0);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::warpPerspective(loadMat(src, useRoi), dst, M, size, flags, borderType, val);
cv::gpu::GpuMat dst = createMat(size, type, useRoi);
cv::gpu::warpPerspective(loadMat(src, useRoi), dst, M, size, flags, borderType, val);
cv::Mat dst_gold;
warpPerspectiveGold(src, M, inverse, size, dst_gold, interpolation, borderType, val);
cv::Mat dst_gold;
warpPerspectiveGold(src, M, inverse, size, dst_gold, interpolation, borderType, val);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-1 : 1.0);
EXPECT_MAT_NEAR(dst_gold, dst, src.depth() == CV_32F ? 1e-1 : 1.0);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpPerspective, testing::Combine(
@ -249,19 +265,27 @@ PARAM_TEST_CASE(WarpPerspectiveNPP, cv::gpu::DeviceInfo, MatType, Inverse, Inter
TEST_P(WarpPerspectiveNPP, Accuracy)
{
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
try
{
cv::Mat src = readImageType("stereobp/aloe-L.png", type);
cv::Mat M = createTransfomMatrix(src.size(), CV_PI / 4);
int flags = interpolation;
if (inverse)
flags |= cv::WARP_INVERSE_MAP;
cv::gpu::GpuMat dst;
cv::gpu::warpPerspective(loadMat(src), dst, M, src.size(), flags);
cv::gpu::GpuMat dst;
cv::gpu::warpPerspective(loadMat(src), dst, M, src.size(), flags);
cv::Mat dst_gold;
warpPerspectiveGold(src, M, inverse, src.size(), dst_gold, interpolation, cv::BORDER_CONSTANT, cv::Scalar::all(0));
cv::Mat dst_gold;
warpPerspectiveGold(src, M, inverse, src.size(), dst_gold, interpolation, cv::BORDER_CONSTANT, cv::Scalar::all(0));
EXPECT_MAT_SIMILAR(dst_gold, dst, 2e-2);
EXPECT_MAT_SIMILAR(dst_gold, dst, 2e-2);
}
catch (...)
{
cv::gpu::resetDevice();
throw;
}
}
INSTANTIATE_TEST_CASE_P(GPU_ImgProc, WarpPerspectiveNPP, testing::Combine(