summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-07-20 13:38:02 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-07-20 13:38:02 +0200
commitb864a6932fbb1f35b0d6fb8e4835307b1d5a2299 (patch)
tree3f4a19e62ac30bdf4c8cefae4a72cd567af06a24 /ftnoir_tracker_pt
parent931541b7d58f747e09c59450f666fb34985d0536 (diff)
parent0c1b4510b3f7a744cc4cad94e0d4dde45925269d (diff)
Merge branch 'unstable' into trackhat-ui
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r--ftnoir_tracker_pt/camera.cpp20
-rw-r--r--ftnoir_tracker_pt/camera.h17
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.cpp29
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.h12
-rw-r--r--ftnoir_tracker_pt/point_tracker.cpp6
5 files changed, 14 insertions, 70 deletions
diff --git a/ftnoir_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp
index 2e745f2a..2989c1fe 100644
--- a/ftnoir_tracker_pt/camera.cpp
+++ b/ftnoir_tracker_pt/camera.cpp
@@ -8,26 +8,10 @@
#include "camera.h"
#include <string>
#include <QDebug>
+#include "opentrack/sleep.hpp"
using namespace cv;
-#ifdef OPENTRACK_API
-#else
-// ----------------------------------------------------------------------------
-void get_camera_device_names(std::vector<std::string>& device_names)
-{
- videoInput VI;
- VI.listDevices();
- std::string device_name;
- for(int index = 0; ; ++index) {
- device_name = VI.getDeviceName(index);
- if (device_name.empty()) break;
- device_names.push_back(device_name);
- }
-}
-#endif
-
-// ----------------------------------------------------------------------------
void Camera::set_device_index(int index)
{
if (desired_index != index)
@@ -113,6 +97,8 @@ void CVCamera::stop()
cap->release();
delete cap;
cap = nullptr;
+ // give opencv time to exit camera threads, etc.
+ portable::sleep(500);
}
active = false;
}
diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h
index 2c42652a..343446ac 100644
--- a/ftnoir_tracker_pt/camera.h
+++ b/ftnoir_tracker_pt/camera.h
@@ -8,21 +8,10 @@
#pragma once
#include <opencv2/core/core.hpp>
-#ifndef OPENTRACK_API
-# include <boost/shared_ptr.hpp>
-#else
-# include <memory>
-# include <opencv2/highgui/highgui.hpp>
-# include <opencv2/highgui/highgui_c.h>
-#endif
+#include <memory>
+#include <opencv2/highgui.hpp>
#include <string>
-#ifndef OPENTRACK_API
-// ----------------------------------------------------------------------------
-void get_camera_device_names(std::vector<std::string>& device_names);
-#endif
-
-// ----------------------------------------------------------------------------
struct CamInfo
{
CamInfo() : res_x(0), res_y(0), fps(0) {}
@@ -89,7 +78,7 @@ public:
void start() override;
void stop() override;
- operator cv::VideoCapture&() { return *cap; }
+ operator cv::VideoCapture*() { return cap; }
protected:
bool _get_frame(cv::Mat* frame) override;
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
index 716fddfd..dbf9cca0 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp
@@ -85,6 +85,8 @@ void Tracker_PT::run()
if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return;
QTextStream log_stream(&log_file);
#endif
+
+ apply_settings();
while((commands & ABORT) == 0)
{
@@ -165,6 +167,7 @@ void Tracker_PT::apply_settings()
{
qDebug()<<"Tracker:: Applying settings";
QMutexLocker l(&camera_mtx);
+ camera.stop();
camera.set_device_index(camera_name_to_index("PS3Eye Camera"));
int res_x, res_y, cam_fps;
switch (s.camera_mode)
@@ -194,6 +197,7 @@ void Tracker_PT::apply_settings()
camera.set_res(res_x, res_y);
camera.set_fps(cam_fps);
+ camera.start();
cv::Mat intrinsics_ = cv::Mat::eye(3, 3, CV_32FC1);
cv::Mat dist_coeffs_ = cv::Mat::zeros(5, 1, CV_32FC1);
intrinsics = cv::Mat();
@@ -228,23 +232,10 @@ void Tracker_PT::start_tracker(QFrame *parent_window)
video_layout->addWidget(video_widget);
video_frame->setLayout(video_layout);
video_widget->resize(video_frame->width(), video_frame->height());
- apply_settings();
- camera.start();
start();
}
-#ifndef OPENTRACK_API
-void Tracker::StopTracker(bool exit)
-{
- set_command(PAUSE);
-}
-#endif
-
-#ifdef OPENTRACK_API
-#define THeadPoseData double
-#endif
-
-void Tracker_PT::data(THeadPoseData *data)
+void Tracker_PT::data(double *data)
{
if (ever_success)
{
@@ -279,13 +270,3 @@ void Tracker_PT::data(THeadPoseData *data)
data[TZ] = t[2] / 10.0;
}
}
-
-//-----------------------------------------------------------------------------
-#ifdef OPENTRACK_API
-#else
-#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
-OPENTRACK_EXPORT ITrackerPtr __stdcall GetTracker()
-{
- return new Tracker_PT;
-}
-#endif
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
index aeda7dd7..97aa54aa 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
@@ -8,9 +8,7 @@
#ifndef FTNOIR_TRACKER_PT_H
#define FTNOIR_TRACKER_PT_H
-#ifdef OPENTRACK_API
-# include "opentrack/plugin-api.hpp"
-#endif
+#include "opentrack/plugin-api.hpp"
#include "ftnoir_tracker_pt_settings.h"
#include "camera.h"
#include "point_extractor.h"
@@ -24,11 +22,7 @@
#include <QMutexLocker>
#include <QTime>
#include <atomic>
-#ifndef OPENTRACK_API
-# include <boost/shared_ptr.hpp>
-#else
-# include <memory>
-#endif
+#include <memory>
#include <vector>
class TrackerDialog_PT;
@@ -48,7 +42,7 @@ public:
Affine pose() { QMutexLocker lock(&mutex); return point_tracker.pose(); }
int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); }
- void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); }
+ void get_cam_info(CamInfo* info) { QMutexLocker lock(&camera_mtx); *info = camera.get_info(); }
public slots:
void apply_settings();
protected:
diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp
index bae89dbe..f141fe36 100644
--- a/ftnoir_tracker_pt/point_tracker.cpp
+++ b/ftnoir_tracker_pt/point_tracker.cpp
@@ -33,12 +33,10 @@ static void set_row(Matx33f& m, int i, const Vec3f& v)
m(i,2) = v[2];
}
-#ifdef OPENTRACK_API
static bool d_vals_sort(const pair<float,int> a, const pair<float,int> b)
{
return a.first < b.first;
}
-#endif
void PointModel::get_d_order(const std::vector<cv::Vec2f>& points, int d_order[], cv::Vec2f d) const
{
@@ -50,11 +48,7 @@ void PointModel::get_d_order(const std::vector<cv::Vec2f>& points, int d_order[]
std::sort(d_vals.begin(),
d_vals.end(),
-#ifdef OPENTRACK_API
d_vals_sort
-#else
- comp
-#endif
);
for (unsigned i = 0; i<points.size(); ++i)