Path: blob/master/modules/imgproc/perf/opencl/perf_houghlines.cpp
16354 views
// This file is part of OpenCV project.1// It is subject to the license terms in the LICENSE file found in the top-level directory2// of this distribution and at http://opencv.org/license.html.34// Copyright (C) 2014, Itseez, Inc., all rights reserved.5// Third party copyrights are property of their respective owners.67#include "../perf_precomp.hpp"8#include "opencv2/ts/ocl_perf.hpp"910#ifdef HAVE_OPENCL1112namespace opencv_test {13namespace ocl {1415///////////// HoughLines //////////////////////1617struct Vec2fComparator18{19bool operator()(const Vec2f& a, const Vec2f b) const20{21if(a[0] != b[0]) return a[0] < b[0];22else return a[1] < b[1];23}24};2526typedef tuple<Size, double, double> ImageSize_RhoStep_ThetaStep_t;27typedef TestBaseWithParam<ImageSize_RhoStep_ThetaStep_t> HoughLinesFixture;2829OCL_PERF_TEST_P(HoughLinesFixture, HoughLines, Combine(OCL_TEST_SIZES,30Values( 0.1, 1 ),31Values( CV_PI / 180.0, 0.1 )))32{33const Size srcSize = get<0>(GetParam());34double rhoStep = get<1>(GetParam());35double thetaStep = get<2>(GetParam());36int threshold = 250;3738UMat usrc(srcSize, CV_8UC1), lines(1, 1, CV_32FC2);39Mat src(srcSize, CV_8UC1);40src.setTo(Scalar::all(0));41line(src, Point(0, 100), Point(src.cols, 100), Scalar::all(255), 1);42line(src, Point(0, 200), Point(src.cols, 200), Scalar::all(255), 1);43line(src, Point(0, 400), Point(src.cols, 400), Scalar::all(255), 1);44line(src, Point(100, 0), Point(100, src.rows), Scalar::all(255), 1);45line(src, Point(200, 0), Point(200, src.rows), Scalar::all(255), 1);46line(src, Point(400, 0), Point(400, src.rows), Scalar::all(255), 1);47src.copyTo(usrc);4849declare.in(usrc).out(lines);5051OCL_TEST_CYCLE() cv::HoughLines(usrc, lines, rhoStep, thetaStep, threshold);5253Mat result;54lines.copyTo(result);55std::sort(result.begin<Vec2f>(), result.end<Vec2f>(), Vec2fComparator());5657SANITY_CHECK(result, 1e-6);58}5960///////////// HoughLinesP /////////////////////6162typedef tuple<string, double, double> Image_RhoStep_ThetaStep_t;63typedef TestBaseWithParam<Image_RhoStep_ThetaStep_t> HoughLinesPFixture;6465OCL_PERF_TEST_P(HoughLinesPFixture, HoughLinesP, Combine(Values("cv/shared/pic5.png", "stitching/a1.png"),66Values( 0.1, 1 ),67Values( CV_PI / 180.0, 0.1 )))68{69string filename = get<0>(GetParam());70double rhoStep = get<1>(GetParam());71double thetaStep = get<2>(GetParam());72int threshold = 100;73double minLineLength = 50, maxGap = 5;7475Mat image = imread(getDataPath(filename), IMREAD_GRAYSCALE);76Canny(image, image, 50, 200, 3);77UMat usrc, lines(1, 1, CV_32SC4);78image.copyTo(usrc);7980declare.in(usrc).out(lines);8182OCL_TEST_CYCLE() cv::HoughLinesP(usrc, lines, rhoStep, thetaStep, threshold, minLineLength, maxGap);8384EXPECT_NE((int) lines.total(), 0);85SANITY_CHECK_NOTHING();86}8788} } // namespace opencv_test::ocl8990#endif // HAVE_OPENCL9192