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})
target_link_libraries(checks-parser PRIVATE ${QRENCODE_LIBRARIES})
endif()
if (BUILD_OFD_LOCAL_QR_SCAN)
target_link_libraries(checks-parser PRIVATE -lzbar)
endif()
# if (BUILD_OFD_LOCAL_QR_SCAN)
# target_link_libraries(checks-parser PRIVATE -lzbar)
# endif()
target_link_libraries(checks-parser PRIVATE -lcurl)
@ -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)
find_package(OpenCV REQUIRED COMPONENTS core imgproc imgcodecs opencv_objdetect)
target_link_libraries(checks-parser PRIVATE ${OpenCV_LIBS})
target_include_directories(checks-parser PUBLIC ${OpenCV_INCLUDE_DIRS})
include_directories( ${OpenCV_INCLUDE_DIRS} )

View File

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

View File

@ -268,6 +268,9 @@
<property name="selectionBehavior">
<enum>QAbstractItemView::SelectionBehavior::SelectRows</enum>
</property>
<property name="sortingEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<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>
</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>
<translation>QR code was not detected on that image. Please edit it again or enter data manually</translation>
</message>
<message>
<location filename="../adjustpicturedialog.cpp" line="41"/>
<location filename="../adjustpicturedialog.cpp" line="44"/>
<source>No QR code</source>
<translation>No QR code</translation>
</message>
@ -112,7 +112,7 @@
<translation type="vanished">0000000000000000</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="319"/>
<location filename="../scenes/mainwindow.ui" line="322"/>
<source>FN (Fiscal Number)</source>
<translatorcomment>FN = Фискальный Номер</translatorcomment>
<translation>FN (Fiscal Number)</translation>
@ -151,13 +151,13 @@
<translation type="vanished">Use your phone as a QR code scanner</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="292"/>
<location filename="../scenes/mainwindow.ui" line="295"/>
<source>FI (Fiscal Identifier)</source>
<translatorcomment>FI = Фискальный Признак</translatorcomment>
<translation>FI (Fiscal Identifier)</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="326"/>
<location filename="../scenes/mainwindow.ui" line="329"/>
<source>Delete selected</source>
<translation type="unfinished"></translation>
</message>
@ -175,12 +175,12 @@
<translation>Date and time of purchase</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="306"/>
<location filename="../scenes/mainwindow.ui" line="309"/>
<source>Operation type</source>
<translation>Operation type</translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="285"/>
<location filename="../scenes/mainwindow.ui" line="288"/>
<source>Parse an E-Mail</source>
<translation>Parse an E-Mail</translation>
</message>
@ -244,7 +244,7 @@
<translation type="unfinished"></translation>
</message>
<message>
<location filename="../scenes/mainwindow.ui" line="299"/>
<location filename="../scenes/mainwindow.ui" line="302"/>
<source>Total</source>
<translation>Total</translation>
</message>

View File

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

View File

@ -22,7 +22,6 @@ public:
Qt::ItemFlags flags(const QModelIndex &index) 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 removeRows(int position, int rows, const QModelIndex &index = QModelIndex()) override;