Path: blob/master/modules/objdetect/perf/perf_qrcode_pipeline.cpp
16339 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#include "perf_precomp.hpp"56namespace opencv_test7{8namespace9{1011typedef ::perf::TestBaseWithParam< std::string > Perf_Objdetect_QRCode;1213PERF_TEST_P_(Perf_Objdetect_QRCode, detect)14{15const std::string name_current_image = GetParam();16const std::string root = "cv/qrcode/";1718std::string image_path = findDataFile(root + name_current_image);19Mat src = imread(image_path, IMREAD_GRAYSCALE), straight_barcode;20ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;2122std::vector< Point > corners;23TEST_CYCLE() ASSERT_TRUE(detectQRCode(src, corners));24SANITY_CHECK(corners);25}2627#ifdef HAVE_QUIRC28PERF_TEST_P_(Perf_Objdetect_QRCode, decode)29{30const std::string name_current_image = GetParam();31const std::string root = "cv/qrcode/";3233std::string image_path = findDataFile(root + name_current_image);34Mat src = imread(image_path, IMREAD_GRAYSCALE), straight_barcode;35ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;3637std::vector< Point > corners;38std::string decoded_info;39ASSERT_TRUE(detectQRCode(src, corners));40TEST_CYCLE() ASSERT_TRUE(decodeQRCode(src, corners, decoded_info, straight_barcode));4142std::vector<uint8_t> decoded_info_uint8_t(decoded_info.begin(), decoded_info.end());43SANITY_CHECK(decoded_info_uint8_t);44SANITY_CHECK(straight_barcode);4546}47#endif4849INSTANTIATE_TEST_CASE_P(/*nothing*/, Perf_Objdetect_QRCode,50::testing::Values(51"version_1_down.jpg", "version_1_left.jpg", "version_1_right.jpg", "version_1_up.jpg", "version_1_top.jpg",52"version_5_down.jpg", "version_5_left.jpg", "version_5_right.jpg", "version_5_up.jpg", "version_5_top.jpg",53"russian.jpg", "kanji.jpg", "link_github_ocv.jpg", "link_ocv.jpg", "link_wiki_cv.jpg"54)55);5657typedef ::perf::TestBaseWithParam< tuple< std::string, Size > > Perf_Objdetect_Not_QRCode;5859PERF_TEST_P_(Perf_Objdetect_Not_QRCode, detect)60{61std::vector<Point> corners;62std::string type_gen = get<0>(GetParam());63Size resolution = get<1>(GetParam());64Mat not_qr_code(resolution, CV_8UC1, Scalar(0));65if (type_gen == "random")66{67RNG rng;68rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1));69}7071TEST_CYCLE() ASSERT_FALSE(detectQRCode(not_qr_code, corners));72SANITY_CHECK_NOTHING();73}7475#ifdef HAVE_QUIRC76PERF_TEST_P_(Perf_Objdetect_Not_QRCode, decode)77{78Mat straight_barcode;79std::string decoded_info;80std::vector< Point > corners;81corners.push_back(Point( 0, 0)); corners.push_back(Point( 0, 5));82corners.push_back(Point(10, 0)); corners.push_back(Point(15, 15));8384std::string type_gen = get<0>(GetParam());85Size resolution = get<1>(GetParam());86Mat not_qr_code(resolution, CV_8UC1, Scalar(0));87if (type_gen == "random")88{89RNG rng;90rng.fill(not_qr_code, RNG::UNIFORM, Scalar(0), Scalar(1));91}9293TEST_CYCLE() ASSERT_FALSE(decodeQRCode(not_qr_code, corners, decoded_info, straight_barcode));94SANITY_CHECK_NOTHING();95}96#endif9798INSTANTIATE_TEST_CASE_P(/*nothing*/, Perf_Objdetect_Not_QRCode,99::testing::Combine(100::testing::Values("zero", "random"),101::testing::Values(Size(640, 480), Size(1280, 720), Size(1920, 1080))102));103104}105} // namespace106107108