1
1
/* *
2
2
* @file CameraEngine.h
3
3
* @author Evans Liu (1369215984@qq.com)
4
- * @brief
4
+ * @brief
5
5
* @version 0.1
6
6
* @date 2024-03-19
7
- *
7
+ *
8
8
* @copyright Copyright (c) 2024
9
- *
9
+ *
10
10
*/
11
11
12
12
#ifndef __CAMERA_ENGINE_H_
13
13
#define __CAMERA_ENGINE_H_
14
14
15
- #include < vector>
16
15
#include < thread>
16
+ #include < vector>
17
+
17
18
18
19
#include < QObject>
19
20
#include < QThread>
20
21
21
22
#include < opencv2/opencv.hpp>
22
23
23
24
#include " AppType.h"
25
+ #include " CameraModel.h"
24
26
#include " ImagePaintItem.h"
25
27
#include " typeDef.h"
26
- # include " CameraModel.h "
28
+
27
29
28
30
#include < slmaster.h>
29
31
@@ -33,28 +35,42 @@ class CameraEngine : public QObject {
33
35
Q_PROPERTY_AUTO (bool , isConnected)
34
36
Q_PROPERTY_AUTO (bool , isBurnWorkFinish)
35
37
public:
36
- static CameraEngine* instance ();
38
+ static CameraEngine * instance ();
37
39
struct OrderTableRecord {
38
40
OrderTableRecord () {}
39
- OrderTableRecord (const int patternsNum, const int shiftTime, const bool isVertical) : patternsNum_(patternsNum), shiftTime_(shiftTime), isVertical_(isVertical) {}
41
+ OrderTableRecord (const int patternsNum, const int shiftTime,
42
+ const bool isVertical)
43
+ : patternsNum_(patternsNum), shiftTime_(shiftTime),
44
+ isVertical_ (isVertical) {}
40
45
int patternsNum_;
41
46
int shiftTime_;
42
47
bool isVertical_;
43
48
};
44
- // Device page
49
+ // Device page
45
50
Q_INVOKABLE void startDetectCameraState ();
46
- Q_INVOKABLE int createStripe (const int pixelDepth, const int direction, const int stripeType, const int defocusMethod, const int imgWidth, const int imgHeight, const int cycles, const int shiftTime, const bool isKeepAdd);
51
+ Q_INVOKABLE int createStripe (const int pixelDepth, const int direction,
52
+ const int stripeType, const int defocusMethod,
53
+ const int imgWidth, const int imgHeight,
54
+ const int clipWidth, const int clipHeight,
55
+ const int cycles, const int shiftTime,
56
+ const bool isKeepAdd);
47
57
Q_INVOKABLE void displayStripe (const int stripeIndex);
48
58
Q_INVOKABLE void selectCamera (const int cameraType);
49
59
Q_INVOKABLE void setCameraJsonPath (const std::string jsonPath);
50
60
Q_INVOKABLE bool connectCamera ();
51
61
Q_INVOKABLE bool disConnectCamera ();
52
62
Q_INVOKABLE void burnStripe ();
53
- Q_INVOKABLE void bindStripePaintItem (ImagePaintItem* stripePaintItem) { stripePaintItem_ = stripePaintItem; }
54
- // offlineScan page
55
- Q_INVOKABLE void bindOfflineCamPaintItem (ImagePaintItem* camPaintItem) { offlineCamPaintItem_ = camPaintItem; }
56
- // scan page
57
- Q_INVOKABLE void setScanMode (const int scanMode) { scanMode_ = AppType::ScanModeType (scanMode); }
63
+ Q_INVOKABLE void bindStripePaintItem (ImagePaintItem *stripePaintItem) {
64
+ stripePaintItem_ = stripePaintItem;
65
+ }
66
+ // offlineScan page
67
+ Q_INVOKABLE void bindOfflineCamPaintItem (ImagePaintItem *camPaintItem) {
68
+ offlineCamPaintItem_ = camPaintItem;
69
+ }
70
+ // scan page
71
+ Q_INVOKABLE void setScanMode (const int scanMode) {
72
+ scanMode_ = AppType::ScanModeType (scanMode);
73
+ }
58
74
Q_INVOKABLE void projectOnce ();
59
75
Q_INVOKABLE void projectContinues ();
60
76
Q_INVOKABLE void pauseProject (const bool isResume);
@@ -64,50 +80,70 @@ class CameraEngine : public QObject {
64
80
Q_INVOKABLE void startScan ();
65
81
Q_INVOKABLE void continuesScan ();
66
82
Q_INVOKABLE void pauseScan ();
67
- Q_INVOKABLE void bindOfflineLeftCamModel (CameraModel* model) { leftCamModel_ = model; }
68
- Q_INVOKABLE void bindOfflineRightCamModel (CameraModel* model) { rightCamModel_ = model; }
69
- Q_INVOKABLE void bindOfflineColorCamModel (CameraModel* model) { colorCamModel_ = model; }
70
- Q_INVOKABLE void bindScanTexturePaintItem (ImagePaintItem* paintItem) { scanTexturePaintItem_ = paintItem; }
71
- Q_INVOKABLE void updateDisplayImg (const QString& imgPath);
72
- Q_INVOKABLE void saveStripe (const QString& path);
83
+ Q_INVOKABLE void bindOfflineLeftCamModel (CameraModel *model) {
84
+ leftCamModel_ = model;
85
+ }
86
+ Q_INVOKABLE void bindOfflineRightCamModel (CameraModel *model) {
87
+ rightCamModel_ = model;
88
+ }
89
+ Q_INVOKABLE void bindOfflineColorCamModel (CameraModel *model) {
90
+ colorCamModel_ = model;
91
+ }
92
+ Q_INVOKABLE void bindScanTexturePaintItem (ImagePaintItem *paintItem) {
93
+ scanTexturePaintItem_ = paintItem;
94
+ }
95
+ Q_INVOKABLE void updateDisplayImg (const QString &imgPath);
96
+ Q_INVOKABLE void saveStripe (const QString &path);
73
97
Q_INVOKABLE void setPatternType (const int patternType);
74
- Q_INVOKABLE bool setNumberAttribute (const QString& attributeName,
75
- const double val);
76
- Q_INVOKABLE bool setBooleanAttribute (const QString& attributeName, const bool val);
77
- Q_INVOKABLE double getNumberAttribute (const QString& attributeName);
78
- Q_INVOKABLE bool getBooleanAttribute (const QString& attributeName);
79
- Q_INVOKABLE QString getStringAttribute (const QString& attributeName);
80
- Q_INVOKABLE const slmaster::cameras::FrameData& getCurFrame () { return frame_; }
81
- std::shared_ptr<slmaster::cameras::SLCamera> getSLCamera () { return slCameraFactory_.getCamera (slmaster::cameras::CameraType (cameraType_)); }
82
- std::vector<OrderTableRecord> getOrderTableRecord () { return orderTableRecord_; }
98
+ Q_INVOKABLE bool setNumberAttribute (const QString &attributeName,
99
+ const double val);
100
+ Q_INVOKABLE bool setBooleanAttribute (const QString &attributeName,
101
+ const bool val);
102
+ Q_INVOKABLE double getNumberAttribute (const QString &attributeName);
103
+ Q_INVOKABLE bool getBooleanAttribute (const QString &attributeName);
104
+ Q_INVOKABLE QString getStringAttribute (const QString &attributeName);
105
+ Q_INVOKABLE const slmaster::cameras::FrameData &getCurFrame () {
106
+ return frame_;
107
+ }
108
+ Q_INVOKABLE bool saveFrame (const QString &path);
109
+ std::shared_ptr<slmaster::cameras::SLCamera> getSLCamera () {
110
+ return slCameraFactory_.getCamera (
111
+ slmaster::cameras::CameraType (cameraType_));
112
+ }
113
+ std::vector<OrderTableRecord> getOrderTableRecord () {
114
+ return orderTableRecord_;
115
+ }
83
116
signals:
84
117
void stripeImgsChanged (const int num);
85
118
void frameCaptured ();
119
+
86
120
private:
87
121
CameraEngine ();
88
122
~CameraEngine ();
89
- CameraEngine (const CameraEngine&) = delete ;
90
- const CameraEngine& operator =(const CameraEngine&) = delete ;
91
- void defocusStripeCreate (std::vector<cv::Mat>& imgs, const int direction, const int cycles, const int shiftTime, AppType::DefocusEncoding method);
92
- void realTimeRenderImg (const QImage& img);
123
+ CameraEngine (const CameraEngine &) = delete;
124
+ const CameraEngine &operator =(const CameraEngine &) = delete ;
125
+ void defocusStripeCreate (std::vector<cv::Mat> &imgs, const int direction,
126
+ const int cycles, const int shiftTime,
127
+ AppType::DefocusEncoding method);
128
+ void realTimeRenderImg (const QImage &img);
93
129
void createTenLine ();
94
130
void switchTrigMode (const bool isTrigLine, const int exposureTime);
95
131
std::vector<OrderTableRecord> orderTableRecord_;
96
132
std::vector<QImage> stripeImgs_;
97
133
AppType::ScanModeType scanMode_;
98
134
AppType::CameraType cameraType_;
99
135
AppType::PatternMethod patternType_;
100
- static CameraEngine* engine_;
101
- ImagePaintItem* stripePaintItem_ = nullptr ;
102
- ImagePaintItem* offlineCamPaintItem_ = nullptr ;
103
- ImagePaintItem* scanTexturePaintItem_ = nullptr ;
136
+ static CameraEngine * engine_;
137
+ ImagePaintItem * stripePaintItem_ = nullptr ;
138
+ ImagePaintItem * offlineCamPaintItem_ = nullptr ;
139
+ ImagePaintItem * scanTexturePaintItem_ = nullptr ;
104
140
std::thread onlineDetectThread_;
105
141
std::thread workThread_;
106
142
slmaster::cameras::SLCameraFactory slCameraFactory_;
107
143
std::shared_ptr<slmaster::cameras::Pattern> pattern_ = nullptr ;
108
- CameraModel* leftCamModel_ = nullptr ;
109
- CameraModel* rightCamModel_ = nullptr ;
110
- CameraModel* colorCamModel_ = nullptr ;
144
+ CameraModel * leftCamModel_ = nullptr ;
145
+ CameraModel * rightCamModel_ = nullptr ;
146
+ CameraModel * colorCamModel_ = nullptr ;
111
147
slmaster::cameras::FrameData frame_;
112
148
std::thread test_thread_;
113
149
std::atomic_bool appExit_;
@@ -116,4 +152,4 @@ class CameraEngine : public QObject {
116
152
std::atomic_bool isContinusStop_;
117
153
};
118
154
119
- #endif // !__CAMERA_ENGINE_H_
155
+ #endif // !__CAMERA_ENGINE_H_
0 commit comments