mirror of
https://github.com/opencv/opencv.git
synced 2024-11-24 11:10:21 +08:00
change resize flag INTER_LINEAR to INTER_LINEAR_EXACT
fix python test_detect_and_decode_multi, sort QR in multiDetect/multiDecode enable tests with "version_5_up.jpg", "version_5_top.jpg"
This commit is contained in:
parent
3a64607d94
commit
d43cb4fe7c
@ -43,10 +43,10 @@ class qrcode_detector_test(NewOpenCVTests):
|
||||
retval, decoded_data, points, straight_qrcode = detector.detectAndDecodeMulti(img)
|
||||
self.assertTrue(retval)
|
||||
self.assertEqual(len(decoded_data), 6)
|
||||
self.assertEqual(decoded_data[0], "TWO STEPS FORWARD")
|
||||
self.assertEqual(decoded_data[1], "EXTRA")
|
||||
self.assertEqual(decoded_data[2], "SKIP")
|
||||
self.assertEqual(decoded_data[3], "STEP FORWARD")
|
||||
self.assertEqual(decoded_data[4], "STEP BACK")
|
||||
self.assertEqual(decoded_data[5], "QUESTION")
|
||||
self.assertTrue("TWO STEPS FORWARD" in decoded_data)
|
||||
self.assertTrue("EXTRA" in decoded_data)
|
||||
self.assertTrue("SKIP" in decoded_data)
|
||||
self.assertTrue("STEP FORWARD" in decoded_data)
|
||||
self.assertTrue("STEP BACK" in decoded_data)
|
||||
self.assertTrue("QUESTION" in decoded_data)
|
||||
self.assertEqual(points.shape, (6, 4, 2))
|
||||
|
@ -66,6 +66,8 @@ PERF_TEST_P_(Perf_Objdetect_QRCode_Multi, detectMulti)
|
||||
std::vector<Point2f> corners;
|
||||
QRCodeDetector qrcode;
|
||||
TEST_CYCLE() ASSERT_TRUE(qrcode.detectMulti(src, corners));
|
||||
sort(corners.begin(), corners.end(), [](const Point2f& corner1, const Point2f& corner2)
|
||||
{return corner1.x == corner2.x ? corner1.y < corner2.y : corner1.x < corner2.x;});
|
||||
SANITY_CHECK(corners);
|
||||
}
|
||||
|
||||
@ -74,7 +76,6 @@ PERF_TEST_P_(Perf_Objdetect_QRCode_Multi, decodeMulti)
|
||||
{
|
||||
const std::string name_current_image = GetParam();
|
||||
const std::string root = "cv/qrcode/multiple/";
|
||||
|
||||
std::string image_path = findDataFile(root + name_current_image);
|
||||
Mat src = imread(image_path);
|
||||
ASSERT_FALSE(src.empty()) << "Can't read image: " << image_path;
|
||||
@ -91,15 +92,22 @@ PERF_TEST_P_(Perf_Objdetect_QRCode_Multi, decodeMulti)
|
||||
ASSERT_FALSE(decoded_info[i].empty());
|
||||
}
|
||||
}
|
||||
std::vector < std::vector< uint8_t > > decoded_info_uint8_t;
|
||||
for(size_t i = 0; i < decoded_info.size(); i++)
|
||||
{
|
||||
std::vector< uint8_t > tmp(decoded_info[i].begin(), decoded_info[i].end());
|
||||
decoded_info_uint8_t.push_back(tmp);
|
||||
ASSERT_EQ(decoded_info.size(), straight_barcode.size());
|
||||
vector<pair<string, Mat> > result;
|
||||
for (size_t i = 0ull; i < decoded_info.size(); i++) {
|
||||
result.push_back(make_pair(decoded_info[i], straight_barcode[i]));
|
||||
}
|
||||
SANITY_CHECK(decoded_info_uint8_t);
|
||||
SANITY_CHECK(straight_barcode);
|
||||
|
||||
sort(result.begin(), result.end(), [](const pair<string, Mat>& v1, const pair<string, Mat>& v2)
|
||||
{return v1.first < v2.first; });
|
||||
vector<vector<uint8_t> > decoded_info_sort;
|
||||
vector<Mat> straight_barcode_sort;
|
||||
for (size_t i = 0ull; i < result.size(); i++) {
|
||||
vector<uint8_t> tmp(result[i].first.begin(), result[i].first.end());
|
||||
decoded_info_sort.push_back(tmp);
|
||||
straight_barcode_sort.push_back(result[i].second);
|
||||
}
|
||||
SANITY_CHECK(decoded_info_sort);
|
||||
SANITY_CHECK(straight_barcode_sort);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -136,7 +136,7 @@ void QRDetect::init(const Mat& src, double eps_vertical_, double eps_horizontal_
|
||||
const int width = cvRound(src.size().width * coeff_expansion);
|
||||
const int height = cvRound(src.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
}
|
||||
else if (min_side > 512.0)
|
||||
{
|
||||
@ -524,7 +524,7 @@ bool QRDetect::localization()
|
||||
const int height = cvRound(bin_barcode.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
Mat intermediate;
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
bin_barcode = intermediate.clone();
|
||||
for (size_t i = 0; i < localization_points.size(); i++)
|
||||
{
|
||||
@ -537,7 +537,7 @@ bool QRDetect::localization()
|
||||
const int height = cvRound(bin_barcode.size().height / coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
Mat intermediate;
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
bin_barcode = intermediate.clone();
|
||||
for (size_t i = 0; i < localization_points.size(); i++)
|
||||
{
|
||||
@ -2742,7 +2742,7 @@ void QRDetectMulti::init(const Mat& src, double eps_vertical_, double eps_horizo
|
||||
const int width = cvRound(src.size().width * coeff_expansion);
|
||||
const int height = cvRound(src.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
}
|
||||
else if (min_side > 512.0)
|
||||
{
|
||||
@ -3099,7 +3099,7 @@ int QRDetectMulti::findNumberLocalizationPoints(vector<Point2f>& tmp_localizatio
|
||||
const int height = cvRound(bin_barcode.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
Mat intermediate;
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
bin_barcode = intermediate.clone();
|
||||
}
|
||||
else if (purpose == ZOOMING)
|
||||
@ -3108,7 +3108,7 @@ int QRDetectMulti::findNumberLocalizationPoints(vector<Point2f>& tmp_localizatio
|
||||
const int height = cvRound(bin_barcode.size().height / coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
Mat intermediate;
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(bin_barcode, intermediate, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
bin_barcode = intermediate.clone();
|
||||
}
|
||||
else
|
||||
@ -3126,7 +3126,7 @@ void QRDetectMulti::findQRCodeContours(vector<Point2f>& tmp_localization_points,
|
||||
const int width = cvRound(bin_barcode.size().width);
|
||||
const int height = cvRound(bin_barcode.size().height);
|
||||
Size new_size(width, height);
|
||||
resize(bar, bar, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(bar, bar, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
blur(bar, blur_image, Size(3, 3));
|
||||
threshold(blur_image, threshold_output, 50, 255, THRESH_BINARY);
|
||||
|
||||
|
@ -11,7 +11,7 @@ std::string qrcode_images_name[] = {
|
||||
"version_2_down.jpg", "version_2_left.jpg", "version_2_right.jpg", "version_2_up.jpg", "version_2_top.jpg",
|
||||
"version_3_down.jpg", "version_3_left.jpg", "version_3_right.jpg", "version_3_up.jpg", "version_3_top.jpg",
|
||||
"version_4_down.jpg", "version_4_left.jpg", "version_4_right.jpg", "version_4_up.jpg", "version_4_top.jpg",
|
||||
"version_5_down.jpg", "version_5_left.jpg"/*"version_5_right.jpg"*/,
|
||||
"version_5_down.jpg", "version_5_left.jpg", /*"version_5_right.jpg",*/ "version_5_up.jpg", "version_5_top.jpg",
|
||||
"russian.jpg", "kanji.jpg", "link_github_ocv.jpg", "link_ocv.jpg", "link_wiki_cv.jpg"
|
||||
// version_5_right.jpg DISABLED after tile fix, PR #22025
|
||||
};
|
||||
@ -87,7 +87,7 @@ TEST(Objdetect_QRCode_Close, generate_test_data)
|
||||
const int width = cvRound(src.size().width * coeff_expansion);
|
||||
const int height = cvRound(src.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
EXPECT_TRUE(detectQRCode(barcode, corners));
|
||||
#ifdef HAVE_QUIRC
|
||||
EXPECT_TRUE(decodeQRCode(barcode, corners, decoded_info, straight_barcode));
|
||||
@ -125,7 +125,7 @@ TEST(Objdetect_QRCode_Monitor, generate_test_data)
|
||||
const int width = cvRound(src.size().width * coeff_expansion);
|
||||
const int height = cvRound(src.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
EXPECT_TRUE(detectQRCode(barcode, corners));
|
||||
#ifdef HAVE_QUIRC
|
||||
EXPECT_TRUE(decodeQRCode(barcode, corners, decoded_info, straight_barcode));
|
||||
@ -380,7 +380,7 @@ TEST_P(Objdetect_QRCode_Monitor, regression)
|
||||
const int width = cvRound(src.size().width * coeff_expansion);
|
||||
const int height = cvRound(src.size().height * coeff_expansion);
|
||||
Size new_size(width, height);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR);
|
||||
resize(src, barcode, new_size, 0, 0, INTER_LINEAR_EXACT);
|
||||
std::vector<Point> corners;
|
||||
std::string decoded_info;
|
||||
QRCodeDetector qrcode;
|
||||
|
Loading…
Reference in New Issue
Block a user