-
Notifications
You must be signed in to change notification settings - Fork 0
/
backend.h
82 lines (65 loc) · 1.94 KB
/
backend.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#ifndef BACKEND_H
#define BACKEND_H
#include <QObject>
#include <QQuickItem>
#include <imageitem.h>
#include "barcodeCreator.h"
#include "MatrImg.h"
Q_DECLARE_METATYPE(bc::bline)
Q_DECLARE_METATYPE(QVector<bc::bline*>)
struct Cound;
// Todo.
// 2 режима
class backend : public QObject
{
Q_OBJECT
public:
explicit backend(QObject *parent = nullptr);
~backend()
{
delete[] resLinesMap;
}
QObject *root = nullptr;
ImageItem *mainImage = nullptr;
ImageItem *processedImage = nullptr;
QQuickItem *sliderP = nullptr;
MatrImg mainMat;
MatrImg sourceBack;
MatrImg resultMart;
MatrImg maskImg;
QImage result;
std::unique_ptr<bc::Barcontainer> barcode = nullptr;
std::vector<Barscalar> colors;
Q_INVOKABLE void setup(QQuickItem *mainImage, QQuickItem* processedImage, QQuickItem *sliderPanel);
Q_INVOKABLE void run(int procType, int colType, int compType);
Q_INVOKABLE void run2(QObject *obj);
Q_INVOKABLE void loadImage(QString path);
Q_INVOKABLE void exportResult(QString path);
Q_INVOKABLE void restoreSource();
Q_INVOKABLE void setTempDir(QString path);
inline bc::Baritem *getBaritem()
{
return barcode ? barcode->getItem(0) : nullptr;
}
inline bc::Baritem *getSortedBaritem()
{
return barcode ? barcode->getItem(1) : nullptr;
}
// //////////////////////////////////////////////
Q_INVOKABLE void processMain(QQuickItem *iamge, QString extra);
Q_INVOKABLE void click(int x, int y);
Q_INVOKABLE void addClass(int classIndex);
Q_INVOKABLE void undoAddClass();
private:
QString base_root;
QString auto_root;
bc::barline *curSelected = nullptr;
bc::barline** resLinesMap = nullptr;
int lastIndex = 0;
MatrImg mask(bc::Baritem *bar, MatrImg &mat, int st, int ed, QString extra);
static QImage matToQImage( const MatrImg &mat, bool matHaveAlpha, bool needAlpha = false);
static MatrImg imread(QString path);
static void imwrite(QString path, const MatrImg& mat, bool saveWithAlpha);
signals:
};
#endif // BACKEND_H