mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 07:43:03 +04:00
Merge branch 4.x
This commit is contained in:
@@ -268,12 +268,12 @@ void CV_ArucoDetectionPerspective::run(int) {
|
||||
}
|
||||
|
||||
if(ArucoAlgParams::USE_APRILTAG == arucoAlgParams){
|
||||
detectorParameters.cornerRefinementMethod = aruco::CORNER_REFINE_APRILTAG;
|
||||
detectorParameters.cornerRefinementMethod = (int)aruco::CORNER_REFINE_APRILTAG;
|
||||
}
|
||||
|
||||
if (ArucoAlgParams::USE_ARUCO3 == arucoAlgParams) {
|
||||
detectorParameters.useAruco3Detection = true;
|
||||
detectorParameters.cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
|
||||
detectorParameters.cornerRefinementMethod = (int)aruco::CORNER_REFINE_SUBPIX;
|
||||
}
|
||||
detector.setDetectorParameters(detectorParameters);
|
||||
|
||||
@@ -653,7 +653,7 @@ TEST_P(ArucoThreading, number_of_threads_does_not_change_results)
|
||||
img_marker.copyTo(img(Rect(shift, shift, height_marker, height_marker)));
|
||||
|
||||
aruco::DetectorParameters detectorParameters = detector.getDetectorParameters();
|
||||
detectorParameters.cornerRefinementMethod = GetParam();
|
||||
detectorParameters.cornerRefinementMethod = (int)GetParam();
|
||||
detector.setDetectorParameters(detectorParameters);
|
||||
|
||||
vector<vector<Point2f> > original_corners;
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "opencv2/objdetect/barcode.hpp"
|
||||
#include <set>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace opencv_test{namespace{
|
||||
|
||||
typedef std::set<string> StringSet;
|
||||
|
||||
// Convert ';'-separated strings to a set
|
||||
inline static StringSet toSet(const string &line)
|
||||
{
|
||||
StringSet res;
|
||||
string::size_type it = 0, ti;
|
||||
while (true)
|
||||
{
|
||||
ti = line.find(';', it);
|
||||
if (ti == string::npos)
|
||||
{
|
||||
res.insert(string(line, it, line.size() - it));
|
||||
break;
|
||||
}
|
||||
res.insert(string(line, it, ti - it));
|
||||
it = ti + 1;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// Convert vector of strings to a set
|
||||
inline static StringSet toSet(const vector<string> &lines)
|
||||
{
|
||||
StringSet res;
|
||||
for (const string & line : lines)
|
||||
res.insert(line);
|
||||
return res;
|
||||
}
|
||||
|
||||
// Get all keys of a map in a vector
|
||||
template<typename T, typename V>
|
||||
inline static vector<T> getKeys(const map<T, V> &m)
|
||||
{
|
||||
vector<T> res;
|
||||
for (const auto & it : m)
|
||||
res.push_back(it.first);
|
||||
return res;
|
||||
}
|
||||
|
||||
struct BarcodeResult
|
||||
{
|
||||
string type;
|
||||
string data;
|
||||
};
|
||||
|
||||
map<string, BarcodeResult> testResults {
|
||||
{ "single/book.jpg", {"EAN_13", "9787115279460"} },
|
||||
{ "single/bottle_1.jpg", {"EAN_13", "6922255451427"} },
|
||||
{ "single/bottle_2.jpg", {"EAN_13", "6921168509256"} },
|
||||
{ "multiple/4_barcodes.jpg", {"EAN_13;EAN_13;EAN_13;EAN_13", "9787564350840;9783319200064;9787118081473;9787122276124"} }
|
||||
};
|
||||
|
||||
typedef testing::TestWithParam< string > BarcodeDetector_main;
|
||||
|
||||
TEST_P(BarcodeDetector_main, interface)
|
||||
{
|
||||
const string fname = GetParam();
|
||||
const string image_path = findDataFile(string("barcode/") + fname);
|
||||
const StringSet expected_lines = toSet(testResults[fname].data);
|
||||
const StringSet expected_types = toSet(testResults[fname].type);
|
||||
const size_t expected_count = expected_lines.size(); // assume codes are unique
|
||||
// TODO: verify points location
|
||||
|
||||
Mat img = imread(image_path);
|
||||
ASSERT_FALSE(img.empty()) << "Can't read image: " << image_path;
|
||||
|
||||
barcode::BarcodeDetector det;
|
||||
vector<Point2f> points;
|
||||
vector<string> types;
|
||||
vector<string> lines;
|
||||
|
||||
// common interface (single)
|
||||
{
|
||||
bool res = det.detect(img, points);
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(expected_count * 4, points.size());
|
||||
}
|
||||
|
||||
{
|
||||
string res = det.decode(img, points);
|
||||
ASSERT_FALSE(res.empty());
|
||||
EXPECT_EQ(1u, expected_lines.count(res));
|
||||
}
|
||||
|
||||
// common interface (multi)
|
||||
{
|
||||
bool res = det.detectMulti(img, points);
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(expected_count * 4, points.size());
|
||||
}
|
||||
|
||||
{
|
||||
bool res = det.decodeMulti(img, points, lines);
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(expected_lines, toSet(lines));
|
||||
}
|
||||
|
||||
// specific interface
|
||||
{
|
||||
bool res = det.decodeWithType(img, points, lines, types);
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(expected_types, toSet(types));
|
||||
EXPECT_EQ(expected_lines, toSet(lines));
|
||||
}
|
||||
|
||||
{
|
||||
bool res = det.detectAndDecodeWithType(img, lines, types, points);
|
||||
ASSERT_TRUE(res);
|
||||
EXPECT_EQ(expected_types, toSet(types));
|
||||
EXPECT_EQ(expected_lines, toSet(lines));
|
||||
}
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/**/, BarcodeDetector_main, testing::ValuesIn(getKeys(testResults)));
|
||||
|
||||
TEST(BarcodeDetector_base, invalid)
|
||||
{
|
||||
auto bardet = barcode::BarcodeDetector();
|
||||
std::vector<Point> corners;
|
||||
vector<cv::String> decoded_info;
|
||||
Mat zero_image = Mat::zeros(256, 256, CV_8UC1);
|
||||
EXPECT_FALSE(bardet.detectMulti(zero_image, corners));
|
||||
corners = std::vector<Point>(4);
|
||||
EXPECT_ANY_THROW(bardet.decodeMulti(zero_image, corners, decoded_info));
|
||||
}
|
||||
|
||||
}} // opencv_test::<anonymous>::
|
||||
@@ -26,7 +26,7 @@ class CV_ArucoBoardPose : public cvtest::BaseTest {
|
||||
params.minDistanceToBorder = 3;
|
||||
if (arucoAlgParams == ArucoAlgParams::USE_ARUCO3) {
|
||||
params.useAruco3Detection = true;
|
||||
params.cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
|
||||
params.cornerRefinementMethod = (int)aruco::CORNER_REFINE_SUBPIX;
|
||||
params.minSideLengthCanonicalImg = 16;
|
||||
params.errorCorrectionRate = 0.8;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ class CV_ArucoRefine : public cvtest::BaseTest {
|
||||
aruco::Dictionary dictionary = aruco::getPredefinedDictionary(aruco::DICT_6X6_250);
|
||||
aruco::DetectorParameters params;
|
||||
params.minDistanceToBorder = 3;
|
||||
params.cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
|
||||
params.cornerRefinementMethod = (int)aruco::CORNER_REFINE_SUBPIX;
|
||||
if (arucoAlgParams == ArucoAlgParams::USE_ARUCO3)
|
||||
params.useAruco3Detection = true;
|
||||
aruco::RefineParameters refineParams(10.f, 3.f, true);
|
||||
|
||||
@@ -612,7 +612,7 @@ TEST(Charuco, testBoardSubpixelCoords)
|
||||
cv::GaussianBlur(gray, gray, Size(5, 5), 1.0);
|
||||
|
||||
aruco::DetectorParameters params;
|
||||
params.cornerRefinementMethod = cv::aruco::CORNER_REFINE_APRILTAG;
|
||||
params.cornerRefinementMethod = (int)cv::aruco::CORNER_REFINE_APRILTAG;
|
||||
|
||||
aruco::CharucoParameters charucoParameters;
|
||||
charucoParameters.cameraMatrix = K;
|
||||
@@ -636,7 +636,7 @@ TEST(Charuco, issue_14014)
|
||||
Mat img = imread(imgPath);
|
||||
|
||||
aruco::DetectorParameters detectorParams;
|
||||
detectorParams.cornerRefinementMethod = aruco::CORNER_REFINE_SUBPIX;
|
||||
detectorParams.cornerRefinementMethod = (int)aruco::CORNER_REFINE_SUBPIX;
|
||||
detectorParams.cornerRefinementMinAccuracy = 0.01;
|
||||
aruco::ArucoDetector detector(aruco::getPredefinedDictionary(aruco::DICT_7X7_250), detectorParams);
|
||||
aruco::CharucoBoard board(Size(8, 5), 0.03455f, 0.02164f, detector.getDictionary());
|
||||
|
||||
@@ -0,0 +1,78 @@
|
||||
// This file is part of OpenCV project.
|
||||
// It is subject to the license terms in the LICENSE file found in the top-level directory
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
#include "test_precomp.hpp"
|
||||
|
||||
namespace opencv_test {
|
||||
|
||||
static inline
|
||||
void check_qr(const string& root, const string& name_current_image, const string& config_name,
|
||||
const std::vector<Point>& corners,
|
||||
const std::vector<string>& decoded_info, const int max_pixel_error,
|
||||
bool isMulti = false) {
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
FileNode images_list = file_config[config_name];
|
||||
size_t images_count = static_cast<size_t>(images_list.size());
|
||||
ASSERT_GT(images_count, 0u) << "Can't find validation data entries in 'test_images': " << dataset_config;
|
||||
for (size_t index = 0; index < images_count; index++) {
|
||||
FileNode config = images_list[(int)index];
|
||||
std::string name_test_image = config["image_name"];
|
||||
if (name_test_image == name_current_image) {
|
||||
if (isMulti) {
|
||||
for(int j = 0; j < int(corners.size()); j += 4) {
|
||||
bool ok = false;
|
||||
for (int k = 0; k < int(corners.size() / 4); k++) {
|
||||
int count_eq_points = 0;
|
||||
for (int i = 0; i < 4; i++) {
|
||||
int x = config["x"][k][i];
|
||||
int y = config["y"][k][i];
|
||||
if(((abs(corners[j + i].x - x)) <= max_pixel_error) && ((abs(corners[j + i].y - y)) <= max_pixel_error))
|
||||
count_eq_points++;
|
||||
}
|
||||
if (count_eq_points == 4) {
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(ok);
|
||||
}
|
||||
}
|
||||
else {
|
||||
for (int i = 0; i < (int)corners.size(); i++) {
|
||||
int x = config["x"][i];
|
||||
int y = config["y"][i];
|
||||
EXPECT_NEAR(x, corners[i].x, max_pixel_error);
|
||||
EXPECT_NEAR(y, corners[i].y, max_pixel_error);
|
||||
}
|
||||
}
|
||||
#ifdef HAVE_QUIRC
|
||||
if (decoded_info.size() == 0ull)
|
||||
return;
|
||||
if (isMulti) {
|
||||
size_t count_eq_info = 0;
|
||||
for(int i = 0; i < int(decoded_info.size()); i++) {
|
||||
for(int j = 0; j < int(decoded_info.size()); j++) {
|
||||
std::string original_info = config["info"][j];
|
||||
if(original_info == decoded_info[i]) {
|
||||
count_eq_info++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(decoded_info.size(), count_eq_info);
|
||||
}
|
||||
else {
|
||||
std::string original_info = config["info"];
|
||||
EXPECT_EQ(decoded_info[0], original_info);
|
||||
}
|
||||
#endif
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
FAIL() << "Not found results for '" << name_current_image << "' image in config file:" << dataset_config <<
|
||||
"Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data.\n";
|
||||
}
|
||||
|
||||
}
|
||||
@@ -3,6 +3,7 @@
|
||||
// of this distribution and at http://opencv.org/license.html.
|
||||
|
||||
#include "test_precomp.hpp"
|
||||
#include "test_qr_utils.hpp"
|
||||
#include "opencv2/imgproc.hpp"
|
||||
|
||||
namespace opencv_test { namespace {
|
||||
@@ -33,6 +34,8 @@ std::string qrcode_images_multiple[] = {
|
||||
"5_qrcodes.png", "6_qrcodes.png", "7_qrcodes.png", "8_close_qrcodes.png"
|
||||
};
|
||||
|
||||
static std::set<std::pair<std::string, std::string>> disabled_samples = {{"5_qrcodes.png", "aruco_based"}};
|
||||
|
||||
//#define UPDATE_QRCODE_TEST_DATA
|
||||
#ifdef UPDATE_QRCODE_TEST_DATA
|
||||
|
||||
@@ -262,43 +265,7 @@ TEST_P(Objdetect_QRCode, regression)
|
||||
#else
|
||||
ASSERT_TRUE(qrcode.detect(src, corners));
|
||||
#endif
|
||||
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
{
|
||||
FileNode images_list = file_config["test_images"];
|
||||
size_t images_count = static_cast<size_t>(images_list.size());
|
||||
ASSERT_GT(images_count, 0u) << "Can't find validation data entries in 'test_images': " << dataset_config;
|
||||
|
||||
for (size_t index = 0; index < images_count; index++)
|
||||
{
|
||||
FileNode config = images_list[(int)index];
|
||||
std::string name_test_image = config["image_name"];
|
||||
if (name_test_image == name_current_image)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int x = config["x"][i];
|
||||
int y = config["y"][i];
|
||||
EXPECT_NEAR(x, corners[i].x, pixels_error);
|
||||
EXPECT_NEAR(y, corners[i].y, pixels_error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_QUIRC
|
||||
std::string original_info = config["info"];
|
||||
EXPECT_EQ(decoded_info, original_info);
|
||||
#endif
|
||||
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
std::cerr
|
||||
<< "Not found results for '" << name_current_image
|
||||
<< "' image in config file:" << dataset_config << std::endl
|
||||
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
|
||||
<< std::endl;
|
||||
}
|
||||
check_qr(root, name_current_image, "test_images", corners, {decoded_info}, pixels_error);
|
||||
}
|
||||
|
||||
typedef testing::TestWithParam< std::string > Objdetect_QRCode_Close;
|
||||
@@ -329,43 +296,7 @@ TEST_P(Objdetect_QRCode_Close, regression)
|
||||
#else
|
||||
ASSERT_TRUE(qrcode.detect(barcode, corners));
|
||||
#endif
|
||||
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
{
|
||||
FileNode images_list = file_config["close_images"];
|
||||
size_t images_count = static_cast<size_t>(images_list.size());
|
||||
ASSERT_GT(images_count, 0u) << "Can't find validation data entries in 'test_images': " << dataset_config;
|
||||
|
||||
for (size_t index = 0; index < images_count; index++)
|
||||
{
|
||||
FileNode config = images_list[(int)index];
|
||||
std::string name_test_image = config["image_name"];
|
||||
if (name_test_image == name_current_image)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int x = config["x"][i];
|
||||
int y = config["y"][i];
|
||||
EXPECT_NEAR(x, corners[i].x, pixels_error);
|
||||
EXPECT_NEAR(y, corners[i].y, pixels_error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_QUIRC
|
||||
std::string original_info = config["info"];
|
||||
EXPECT_EQ(decoded_info, original_info);
|
||||
#endif
|
||||
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
std::cerr
|
||||
<< "Not found results for '" << name_current_image
|
||||
<< "' image in config file:" << dataset_config << std::endl
|
||||
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
|
||||
<< std::endl;
|
||||
}
|
||||
check_qr(root, name_current_image, "close_images", corners, {decoded_info}, pixels_error);
|
||||
}
|
||||
|
||||
typedef testing::TestWithParam< std::string > Objdetect_QRCode_Monitor;
|
||||
@@ -396,43 +327,7 @@ TEST_P(Objdetect_QRCode_Monitor, regression)
|
||||
#else
|
||||
ASSERT_TRUE(qrcode.detect(barcode, corners));
|
||||
#endif
|
||||
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
{
|
||||
FileNode images_list = file_config["monitor_images"];
|
||||
size_t images_count = static_cast<size_t>(images_list.size());
|
||||
ASSERT_GT(images_count, 0u) << "Can't find validation data entries in 'test_images': " << dataset_config;
|
||||
|
||||
for (size_t index = 0; index < images_count; index++)
|
||||
{
|
||||
FileNode config = images_list[(int)index];
|
||||
std::string name_test_image = config["image_name"];
|
||||
if (name_test_image == name_current_image)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int x = config["x"][i];
|
||||
int y = config["y"][i];
|
||||
EXPECT_NEAR(x, corners[i].x, pixels_error);
|
||||
EXPECT_NEAR(y, corners[i].y, pixels_error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_QUIRC
|
||||
std::string original_info = config["info"];
|
||||
EXPECT_EQ(decoded_info, original_info);
|
||||
#endif
|
||||
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
std::cerr
|
||||
<< "Not found results for '" << name_current_image
|
||||
<< "' image in config file:" << dataset_config << std::endl
|
||||
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
|
||||
<< std::endl;
|
||||
}
|
||||
check_qr(root, name_current_image, "monitor_images", corners, {decoded_info}, pixels_error);
|
||||
}
|
||||
|
||||
typedef testing::TestWithParam< std::string > Objdetect_QRCode_Curved;
|
||||
@@ -458,56 +353,26 @@ TEST_P(Objdetect_QRCode_Curved, regression)
|
||||
#else
|
||||
ASSERT_TRUE(qrcode.detect(src, corners));
|
||||
#endif
|
||||
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
{
|
||||
FileNode images_list = file_config["test_images"];
|
||||
size_t images_count = static_cast<size_t>(images_list.size());
|
||||
ASSERT_GT(images_count, 0u) << "Can't find validation data entries in 'test_images': " << dataset_config;
|
||||
|
||||
for (size_t index = 0; index < images_count; index++)
|
||||
{
|
||||
FileNode config = images_list[(int)index];
|
||||
std::string name_test_image = config["image_name"];
|
||||
if (name_test_image == name_current_image)
|
||||
{
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int x = config["x"][i];
|
||||
int y = config["y"][i];
|
||||
EXPECT_NEAR(x, corners[i].x, pixels_error);
|
||||
EXPECT_NEAR(y, corners[i].y, pixels_error);
|
||||
}
|
||||
|
||||
#ifdef HAVE_QUIRC
|
||||
std::string original_info = config["info"];
|
||||
EXPECT_EQ(decoded_info, original_info);
|
||||
#endif
|
||||
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
std::cerr
|
||||
<< "Not found results for '" << name_current_image
|
||||
<< "' image in config file:" << dataset_config << std::endl
|
||||
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
|
||||
<< std::endl;
|
||||
}
|
||||
check_qr(root, name_current_image, "test_images", corners, {decoded_info}, pixels_error);
|
||||
}
|
||||
|
||||
typedef testing::TestWithParam < std::string > Objdetect_QRCode_Multi;
|
||||
typedef testing::TestWithParam<std::tuple<std::string, std::string>> Objdetect_QRCode_Multi;
|
||||
TEST_P(Objdetect_QRCode_Multi, regression)
|
||||
{
|
||||
const std::string name_current_image = GetParam();
|
||||
const std::string name_current_image = get<0>(GetParam());
|
||||
const std::string root = "qrcode/multiple/";
|
||||
const std::string method = get<1>(GetParam());
|
||||
const int pixels_error = 4;
|
||||
|
||||
std::string image_path = findDataFile(root + name_current_image);
|
||||
Mat src = imread(image_path);
|
||||
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
|
||||
QRCodeDetector qrcode;
|
||||
if (disabled_samples.find({name_current_image, method}) != disabled_samples.end())
|
||||
throw SkipTestException(name_current_image + " is disabled sample for method " + method);
|
||||
GraphicalCodeDetector qrcode = QRCodeDetector();
|
||||
if (method == "aruco_based") {
|
||||
qrcode = QRCodeDetectorAruco();
|
||||
}
|
||||
std::vector<Point> corners;
|
||||
#ifdef HAVE_QUIRC
|
||||
std::vector<cv::String> decoded_info;
|
||||
@@ -521,75 +386,15 @@ TEST_P(Objdetect_QRCode_Multi, regression)
|
||||
#else
|
||||
ASSERT_TRUE(qrcode.detectMulti(src, corners));
|
||||
#endif
|
||||
|
||||
const std::string dataset_config = findDataFile(root + "dataset_config.json");
|
||||
FileStorage file_config(dataset_config, FileStorage::READ);
|
||||
ASSERT_TRUE(file_config.isOpened()) << "Can't read validation data: " << dataset_config;
|
||||
{
|
||||
FileNode images_list = file_config["multiple_images"];
|
||||
size_t images_count = static_cast<size_t>(images_list.size());
|
||||
ASSERT_GT(images_count, 0u) << "Can't find validation data entries in 'test_images': " << dataset_config;
|
||||
for (size_t index = 0; index < images_count; index++)
|
||||
{
|
||||
FileNode config = images_list[(int)index];
|
||||
std::string name_test_image = config["image_name"];
|
||||
if (name_test_image == name_current_image)
|
||||
{
|
||||
for(int j = 0; j < int(corners.size()); j += 4)
|
||||
{
|
||||
bool ok = false;
|
||||
for (int k = 0; k < int(corners.size() / 4); k++)
|
||||
{
|
||||
int count_eq_points = 0;
|
||||
for (int i = 0; i < 4; i++)
|
||||
{
|
||||
int x = config["x"][k][i];
|
||||
int y = config["y"][k][i];
|
||||
if(((abs(corners[j + i].x - x)) <= pixels_error) && ((abs(corners[j + i].y - y)) <= pixels_error))
|
||||
count_eq_points++;
|
||||
}
|
||||
if (count_eq_points == 4)
|
||||
{
|
||||
ok = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
EXPECT_TRUE(ok);
|
||||
}
|
||||
|
||||
#ifdef HAVE_QUIRC
|
||||
size_t count_eq_info = 0;
|
||||
for(int i = 0; i < int(decoded_info.size()); i++)
|
||||
{
|
||||
for(int j = 0; j < int(decoded_info.size()); j++)
|
||||
{
|
||||
std::string original_info = config["info"][j];
|
||||
if(original_info == decoded_info[i])
|
||||
{
|
||||
count_eq_info++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
EXPECT_EQ(decoded_info.size(), count_eq_info);
|
||||
#endif
|
||||
|
||||
return; // done
|
||||
}
|
||||
}
|
||||
std::cerr
|
||||
<< "Not found results for '" << name_current_image
|
||||
<< "' image in config file:" << dataset_config << std::endl
|
||||
<< "Re-run tests with enabled UPDATE_QRCODE_TEST_DATA macro to update test data."
|
||||
<< std::endl;
|
||||
}
|
||||
check_qr(root, name_current_image, "multiple_images", corners, decoded_info, pixels_error, true);
|
||||
}
|
||||
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode, testing::ValuesIn(qrcode_images_name));
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Close, testing::ValuesIn(qrcode_images_close));
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Monitor, testing::ValuesIn(qrcode_images_monitor));
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Curved, testing::ValuesIn(qrcode_images_curved));
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Multi, testing::ValuesIn(qrcode_images_multiple));
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_Multi, testing::Combine(testing::ValuesIn(qrcode_images_multiple),
|
||||
testing::Values("contours_based", "aruco_based")));
|
||||
|
||||
TEST(Objdetect_QRCode_decodeMulti, decode_regression_16491)
|
||||
{
|
||||
@@ -611,8 +416,10 @@ TEST(Objdetect_QRCode_decodeMulti, decode_regression_16491)
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Objdetect_QRCode_detectMulti, detect_regression_16961)
|
||||
typedef testing::TestWithParam<std::string> Objdetect_QRCode_detectMulti;
|
||||
TEST_P(Objdetect_QRCode_detectMulti, detect_regression_16961)
|
||||
{
|
||||
const std::string method = GetParam();
|
||||
const std::string name_current_image = "9_qrcodes.jpg";
|
||||
const std::string root = "qrcode/multiple/";
|
||||
|
||||
@@ -620,7 +427,10 @@ TEST(Objdetect_QRCode_detectMulti, detect_regression_16961)
|
||||
Mat src = imread(image_path);
|
||||
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
|
||||
|
||||
QRCodeDetector qrcode;
|
||||
GraphicalCodeDetector qrcode = QRCodeDetector();
|
||||
if (method == "aruco_based") {
|
||||
qrcode = QRCodeDetectorAruco();
|
||||
}
|
||||
std::vector<Point> corners;
|
||||
EXPECT_TRUE(qrcode.detectMulti(src, corners));
|
||||
ASSERT_FALSE(corners.empty());
|
||||
@@ -628,21 +438,27 @@ TEST(Objdetect_QRCode_detectMulti, detect_regression_16961)
|
||||
EXPECT_EQ(corners.size(), expect_corners_size);
|
||||
}
|
||||
|
||||
TEST(Objdetect_QRCode_decodeMulti, check_output_parameters_type_19363)
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_detectMulti, testing::Values("contours_based", "aruco_based"));
|
||||
typedef testing::TestWithParam<std::string> Objdetect_QRCode_detectAndDecodeMulti;
|
||||
TEST_P(Objdetect_QRCode_detectAndDecodeMulti, check_output_parameters_type_19363)
|
||||
{
|
||||
const std::string name_current_image = "9_qrcodes.jpg";
|
||||
const std::string root = "qrcode/multiple/";
|
||||
const std::string method = GetParam();
|
||||
|
||||
std::string image_path = findDataFile(root + name_current_image);
|
||||
Mat src = imread(image_path);
|
||||
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
|
||||
#ifdef HAVE_QUIRC
|
||||
QRCodeDetector qrcode;
|
||||
GraphicalCodeDetector qrcode = QRCodeDetector();
|
||||
if (method == "aruco_based") {
|
||||
qrcode = QRCodeDetectorAruco();
|
||||
}
|
||||
std::vector<Point> corners;
|
||||
std::vector<cv::String> decoded_info;
|
||||
#if 0 // FIXIT: OutputArray::create() type check
|
||||
std::vector<Mat2b> straight_barcode_nchannels;
|
||||
EXPECT_ANY_THROW(qrcode.detectAndDecodeMulti(src, decoded_info, corners, straight_barcode_nchannels));
|
||||
EXPECT_ANY_THROW(qrcode->detectAndDecodeMulti(src, decoded_info, corners, straight_barcode_nchannels));
|
||||
#endif
|
||||
|
||||
int expected_barcode_type = CV_8UC1;
|
||||
@@ -653,6 +469,8 @@ TEST(Objdetect_QRCode_decodeMulti, check_output_parameters_type_19363)
|
||||
EXPECT_EQ(expected_barcode_type, straight_barcode[i].type());
|
||||
#endif
|
||||
}
|
||||
INSTANTIATE_TEST_CASE_P(/**/, Objdetect_QRCode_detectAndDecodeMulti, testing::Values("contours_based", "aruco_based"));
|
||||
|
||||
|
||||
TEST(Objdetect_QRCode_detect, detect_regression_20882)
|
||||
{
|
||||
@@ -793,14 +611,18 @@ TEST(Objdetect_QRCode_decode, decode_regression_version_25)
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST(Objdetect_QRCode_decodeMulti, decode_9_qrcodes_version7)
|
||||
TEST_P(Objdetect_QRCode_detectAndDecodeMulti, decode_9_qrcodes_version7)
|
||||
{
|
||||
const std::string name_current_image = "9_qrcodes_version7.jpg";
|
||||
const std::string root = "qrcode/multiple/";
|
||||
|
||||
std::string image_path = findDataFile(root + name_current_image);
|
||||
Mat src = imread(image_path);
|
||||
QRCodeDetector qrcode;
|
||||
const std::string method = GetParam();
|
||||
GraphicalCodeDetector qrcode = QRCodeDetector();
|
||||
if (method == "aruco_based") {
|
||||
qrcode = QRCodeDetectorAruco();
|
||||
}
|
||||
std::vector<Point> corners;
|
||||
std::vector<cv::String> decoded_info;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user