Object Detection  5.0
Image Processing Using Qt and Opencv
cvvideocapture.h
1 #ifndef CVVIDEOCAPTURE_H
2 #define CVVIDEOCAPTURE_H
3 
4 #include <QWidget>
5 #include <QPushButton>
6 #include <QLabel>
7 #include <QGridLayout>
8 #include <QTimer>
9 #include <QSpinBox>
10 
11 #include <opencv2/core/mat.hpp>
12 
13 #include <opencv2/videoio.hpp>
14 #include "cvvideocapturelib.h"
15 class CVVIDEOCAPTURESHARED_EXPORT CVVideoCapture : public QWidget
16 {
17  Q_OBJECT
18 
19 public:
20  CVVideoCapture(QWidget *parent = 0);
21  virtual ~CVVideoCapture();
22  int device() const;
23  void setDevice(int device);
24 
25  cv::Mat currentFrame() const;
26  void setCurrentFrame(const cv::Mat &currentFrame);
27 
28  QImage toImage(const cv::Mat &m);
29 private:
30  int m_device;
31  QPushButton *m_startButton;
32  QPushButton *m_stopButton;
33  QLabel *m_frameLabel;
34  QLabel *m_infoLabel;
35  QLabel *m_stateLabel;
36  QGridLayout *m_container;
37  QTimer m_timer;
38  QSpinBox *m_deviceSpinBox;
39  cv::VideoCapture m_capture;
40  cv::Mat m_currentFrame;
41  void createConnections();
42 protected:
43 public slots:
44  virtual void captureFrame();
45  virtual void stop();
46  virtual void start();
47  virtual void changeDevice(int device);
48 signals:
49  void frameCaptured(cv::Mat frame);
50  void stopped();
51  void started();
52  void deviceChanged(int device);
53 };
54 
55 #endif