summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-06 11:41:16 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-06 11:41:16 +0200
commit3a54a111567370ecf903704d702d12736b693a8e (patch)
tree1981d1bb3a97165d954ed8856061bb44d88fdd7c /ftnoir_tracker_pt
parentf58efb5c2c51e5866d4640036865792b822641f6 (diff)
parentfcb8ca75c0c274be2321f0ba91e9f129ae63e354 (diff)
Merge branch 'unstable' into trackhat-ui
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r--ftnoir_tracker_pt/camera.h3
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.cpp8
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.h6
3 files changed, 15 insertions, 2 deletions
diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h
index bffd19ee..63614ded 100644
--- a/ftnoir_tracker_pt/camera.h
+++ b/ftnoir_tracker_pt/camera.h
@@ -89,12 +89,13 @@ public:
void start() override;
void stop() override;
+ operator cv::VideoCapture&() { return *cap; }
+
protected:
bool _get_frame(cv::Mat* frame) override;
void _set_fps() override;
void _set_res() override;
void _set_device_index() override;
-
private:
cv::VideoCapture* cap;
};
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
index 2f852343..d48f9252 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
@@ -86,7 +86,12 @@ void Tracker_PT::run()
const double dt = time.elapsed() * 1e-9;
time.start();
cv::Mat frame;
- const bool new_frame = camera.get_frame(dt, &frame);
+ bool new_frame;
+
+ {
+ QMutexLocker l(&camera_mtx);
+ new_frame = camera.get_frame(dt, &frame);
+ }
if (new_frame && !frame.empty())
{
@@ -145,6 +150,7 @@ void Tracker_PT::run()
void Tracker_PT::apply_settings()
{
qDebug()<<"Tracker:: Applying settings";
+ QMutexLocker l(&camera_mtx);
QMutexLocker lock(&mutex);
camera.set_device_index(camera_name_to_index("PS3Eye Camera"));
int res_x, res_y, cam_fps;
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
index 3b9f1648..d0764933 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
@@ -17,6 +17,7 @@
#include "point_tracker.h"
#include "pt_video_widget.h"
#include "opentrack/timer.hpp"
+#include "opentrack/opencv-camera-dialog.hpp"
#include <QThread>
#include <QMutex>
@@ -30,11 +31,15 @@
#endif
#include <vector>
+class TrackerDialog_PT;
+
//-----------------------------------------------------------------------------
// Constantly processes the tracking chain in a separate thread
class Tracker_PT : public QThread, public ITracker
{
Q_OBJECT
+ friend class camera_dialog<Tracker_PT>;
+ friend class TrackerDialog_PT;
public:
Tracker_PT();
~Tracker_PT() override;
@@ -61,6 +66,7 @@ private:
volatile int commands;
+ QMutex camera_mtx;
CVCamera camera;
PointExtractor point_extractor;
PointTracker point_tracker;