summaryrefslogtreecommitdiffhomepage
path: root/FTNoIR_Tracker_SM
diff options
context:
space:
mode:
Diffstat (limited to 'FTNoIR_Tracker_SM')
-rw-r--r--FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h9
-rw-r--r--FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj2
-rw-r--r--FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp52
3 files changed, 41 insertions, 22 deletions
diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h
index 0687730a..12bfbe80 100644
--- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h
+++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h
@@ -1,12 +1,14 @@
#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
#include "ui_FTNoIR_SMClientcontrols.h"
-#include <sm_api_qt.h>
+#include "sm_api_qt.h"
#include <QMessageBox>
#include <QSettings>
#include "Windows.h"
#include "math.h"
+using namespace std;
+//using namespace sm::faceapi::samplecode;
using namespace sm::faceapi;
using namespace sm::faceapi::qt;
@@ -19,7 +21,8 @@ public:
void Release();
void Initialize();
void StartTracker();
- void GiveHeadPoseData(THeadPoseData *data);
+ void StopTracker();
+ bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good
void loadSettings();
bool setParameterValue(const int index, const float newvalue);
@@ -30,8 +33,6 @@ private:
QSharedPointer<EngineBase> _engine;
smEngineHandle _engine_handle;
- THeadPoseData newHeadPose; // Structure with new headpose
-
//parameter list for the filter-function(s)
enum
{
diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj
index 243e919b..cf0cd64f 100644
--- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj
+++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj
@@ -38,7 +38,7 @@
/>
<Tool
Name="VCCLCompilerTool"
- AdditionalIncludeDirectories=".\GeneratedFiles;&quot;$(QTDIR)\include&quot;;&quot;.\GeneratedFiles\$(ConfigurationName)&quot;;&quot;$(QTDIR)\include\qtmain&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtNetwork&quot;;&quot;$(QTDIR)\include\QtGui&quot;;.\;&quot;$(SM_API_PATH)\include&quot;;&quot;$(SM_API_CPP_WRAPPERS)\include&quot;;&quot;$(SM_API_QTDIR)\include&quot;;&quot;$(SM_API_WIDGETS)\include&quot;"
+ AdditionalIncludeDirectories=".\GeneratedFiles;&quot;$(QTDIR)\include&quot;;&quot;.\GeneratedFiles\$(ConfigurationName)&quot;;&quot;$(QTDIR)\include\qtmain&quot;;&quot;$(QTDIR)\include\QtCore&quot;;&quot;$(QTDIR)\include\QtNetwork&quot;;&quot;$(QTDIR)\include\QtGui&quot;;.\;&quot;$(SM_API_PATH)\include&quot;;&quot;$(SM_API_CPP_WRAPPERS)\include&quot;;&quot;$(SM_API_WIDGETS)\include&quot;;&quot;$(SM_API_QTLIB)\include&quot;"
PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;FTNOIR_TRACKER_BASE_LIB"
RuntimeLibrary="2"
TreatWChar_tAsBuiltInType="false"
diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp
index 930ce090..ee1b049d 100644
--- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp
+++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp
@@ -1,7 +1,7 @@
#include "ftnoir_tracker_sm.h"
using namespace sm::faceapi;
-using namespace sm::faceapi::qt;
+//using namespace sm::faceapi::qt;
FTNoIR_Tracker_SM::FTNoIR_Tracker_SM()
{
@@ -13,17 +13,12 @@ FTNoIR_Tracker_SM::FTNoIR_Tracker_SM()
parameterRange.append(std::pair<float,float>(1000.0f,9999.0f));
parameterValueAsFloat.append(0.0f);
setParameterValue(kPortAddress,5551.0f);
-
- newHeadPose.x = 0.0f;
- newHeadPose.y = 0.0f;
- newHeadPose.z = 0.0f;
- newHeadPose.yaw = 0.0f;
- newHeadPose.pitch = 0.0f;
- newHeadPose.roll = 0.0f;
}
FTNoIR_Tracker_SM::~FTNoIR_Tracker_SM()
{
+ _engine->stop();
+ smAPIQuit();
}
void FTNoIR_Tracker_SM::Release()
@@ -52,8 +47,6 @@ void FTNoIR_Tracker_SM::Initialize()
CameraInfo::registerType(SM_API_CAMERA_TYPE_WDM);
_engine = QSharedPointer<HeadTrackerV2>(new HeadTrackerV2());
- // starts the faceapi engine
- _engine->start();
}
catch (sm::faceapi::Error &e)
{
@@ -66,20 +59,45 @@ void FTNoIR_Tracker_SM::Initialize()
void FTNoIR_Tracker_SM::StartTracker()
{
+
+ // starts the faceapi engine
+ if (_engine->state() != SM_API_ENGINE_STATE_HT_TRACKING) {
+ _engine->start();
+ }
+
+ // some parameteres [optional]
+ smHTSetHeadPosePredictionEnabled( _engine->handle(), false);
+ smHTSetLipTrackingEnabled( _engine->handle(), false);
+ smLoggingSetFileOutputEnable( false );
return;
}
-void FTNoIR_Tracker_SM::GiveHeadPoseData(THeadPoseData *data)
+void FTNoIR_Tracker_SM::StopTracker()
{
- data->x = newHeadPose.x;
- data->y = newHeadPose.y;
- data->z = newHeadPose.z;
- data->yaw = newHeadPose.yaw;
- data->pitch = newHeadPose.pitch;
- data->roll = newHeadPose.roll;
+
+ // stops the faceapi engine
+ _engine->stop();
return;
}
+bool FTNoIR_Tracker_SM::GiveHeadPoseData(THeadPoseData *data)
+{
+ smEngineHeadPoseData head_pose; // headpose from faceAPI
+ smEngineHeadPoseData temp_head_pose; // headpose from faceAPI
+
+ smReturnCode smret = smHTCurrentHeadPose(_engine->handle(), &temp_head_pose);
+ memcpy(&head_pose, &temp_head_pose, sizeof(smEngineHeadPoseData));
+
+ data->x = head_pose.head_pos.x * 100.0f; // From meters to centimeters
+ data->y = head_pose.head_pos.y * 100.0f;
+ data->z = head_pose.head_pos.z * 100.0f;
+ data->yaw = head_pose.head_rot.y_rads * 57.295781f; // From rads to degrees
+ data->pitch = head_pose.head_rot.x_rads * 57.295781f;
+ data->roll = head_pose.head_rot.z_rads * 57.295781f;
+
+ return ( head_pose.confidence > 0 );
+}
+
bool FTNoIR_Tracker_SM::setParameterValue(const int index, const float newvalue)
{
if ((index >= 0) && (index < parameterValueAsFloat.size()))