diff options
Diffstat (limited to 'ftnoir_tracker_fd')
-rw-r--r-- | ftnoir_tracker_fd/FTNoIR_FD_Controls.ui | 152 | ||||
-rw-r--r-- | ftnoir_tracker_fd/FTNoIR_Tracker_FD.h | 114 | ||||
-rw-r--r-- | ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj | 379 | ||||
-rw-r--r-- | ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj | 376 | ||||
-rw-r--r-- | ftnoir_tracker_fd/Tracker.qrc | 5 | ||||
-rw-r--r-- | ftnoir_tracker_fd/face-detect.h | 39 | ||||
-rw-r--r-- | ftnoir_tracker_fd/ftnoir_tracker_facedetect.cpp | 214 | ||||
-rw-r--r-- | ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp | 180 | ||||
-rw-r--r-- | ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp | 85 | ||||
-rw-r--r-- | ftnoir_tracker_fd/images/FaceDetect.ico | bin | 0 -> 5430 bytes |
10 files changed, 1544 insertions, 0 deletions
diff --git a/ftnoir_tracker_fd/FTNoIR_FD_Controls.ui b/ftnoir_tracker_fd/FTNoIR_FD_Controls.ui new file mode 100644 index 00000000..0bb8028f --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_FD_Controls.ui @@ -0,0 +1,152 @@ +<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>UICFDClientControls</class>
+ <widget class="QWidget" name="UICFDClientControls">
+ <property name="windowModality">
+ <enum>Qt::ApplicationModal</enum>
+ </property>
+ <property name="geometry">
+ <rect>
+ <x>0</x>
+ <y>0</y>
+ <width>283</width>
+ <height>151</height>
+ </rect>
+ </property>
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Preferred" vsizetype="Preferred">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="windowTitle">
+ <string>FaceDetect tracker settings</string>
+ </property>
+ <property name="windowIcon">
+ <iconset>
+ <normaloff>images/FaceTrackNoIR.ico</normaloff>images/FaceTrackNoIR.ico</iconset>
+ </property>
+ <property name="layoutDirection">
+ <enum>Qt::LeftToRight</enum>
+ </property>
+ <property name="autoFillBackground">
+ <bool>false</bool>
+ </property>
+ <layout class="QFormLayout" name="formLayout_2">
+ <property name="sizeConstraint">
+ <enum>QLayout::SetFixedSize</enum>
+ </property>
+ <item row="0" column="0">
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <layout class="QVBoxLayout" name="verticalLayout">
+ <item>
+ <layout class="QFormLayout" name="formLayout">
+ <property name="fieldGrowthPolicy">
+ <enum>QFormLayout::AllNonFixedFieldsGrow</enum>
+ </property>
+ <item row="1" column="0">
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Changes take effect after tracker restart.</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="0">
+ <widget class="QLabel" name="label_9">
+ <property name="text">
+ <string>Camera (indices from 0)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="2" column="1">
+ <widget class="QSpinBox" name="cameraId">
+ <property name="maximum">
+ <number>100</number>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="0">
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Haar detection timeout (ms)</string>
+ </property>
+ </widget>
+ </item>
+ <item row="3" column="1">
+ <widget class="QSpinBox" name="redetect_ms">
+ <property name="maximum">
+ <number>2000</number>
+ </property>
+ <property name="singleStep">
+ <number>50</number>
+ </property>
+ <property name="value">
+ <number>200</number>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="0">
+ <widget class="QLabel" name="label_10">
+ <property name="text">
+ <string>Video Widget</string>
+ </property>
+ </widget>
+ </item>
+ <item row="5" column="1">
+ <widget class="QCheckBox" name="videoWidget">
+ <property name="layoutDirection">
+ <enum>Qt::RightToLeft</enum>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="okButton">
+ <property name="text">
+ <string>OK</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </widget>
+ <resources/>
+ <connections/>
+ <slots>
+ <slot>startEngineClicked()</slot>
+ <slot>stopEngineClicked()</slot>
+ <slot>cameraSettingsClicked()</slot>
+ </slots>
+</ui>
diff --git a/ftnoir_tracker_fd/FTNoIR_Tracker_FD.h b/ftnoir_tracker_fd/FTNoIR_Tracker_FD.h new file mode 100644 index 00000000..02e95bb4 --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_Tracker_FD.h @@ -0,0 +1,114 @@ +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h"
+#include "face-detect.h"
+#include "ui_FTNoIR_FD_controls.h"
+
+#include <Qt>
+#include <QtCore/QEvent>
+#include <Qt/qt_windows.h>
+
+#include <QMessageBox>
+#include <QSettings>
+#include <QProcess>
+#include "math.h"
+#include <Windows.h>
+
+using namespace std;
+
+static LPTSTR prog_cmdline = (LPTSTR) TEXT("face-detect.exe");
+static LPTSTR fd_shm_name = (LPTSTR) TEXT("face-detect-shm");
+static LPTSTR fd_mutex_name = (LPTSTR) TEXT("face-detect-mutex");
+
+class VideoWidget : public QWidget
+{
+ Q_OBJECT
+public:
+ VideoWidget(HANDLE hMutex, unsigned char* data, struct face_detect_shm* shm);
+protected:
+ void paintEvent(QPaintEvent*);
+private:
+ HANDLE hMutex;
+ unsigned char* data;
+ struct face_detect_shm* shm;
+};
+
+class FTNoIR_Tracker : public ITracker
+{
+public:
+ FTNoIR_Tracker();
+ ~FTNoIR_Tracker();
+
+ 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 setParameterValue(const int index, const float newvalue);
+ bool notifyZeroed();
+ void refreshVideo();
+
+private:
+ bool activep;
+ //QList<std::pair<float,float>> parameterRange;
+ //QList<float> parameterValueAsFloat;
+ void TerminateTracker();
+ HANDLE hMutex, hMapFile;
+ struct face_detect_shm* shm;
+ PROCESS_INFORMATION procInfo;
+ VideoWidget* ctrl;
+ QFrame* qframe;
+};
+
+class TrackerControls: public QWidget, Ui::UICFDClientControls, public ITrackerDialog
+{
+ Q_OBJECT
+public:
+
+ explicit TrackerControls();
+ virtual ~TrackerControls();
+ void Release(); // Member functions which are accessible from outside the DLL
+ void Initialize(QWidget *parent);
+ void registerTracker(ITracker *tracker) {};
+ void unRegisterTracker() {};
+ void NotifyZeroing();
+
+private:
+ Ui::UICFDClientControls ui;
+ void loadSettings();
+ void save();
+
+ bool settingsDirty;
+ HANDLE hMapFile, hMutex;
+ struct face_detect_shm* shm;
+
+private slots:
+ void doOK();
+ void doCancel();
+ void settingChanged() { settingsDirty = true; };
+ void doSetRedetectMs(int val);
+ void doSetCameraId(int val);
+ void doSetVideoWidget(bool val);
+signals:
+};
+
+//*******************************************************************************************************
+// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker
+//*******************************************************************************************************
+class FTNoIR_TrackerDll : public ITrackerDll
+{
+public:
+ FTNoIR_TrackerDll();
+ ~FTNoIR_TrackerDll();
+
+ void Initialize();
+
+ 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;
+};
diff --git a/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj new file mode 100644 index 00000000..74fa6fec --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj @@ -0,0 +1,379 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="8,00"
+ Name="FTNoIR_Tracker_FD"
+ ProjectGUID="{0FE16301-240D-42B9-9141-12294BA08AC4}"
+ RootNamespace="FTNoIR_Tracker_FD"
+ Keyword="Qt4VSv1.0"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)\bin"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories="".\GeneratedFiles";"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\qtmain";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtGui";".\";"$(QTDIR)\include\QtOpenGL""
+ PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;FTNOIR_TRACKER_BASE_LIB;QT_DLL;QT_OPENGL_LIB"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmain.lib QtCore4.lib QtGui4.lib QtNetwork4.lib gdiplus.lib QtOpenGLd4.lib opengl32.lib glu32.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ AdditionalLibraryDirectories=""$(QTDIR)\lib";"C:\Users\sthalik\Documents\facetracknoir\face-detect""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ OptimizeReferences="1"
+ EnableCOMDATFolding="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"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)/bin_dbg"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories="".\GeneratedFiles";"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\qtmain";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtGui";".\";"$(QTDIR)\include\QtOpenGL""
+ PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_CORE_LIB;FTNOIR_TRACKER_BASE_LIB;QT_DLL;QT_OPENGL_LIB"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmaind.lib QtCored4.lib QtGuid4.lib QtNetworkd4.lib gdiplus.lib QtOpenGLd4.lib opengl32.lib glu32.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ AdditionalLibraryDirectories="$(QTDIR)\lib"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCWebDeploymentTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;cxx;c;def"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\ftnoir_tracker_facedetect.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ftnoir_tracker_facedetect_dialog.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ftnoir_tracker_facedetect_dll.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\face-detect.h"
+ >
+ </File>
+ <File
+ RelativePath="..\FTNoIR_Tracker_Base\ftnoir_tracker_base.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FTNoIR_Tracker_FD.h"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Moc'ing FTNoIR_Tracker_FD.h..."
+ CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_DLL -D_WINDLL "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtGui" "-I."
"
+ AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
+ Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Moc'ing FTNoIR_Tracker_FD.h..."
+ CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_CORE_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_DLL -D_WINDLL "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtGui" "-I."
"
+ AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
+ Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Form Files"
+ Filter="ui"
+ UniqueIdentifier="{99349809-55BA-4b9d-BF79-8FDBB0286EB3}"
+ >
+ <File
+ RelativePath=".\FTNoIR_FD_Controls.ui"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Uic'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
"
+ AdditionalDependencies="$(QTDIR)\bin\uic.exe"
+ Outputs="".\GeneratedFiles\ui_$(InputName).h""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Uic'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
"
+ AdditionalDependencies="$(QTDIR)\bin\uic.exe"
+ Outputs="".\GeneratedFiles\ui_$(InputName).h""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="qrc;*"
+ UniqueIdentifier="{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}"
+ ParseFiles="false"
+ >
+ <File
+ RelativePath=".\Tracker.qrc"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\rcc.exe" -name "$(InputName)" -no-compress "$(InputPath)" -o .\GeneratedFiles\qrc_$(InputName).cpp
"
+ AdditionalDependencies="$(InputPath);.\images\Visage.ico"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\rcc.exe" -name "$(InputName)" -no-compress "$(InputPath)" -o .\GeneratedFiles\qrc_$(InputName).cpp
"
+ AdditionalDependencies="$(InputPath);.\images\Visage.ico"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Generated Files"
+ Filter="moc;h;cpp"
+ UniqueIdentifier="{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}"
+ >
+ <File
+ RelativePath=".\generatedfiles\qrc_Tracker.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <Filter
+ Name="Release"
+ Filter="cpp;moc"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\generatedfiles\release\moc_FTNoIR_Tracker_FD.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Debug"
+ Filter="cpp;moc"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\GeneratedFiles\Debug\moc_FTNoIR_Tracker_FD.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ <Global
+ Name="lupdateOnBuild"
+ Value="1"
+ />
+ <Global
+ Name="MocDir"
+ Value=".\GeneratedFiles\$(ConfigurationName)"
+ />
+ <Global
+ Name="MocOptions"
+ Value=""
+ />
+ <Global
+ Name="QtVersion Win32"
+ Value="4.6.2"
+ />
+ <Global
+ Name="RccDir"
+ Value=".\GeneratedFiles"
+ />
+ <Global
+ Name="UicDir"
+ Value=".\GeneratedFiles"
+ />
+ </Globals>
+</VisualStudioProject>
diff --git a/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj new file mode 100644 index 00000000..a37729e1 --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj @@ -0,0 +1,376 @@ +<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+ ProjectType="Visual C++"
+ Version="9,00"
+ Name="FTNoIR_Tracker_FD"
+ ProjectGUID="{0FE16301-240D-42B9-9141-12294BA08AC4}"
+ RootNamespace="FTNoIR_Tracker_FD"
+ Keyword="Qt4VSv1.0"
+ TargetFrameworkVersion="131072"
+ >
+ <Platforms>
+ <Platform
+ Name="Win32"
+ />
+ </Platforms>
+ <ToolFiles>
+ </ToolFiles>
+ <Configurations>
+ <Configuration
+ Name="Release|Win32"
+ OutputDirectory="$(SolutionDir)\bin"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ AdditionalIncludeDirectories=".\GeneratedFiles;"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\qtmain";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtGui";.\"
+ PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_NO_DEBUG;NDEBUG;QT_CORE_LIB;FTNOIR_TRACKER_BASE_LIB;QT_DLL"
+ RuntimeLibrary="2"
+ TreatWChar_tAsBuiltInType="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmain.lib QtCore4.lib QtGui4.lib QtNetwork4.lib gdiplus.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ AdditionalLibraryDirectories=""$(QTDIR)\lib";"C:\Users\sthalik\Documents\facetracknoir\face-detect""
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ <Configuration
+ Name="Debug|Win32"
+ OutputDirectory="$(SolutionDir)/bin_dbg"
+ IntermediateDirectory="$(ConfigurationName)"
+ ConfigurationType="2"
+ >
+ <Tool
+ Name="VCPreBuildEventTool"
+ />
+ <Tool
+ Name="VCCustomBuildTool"
+ />
+ <Tool
+ Name="VCXMLDataGeneratorTool"
+ />
+ <Tool
+ Name="VCWebServiceProxyGeneratorTool"
+ />
+ <Tool
+ Name="VCMIDLTool"
+ />
+ <Tool
+ Name="VCCLCompilerTool"
+ Optimization="0"
+ AdditionalIncludeDirectories=".\GeneratedFiles;"$(QTDIR)\include";".\GeneratedFiles\$(ConfigurationName)";"$(QTDIR)\include\qtmain";"$(QTDIR)\include\QtCore";"$(QTDIR)\include\QtNetwork";"$(QTDIR)\include\QtGui";.\"
+ PreprocessorDefinitions="UNICODE;WIN32;QT_LARGEFILE_SUPPORT;QT_THREAD_SUPPORT;QT_CORE_LIB;FTNOIR_TRACKER_BASE_LIB;QT_DLL"
+ RuntimeLibrary="3"
+ TreatWChar_tAsBuiltInType="false"
+ DebugInformationFormat="3"
+ />
+ <Tool
+ Name="VCManagedResourceCompilerTool"
+ />
+ <Tool
+ Name="VCResourceCompilerTool"
+ />
+ <Tool
+ Name="VCPreLinkEventTool"
+ />
+ <Tool
+ Name="VCLinkerTool"
+ AdditionalDependencies="qtmaind.lib QtCored4.lib QtGuid4.lib QtNetworkd4.lib gdiplus.lib"
+ OutputFile="$(OutDir)\$(ProjectName).dll"
+ AdditionalLibraryDirectories="$(QTDIR)\lib"
+ GenerateDebugInformation="true"
+ SubSystem="2"
+ RandomizedBaseAddress="1"
+ DataExecutionPrevention="0"
+ />
+ <Tool
+ Name="VCALinkTool"
+ />
+ <Tool
+ Name="VCManifestTool"
+ />
+ <Tool
+ Name="VCXDCMakeTool"
+ />
+ <Tool
+ Name="VCBscMakeTool"
+ />
+ <Tool
+ Name="VCFxCopTool"
+ />
+ <Tool
+ Name="VCAppVerifierTool"
+ />
+ <Tool
+ Name="VCPostBuildEventTool"
+ />
+ </Configuration>
+ </Configurations>
+ <References>
+ </References>
+ <Files>
+ <Filter
+ Name="Source Files"
+ Filter="cpp;cxx;c;def"
+ UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
+ >
+ <File
+ RelativePath=".\ftnoir_tracker_facedetect.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ftnoir_tracker_facedetect_dialog.cpp"
+ >
+ </File>
+ <File
+ RelativePath=".\ftnoir_tracker_facedetect_dll.cpp"
+ >
+ </File>
+ </Filter>
+ <Filter
+ Name="Header Files"
+ Filter="h"
+ UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
+ >
+ <File
+ RelativePath=".\face-detect.h"
+ >
+ </File>
+ <File
+ RelativePath="..\FTNoIR_Tracker_Base\ftnoir_tracker_base.h"
+ >
+ </File>
+ <File
+ RelativePath=".\FTNoIR_Tracker_FD.h"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Moc'ing FTNoIR_Tracker_FD.h..."
+ CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_NO_DEBUG -DNDEBUG -DQT_CORE_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_DLL -D_WINDLL "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtGui" "-I."
"
+ AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
+ Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Moc'ing FTNoIR_Tracker_FD.h..."
+ CommandLine=""$(QTDIR)\bin\moc.exe" "$(InputPath)" -o ".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp" -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_THREAD_SUPPORT -DQT_CORE_LIB -DFTNOIR_TRACKER_BASE_LIB -DQT_DLL -D_WINDLL "-I.\GeneratedFiles" "-I$(QTDIR)\include" "-I.\GeneratedFiles\$(ConfigurationName)\." "-I$(QTDIR)\include\qtmain" "-I$(QTDIR)\include\QtCore" "-I$(QTDIR)\include\QtNetwork" "-I$(QTDIR)\include\QtGui" "-I."
"
+ AdditionalDependencies=""$(QTDIR)\bin\moc.exe";$(InputPath)"
+ Outputs="".\GeneratedFiles\$(ConfigurationName)\moc_$(InputName).cpp""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Form Files"
+ Filter="ui"
+ UniqueIdentifier="{99349809-55BA-4b9d-BF79-8FDBB0286EB3}"
+ >
+ <File
+ RelativePath=".\FTNoIR_FD_Controls.ui"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Uic'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
"
+ AdditionalDependencies="$(QTDIR)\bin\uic.exe"
+ Outputs="".\GeneratedFiles\ui_$(InputName).h""
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Uic'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\uic.exe" -o ".\GeneratedFiles\ui_$(InputName).h" "$(InputPath)"
"
+ AdditionalDependencies="$(QTDIR)\bin\uic.exe"
+ Outputs="".\GeneratedFiles\ui_$(InputName).h""
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Resource Files"
+ Filter="qrc;*"
+ UniqueIdentifier="{D9D6E242-F8AF-46E4-B9FD-80ECBC20BA3E}"
+ ParseFiles="false"
+ >
+ <File
+ RelativePath=".\Tracker.qrc"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\rcc.exe" -name "$(InputName)" -no-compress "$(InputPath)" -o .\GeneratedFiles\qrc_$(InputName).cpp
"
+ AdditionalDependencies="$(InputPath);.\images\Visage.ico"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCustomBuildTool"
+ Description="Rcc'ing $(InputFileName)..."
+ CommandLine=""$(QTDIR)\bin\rcc.exe" -name "$(InputName)" -no-compress "$(InputPath)" -o .\GeneratedFiles\qrc_$(InputName).cpp
"
+ AdditionalDependencies="$(InputPath);.\images\Visage.ico"
+ Outputs=".\GeneratedFiles\qrc_$(InputName).cpp"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Generated Files"
+ Filter="moc;h;cpp"
+ UniqueIdentifier="{71ED8ED8-ACB9-4CE9-BBE1-E00B30144E11}"
+ >
+ <File
+ RelativePath=".\generatedfiles\qrc_Tracker.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ <FileConfiguration
+ Name="Debug|Win32"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ UsePrecompiledHeader="0"
+ />
+ </FileConfiguration>
+ </File>
+ <Filter
+ Name="Release"
+ Filter="cpp;moc"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\generatedfiles\release\moc_FTNoIR_Tracker_FD.cpp"
+ >
+ <FileConfiguration
+ Name="Debug|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ <Filter
+ Name="Debug"
+ Filter="cpp;moc"
+ SourceControlFiles="false"
+ >
+ <File
+ RelativePath=".\GeneratedFiles\Debug\moc_FTNoIR_Tracker_FD.cpp"
+ >
+ <FileConfiguration
+ Name="Release|Win32"
+ ExcludedFromBuild="true"
+ >
+ <Tool
+ Name="VCCLCompilerTool"
+ />
+ </FileConfiguration>
+ </File>
+ </Filter>
+ </Filter>
+ </Files>
+ <Globals>
+ <Global
+ Name="lupdateOnBuild"
+ Value="0"
+ />
+ <Global
+ Name="MocDir"
+ Value=".\GeneratedFiles\$(ConfigurationName)"
+ />
+ <Global
+ Name="MocOptions"
+ Value=""
+ />
+ <Global
+ Name="QtVersion Win32"
+ Value="$(DefaultQtVersion)"
+ />
+ <Global
+ Name="RccDir"
+ Value=".\GeneratedFiles"
+ />
+ <Global
+ Name="UicDir"
+ Value=".\GeneratedFiles"
+ />
+ </Globals>
+</VisualStudioProject>
diff --git a/ftnoir_tracker_fd/Tracker.qrc b/ftnoir_tracker_fd/Tracker.qrc new file mode 100644 index 00000000..d988ba71 --- /dev/null +++ b/ftnoir_tracker_fd/Tracker.qrc @@ -0,0 +1,5 @@ +<RCC> + <qresource prefix="/"> + <file>images/FaceDetect.ico</file> + </qresource> +</RCC> diff --git a/ftnoir_tracker_fd/face-detect.h b/ftnoir_tracker_fd/face-detect.h new file mode 100644 index 00000000..fc359c53 --- /dev/null +++ b/ftnoir_tracker_fd/face-detect.h @@ -0,0 +1,39 @@ +#if defined(_WIN32) || defined(WIN32) +# ifdef __cplusplus +# define FDAPI_EXTERN extern "C" +# else +# define FDAPI_EXTERN +# endif +# define FDAPI(ret) FDAPI_EXTERN __declspec(dllexport) ret __cdecl +#else +# define FDAPI(ret) ret +#endif + +struct face_detect_settings { + unsigned char magic, quit, newOutput, widgetp; + int redetect_ms, camera_id; +}; + +struct face_detect; +FDAPI(struct face_detect*) face_detect_init(const char* eyes_model, + const char* nose_model, + const char* mouth_model, + const char* face_model, + int capture_no, + struct face_detect_settings* settings); +FDAPI(void) face_detect_free(struct face_detect *ctx); +FDAPI(int) face_detect_cycle(struct face_detect *ctx, float *data); +FDAPI(void) face_detect_zero(struct face_detect *ctx); + +FDAPI(unsigned char*) face_detect_video(struct face_detect* ctx); + +#define FD_VIDEO_WIDTH 252 +#define FD_VIDEO_HEIGHT 189 +#define FD_MAGIC 0x42 + +struct face_detect_shm { + unsigned char zerop, received; + float data[6]; + unsigned char pixels[FD_VIDEO_WIDTH * FD_VIDEO_HEIGHT * 3]; + struct face_detect_settings settings; +}; diff --git a/ftnoir_tracker_fd/ftnoir_tracker_facedetect.cpp b/ftnoir_tracker_fd/ftnoir_tracker_facedetect.cpp new file mode 100644 index 00000000..620fb9fd --- /dev/null +++ b/ftnoir_tracker_fd/ftnoir_tracker_facedetect.cpp @@ -0,0 +1,214 @@ +/* Copyright (c) 2012 Stanislaw Halik
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#include "ftnoir_tracker_fd.h"
+#include <Qt>
+#include <QPainter>
+#include <QPaintEngine>
+
+static void load_settings(struct face_detect_settings* out) {
+ qDebug("[!] load_settings()");
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ iniFile.beginGroup ( "FaceDetectTracker" );
+ out->redetect_ms = iniFile.value("RedetectMs", 500).toInt();
+ out->camera_id = iniFile.value("CameraId", 0).toInt();
+ out->quit = 0;
+ out->newOutput = 0;
+ out->magic = FD_MAGIC;
+ out->widgetp = iniFile.value("VideoWidget", true).toBool();
+ iniFile.endGroup ();
+}
+
+static void save_settings(const struct face_detect_settings* in) {
+
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ iniFile.beginGroup ( "FaceDetectTracker" );
+ iniFile.setValue("RedetectMs", in->redetect_ms);
+ iniFile.setValue("CameraId", in->camera_id);
+ iniFile.setValue("VideoWidget", in->widgetp);
+ iniFile.endGroup ();
+}
+
+VideoWidget::VideoWidget(HANDLE hMutex, unsigned char* data, struct face_detect_shm* shm) {
+ this->hMutex = hMutex;
+ this->data = data;
+ this->shm = shm;
+}
+
+void VideoWidget::paintEvent(QPaintEvent*) {
+ WaitForSingleObject(hMutex, INFINITE);
+ if (!this->shm->settings.widgetp) {
+ ReleaseMutex(hMutex);
+ return;
+ }
+ QPainter painter(this);
+ QImage image(data, FD_VIDEO_WIDTH, FD_VIDEO_HEIGHT, QImage::Format_RGB888);
+ QRectF rect(0, 0, FD_VIDEO_WIDTH, FD_VIDEO_HEIGHT);
+ painter.paintEngine()->drawImage(rect, image.rgbSwapped(), rect);
+ ReleaseMutex(hMutex);
+}
+
+FTNoIR_Tracker::FTNoIR_Tracker()
+{
+ qDebug("making tracker FaceDetect");
+
+ hMutex = CreateMutex(NULL, false, fd_mutex_name);
+ hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(struct face_detect_shm), fd_shm_name);
+ shm = (struct face_detect_shm*) MapViewOfFile(hMapFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, sizeof(struct face_detect_shm));
+ memset(shm, 0, sizeof(struct face_detect_shm));
+ activep = 0;
+ procInfo.hProcess = INVALID_HANDLE_VALUE;
+ ctrl = NULL;
+ qframe = NULL;
+}
+
+void FTNoIR_Tracker::TerminateTracker() {
+ if (procInfo.hProcess != INVALID_HANDLE_VALUE) {
+ shm->settings.quit = 1;
+ //TerminateProcess(procInfo.hProcess, 42);
+ CloseHandle(procInfo.hProcess);
+ CloseHandle(procInfo.hThread);
+ procInfo.hProcess = INVALID_HANDLE_VALUE;
+ }
+}
+
+FTNoIR_Tracker::~FTNoIR_Tracker()
+{
+ WaitForSingleObject(hMutex, INFINITE);
+ TerminateTracker();
+ UnmapViewOfFile(shm);
+ //CloseHandle(hMapFile);
+ ReleaseMutex(hMutex);
+ //CloseHandle(hMutex);
+}
+
+void FTNoIR_Tracker::Initialize( QFrame *videoframe )
+{
+ qDebug("FTNoIR_Tracker::Initialize()");
+ WaitForSingleObject(hMutex, INFINITE);
+ videoframe->setAttribute(Qt::WA_NativeWindow);
+ videoframe->show();
+ ctrl = new VideoWidget(hMutex, shm->pixels, shm);
+ QHBoxLayout* layout = new QHBoxLayout();
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->addWidget(ctrl);
+ videoframe->setLayout(layout);
+ ctrl->resize(FD_VIDEO_WIDTH, FD_VIDEO_HEIGHT);
+ qframe = videoframe;
+ loadSettings();
+ ReleaseMutex(hMutex);
+}
+
+void FTNoIR_Tracker::refreshVideo() {
+ QWidget* w;
+ WaitForSingleObject(hMutex, INFINITE);
+ w = ctrl;
+ ReleaseMutex(hMutex);
+ if (w != NULL)
+ w->update();
+}
+
+void FTNoIR_Tracker::StartTracker( HWND parent_window )
+{
+ WaitForSingleObject(hMutex, INFINITE);
+ qDebug("* tracker starting");
+ activep = true;
+ ReleaseMutex(hMutex);
+}
+
+void FTNoIR_Tracker::StopTracker( bool exit )
+{
+ WaitForSingleObject(hMutex, INFINITE);
+ qDebug("* tracker stopping");
+ activep = false;
+ if (exit) {
+ TerminateTracker();
+ if (qframe && qframe->layout()) {
+ delete qframe->layout();
+ qframe = NULL;
+ }
+ if (ctrl) {
+ delete ctrl;
+ ctrl = NULL;
+ }
+ }
+ ReleaseMutex(hMutex);
+}
+
+bool FTNoIR_Tracker::notifyZeroed() {
+ qDebug("notifying of zero");
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->zerop = 1;
+ ReleaseMutex(hMutex);
+ return true;
+}
+
+bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data)
+{
+ WaitForSingleObject(hMutex, INFINITE);
+ if (procInfo.hProcess == INVALID_HANDLE_VALUE) {
+ STARTUPINFO si;
+ SECURITY_ATTRIBUTES sa;
+ sa.bInheritHandle = 1;
+ sa.lpSecurityDescriptor = NULL;
+ sa.nLength = sizeof(SECURITY_ATTRIBUTES);
+ memset(&si, 0, sizeof(STARTUPINFO));
+ si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES;
+ si.cb = sizeof(STARTUPINFO);
+ si.hStdOutput = NULL;
+ si.hStdError = NULL;
+ si.hStdInput = NULL;
+ if (!CreateProcess(prog_cmdline, NULL, NULL, NULL, true, 0, NULL, NULL, &si, &procInfo)) {
+ qDebug("Badness! %d", GetLastError());
+ }
+ }
+
+ shm->received = 1;
+
+ if (activep) {
+ shm->settings.newOutput = 0;
+ data->x = shm->data[3];
+ data->y = shm->data[4];
+ data->z = shm->data[5];
+ data->yaw = shm->data[0];
+ data->pitch = shm->data[1];
+ data->roll = shm->data[2];
+ ReleaseMutex(hMutex);
+ return true;
+ }
+ ReleaseMutex(hMutex);
+ return false;
+}
+
+//
+// Load the current Settings from the currently 'active' INI-file.
+//
+void FTNoIR_Tracker::loadSettings() {
+ load_settings(&shm->settings);
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker object.
+
+// Export both decorated and undecorated names.
+// GetTracker - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTracker@0 - Common name decoration for __stdcall functions in C language.
+#pragma comment(linker, "/export:GetTracker=_GetTracker@0")
+
+FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker()
+{
+ return new FTNoIR_Tracker;
+}
diff --git a/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp new file mode 100644 index 00000000..71b19242 --- /dev/null +++ b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp @@ -0,0 +1,180 @@ +/* Copyright (c) 2012 Stanislaw Halik
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ */
+
+#include "ftnoir_tracker_fd.h"
+#include <Qt>
+#include <QPainter>
+#include <QPaintEngine>
+
+//*******************************************************************************************************
+// faceDetect Settings-dialog.
+//*******************************************************************************************************
+
+static void load_settings(struct face_detect_settings* out) {
+ qDebug("[!] load_settings()");
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ iniFile.beginGroup ( "FaceDetectTracker" );
+ out->redetect_ms = iniFile.value("RedetectMs", 500).toInt();
+ out->camera_id = iniFile.value("CameraId", 0).toInt();
+ out->quit = 0;
+ out->newOutput = 0;
+ out->magic = FD_MAGIC;
+ out->widgetp = iniFile.value("VideoWidget", true).toBool();
+ iniFile.endGroup ();
+}
+
+static void save_settings(const struct face_detect_settings* in) {
+
+ QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER)
+
+ QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString();
+ QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file)
+
+ iniFile.beginGroup ( "FaceDetectTracker" );
+ iniFile.setValue("RedetectMs", in->redetect_ms);
+ iniFile.setValue("CameraId", in->camera_id);
+ iniFile.setValue("VideoWidget", in->widgetp);
+ iniFile.endGroup ();
+}
+
+
+//
+// Constructor for server-settings-dialog
+//
+TrackerControls::TrackerControls() :
+QWidget()
+{
+ qDebug("[!] TrackerControls::TrackerControls()");
+ hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(struct face_detect_shm), fd_shm_name);
+ shm = (struct face_detect_shm*) MapViewOfFile(hMapFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, sizeof(struct face_detect_shm));
+ hMutex = CreateMutex(NULL, false, fd_mutex_name);
+ ui.setupUi( this );
+
+ load_settings(&shm->settings);
+
+ ui.redetect_ms->setValue(shm->settings.redetect_ms);
+ ui.cameraId->setValue(shm->settings.camera_id);
+ ui.videoWidget->setChecked(shm->settings.widgetp);
+
+ settingsDirty = false;
+
+ // what a load of boilerplate...
+ QObject::connect(ui.okButton, SIGNAL(clicked()), this, SLOT(doOK()));
+ QObject::connect(ui.cancelButton, SIGNAL(clicked()), this, SLOT(doCancel()));
+ QObject::connect(ui.redetect_ms, SIGNAL(valueChanged(int)), this, SLOT(doSetRedetectMs(int)));
+ QObject::connect(ui.cameraId, SIGNAL(valueChanged(int)), this, SLOT(doSetCameraId(int)));
+ QObject::connect(ui.videoWidget, SIGNAL(toggled(bool)), this, SLOT(doSetVideoWidget(bool)));
+}
+
+void TrackerControls::save() {
+ save_settings(&shm->settings);
+ settingsDirty = false;
+}
+
+void TrackerControls::doSetCameraId(int val) {
+ settingsDirty = true;
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->settings.camera_id = val;
+ ReleaseMutex(hMutex);
+}
+
+void TrackerControls::doSetVideoWidget(bool val) {
+ settingsDirty = true;
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->settings.widgetp = val;
+ ReleaseMutex(hMutex);
+}
+
+void TrackerControls::doSetRedetectMs(int val) {
+ settingsDirty = true;
+ WaitForSingleObject(hMutex, INFINITE);
+ shm->settings.redetect_ms = val;
+ ReleaseMutex(hMutex);
+}
+
+//
+// Destructor for server-dialog
+//
+TrackerControls::~TrackerControls() {
+ UnmapViewOfFile(shm);
+ //CloseHandle(hMutex);
+ //CloseHandle(hMapFile);
+}
+
+void TrackerControls::Release()
+{
+ delete this;
+}
+
+//
+// Initialize tracker-client-dialog
+//
+void TrackerControls::Initialize(QWidget *parent) {
+
+ QPoint offsetpos(200, 200);
+ if (parent) {
+ this->move(parent->pos() + offsetpos);
+ }
+ show();
+}
+
+//
+// OK clicked on server-dialog
+//
+void TrackerControls::doOK() {
+ save();
+ this->close();
+}
+
+//
+// Cancel clicked on server-dialog
+//
+void TrackerControls::doCancel() {
+ //
+ // Ask if changed Settings should be saved
+ //
+ if (settingsDirty) {
+ int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard );
+
+ switch (ret) {
+ case QMessageBox::Save:
+ save();
+ this->close();
+ break;
+ case QMessageBox::Discard:
+ this->close();
+ break;
+ case QMessageBox::Cancel:
+ // Cancel was clicked
+ break;
+ default:
+ // should never be reached
+ break;
+ }
+ }
+ else {
+ this->close();
+ }
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker-settings dialog object.
+
+// Export both decorated and undecorated names.
+// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language.
+#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0")
+
+FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( )
+{
+ return new TrackerControls;
+}
diff --git a/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp new file mode 100644 index 00000000..8e010e3e --- /dev/null +++ b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp @@ -0,0 +1,85 @@ +/********************************************************************************
+* FaceTrackNoIR This program is a private project of some enthusiastic *
+* gamers from Holland, who don't like to pay much for *
+* head-tracking. *
+* *
+* Copyright (C) 2012 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):
+ 20120830 - WVR: The Dialog class was used to get general info on the DLL. This
+ had a big disadvantage: the complete dialog was loaded, just to get
+ some data and then it was deleted again (without ever showing the dialog).
+ The TrackerDll class solves this.
+ The functions to get the name(s) and icon were removed from the two other classes.
+*/
+#include "ftnoir_tracker_fd.h"
+#include <QDebug>
+
+FTNoIR_TrackerDll::FTNoIR_TrackerDll() {
+ //populate the description strings
+ trackerFullName = "faceDetect V1.0.0";
+ trackerShortName = "faceDetect";
+ trackerDescription = "Stans' faceDetect V1.0.0";
+}
+
+FTNoIR_TrackerDll::~FTNoIR_TrackerDll()
+{
+
+}
+
+void FTNoIR_TrackerDll::Initialize()
+{
+ return;
+}
+
+void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerFullName;
+};
+
+void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerShortName;
+};
+
+void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled)
+{
+ *strToBeFilled = trackerDescription;
+};
+
+void FTNoIR_TrackerDll::getIcon(QIcon *icon)
+{
+ *icon = QIcon(":/images/FaceDetect.ico");
+};
+
+////////////////////////////////////////////////////////////////////////////////
+// Factory function that creates instances if the Tracker object.
+
+// Export both decorated and undecorated names.
+// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress
+// Win32 API function.
+// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language.
+#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0")
+
+FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll()
+{
+ return new FTNoIR_TrackerDll;
+}
diff --git a/ftnoir_tracker_fd/images/FaceDetect.ico b/ftnoir_tracker_fd/images/FaceDetect.ico Binary files differnew file mode 100644 index 00000000..8e862cee --- /dev/null +++ b/ftnoir_tracker_fd/images/FaceDetect.ico |