From 37a77d7228fc49d282bfbca06bcf40df977211ff Mon Sep 17 00:00:00 2001 From: leca Date: Sat, 14 Jun 2025 19:57:08 +0300 Subject: [PATCH] downsize images l.t. 500 pixels --- CMakeLists.txt | 2 +- email_parser/emailparser.cpp | 6 ++++++ translations/en_US.ts | 2 +- translations/ru_RU.ts | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 66361be..3a15cf8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -222,7 +222,7 @@ include_directories(${Boost_INCLUDE_DIRS}) target_link_libraries(checks-parser PUBLIC ${Boost_LIBRARIES}) if (BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN) - find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs opencv_objdetect videoio) + find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs opencv_objdetect videoio highgui) target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS}) target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS}) include_directories( ${OpenCV_INCLUDE_DIRS} ) diff --git a/email_parser/emailparser.cpp b/email_parser/emailparser.cpp index 7e27fee..30272d9 100644 --- a/email_parser/emailparser.cpp +++ b/email_parser/emailparser.cpp @@ -199,6 +199,12 @@ std::string EmailParser::handle_image(std::string &content) { } if (image.empty()) return ""; + if (image.rows >= 500 || image.cols >= 500) { + cv::Mat copy(image); + cv::resize(copy, image, cv::Size(150, 150), cv::INTER_LINEAR); + cv::imwrite(get_path_relative_to_home(".local/share/checks_parser/tmp.jpg"), image); + } + cv::QRCodeDetector qrDecoder = cv::QRCodeDetector(); std::string decoded_qr = qrDecoder.detectAndDecode(image); return find_check_parameters(decoded_qr); diff --git a/translations/en_US.ts b/translations/en_US.ts index 8f0e384..eb63ddf 100644 --- a/translations/en_US.ts +++ b/translations/en_US.ts @@ -671,7 +671,7 @@ QObject - + Using locale: Using locale: diff --git a/translations/ru_RU.ts b/translations/ru_RU.ts index bff8434..ad91bae 100644 --- a/translations/ru_RU.ts +++ b/translations/ru_RU.ts @@ -647,7 +647,7 @@ QObject - + Using locale: Использую локаль: