-
Notifications
You must be signed in to change notification settings - Fork 2
/
camera.h
109 lines (86 loc) · 2.8 KB
/
camera.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
//=============================================================================
// Cam
// Webcam client
//
// Copyright (C) 2016 Werner Schweer
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2
// as published by the Free Software Foundation and appearing in
// the file LICENCE.GPL
//=============================================================================
#ifndef __CAMERA_H__
#define __CAMERA_H__
#include <thread>
#include <vector>
#include <QWidget>
#include <QString>
#include <QSize>
class V4l2;
//---------------------------------------------------------
// CamDeviceFormat
//---------------------------------------------------------
struct CamDeviceFormat {
QSize size;
std::vector<int> frameRates;
};
//---------------------------------------------------------
// CamDevice
//---------------------------------------------------------
struct CamDevice {
QString shortName;
QString name;
QString device;
QString buttonDevice;
std::vector<CamDeviceFormat> formats;
};
//---------------------------------------------------------
// CamDeviceSetting
//---------------------------------------------------------
struct CamDeviceSetting {
CamDevice* device;
QSize size;
int fps;
};
//---------------------------------------------------------
// Camera
//---------------------------------------------------------
class Camera : public QWidget {
Q_OBJECT
V4l2* cam { 0 };
bool isstreaming { false };
QImage image;
qreal mag { 1.0 };
bool snapshot { false };
bool _crosshair { true };
QString _picturePath { "" };
QString _picturePrefix { "pic" };
int pictureNumber { 1 };
CamDeviceSetting setting;
std::thread grabLoop;
std::thread buttonLoop;
virtual void resizeEvent(QResizeEvent*) override;
virtual void wheelEvent(QWheelEvent*) override;
virtual void paintEvent(QPaintEvent*) override;
void loop();
void watchButton();
public slots:
void takeSnapshot();
void setPicturePath(const QString& s);
void setPicturePrefix(const QString& s);
void setCrosshair(bool val) { _crosshair = val; }
signals:
void cameraButtonPressed();
void click(const QString&, int);
public:
Camera(QWidget* parent = 0);
~Camera();
int start();
int stop();
int init(const CamDeviceSetting&);
void change(const CamDeviceSetting&);
const QString& picturePath() const { return _picturePath; }
const QString& picturePrefix() const { return _picturePrefix; }
bool crosshair() const { return _crosshair; }
};
#endif