-
Notifications
You must be signed in to change notification settings - Fork 16
/
cameragrabber.h
94 lines (80 loc) · 3.14 KB
/
cameragrabber.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
/****************************************************************************
**
** This library is free software; you can redistribute it and/or
** modify it under the terms of the GNU Lesser General Public
** License as published by the Free Software Foundation; either
** version 2.1 of the License, or (at your option) any later version.
**
** This library is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
** Lesser General Public License for more details.
**
** You should have received a copy of the GNU Lesser General Public
** License along with this library; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
**
****************************************************************************/
#ifndef CAMERAGRABBER_H
#define CAMERAGRABBER_H
#include "abstractimagegrabber.h"
#include <QStringList>
class CvCapture;
//! The CameraGrabber class allows the application to capture frames from a camera device.
/*!
Using this class you can capture frames with variable frame rate from a camera device. In order to get available devices
call the availableDeviceNames() static function. To let CameraGrabber know which camera it must grab pass the device index to the setDeviceIndex() function.
The CameraGrabber class has the setInitializationTime() function to set time the app will wait before grabbing start. It is need to be used because you
will get black(or other colors) frames while a device is turning on. To get maximum frame size supported by a device use the the maximumFrameSize() static function.
If you want to get a frame with the size that smaller or larger than maximumFrameSize() then you can set the needed size calling the setSize() function.
The signal frameAvailable() is emmited whenever a new frame is available.
*/
class CameraGrabber : public AbstractImageGrabber
{
Q_OBJECT
public:
CameraGrabber(QObject *parent = 0);
virtual ~CameraGrabber();
/*!
Lets CameraGrabber know which device it must grab.
\sa deviceIndex()
\sa availableDeviceNames()
*/
void setDeviceIndex(int index);
/*!
Returns current device index.
\sa setDeviceIndex()
*/
int deviceIndex() const;
/*!
Sets the frame size. A frame will be scaled as large as possible inside a given size, preserving the aspect ratio.
\sa size()
*/
void setSize(const QSize &size);
/*!
Returns the frame size.
\sa setSize()
*/
QSize size() const;
/*!
Returns names of available cameras.
*/
static QStringList availableDeviceNames();
/*!
Returns the maximum frame size supported by a device.
\sa availableDeviceNames()
*/
static QSize maximumFrameSize(int deviceIndex);
public Q_SLOTS:
bool start();
private Q_SLOTS:
void onStateChanged(AbstractGrabber::State state);
private:
bool createCamera();
void releaseCamera();
QImage captureFrame();
CvCapture *m_camera;
int m_deviceIndex;
QSize m_size;
};
#endif // CAMERAGRABBER_H