-
Notifications
You must be signed in to change notification settings - Fork 10
/
imageacquisition.h
127 lines (105 loc) · 3.53 KB
/
imageacquisition.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
#ifndef IMAGEACQUISITION_H
#define IMAGEACQUISITION_H
#include <QThread>
#ifndef __APPLE__
# include "HalconCpp.h"
# include "Halcon.h"
# include "HFramegrabber.h"
#else
# ifndef HC_LARGE_IMAGES
# include <HALCONCpp/HalconCpp.h>
# else
# include <HALCONCppxl/HalconCpp.h>
# endif
#endif
#include <QImage>
#include "defaults.h"
#include <QSignalMapper>
#include <QQueue>
#include<QtCharts/QLineSeries>
using namespace QtCharts;
// Custom class to store image and save path in a queue (Buffer for writing)
class RecordingBuffer
{
// Access specifier
public:
// Data Members
HalconCpp::HImage image;
QString imageSavePath;
//Default Constructor
RecordingBuffer(HalconCpp::HImage image, QString imageSavePath)
{
this->image = image;
this->imageSavePath=imageSavePath;
}
};
class ImageAcquisition : public QThread
{
Q_OBJECT
private:
HalconCpp::HFramegrabber imageAcquisitionHandle;
bool stopAcquisition=false;
int counter=0;
QString deviceName, deviceType, deviceMake;
// CameraControls cameraControls;
bool recording=false;
bool supplyHistogramData=false;
bool supplyHistogramDataForLine=false;
public:
// Constructor
ImageAcquisition(QString deviceType, QString deviceMake, QString deviceName, QObject *parent=0);
HalconCpp::HImage currentImage;
// Image Buffer
QQueue<RecordingBuffer> imageBuffer;
// QString uid;
QString currentRecordSaveDir;
int currentBufferImageCounter;
bool writeInProgress=false;
double imageRotation = 0.0;
bool enableGrid = false;
bool mirrorImageHorizontal=false;
bool mirrorImageVertical=false;
double dynamicWidth=100.0, dynamicHeight=100.0;
// Coordinates for histogram
int x1,x2,y1,y2;
QList<QPair<int, int>> coordinates;
// Member Functions
bool HImage2QImage(HalconCpp::HImage &from, QImage &to);
void setupCameraControls();
HalconCpp::HTuple getValueForParam(std::string paramString);
// void setValueForParam(std::string paramString, int paramValue);
void setValueForParam(std::string paramString, std::string paramValue);
void setValueForParam(std::string paramString, double paramValue);
void setValueForParam(std::string paramString, bool paramState);
// void setValueForParam(std::string paramString, long paramValue);
void startAquisition();
// Setters and Getters
QString getDeviceName() const;
void setDeviceName(const QString &value);
int getCounter() const;
void setCounter(int value);
HalconCpp::HFramegrabber getImageAcquisitionHandle() const;
void setImageAcquisitionHandle(const HalconCpp::HFramegrabber &value);
bool getStopAcquisition() const;
void setStopAcquisition(bool value);
void setRecording(bool value){recording=value;}
bool getRecording(){return recording;}
bool getSupplyHistogramData() const;
void setSupplyHistogramData(bool value);
QString getDeviceType() const;
void setDeviceType(const QString &value);
QString getDeviceMake() const;
void setDeviceMake(const QString &value);
bool getSupplyHistogramDataForLine() const;
void setSupplyHistogramDataForLine(bool value);
QList<QPair<int, int> > getCoordinates() const;
void setCoordinates(const QList<QPair<int, int> > &value);
signals:
void renderImageSignal(QImage);
void updateStatusBarSignal(QString);
void renderHistogramSignal(QList<QLineSeries*>, int);
void renderHistogramSignalForLine(QList<QLineSeries*>, int);
protected:
void run();
};
#endif // IMAGEACQUISITION_H