summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_hatire/ftnoir_tracker_hat.h
blob: ba96d91cdd7d16dd3449e067955b236d87e48445 (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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#ifndef FTNOIR_TRACKER_HAT_H
#define FTNOIR_TRACKER_HAT_H

#ifdef OPENTRACK_API
#   include "ftnoir_tracker_base/ftnoir_tracker_base.h"
#   include "facetracknoir/plugin-support.h"
#else
#	include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
#endif
#include "ftnoir_tracker_hat_settings.h"
#include "ftnoir_arduino_type.h"
#include <QObject>
#include <QPalette>
#include <QtGui>
#include <QByteArray>
#include <QMessageBox>
#include <QtSerialPort/QSerialPort>
#include <QtSerialPort/QSerialPortInfo>
#include <QMutex>
#include <QMutexLocker>
#include <QSettings>

#define VER_FILEVERSION_STR         "Version 2.1.0\0"

class FTNoIR_Tracker : public QObject, public ITracker 
{ 
  Q_OBJECT
public:
	FTNoIR_Tracker();
	~FTNoIR_Tracker();

#ifdef OPENTRACK_API
    void StartTracker(QFrame*);
    void GetHeadPoseData(double *data);
    int preferredHz();
    void center();
#else
    void Initialize( QFrame *videoframe );
    void StartTracker(HWND parent_window);
    void StopTracker(bool exit);
    bool GiveHeadPoseData(THeadPoseData *data);
    void notifyCenter();
#endif
	void applysettings(const TrackerSettings& settings);
	bool notifyZeroed();
	void reset();
	void SerialInfo();
	void sendcmd(const QByteArray &cmd);
	void get_info( int *tps );

private Q_SLOTS:
    void SerialRead();

signals:
    void sendMsgInfo(const QByteArray &MsgInfo);


private:
 	QSerialPort *ComPort;
    TArduinoData ArduinoData, HAT ;                              // Trame from Arduino
    QByteArray dataRead;
    QByteArray dataToSend;
	QByteArray Begin;
    QByteArray End;
	QMutex mutex;
	int frame_cnt;
    bool new_frame;

    TrackerSettings settings;

	bool bEnableRoll;
	bool bEnablePitch;
	bool bEnableYaw;
	bool bEnableX;
	bool bEnableY;
	bool bEnableZ;

	bool bInvertRoll;
	bool bInvertPitch;
	bool bInvertYaw;
	bool bInvertX;
	bool bInvertY;
	bool bInvertZ;

	int iRollAxe;
	int iPitchAxe;
	int iYawAxe;
	int iXAxe;
	int iYAxe;
	int iZAxe;

	QByteArray  sCmdStart;
	QByteArray  sCmdStop;
	QByteArray  sCmdInit;
	QByteArray  sCmdReset;
	QByteArray  sCmdCenter;
	QByteArray  sCmdZero;

	int iDelayInit;
	int iDelayStart;
	int iDelaySeq;

	bool bBigEndian;

	QString sSerialPortName;
	QSerialPort::BaudRate iBaudRate;
	QSerialPort::DataBits iDataBits;
	QSerialPort::Parity iParity;
	QSerialPort::StopBits iStopBits;
	QSerialPort::FlowControl iFlowControl;
#ifdef OPENTRACK_API
    int iFpsArduino;
#endif
    int CptError;


};


//*******************************************************************************************************
// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
//*******************************************************************************************************
class TrackerDll :
#if defined(OPENTRACK_API)
        public Metadata
#else
        public ITrackerDll
#endif
{
public:
	TrackerDll();
	~TrackerDll();

#ifndef OPENTRACK_API
	void Initialize();
#endif

	void getFullName(QString *strToBeFilled);
	void getShortName(QString *strToBeFilled);
	void getDescription(QString *strToBeFilled);
	void getIcon(QIcon *icon);

private:
	QString trackerFullName;									// Trackers' name and description
	QString trackerShortName;
	QString trackerDescription;
};


#endif // FTNOIR_TRACKER_HAT_H