summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h
blob: 702f236ea0a4746230dbc0751c58b390e9cda205 (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
#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
#include "..\ftnoir_tracker_base\ftnoir_tracker_sm_types.h"
#include "ui_FTNoIR_SM_controls.h"

#include <QMessageBox>
#include <QSettings>
#include <QProcess>
#include "Windows.h"
#include "math.h"

using namespace std;

class FTNoIR_Tracker_SM : public ITracker
{
public:
	FTNoIR_Tracker_SM();
	~FTNoIR_Tracker_SM();

	void Release();
    void Initialize( QFrame *videoframe );
    void StartTracker( HWND parent_window );
    void StopTracker( bool exit );
	bool GiveHeadPoseData(THeadPoseData *data);				// Returns true if confidence is good
	void loadSettings();
	bool SMCreateMapping();

	bool setParameterValue(const int index, const float newvalue);

private:
	//
	// global variables
	//
	HANDLE hSMMemMap;
	SMMemMap *pMemData;
	HANDLE hSMMutex;
//	smEngineHeadPoseData new_head_pose;
	QProcess *faceAPI;

	enum
	{
		kPortAddress=0,										// Index in QList
		kNumFilterParameters								// Indicate number of parameters used
	};
	QList<std::pair<float,float>>	parameterRange;
	QList<float>					parameterValueAsFloat;

};

// Widget that has controls for SMoIR protocol client-settings.
class SMClientControls: public QWidget, Ui::UICSMClientControls, public ITrackerDialog
{
    Q_OBJECT
public:

	explicit SMClientControls();
    virtual ~SMClientControls();
	void showEvent ( QShowEvent * event );

	void Release();											// Member functions which are accessible from outside the DLL
    void Initialize(QWidget *parent);

private:
	Ui::UICSMClientControls ui;
	void loadSettings();
	void save();
	bool SMCreateMapping();
	void doCommand( int command );

	/** helper **/
	bool settingsDirty;

	//
	// global variables
	//
	HANDLE hSMMemMap;
	SMMemMap *pMemData;
	HANDLE hSMMutex;
    smEngineHandle *engine_handle;
	QTimer *timUpdateSettings;								// Timer to display current settings

private slots:
	void doOK();
	void doCancel();
	void settingChanged() { settingsDirty = true; };
	void showSettings();
	void doStartEngine(){
		doCommand(FT_SM_START);
	}
	void doStopEngine(){
		doCommand(FT_SM_STOP);
	}
	void doShowCam(){
		doCommand(FT_SM_SHOW_CAM);
	}
};