mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Merge pull request #24350 from dkurt:py_return_non_utf8_string
Encode QR code data to UTF-8 #24350 ### Pull Request Readiness Checklist **Merge with extra**: https://github.com/opencv/opencv_extra/pull/1105 resolves https://github.com/opencv/opencv/issues/23728 This is first PR in a series. Here we just return a raw Unicode. Later I will try expand QR codes decoding methods to use ECI assignment number and return a string with proper encoding, not only UTF-8 or raw unicode. See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
@@ -637,4 +637,25 @@ TEST_P(Objdetect_QRCode_detectAndDecodeMulti, decode_9_qrcodes_version7)
|
||||
|
||||
#endif // UPDATE_QRCODE_TEST_DATA
|
||||
|
||||
TEST(Objdetect_QRCode_detectAndDecode, utf8_output)
|
||||
{
|
||||
#ifndef HAVE_QUIRC
|
||||
throw SkipTestException("Quirc is required for decoding");
|
||||
#else
|
||||
const std::string name_current_image = "umlaut.png";
|
||||
const std::string root = "qrcode/";
|
||||
|
||||
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;
|
||||
std::vector<Point> corners;
|
||||
Mat straight;
|
||||
std::string decoded_info = qrcode.detectAndDecode(src, corners, straight);
|
||||
EXPECT_FALSE(decoded_info.empty());
|
||||
EXPECT_NE(decoded_info.find("M\xc3\xbcllheimstrasse"), std::string::npos);
|
||||
#endif // HAVE_QUIRC
|
||||
}
|
||||
|
||||
}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user