-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDCVCameraHandler.h
117 lines (94 loc) · 3.08 KB
/
DCVCameraHandler.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
/*
* DCVCameraHandler.h
*
* Created on: Oct 12, 2015
* Author: Tim
*/
#ifndef DCVCAMERAHANDLER_H_
#define DCVCAMERAHANDLER_H_
/*****************************************************************************
****************************** I N C L U D E *******************************
*****************************************************************************/
#include <QTimer>
#include <QMenuBar>
#include <QMenu>
#include <QToolBar>
#include <opencv2/videoio.hpp>
#include "CVImage.h"
/*****************************************************************************
*
*** class DCVCameraHandler
*
* Class to provide a stanard interface to an OpenCV camera. A user interace
* with menu and toolbar items is provided.
*
*****************************************************************************/
class DCVCameraHandler : public QObject
{
Q_OBJECT
public:
DCVCameraHandler(QWidget* pParent);
DCVCameraHandler(QWidget* pParent, QSize CameraResolution);
DCVCameraHandler(const DCVCameraHandler& src) = delete;
~DCVCameraHandler()
{
return;
}
DCVCameraHandler& operator=(const DCVCameraHandler& rhs) = delete;
void AddCameraMenu(QMenuBar* pMenuBar);
void AddCamerasMenuItems(QMenu* pMenu);
void AddCameraButtons(QMenu* pMenu);
void AddCameraMenuMirrorItems(QMenu* pMenu);
void AddCameraButtons(QToolBar* pToolBar);
int GetCaptureInterval() const
{
return (m_CaptureTimer.interval());
}
bool IsRunning() const
{
return (m_bRunning);
}
// Query the underlying device for actual resolution
// TTC Should be const but cv::VideoCapture is not const correct
QSize GetActualResolution();
signals:
void imageCaptured(DCVImage& Image);
void CameraStarted();
void CameraStopped();
public slots:
void StartCamera();
void StopCamera();
void MirrorHorizontal();
void MirrorVertical();
bool SetResolution(int nWidth, int nHeight);
bool SetResolution(QSize Resolution);
void SetCaptureInterval(int nInterval)
{
m_CaptureTimer.setInterval(nInterval);
return;
}
protected:
QWidget* m_pParentWidget;
QSize m_CameraResolution;
cv::VideoCapture m_ImageCapture;
bool m_bRunning;
DCVImage m_CapturedImage;
QTimer m_CaptureTimer;
QAction* m_pActionStart;
QAction* m_pActionStop;
bool m_bMirrorHorizontal;
bool m_bMirrorVertical;
QAction* m_pActionMirrorHorizontal;
QAction* m_pActionMirrorVertical;
void CreateStartAction();
void CreateStopAction();
void CreateMirrorHorizontalAction();
void CreateMirrorVerticalAction();
protected slots:
void SetCamera(int nCamera);
void UpdateCameraDevice(QAction *pAction);
void CaptureImage();
private:
};
// end of class DCVCameraHandler
#endif /* DCVCAMERAHANDLER_H_ */