remove zbar dependency

This commit is contained in:
leca 2025-05-23 22:58:14 +03:00
parent 84261d20e5
commit ac355b7d9e
6 changed files with 44 additions and 37 deletions

View File

@ -207,9 +207,9 @@ if (BUILD_OFD_BINARYEYE_SCAN)
link_directories(${QRENCODE_LIBRARY_DIRS}) link_directories(${QRENCODE_LIBRARY_DIRS})
target_link_libraries(checks-parser PRIVATE ${QRENCODE_LIBRARIES}) target_link_libraries(checks-parser PRIVATE ${QRENCODE_LIBRARIES})
endif() endif()
if (BUILD_OFD_LOCAL_QR_SCAN) # if (BUILD_OFD_LOCAL_QR_SCAN)
target_link_libraries(checks-parser PRIVATE -lzbar) # target_link_libraries(checks-parser PRIVATE -lzbar)
endif() # endif()
target_link_libraries(checks-parser PRIVATE -lcurl) target_link_libraries(checks-parser PRIVATE -lcurl)
@ -222,7 +222,7 @@ include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(checks-parser PUBLIC ${Boost_LIBRARIES}) target_link_libraries(checks-parser PUBLIC ${Boost_LIBRARIES})
if (BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN) if (BUILD_OFD_LOCAL_QR_SCAN OR BUILD_OFD_BINARYEYE_SCAN)
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs) find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs opencv_objdetect)
target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS}) target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS})
target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS}) target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS})
include_directories( ${OpenCV_INCLUDE_DIRS} ) include_directories( ${OpenCV_INCLUDE_DIRS} )

View File

@ -1,13 +1,16 @@
#include "adjustpicturedialog.h" #include "adjustpicturedialog.h"
#include "ui_adjustpicturedialog.h" #include "ui_adjustpicturedialog.h"
#include "utils/utils.h" #include <utils/utils.h>
#include <opencv2/objdetect.hpp>
#include <opencv2/imgcodecs.hpp> #include <opencv2/imgcodecs.hpp>
#include <opencv2/imgproc.hpp> #include <opencv2/highgui/highgui.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <string> #include <string>
#include <opencv2/core/mat.hpp>
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox> #include <QMessageBox>
#include <zbar.h>
using cv::QRCodeDetector, cv::Mat;
AdjustPictureDialog::AdjustPictureDialog(QWidget *parent, std::string imagePath) AdjustPictureDialog::AdjustPictureDialog(QWidget *parent, std::string imagePath)
: QDialog(parent) : QDialog(parent)
@ -54,24 +57,26 @@ void AdjustPictureDialog::accept() {
} }
std::string AdjustPictureDialog::decode() { std::string AdjustPictureDialog::decode() {
cv::Mat im = cv::imread(get_path_relative_to_home(".local/share/checks_parser/temp.png")); Mat im = cv::imread(get_path_relative_to_home(".local/share/checks_parser/temp.png"));
QRCodeDetector qrDecoder = QRCodeDetector();
return qrDecoder.detectAndDecode(im);
zbar::ImageScanner scanner; // zbar::ImageScanner scanner;
scanner.set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_ENABLE, 1); // scanner.set_config(zbar::ZBAR_QRCODE, zbar::ZBAR_CFG_ENABLE, 1);
cv::Mat imGray; // cv::Mat imGray;
cv::cvtColor(im, imGray, cv::COLOR_BGR2GRAY); // cv::cvtColor(im, imGray, cv::COLOR_BGR2GRAY);
zbar::Image image(im.cols, im.rows, "Y800", (uchar *) imGray.data, im.cols * im.rows); // zbar::Image image(im.cols, im.rows, "Y800", (uchar *) imGray.data, im.cols * im.rows);
scanner.scan(image); // scanner.scan(image);
std::string result = ""; // std::string result = "";
for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol) { // for (zbar::Image::SymbolIterator symbol = image.symbol_begin(); symbol != image.symbol_end(); ++symbol) {
result = symbol->get_data(); // result = symbol->get_data();
} // }
return result; // return result;
} }
void AdjustPictureDialog::computeContrastLookupTable() { void AdjustPictureDialog::computeContrastLookupTable() {

View File

@ -268,6 +268,9 @@
<property name="selectionBehavior"> <property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum> <enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property> </property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget> </widget>
</item> </item>
<item row="6" column="2" colspan="4"> <item row="6" column="2" colspan="4">

View File

@ -14,12 +14,12 @@
<translation>Please, zoom to qr code and adjust contrast so that qr code looks sharp</translation> <translation>Please, zoom to qr code and adjust contrast so that qr code looks sharp</translation>
</message> </message>
<message> <message>
<location filename="../adjustpicturedialog.cpp" line="39"/> <location filename="../adjustpicturedialog.cpp" line="42"/>
<source>QR code was not detected on that image. Please edit it again or enter data manually</source> <source>QR code was not detected on that image. Please edit it again or enter data manually</source>
<translation>QR code was not detected on that image. Please edit it again or enter data manually</translation> <translation>QR code was not detected on that image. Please edit it again or enter data manually</translation>
</message> </message>
<message> <message>
<location filename="../adjustpicturedialog.cpp" line="41"/> <location filename="../adjustpicturedialog.cpp" line="44"/>
<source>No QR code</source> <source>No QR code</source>
<translation>No QR code</translation> <translation>No QR code</translation>
</message> </message>
@ -112,7 +112,7 @@
<translation type="vanished">0000000000000000</translation> <translation type="vanished">0000000000000000</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="319"/> <location filename="../scenes/mainwindow.ui" line="322"/>
<source>FN (Fiscal Number)</source> <source>FN (Fiscal Number)</source>
<translatorcomment>FN = Фискальный Номер</translatorcomment> <translatorcomment>FN = Фискальный Номер</translatorcomment>
<translation>FN (Fiscal Number)</translation> <translation>FN (Fiscal Number)</translation>
@ -151,13 +151,13 @@
<translation type="vanished">Use your phone as a QR code scanner</translation> <translation type="vanished">Use your phone as a QR code scanner</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="292"/> <location filename="../scenes/mainwindow.ui" line="295"/>
<source>FI (Fiscal Identifier)</source> <source>FI (Fiscal Identifier)</source>
<translatorcomment>FI = Фискальный Признак</translatorcomment> <translatorcomment>FI = Фискальный Признак</translatorcomment>
<translation>FI (Fiscal Identifier)</translation> <translation>FI (Fiscal Identifier)</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="326"/> <location filename="../scenes/mainwindow.ui" line="329"/>
<source>Delete selected</source> <source>Delete selected</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -175,12 +175,12 @@
<translation>Date and time of purchase</translation> <translation>Date and time of purchase</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="306"/> <location filename="../scenes/mainwindow.ui" line="309"/>
<source>Operation type</source> <source>Operation type</source>
<translation>Operation type</translation> <translation>Operation type</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="285"/> <location filename="../scenes/mainwindow.ui" line="288"/>
<source>Parse an E-Mail</source> <source>Parse an E-Mail</source>
<translation>Parse an E-Mail</translation> <translation>Parse an E-Mail</translation>
</message> </message>
@ -244,7 +244,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="299"/> <location filename="../scenes/mainwindow.ui" line="302"/>
<source>Total</source> <source>Total</source>
<translation>Total</translation> <translation>Total</translation>
</message> </message>

View File

@ -14,12 +14,12 @@
<translation>Пожалуйста, приблизьте QR код и настройте контраст, чтобы он читался</translation> <translation>Пожалуйста, приблизьте QR код и настройте контраст, чтобы он читался</translation>
</message> </message>
<message> <message>
<location filename="../adjustpicturedialog.cpp" line="39"/> <location filename="../adjustpicturedialog.cpp" line="42"/>
<source>QR code was not detected on that image. Please edit it again or enter data manually</source> <source>QR code was not detected on that image. Please edit it again or enter data manually</source>
<translation>QR код не найден на этом изображении. Пожалуйста, попытайтесь снова или введите данные вручную</translation> <translation>QR код не найден на этом изображении. Пожалуйста, попытайтесь снова или введите данные вручную</translation>
</message> </message>
<message> <message>
<location filename="../adjustpicturedialog.cpp" line="41"/> <location filename="../adjustpicturedialog.cpp" line="44"/>
<source>No QR code</source> <source>No QR code</source>
<translation>QR код не найден</translation> <translation>QR код не найден</translation>
</message> </message>
@ -112,7 +112,7 @@
<translation type="vanished">0000000000000000</translation> <translation type="vanished">0000000000000000</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="319"/> <location filename="../scenes/mainwindow.ui" line="322"/>
<source>FN (Fiscal Number)</source> <source>FN (Fiscal Number)</source>
<translatorcomment>Фискальный Норма</translatorcomment> <translatorcomment>Фискальный Норма</translatorcomment>
<translation>ФН</translation> <translation>ФН</translation>
@ -151,13 +151,13 @@
<translation type="vanished">Использовать телефон как сканнер QR</translation> <translation type="vanished">Использовать телефон как сканнер QR</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="292"/> <location filename="../scenes/mainwindow.ui" line="295"/>
<source>FI (Fiscal Identifier)</source> <source>FI (Fiscal Identifier)</source>
<translatorcomment>Фискальный Признак</translatorcomment> <translatorcomment>Фискальный Признак</translatorcomment>
<translation>ФП</translation> <translation>ФП</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="326"/> <location filename="../scenes/mainwindow.ui" line="329"/>
<source>Delete selected</source> <source>Delete selected</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
@ -167,12 +167,12 @@
<translation>Дата и время покупки</translation> <translation>Дата и время покупки</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="306"/> <location filename="../scenes/mainwindow.ui" line="309"/>
<source>Operation type</source> <source>Operation type</source>
<translation>Тип операции</translation> <translation>Тип операции</translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="285"/> <location filename="../scenes/mainwindow.ui" line="288"/>
<source>Parse an E-Mail</source> <source>Parse an E-Mail</source>
<translation>Парсить E-Mail</translation> <translation>Парсить E-Mail</translation>
</message> </message>
@ -232,7 +232,7 @@
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message> <message>
<location filename="../scenes/mainwindow.ui" line="299"/> <location filename="../scenes/mainwindow.ui" line="302"/>
<source>Total</source> <source>Total</source>
<translation>Итого</translation> <translation>Итого</translation>
</message> </message>

View File

@ -22,7 +22,6 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) const override; Qt::ItemFlags flags(const QModelIndex &index) const override;
Qt::DropActions supportedDropActions() const override; Qt::DropActions supportedDropActions() const override;
// bool insertRow(int row, int count, const QModelIndex &parent = QModelIndex());
bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override; bool insertRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;
bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override; bool removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;