summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2013-04-24 17:57:29 +0200
committerStanislaw Halik <sthalik@misaki.pl>2013-04-24 17:57:29 +0200
commitda9bc9bb5438002e9711720e2446bf6e4d47e386 (patch)
tree5a782153b56c2326796af3db31693da23465ee7e /ftnoir_tracker_pt
parent2f59cf809c3ed96f28fa53b0671091b5b2a7ce95 (diff)
Use atomic ops instead of locking
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.cpp23
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.h2
2 files changed, 12 insertions, 13 deletions
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
index 654e9924..09e758c7 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
@@ -39,13 +39,13 @@ Tracker::~Tracker()
void Tracker::set_command(Command command)
{
- QMutexLocker lock(&mutex);
+ //QMutexLocker lock(&mutex);
commands |= command;
}
void Tracker::reset_command(Command command)
{
- QMutexLocker lock(&mutex);
+ //QMutexLocker lock(&mutex);
commands &= ~command;
}
@@ -65,11 +65,10 @@ void Tracker::run()
forever
{
{
-
- QMutexLocker lock(&mutex);
+ QMutexLocker lock(&mutex);
if (should_quit)
break;
-
+
if (commands & ABORT) break;
if (commands & PAUSE) continue;
commands = 0;
@@ -149,27 +148,25 @@ void Tracker::refreshVideo()
Mat frame_copy;
std::auto_ptr< vector<Vec2f> > points;
{
-//QMutexLocker lock(&mutex);
+ //QMutexLocker lock(&mutex);
if (!draw_frame || frame.empty()) return;
// copy the frame and points from the tracker thread
frame_copy = frame.clone();
points = std::auto_ptr< vector<Vec2f> >(new vector<Vec2f>(point_extractor.get_points()));
}
-
+ //QMutexLocker lck(&mutex);
video_widget->update_image(frame_copy, points);
}
}
void Tracker::StartTracker(QFrame* videoframe)
{
- const int VIDEO_FRAME_WIDTH = 252;
- const int VIDEO_FRAME_HEIGHT = 189;
+ const int VIDEO_FRAME_WIDTH = videoframe->width();
+ const int VIDEO_FRAME_HEIGHT = videoframe->height();
TrackerSettings settings;
settings.load_ini();
apply(settings);
- camera.start();
- start();
qDebug("Tracker::Initialize");
// setup video frame
video_widget = new VideoWidget(videoframe);
@@ -180,9 +177,11 @@ void Tracker::StartTracker(QFrame* videoframe)
videoframe->setLayout(layout);
video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT);
videoframe->show();
- reset_command(PAUSE);
connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget()), Qt::QueuedConnection);
timer.start(40);
+ camera.start();
+ start();
+ reset_command(PAUSE);
}
void Tracker::paint_widget() {
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
index 014cab76..0c45c6b6 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
@@ -80,7 +80,7 @@ protected:
bool bEnableZ;
long frame_count;
- int commands;
+ volatile int commands;
VideoWidget* video_widget;
Timer time;