summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_pt
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-05 01:22:11 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-05 01:22:11 +0200
commitcfffa29e29db6b2234c7f534b1ebcd612b7f4914 (patch)
tree35126a8dfc5304efaa4617efbc92e31617e4a030 /ftnoir_tracker_pt
parent97bd173ee4b6f30c12ca590e213b21bbc83f8617 (diff)
flush
Diffstat (limited to 'ftnoir_tracker_pt')
-rw-r--r--ftnoir_tracker_pt/camera.h2
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt.h54
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp88
-rw-r--r--ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h4
-rw-r--r--ftnoir_tracker_pt/point_extractor.h4
-rw-r--r--ftnoir_tracker_pt/point_tracker.h74
-rw-r--r--ftnoir_tracker_pt/pt_video_widget.h2
-rw-r--r--ftnoir_tracker_pt/trans_calib.h2
8 files changed, 115 insertions, 115 deletions
diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h
index 7ebbcb67..889bf2d3 100644
--- a/ftnoir_tracker_pt/camera.h
+++ b/ftnoir_tracker_pt/camera.h
@@ -8,7 +8,7 @@
#ifndef CAMERA_H
#define CAMERA_H
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#ifndef OPENTRACK_API
# include <boost/shared_ptr.hpp>
#else
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
index 5bcfd37d..fff8d4ab 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt.h
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h
@@ -22,7 +22,7 @@
#include <QMutex>
#include <QMutexLocker>
#include <QTime>
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#include <atomic>
#ifndef OPENTRACK_API
# include <boost/shared_ptr.hpp>
@@ -36,53 +36,53 @@
class Tracker : public ITracker, protected QThread
{
public:
- Tracker();
+ Tracker();
~Tracker() override;
void StartTracker(QFrame* parent_window) override;
void GetHeadPoseData(double* data) override;
void apply(settings& s);
- void apply_inner();
- void center();
- void reset(); // reset the trackers internal state variables
+ void apply_inner();
+ void center();
+ void reset(); // reset the trackers internal state variables
- void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_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_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_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(); }
protected:
void run() override;
private:
- QMutex mutex;
- // thread commands
- enum Command {
- ABORT = 1<<0
- };
- void set_command(Command command);
- void reset_command(Command command);
+ QMutex mutex;
+ // thread commands
+ enum Command {
+ ABORT = 1<<0
+ };
+ void set_command(Command command);
+ void reset_command(Command command);
volatile int commands;
CVCamera camera;
- FrameRotation frame_rotation;
- PointExtractor point_extractor;
- PointTracker point_tracker;
+ FrameRotation frame_rotation;
+ PointExtractor point_extractor;
+ PointTracker point_tracker;
- FrameTrafo X_GH_0; // for centering
- cv::Vec3f t_MH; // translation from model frame to head frame
- cv::Matx33f R_GC; // rotation from opengl reference frame to camera frame
+ FrameTrafo X_GH_0; // for centering
+ cv::Vec3f t_MH; // translation from model frame to head frame
+ cv::Matx33f R_GC; // rotation from opengl reference frame to camera frame
- // --- ui ---
- cv::Mat frame; // the output frame for display
+ // --- ui ---
+ cv::Mat frame; // the output frame for display
PTVideoWidget* video_widget;
- QFrame* video_frame;
-
+ QFrame* video_frame;
+
settings s;
std::atomic<settings*> new_settings;
Timer time;
-
+
static constexpr double rad2deg = 180.0/3.14159265;
static constexpr double deg2rad = 3.14159265/180.0;
-
+
PointModel model;
};
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp
index 6cd6135c..3af7b560 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp
@@ -9,7 +9,7 @@
#include <QMessageBox>
#include <QDebug>
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#ifndef OPENTRACK_API
# include <boost/shared_ptr.hpp>
#else
@@ -25,14 +25,14 @@ TrackerDialog::TrackerDialog()
timer(this),
trans_calib_running(false)
{
- ui.setupUi( this );
+ ui.setupUi( this );
vector<string> device_names;
- get_camera_device_names(device_names);
+ get_camera_device_names(device_names);
for (vector<string>::iterator iter = device_names.begin(); iter != device_names.end(); ++iter)
- {
- ui.camdevice_combo->addItem(iter->c_str());
- }
+ {
+ ui.camdevice_combo->addItem(iter->c_str());
+ }
ui.camroll_combo->addItem("-90");
ui.camroll_combo->addItem("0");
@@ -82,7 +82,7 @@ TrackerDialog::TrackerDialog()
connect(ui.model_tabs, SIGNAL(currentChanged(int)), this, SLOT(set_model(int)));
connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info()));
- timer.start(100);
+ timer.start(100);
connect(ui.buttonBox_2, SIGNAL(clicked(QAbstractButton*)), this, SLOT(do_apply_without_saving(QAbstractButton*)));
}
@@ -96,7 +96,7 @@ void TrackerDialog::set_model_clip()
s.m02_y = -static_cast<double>(s.clip_by);
s.m02_z = -static_cast<double>(s.clip_bz);
- settings_changed();
+ settings_changed();
}
void TrackerDialog::set_model_cap()
@@ -108,12 +108,12 @@ void TrackerDialog::set_model_cap()
s.m02_y = -static_cast<double>(s.cap_y);
s.m02_z = -static_cast<double>(s.cap_z);
- settings_changed();
+ settings_changed();
}
void TrackerDialog::set_model_custom()
{
- settings_changed();
+ settings_changed();
}
void TrackerDialog::set_model(int val)
@@ -123,38 +123,38 @@ void TrackerDialog::set_model(int val)
void TrackerDialog::startstop_trans_calib(bool start)
{
- if (start)
- {
- qDebug()<<"TrackerDialog:: Starting translation calibration";
- trans_calib.reset();
- trans_calib_running = true;
- }
- else
- {
- qDebug()<<"TrackerDialog:: Stoppping translation calibration";
- trans_calib_running = false;
+ if (start)
+ {
+ qDebug()<<"TrackerDialog:: Starting translation calibration";
+ trans_calib.reset();
+ trans_calib_running = true;
+ }
+ else
+ {
+ qDebug()<<"TrackerDialog:: Stoppping translation calibration";
+ trans_calib_running = false;
{
auto tmp = trans_calib.get_estimate();
s.t_MH_x = tmp[0];
s.t_MH_y = tmp[1];
s.t_MH_z = tmp[2];
}
- settings_changed();
- }
+ settings_changed();
+ }
}
void TrackerDialog::poll_tracker_info()
{
if (tracker)
- {
+ {
QString to_print;
-
+
// display caminfo
CamInfo info;
tracker->get_cam_info(&info);
to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS";
ui.caminfo_label->setText(to_print);
-
+
// display pointinfo
int n_points = tracker->get_n_points();
to_print = QString::number(n_points);
@@ -163,7 +163,7 @@ void TrackerDialog::poll_tracker_info()
else
to_print += " BAD!";
ui.pointinfo_label->setText(to_print);
-
+
// update calibration
if (trans_calib_running) trans_calib_step();
}
@@ -177,16 +177,16 @@ void TrackerDialog::poll_tracker_info()
void TrackerDialog::trans_calib_step()
{
- if (tracker)
- {
- FrameTrafo X_CM;
- tracker->get_pose(&X_CM);
- trans_calib.update(X_CM.R, X_CM.t);
- cv::Vec3f t_MH = trans_calib.get_estimate();
+ if (tracker)
+ {
+ FrameTrafo X_CM;
+ tracker->get_pose(&X_CM);
+ trans_calib.update(X_CM.R, X_CM.t);
+ cv::Vec3f t_MH = trans_calib.get_estimate();
s.t_MH_x = t_MH[0];
s.t_MH_y = t_MH[1];
s.t_MH_z = t_MH[2];
- }
+ }
}
void TrackerDialog::settings_changed()
@@ -203,7 +203,7 @@ void TrackerDialog::save()
void TrackerDialog::doOK()
{
save();
- close();
+ close();
}
void TrackerDialog::do_apply_without_saving(QAbstractButton*)
@@ -225,7 +225,7 @@ void TrackerDialog::do_apply_without_saving(QAbstractButton*)
void TrackerDialog::doApply()
{
- save();
+ save();
}
void TrackerDialog::doCancel()
@@ -236,23 +236,23 @@ void TrackerDialog::doCancel()
void TrackerDialog::registerTracker(ITracker *t)
{
- qDebug()<<"TrackerDialog:: Tracker registered";
- tracker = static_cast<Tracker*>(t);
+ qDebug()<<"TrackerDialog:: Tracker registered";
+ tracker = static_cast<Tracker*>(t);
if (isVisible() & s.b->modifiedp())
tracker->apply(s);
- ui.tcalib_button->setEnabled(true);
- //ui.center_button->setEnabled(true);
+ ui.tcalib_button->setEnabled(true);
+ //ui.center_button->setEnabled(true);
}
void TrackerDialog::unRegisterTracker()
{
- qDebug()<<"TrackerDialog:: Tracker un-registered";
- tracker = NULL;
- ui.tcalib_button->setEnabled(false);
- //ui.center_button->setEnabled(false);
+ qDebug()<<"TrackerDialog:: Tracker un-registered";
+ tracker = NULL;
+ ui.tcalib_button->setEnabled(false);
+ //ui.center_button->setEnabled(false);
}
extern "C" OPENTRACK_EXPORT ITrackerDialog* GetDialog( )
{
- return new TrackerDialog;
+ return new TrackerDialog;
}
diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h
index 365776e4..e8cac679 100644
--- a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h
+++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h
@@ -8,7 +8,7 @@
#ifndef FTNOIR_TRACKER_PT_SETTINGS_H
#define FTNOIR_TRACKER_PT_SETTINGS_H
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#include "point_tracker.h"
#include "facetracknoir/options.h"
@@ -36,7 +36,7 @@ struct settings
value<int> clip_ty, clip_tz, clip_by, clip_bz;
value<int> active_model_panel, cap_x, cap_y, cap_z;
-
+
// XXX todo red channel only, good for crapola CCD sensors -sh 20140922
settings() :
diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h
index 3ef82900..5252b68d 100644
--- a/ftnoir_tracker_pt/point_extractor.h
+++ b/ftnoir_tracker_pt/point_extractor.h
@@ -8,8 +8,8 @@
#ifndef POINTEXTRACTOR_H
#define POINTEXTRACTOR_H
-#include <opencv2/opencv.hpp>
-#include <opencv2/imgproc/imgproc_c.h>
+#include <opencv2/core/core.hpp>
+#include <opencv2/imgproc/imgproc.hpp>
// ----------------------------------------------------------------------------
// Extracts points from an opencv image
diff --git a/ftnoir_tracker_pt/point_tracker.h b/ftnoir_tracker_pt/point_tracker.h
index c8212538..d65494a4 100644
--- a/ftnoir_tracker_pt/point_tracker.h
+++ b/ftnoir_tracker_pt/point_tracker.h
@@ -8,7 +8,7 @@
#ifndef POINTTRACKER_H
#define POINTTRACKER_H
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#ifndef OPENTRACK_API
# include <boost/shared_ptr.hpp>
#else
@@ -21,31 +21,31 @@
class FrameTrafo
{
public:
- FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {}
- FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {}
+ FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {}
+ FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {}
- cv::Matx33f R;
- cv::Vec3f t;
+ cv::Matx33f R;
+ cv::Vec3f t;
};
inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y)
{
- return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t);
+ return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t);
}
inline FrameTrafo operator*(const cv::Matx33f& X, const FrameTrafo& Y)
{
- return FrameTrafo(X*Y.R, X*Y.t);
+ return FrameTrafo(X*Y.R, X*Y.t);
}
inline FrameTrafo operator*(const FrameTrafo& X, const cv::Matx33f& Y)
{
- return FrameTrafo(X.R*Y, X.t);
+ return FrameTrafo(X.R*Y, X.t);
}
inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v)
{
- return X.R*v + X.t;
+ return X.R*v + X.t;
}
@@ -55,28 +55,28 @@ inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v)
// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"]
class PointModel
{
- friend class PointTracker;
+ friend class PointTracker;
public:
- static constexpr int N_POINTS = 3;
+ static constexpr int N_POINTS = 3;
- PointModel(cv::Vec3f M01, cv::Vec3f M02);
+ PointModel(cv::Vec3f M01, cv::Vec3f M02);
PointModel();
- inline const cv::Vec3f& get_M01() const { return M01; }
- inline const cv::Vec3f& get_M02() const { return M02; }
+ inline const cv::Vec3f& get_M01() const { return M01; }
+ inline const cv::Vec3f& get_M02() const { return M02; }
private:
- cv::Vec3f M01; // M01 in model frame
- cv::Vec3f M02; // M02 in model frame
+ cv::Vec3f M01; // M01 in model frame
+ cv::Vec3f M02; // M02 in model frame
- cv::Vec3f u; // unit vector perpendicular to M01,M02-plane
+ cv::Vec3f u; // unit vector perpendicular to M01,M02-plane
- cv::Matx22f P;
+ cv::Matx22f P;
- cv::Vec2f d; // determinant vector for point correspondence
- int d_order[3]; // sorting of projected model points with respect to d scalar product
+ cv::Vec2f d; // determinant vector for point correspondence
+ int d_order[3]; // sorting of projected model points with respect to d scalar product
- void get_d_order(const std::vector<cv::Vec2f>& points, int d_order[]) const;
+ void get_d_order(const std::vector<cv::Vec2f>& points, int d_order[]) const;
};
// ----------------------------------------------------------------------------
@@ -86,29 +86,29 @@ private:
class PointTracker
{
public:
- PointTracker();
- // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5)
- // f : (focal length)/(sensor width)
- // dt : time since last call
- void track(const std::vector<cv::Vec2f>& projected_points, const PointModel& model);
- FrameTrafo get_pose() const { return X_CM; }
- void reset();
+ PointTracker();
+ // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5)
+ // f : (focal length)/(sensor width)
+ // dt : time since last call
+ void track(const std::vector<cv::Vec2f>& projected_points, const PointModel& model);
+ FrameTrafo get_pose() const { return X_CM; }
+ void reset();
private:
// the points in model order
typedef struct { cv::Vec2f points[PointModel::N_POINTS]; } PointOrder;
- static constexpr float focal_length = 1.0f;
-
- inline cv::Vec2f project(const cv::Vec3f& v_M)
- {
- cv::Vec3f v_C = X_CM * v_M;
- return cv::Vec2f(focal_length*v_C[0]/v_C[2], focal_length*v_C[1]/v_C[2]);
- }
+ static constexpr float focal_length = 1.0f;
+
+ inline cv::Vec2f project(const cv::Vec3f& v_M)
+ {
+ cv::Vec3f v_C = X_CM * v_M;
+ return cv::Vec2f(focal_length*v_C[0]/v_C[2], focal_length*v_C[1]/v_C[2]);
+ }
PointOrder find_correspondences(const std::vector<cv::Vec2f>& projected_points, const PointModel &model);
int POSIT(const PointModel& point_model, const PointOrder& order); // The POSIT algorithm, returns the number of iterations
-
- FrameTrafo X_CM; // trafo from model to camera
+
+ FrameTrafo X_CM; // trafo from model to camera
};
#endif //POINTTRACKER_H
diff --git a/ftnoir_tracker_pt/pt_video_widget.h b/ftnoir_tracker_pt/pt_video_widget.h
index de2c7efb..f2b41d63 100644
--- a/ftnoir_tracker_pt/pt_video_widget.h
+++ b/ftnoir_tracker_pt/pt_video_widget.h
@@ -10,7 +10,7 @@
#include <QObject>
#include <QTime>
#include <QDialog>
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
#ifndef OPENTRACK_API
# include <QGLWidget>
# include <boost/shared_ptr.hpp>
diff --git a/ftnoir_tracker_pt/trans_calib.h b/ftnoir_tracker_pt/trans_calib.h
index 5c321b2c..c2c02b38 100644
--- a/ftnoir_tracker_pt/trans_calib.h
+++ b/ftnoir_tracker_pt/trans_calib.h
@@ -8,7 +8,7 @@
#ifndef TRANSCALIB_H
#define TRANSCALIB_H
-#include <opencv2/opencv.hpp>
+#include <opencv2/core/core.hpp>
//-----------------------------------------------------------------------------
// Calibrates the translation from head to model = t_MH