]> git.defcon.no Git - qopencamwidget/blob - qopencamwidget.h
Qt Widget that handles webcams :D
[qopencamwidget] / qopencamwidget.h
1 /*
2 This file is one part of two, that together make
3 QOpenCamWidget, a Qt 4 widget that displays video input
4 from a webcam, along with an optional snapshot button.
5
6 Copyright (C) 2009 Jon Langseth
7
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation in its version 2
11 of the License.
12
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 */
22
23 #ifndef QOPENCVWIDGET_H
24 #define QOPENCVWIDGET_H
25 #include <QtGui>
26 #include <opencv/cv.h>
27 #include <opencv/highgui.h>
28
29 class QOpenCamWidget
30 : public QWidget
31 {
32 Q_OBJECT
33
34 private:
35 CvCapture *capture;
36 QTimer *frametimer;
37 QImage *nextFrame;
38 //QImage *snapshot;
39 QLabel *canvas;
40 QVBoxLayout *layout;
41 QPushButton *trigger;
42 bool trigger_active;
43
44 public:
45 // Defaults, standard elements ;)
46 QOpenCamWidget(QWidget *parent = 0);
47 ~QOpenCamWidget(void);
48
49 // Overides, reimplementation of abstract
50 void paintEvent ( QPaintEvent * event );
51
52 // Public methods specific to this class
53 void setSnapshotVisible( bool visible );
54 bool grabCapture(int source);
55 void startCapture(void);
56 QImage* Ipl2QImage(const IplImage *img);
57
58 public slots:
59 void grabFrame(void);
60 void startSnap();
61 signals:
62 void imageReady(QImage snapshot);
63 };
64
65 #endif
66