summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/tracker.h
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2014-10-04 17:28:49 +0200
committerStanislaw Halik <sthalik@misaki.pl>2014-10-04 17:28:49 +0200
commit97bd173ee4b6f30c12ca590e213b21bbc83f8617 (patch)
tree41c6c2dc601ef78816c1fc27af1f0ba8b4d4ed0d /facetracknoir/tracker.h
parentb8c5e24223988c84331693371bb9b0d71b7ef821 (diff)
flush before windows breaks and data lossage
Diffstat (limited to 'facetracknoir/tracker.h')
-rw-r--r--facetracknoir/tracker.h77
1 files changed, 17 insertions, 60 deletions
diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h
index 54350164..05ae4180 100644
--- a/facetracknoir/tracker.h
+++ b/facetracknoir/tracker.h
@@ -11,85 +11,42 @@
#include <QDebug>
#include <QMutex>
#include "plugin-support.h"
+#include "mappings.hpp"
+
#include <vector>
+#include <atomic>
#include <qfunctionconfigurator/functionconfig.h>
#include "tracker_types.h"
#include "facetracknoir/main-settings.hpp"
#include "facetracknoir/options.h"
#include "facetracknoir/timer.hpp"
-using namespace options;
-class THeadPoseDOF {
-public:
- THeadPoseDOF(QString primary,
- QString secondary,
- int maxInput1,
- int maxOutput1,
- int maxInput2,
- int maxOutput2,
- axis_opts* opts) :
- headPos(0),
- curve(maxInput1, maxOutput1),
- curveAlt(maxInput2, maxOutput2),
- opts(*opts),
- name1(primary),
- name2(secondary)
- {
- QSettings settings("opentrack");
- QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/settings/default.ini" ).toString();
- QSettings iniFile( currentFile, QSettings::IniFormat );
- curve.loadSettings(iniFile, primary);
- curveAlt.loadSettings(iniFile, secondary);
- }
- volatile double headPos;
- FunctionConfig curve;
- FunctionConfig curveAlt;
- axis_opts& opts;
- QString name1, name2;
-};
-class FaceTrackNoIR;
class Tracker : protected QThread {
- Q_OBJECT
-
+ Q_OBJECT
private:
- FaceTrackNoIR *mainApp;
QMutex mtx;
main_settings& s;
- volatile bool should_quit;
+ // XXX can be const-cast when functionconfig const-correct -sh 20141004
+ Mappings& m;
Timer t;
-protected:
- void run();
+ T6DOF output_pose, raw_6dof;
+ std::atomic<bool> centerp;
+ std::atomic<bool> enabledp;
+ std::atomic<bool> should_quit;
+ static void get_curve(double pos, double& out, Mapping& axis);
+protected:
+ void run() override;
public:
- Tracker( FaceTrackNoIR *parent, main_settings& s);
+ Tracker(main_settings& s, Mappings& m);
~Tracker();
- void getHeadPose(double *data);
- void getOutputHeadPose(double *data);
- volatile bool do_center;
- volatile bool enabled;
-
- T6DOF output_camera, raw_6dof;
-
+ void get_raw_and_mapped_poses(double* mapped, double* raw) const;
void start() { QThread::start(); }
+ void center() { centerp.store(true); }
+ void toggle_enabled() { enabledp.store(!enabledp.load()); }
};
-
-class HeadPoseData {
-public:
- THeadPoseDOF axes[6];
- HeadPoseData(std::vector<axis_opts*> opts) :
- axes {
- THeadPoseDOF("tx","tx_alt", 100, 100, 100, 100, opts[TX]),
- THeadPoseDOF("ty","ty_alt", 100, 100, 100, 100, opts[TY]),
- THeadPoseDOF("tz","tz_alt", 100, 100, 100, 100, opts[TZ]),
- THeadPoseDOF("rx", "rx_alt", 180, 180, 180, 180, opts[Yaw]),
- THeadPoseDOF("ry", "ry_alt", 90, 90, 90, 90, opts[Pitch]),
- THeadPoseDOF("rz", "rz_alt", 180, 180, 180, 180, opts[Roll])
- }
- {}
-};
-
#endif