mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 15:23:05 +04:00
Remove QUIRC library dependency
This commit is contained in:
@@ -11,10 +11,6 @@
|
||||
#include <opencv2/core/utils/logger.hpp>
|
||||
#include "graphical_code_detector_impl.hpp"
|
||||
|
||||
#ifdef HAVE_QUIRC
|
||||
#include "quirc.h"
|
||||
#endif
|
||||
|
||||
#include <array>
|
||||
#include <limits>
|
||||
#include <cmath>
|
||||
@@ -2806,40 +2802,7 @@ bool QRDecode::decodingProcess()
|
||||
QRCodeEncoder::ECIEncodings eci;
|
||||
const uint8_t* payload;
|
||||
size_t payload_len;
|
||||
#ifdef HAVE_QUIRC
|
||||
if (straight.empty()) { return false; }
|
||||
|
||||
quirc_code qr_code;
|
||||
memset(&qr_code, 0, sizeof(qr_code));
|
||||
|
||||
qr_code.size = straight.size().width;
|
||||
for (int x = 0; x < qr_code.size; x++)
|
||||
{
|
||||
for (int y = 0; y < qr_code.size; y++)
|
||||
{
|
||||
int position = y * qr_code.size + x;
|
||||
qr_code.cell_bitmap[position >> 3]
|
||||
|= straight.ptr<uint8_t>(y)[x] ? 0 : (1 << (position & 7));
|
||||
}
|
||||
}
|
||||
|
||||
quirc_data qr_code_data;
|
||||
quirc_decode_error_t errorCode = quirc_decode(&qr_code, &qr_code_data);
|
||||
|
||||
if(errorCode == QUIRC_ERROR_DATA_ECC){
|
||||
quirc_flip(&qr_code);
|
||||
errorCode = quirc_decode(&qr_code, &qr_code_data);
|
||||
}
|
||||
|
||||
if (errorCode != 0) { return false; }
|
||||
|
||||
CV_LOG_INFO(NULL, "QR: decoded with .version=" << qr_code_data.version << " .data_type=" << qr_code_data.data_type << " .eci=" << qr_code_data.eci << " .payload_len=" << qr_code_data.payload_len)
|
||||
|
||||
mode = static_cast<QRCodeEncoder::EncodeMode>(qr_code_data.data_type);
|
||||
eci = static_cast<QRCodeEncoder::ECIEncodings>(qr_code_data.eci);
|
||||
payload = qr_code_data.payload;
|
||||
payload_len = qr_code_data.payload_len;
|
||||
#else
|
||||
auto decoder = QRCodeDecoder::create();
|
||||
if (!decoder->decode(straight, result_info))
|
||||
return false;
|
||||
@@ -2850,7 +2813,6 @@ bool QRDecode::decodingProcess()
|
||||
structure_info.parity = decoder->parity;
|
||||
structure_info.sequence_num = decoder->sequence_num;
|
||||
structure_info.total_num = decoder->total_num;
|
||||
#endif
|
||||
|
||||
// Check output string format
|
||||
switch (mode)
|
||||
@@ -2874,7 +2836,7 @@ bool QRDecode::decodingProcess()
|
||||
if (eci == QRCodeEncoder::ECIEncodings::ECI_UTF8) {
|
||||
CV_LOG_INFO(NULL, "QR: payload ECI is UTF-8");
|
||||
if (!checkUTF8(payload, payload_len)) {
|
||||
CV_LOG_INFO(NULL, "QUIRC_DATA_TYPE_BYTE with UTF-8 ECI must be UTF-8 compatible string");
|
||||
CV_LOG_INFO(NULL, "QRCode in BYTE mode with UTF-8 ECI must be UTF-8 compatible string");
|
||||
return false;
|
||||
}
|
||||
result_info.assign((const char*)payload, payload_len);
|
||||
@@ -2886,7 +2848,7 @@ bool QRDecode::decodingProcess()
|
||||
result_info.assign((const char*)payload, payload_len);
|
||||
} else {
|
||||
if (checkUTF8(payload, payload_len)) {
|
||||
CV_LOG_INFO(NULL, "QR: payload QUIRC_DATA_TYPE_BYTE is UTF-8 compatible, return as-is");
|
||||
CV_LOG_INFO(NULL, "QR: payload bytes are UTF-8 compatible, return as-is");
|
||||
result_info.assign((const char*)payload, payload_len);
|
||||
} else {
|
||||
CV_LOG_INFO(NULL, "QR: assume 1-byte per symbol encoding");
|
||||
|
||||
Reference in New Issue
Block a user