-
Notifications
You must be signed in to change notification settings - Fork 38
/
cameradatafeed.h
120 lines (112 loc) · 2.81 KB
/
cameradatafeed.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
#ifndef CAMERADATAFEED_H
#define CAMERADATAFEED_H
#include <QObject>
#include <linux/videodev2.h>
#include <linux/uvcvideo.h>
#include <linux/usb/video.h>
#include <fcntl.h>
#include <stdio.h>
#include <sys/ioctl.h>
#include <sys/mman.h>
#include <errno.h>
#include <QTextStream>
#include <QTimer>
#include <QString>
#include <unistd.h>
#include <QImage>
#include <QDateTime>
#include <opencv2/opencv.hpp>
//using std::string;
using namespace std;
using namespace cv;
class CameraDataFeed : public QObject
{
Q_OBJECT
~CameraDataFeed();
QTextStream out;
QString device;
QString snapshotDir;
int fd;
QImage colorImage;
QImage depthImage;
QImage infraredImage;
bool takeSnap;
u_int16_t depthMin;
u_int16_t depthMax;
u_int16_t depthMask;
u_int32_t fourcc;
struct v4l2_format v4l2Format;
__u32 buffercount;
v4l2_buffer * buffers;
struct v4l2_requestbuffers reqestBuffers;
QTimer *timer;
void printState();
bool openCamera();
void openFifo();
bool getControls();
bool setFormat();
bool reqBuffers();
bool freeBuffers();
bool newBufArray();
bool queryAllBuffers();
bool mMAP();
bool qbuf();
bool startClock();
bool stopClock();
bool startStream();
bool stopStream();
bool closeCamera();
bool freeMmap();
bool freeBufferArray();
void createImages(void * voidData);
enum State {
OPEN = (1u << 0),
FMT = (1u << 1),
REQBUFS = (1u << 2),
BUFFERS_ARRAY = (1u << 3),
QUERYBUF = (1u << 4),
MMAP = (1u << 5),
QBUF = (1u << 6),
STREAM = (1u << 7),
TIMER = (1u << 8),
};
enum PixelFormat {
YUYV = 0x56595559,
INVZ = 0x5a564e49,
INZI = 0x495a4e49,
INVR = 0x52564e49,
INRI = 0x49524e49,
INVI = 0x49564e49,
RELI = 0x494c4552
};
// static const char ** StateStrings = {
// "OPEN", "FMT", "REQBUFS", "BUFFERS_ARRAY", "QUERYBUF",
// "MMAP", "QBUF", "STREAM", "TIMER"
// };
State state;
public:
explicit CameraDataFeed(QObject *parent = 0);
void setControl(int control, int value);
signals:
// void newData(void *);
void newColorImage(QImage);
void newDepthImage(QImage);
void newInfraredImage(QImage);
public slots:
void updateData();
void startVideo();
void stopVideo();
void setCameraDevice(QString);
void setFourcc(u_int32_t);
void setLaserPower(int);
void setIvcamSetting(int);
void setMrtoSetting(int);
void setFilterSetting(int);
void setConfidenceSetting(int);
void setDepthMin(int);
void setDepthMax(int);
void setDepthMask(int);
void savePicture();
void setSnapshotDir(QString);
};
#endif // CAMERADATAFEED_H