summaryrefslogtreecommitdiffhomepage
path: root/faceAPI
diff options
context:
space:
mode:
authorWim Vriend <facetracknoir@gmail.com>2011-03-22 21:34:47 +0000
committerWim Vriend <facetracknoir@gmail.com>2011-03-22 21:34:47 +0000
commit277cc7603eb6b4d9fed6a0a2de245e4cdde6ee8b (patch)
tree1774fa28018005e4c96f5717d6d461dfb0123d5f /faceAPI
parentbe57b6b8d3f8339980df08f196d23415f7974418 (diff)
Successfully use console app for faceAPI 3.2.6. combined with tracker class in DLL.
Even managed to get the video-widget connected to the main-window... git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@56 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb
Diffstat (limited to 'faceAPI')
-rw-r--r--faceAPI/FaceAPI2FSX.vcproj233
-rw-r--r--faceAPI/main.cpp95
-rw-r--r--faceAPI/utils.h26
3 files changed, 316 insertions, 38 deletions
diff --git a/faceAPI/FaceAPI2FSX.vcproj b/faceAPI/FaceAPI2FSX.vcproj
new file mode 100644
index 00000000..e936c79c
--- /dev/null
+++ b/faceAPI/FaceAPI2FSX.vcproj
@@ -0,0 +1,233 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8.00"
+ Name="FTNoIR_FaceAPI_EXE"
+ ProjectGUID="{EF743D32-0980-44D9-BA9E-B9D2456251AC}"
+ RootNamespace="TestAppConsole"
+ Keyword="Win32Proj"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(ProjectDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine=""
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ CommandLine=""
+ Outputs=""
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="C:\Program Files\SeeingMachines\FaceTrackingAPI_NC 3.2\API\include"
+ PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE"
+ MinimalRebuild="true"
+ BasicRuntimeChecks="3"
+ RuntimeLibrary="3"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="4"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="smft32.lib user32.lib"
+ LinkIncremental="2"
+ AdditionalLibraryDirectories="..\..\FaceAPI\bin;..\..\SimConnect"
+ IgnoreDefaultLibraryNames=""
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine=""
+ />
+ </Configuration>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(ProjectDir)$(ConfigurationName)"
+ IntermediateDirectory="$(ProjectDir)$(ConfigurationName)"
+ ConfigurationType="1"
+ CharacterSet="1"
+ WholeProgramOptimization="1"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ CommandLine=""
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="&quot;C:\Program Files\SeeingMachines\FaceTrackingAPI_NC 3.2\API\include&quot;;..\FTNoIR_Tracker_Base"
+ PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE"
+ RuntimeLibrary="2"
+ UsePrecompiledHeader="0"
+ WarningLevel="4"
+ Detect64BitPortabilityProblems="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="smft32.lib user32.lib"
+ OutputFile="..\bin\$(ProjectName).exe"
+ LinkIncremental="1"
+ AdditionalLibraryDirectories="&quot;C:\Program Files\SeeingMachines\FaceTrackingAPI_NC 3.2\API\bin&quot;"
+ GenerateDebugInformation="true"
+ SubSystem="1"
+ OptimizeReferences="2"
+ EnableCOMDATFolding="2"
+ TargetMachine="1"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ CommandLine=""
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Headers"
+ >
+ <File
+ RelativePath=".\build_options.h"
+ >
+ </File>
+ <File
+ RelativePath="..\FTNoIR_Tracker_Base\ftnoir_tracker_sm_types.h"
+ >
+ </File>
+ <File
+ RelativePath=".\lock.h"
+ >
+ </File>
+ <File
+ RelativePath=".\lockfree.h"
+ >
+ </File>
+ <File
+ RelativePath=".\mutex.h"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.h"
+ >
+ </File>
+ <File
+ RelativePath=".\utils.h"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Sources"
+ >
+ <File
+ RelativePath=".\main.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\stdafx.cpp"
+ >
+ </File>
+ </Filter>
+ </Files>
+ <Globals>
+ </Globals>
+</VisualStudioProject>
diff --git a/faceAPI/main.cpp b/faceAPI/main.cpp
index f1c5f768..3b260dca 100644
--- a/faceAPI/main.cpp
+++ b/faceAPI/main.cpp
@@ -1,9 +1,33 @@
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
-//
-// FaceAPI2FSX program implementation
-// Merges the old CockpitCamera.cpp and TestAppConsole.cpp into a single file
-//
-//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+/********************************************************************************
+* FaceTrackNoIR This program is a private project of the some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2011 Wim Vriend (Developing) *
+* Ron Hendriks (Researching and Testing) *
+* *
+* Homepage *
+* *
+* This program is free software; you can redistribute it and/or modify it *
+* under the terms of the GNU General Public License as published by the *
+* Free Software Foundation; either version 3 of the License, or (at your *
+* option) any later version. *
+* *
+* This program is distributed in the hope that it will be useful, but *
+* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
+* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for *
+* more details. *
+* *
+* You should have received a copy of the GNU General Public License along *
+* with this program; if not, see <http://www.gnu.org/licenses/>. *
+*********************************************************************************/
+/*
+ Modifications (last one on top):
+ 20110322 - WVR: Somehow the video-widget of faceAPI version 3.2.6. does not
+ work with FaceTrackNoIR (Qt issue?!). To be able to use
+ release 3.2.6 of faceAPI anyway, this console-app is used.
+ It exchanges data with FaceTrackNoIR via shared-memory...
+*/
//Precompiled header
#include "stdafx.h"
@@ -184,7 +208,8 @@ smCameraHandle createFirstCamera()
// The main function: setup a tracking engine and show a video window, then loop on the keyboard.
void run()
{
- // Capture control-C
+ char msg[100];
+ // Capture control-C
// signal(SIGINT, CtrlCHandler);
// Make the console window a bit bigger (see utils.h)
@@ -295,7 +320,12 @@ void run()
// Create and show a video-display window
smVideoDisplayHandle video_display_handle = 0;
- THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,0,TRUE));
+ if (pMemData) {
+ THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,(smWindowHandle) pMemData->handle,TRUE));
+ }
+ else {
+ THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,0,TRUE));
+ }
// Setup the VideoDisplay
THROW_ON_ERROR(smVideoDisplaySetFlags(video_display_handle,g_overlay_flags));
@@ -304,9 +334,7 @@ void run()
smWindowHandle win_handle = 0;
THROW_ON_ERROR(smVideoDisplayGetWindowHandle(video_display_handle,&win_handle));
SetWindowText(win_handle, _T("faceAPI Video-widget"));
-
- // Start tracking
- THROW_ON_ERROR(smEngineStart(engine_handle));
+ MoveWindow(win_handle, 0, 0, 250, 150, true);
// Loop on the keyboard
while (processKeyPress(engine_handle, video_display_handle) && !stopCommand)
@@ -335,7 +363,37 @@ void run()
// Prevent CPU overload in our simple loop.
const int frame_period_ms = 10;
Sleep(frame_period_ms);
- }
+
+ //
+ // Process the command sent by FaceTrackNoIR.
+ //
+ sprintf_s(msg, "Command: %d\n", pMemData->command);
+ OutputDebugStringA(msg);
+ if (pMemData) {
+ switch (pMemData->command) {
+ case FT_SM_START:
+ THROW_ON_ERROR(smEngineStart(engine_handle)); // Start tracking
+ pMemData->command = 0; // Reset
+ break;
+
+ case FT_SM_STOP:
+ THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking
+ pMemData->command = 0; // Reset
+ break;
+
+ case FT_SM_EXIT:
+ THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking
+ stopCommand = TRUE;
+ pMemData->command = 0; // Reset
+ break;
+
+ default:
+ pMemData->command = 0; // Reset
+ // should never be reached
+ break;
+ }
+ }
+ } // While(1)
// Destroy engine
THROW_ON_ERROR(smEngineDestroy(&engine_handle));
@@ -382,33 +440,20 @@ int _tmain(int /*argc*/, _TCHAR** /*argv*/)
//
void updateHeadPose(smEngineHeadPoseData* temp_head_pose)
{
- char msg[100];
-
- OutputDebugString(_T("updateHeadPose() says: Starting Function\n"));
-
//
// Check if the pointer is OK and wait for the Mutex.
//
if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) {
- OutputDebugString(_T("updateHeadPose() says: Writing Data\n"));
-
//
// Copy the Raw measurements directly to the client.
//
if (temp_head_pose->confidence > 0.0f)
{
memcpy(&pMemData->data.new_pose,temp_head_pose,sizeof(smEngineHeadPoseData));
- sprintf(msg, "HeadPose Yaw: %.2f\n", pMemData->data.new_pose.head_rot.x_rads);
- OutputDebugStringA(msg);
- }
-
- if (pMemData->command == 100) {
- stopCommand = TRUE;
}
ReleaseMutex(hSMMutex);
}
-
};
//
diff --git a/faceAPI/utils.h b/faceAPI/utils.h
index 9c67665e..1fdb35b5 100644
--- a/faceAPI/utils.h
+++ b/faceAPI/utils.h
@@ -25,7 +25,7 @@ namespace sm
bool g_ctrl_c_detected(false);
bool g_do_head_pose_printing(false);
bool g_do_face_data_printing(false);
- unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH);
+ unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH | SM_API_VIDEO_DISPLAY_PERFORMANCE);
// CTRL-C handler function
void __cdecl CtrlCHandler(int)
@@ -324,20 +324,20 @@ namespace sm
{
HANDLE console_handle = GetStdHandle(STD_OUTPUT_HANDLE);
// Buffer of 255 x 1024
- ////COORD buffer_size;
- ////buffer_size.X = 255;
- ////buffer_size.Y = 1024;
- ////SetConsoleScreenBufferSize(console_handle, buffer_size);
- ////// Window size of 120 x 50
- ////SMALL_RECT window_size;
- ////window_size.Left = 0;
- ////window_size.Right = 20;
- ////window_size.Top = 0;
- ////window_size.Bottom = 20;
- ////SetConsoleWindowInfo(console_handle,TRUE,&window_size);
+ COORD buffer_size;
+ buffer_size.X = 255;
+ buffer_size.Y = 1024;
+ SetConsoleScreenBufferSize(console_handle, buffer_size);
+ // Window size of 120 x 50
+ SMALL_RECT window_size;
+ window_size.Left = 0;
+ window_size.Right = 120;
+ window_size.Top = 0;
+ window_size.Bottom = 50;
+ SetConsoleWindowInfo(console_handle,TRUE,&window_size);
// Green text
SetConsoleTextAttribute(console_handle, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
- ShowWindow(GetConsoleWindow(), SW_HIDE);
+// ShowWindow(GetConsoleWindow(), SW_HIDE);
}
}
}