summaryrefslogtreecommitdiffhomepage
path: root/facetracknoir/tracker.h
blob: 543501640c54967b069cfb6301b0eaca8d26f231 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef __TRACKER_H__
#define __TRACKER_H__

#include <QThread>
#include <QMessageBox>
#include <QLineEdit>
#include <QPoint>
#include <QWaitCondition>
#include <QList>
#include <QPainterPath>
#include <QDebug>
#include <QMutex>
#include "plugin-support.h"
#include <vector>

#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

private:
    FaceTrackNoIR *mainApp;
    QMutex mtx;
    main_settings& s;
    volatile bool should_quit;
    Timer t;
protected:
	void run();

public:
    Tracker( FaceTrackNoIR *parent, main_settings& s);
    ~Tracker();

    void getHeadPose(double *data);
    void getOutputHeadPose(double *data);
    volatile bool do_center;
    volatile bool enabled;
    
    T6DOF output_camera, raw_6dof;

    void start() { QThread::start(); }
};

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