Fixed Threshold Button Not Applying Threshold
[EconoBoard.git] / src / camerathread.h
bloba6eb64712ac4cf4c1d44cc82c7b9f45f7afd2959
1 /*************************************************************************
2 Copyright 2009, Matthew Thompson, Lee Hicks
4 This file is part of EconoBoard.
6 EconoBoard is free software: you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation, either version 3 of the License, or
9 (at your option) any later version.
11 EconoBoard is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with EconoBoard. If not, see <http://www.gnu.org/licenses/>.
18 *************************************************************************/
20 #ifndef EBCAMERATHREAD_H
21 #define EBCAMERATHREAD_H
23 #include <QThread>
24 #include <QMutex>
25 #include <QTimer>
26 #include <QImage>
27 #include <cv.h>
28 #include <highgui.h>
30 #define SMALLEST_REGION 10
32 namespace eb
35 class CameraThread : public QThread
37 Q_OBJECT
39 public:
40 CameraThread(QObject *parent = 0);
41 ~CameraThread();
43 inline bool canCapture()
45 return capture;
47 inline int camera()
49 return camid;
51 inline int threshold()
53 return thresh;
56 public slots:
57 void attachView();
58 void detachView();
60 void grab();
62 void setThreshold(int t);
63 void setCamera(int idx);
64 void setDisplayUpdate(int ms); // set to 0 to stop converting
65 void setCaptureUpdate(int ms);
66 void setApplyThreshold(bool apply);
68 private slots:
69 void updateFrame();
71 signals:
72 void imageGrabbed(const QImage &img);
73 void FPSCalculated(int fps);
75 protected:
76 void run();
78 private:
79 class TargetPoint
81 public:
82 TargetPoint() : valid(false) {}
83 TargetPoint(int X, int Y) : valid(true), x(X), y(Y) {}
85 bool valid;
86 int x, y;
89 TargetPoint tpoint;
91 IplImage *captureFrame();
93 QImage defaultImage();
94 QImage convertImage();
96 void allocateBuffers();
97 void destroyBuffers();
99 TargetPoint applyFilters(IplImage *img);
101 int camid, numchannels, thresh;
102 int updateDelay, captureDelay, views;
103 bool applyThreshold;
105 QSize frameSize;
107 QTimer updateTimer, captureTimer;
108 QMutex filterMut, captureMut;
109 QImage tmp;
111 IplImage *bufferImg, *filterImg, *tmpImg;
112 CvCapture *capture;
118 #endif