summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--ftnoir_tracker_pt/video_widget.cpp53
-rw-r--r--ftnoir_tracker_pt/video_widget.h4
2 files changed, 29 insertions, 28 deletions
diff --git a/ftnoir_tracker_pt/video_widget.cpp b/ftnoir_tracker_pt/video_widget.cpp
index c297c455..1b8b4a7a 100644
--- a/ftnoir_tracker_pt/video_widget.cpp
+++ b/ftnoir_tracker_pt/video_widget.cpp
@@ -39,33 +39,34 @@ void VideoWidget::resizeGL(int w, int h)
void VideoWidget::paintGL()
{
- QMutexLocker lck(&mtx);
+ QMutexLocker((QMutex*)&mtx);
if (resized_qframe.size() == size() || (resized_qframe.width() <= width() && resized_qframe.height() <= height())) {
glDrawPixels(resized_qframe.width(), resized_qframe.height(), GL_RGB, GL_UNSIGNED_BYTE, resized_qframe.bits());
-
- const int crosshair_radius = 10;
- const int crosshair_thickness = 1;
-
- glColor3f(1.0, 0.0, 0.0);
- glLineWidth(crosshair_thickness);
- int x,y;
- for (vector<Vec2f>::iterator iter = points->begin();
- iter != points->end();
- ++iter)
- {
- x = (*iter)[0] * resized_qframe.width() + resized_qframe.width()/2.0 + 0.5;
- y = (*iter)[1] * resized_qframe.width() + resized_qframe.height()/2.0 + 0.5;
-
- glBegin(GL_LINES);
- glVertex2i(x-crosshair_radius, y);
- glVertex2i(x+crosshair_radius, y);
- glEnd();
- glBegin(GL_LINES);
- glVertex2i(x, y-crosshair_radius);
- glVertex2i(x, y+crosshair_radius);
- glEnd();
- }
-
+ if (points.get() != NULL)
+ {
+ const int crosshair_radius = 10;
+ const int crosshair_thickness = 1;
+
+ glColor3f(1.0, 0.0, 0.0);
+ glLineWidth(crosshair_thickness);
+ int x,y;
+ for (vector<Vec2f>::iterator iter = points->begin();
+ iter != points->end();
+ ++iter)
+ {
+ x = (*iter)[0] * resized_qframe.width() + resized_qframe.width()/2.0 + 0.5;
+ y = (*iter)[1] * resized_qframe.width() + resized_qframe.height()/2.0 + 0.5;
+
+ glBegin(GL_LINES);
+ glVertex2i(x-crosshair_radius, y);
+ glVertex2i(x+crosshair_radius, y);
+ glEnd();
+ glBegin(GL_LINES);
+ glVertex2i(x, y-crosshair_radius);
+ glVertex2i(x, y+crosshair_radius);
+ glEnd();
+ }
+ }
} else {
glClear(GL_DEPTH_BUFFER_BIT);
}
@@ -75,7 +76,6 @@ void VideoWidget::paintGL()
void VideoWidget::resize_frame()
{
- QMutexLocker lck(&mtx);
#ifdef _WIN32
if (qframe.size() == size() || (qframe.width() <= width() && qframe.height() <= height()))
resized_qframe = qframe.mirrored();
@@ -96,6 +96,7 @@ void VideoWidget::update()
void VideoWidget::update_image(Mat frame, std::auto_ptr< vector<Vec2f> > points)
{
+ QMutexLocker((QMutex*)&mtx);
this->frame = frame;
this->points = points;
diff --git a/ftnoir_tracker_pt/video_widget.h b/ftnoir_tracker_pt/video_widget.h
index 2425603b..bb567478 100644
--- a/ftnoir_tracker_pt/video_widget.h
+++ b/ftnoir_tracker_pt/video_widget.h
@@ -22,7 +22,7 @@ class VideoWidget : public QGLWidget
Q_OBJECT
public:
- VideoWidget(QWidget *parent) : QGLWidget(parent) {
+ VideoWidget(QWidget *parent) : QGLWidget(parent), mtx() {
#if !defined(_WIN32)
setAttribute(Qt::WA_NativeWindow, true);
#endif
@@ -41,9 +41,9 @@ private:
cv::Mat frame;
QImage qframe;
QImage resized_qframe;
+ QMutex mtx;
std::auto_ptr< std::vector<cv::Vec2f> > points;
- QMutex mtx;
};
#endif // VIDEOWIDGET_H