From 9184ea73941814b95c2768d8bcca8bdb77655891 Mon Sep 17 00:00:00 2001 From: Wim Vriend Date: Sat, 17 Mar 2012 16:15:51 +0000 Subject: Changed Tracker code, so the DLL's are true plug-ins. FaceTrackNoIR will scan the bin folder for FTNoIR_Tracker*.dll and put the names in the combobox. All Trackers have 3 new member-functions (like the filters). git-svn-id: svn+ssh://svn.code.sf.net/p/facetracknoir/code@104 19e81ba0-9b1a-49c3-bd6c-561e1906d5fb --- FTNoIR_Filter_Base/ftnoir_filter_base.h | 12 +- FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui | 633 +++++++++++---------- FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h | 12 +- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp | 6 +- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp | 6 +- FTNoIR_Protocol_Base/ftnoir_protocol_base.h | 5 +- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp | 4 +- FTNoIR_Protocol_FTIR/FTIRTypes.h | 5 +- FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp | 75 ++- FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h | 6 +- FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h | 2 +- FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h | 1 + FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj | 2 +- FTNoIR_Tracker_Base/ftnoir_tracker_base.h | 69 +-- FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui | 152 +++++ FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h | 108 ++++ FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.vcproj | 382 +++++++++++++ FTNoIR_Tracker_FD/Tracker.qrc | 5 + FTNoIR_Tracker_FD/face-detect.h | 39 ++ FTNoIR_Tracker_FD/ftnoir_tracker_facedetect.cpp | 251 ++++++++ .../ftnoir_tracker_facedetect_dialog.cpp | 208 +++++++ FTNoIR_Tracker_FD/images/FaceDetect.ico | Bin 0 -> 5430 bytes FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h | 60 +- FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj | 82 +++ FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp | 409 +++---------- FTNoIR_Tracker_SM/images/SeeingMachines.ico | Bin 0 -> 37798 bytes FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h | 47 +- FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj | 4 + FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp | 274 +++------ FaceTrackNoIR.sln | 8 +- FaceTrackNoIR.suo | Bin 449536 -> 520192 bytes FaceTrackNoIR/FaceTrackNoIR.cpp | 249 +++++--- FaceTrackNoIR/FaceTrackNoIR.h | 3 + FaceTrackNoIR/FaceTrackNoIR.qrc | 1 - FaceTrackNoIR/FaceTrackNoIR.ui | 20 +- FaceTrackNoIR/tracker.cpp | 66 ++- FaceTrackNoIR/tracker.h | 17 +- List of compatible games.xls | Bin 40448 -> 40448 bytes List of compatible webcams.xls | Bin 32768 -> 32768 bytes bin/QBezierConfigurator.dll | Bin 49152 -> 49152 bytes bin/Settings/ArmA.ini | 10 +- bin/Settings/FF5.ini | 12 +- bin/Settings/FreeFalcon.ini | 22 +- bin/Settings/IL2.ini | 42 +- bin/Settings/Mouse Look.ini | 16 +- bin/Settings/SimConnect.ini | 8 + bin/UIElements/SetupFaceTrackNoIR.jpg | Bin 9780 -> 21508 bytes 47 files changed, 2211 insertions(+), 1122 deletions(-) create mode 100644 FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui create mode 100644 FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h create mode 100644 FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.vcproj create mode 100644 FTNoIR_Tracker_FD/Tracker.qrc create mode 100644 FTNoIR_Tracker_FD/face-detect.h create mode 100644 FTNoIR_Tracker_FD/ftnoir_tracker_facedetect.cpp create mode 100644 FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp create mode 100644 FTNoIR_Tracker_FD/images/FaceDetect.ico create mode 100644 FTNoIR_Tracker_SM/images/SeeingMachines.ico diff --git a/FTNoIR_Filter_Base/ftnoir_filter_base.h b/FTNoIR_Filter_Base/ftnoir_filter_base.h index e7dcd6bc..3d617abc 100644 --- a/FTNoIR_Filter_Base/ftnoir_filter_base.h +++ b/FTNoIR_Filter_Base/ftnoir_filter_base.h @@ -23,9 +23,9 @@ struct IFilter virtual void Initialize() = 0; virtual void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) = 0; - virtual void getFilterFullName(QString *strToBeFilled) = 0; - virtual void getFilterShortName(QString *strToBeFilled) = 0; - virtual void getFilterDescription(QString *strToBeFilled) = 0; + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; }; // Handle type. In C++ language the interface type is used. @@ -59,9 +59,9 @@ struct IFilterDialog virtual void Release() = 0; // Member required to enable Auto-remove virtual void Initialize(QWidget *parent, IFilterPtr ptr) = 0; - virtual void getFilterFullName(QString *strToBeFilled) = 0; - virtual void getFilterShortName(QString *strToBeFilled) = 0; - virtual void getFilterDescription(QString *strToBeFilled) = 0; + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; virtual void getIcon(QIcon *icon) = 0; }; diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui b/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui index cbd61d53..e9419a73 100644 --- a/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui +++ b/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui @@ -6,10 +6,16 @@ 0 0 - 411 - 225 + 371 + 380 + + + 0 + 380 + + EWMA2 Filter settings FaceTrackNoIR @@ -28,293 +34,338 @@ - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - - - - Min. - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - - - - Max. - - + + + QLayout::SetMinimumSize + + + + + + + + 0 + 0 + + + + + 30 + 16777215 + + + + + + + Max. + + + + + + + + 0 + 0 + + + + + 30 + 16777215 + + + + + + + Curve + + + + + + + + 45 + 15 + + + + 1 + + + 100 + + + 10 + + + 2 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 40 + 22 + + + + background:none; + + + 1 + + + 100 + + + 5 + + + 2 + + + + + + + + 35 + 0 + + + + + 30 + 16777215 + + + + + + + frames + + + + + + + + 45 + 15 + + + + 1 + + + 100 + + + 10 + + + 10 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 40 + 22 + + + + background:none; + + + 1 + + + 100 + + + 5 + + + 10 + + + + + + + + 35 + 0 + + + + + 30 + 16777215 + + + + + + + frames + + + + + + + + 45 + 15 + + + + 1 + + + 100 + + + 10 + + + 10 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 40 + 22 + + + + background:none; + + + 100 + + + 5 + + + 10 + + + + + + + + 0 + 0 + + + + + 30 + 16777215 + + + + + + + pow + + + + + + + + 0 + 0 + + + + + 30 + 16777215 + + + + + + + Min. + + + + - - + + 0 - 0 - - - - - 30 - 16777215 - - - - - - - Curve - - - - - - - - 45 - 15 - - - - 1 - - - 100 - - - 10 - - - 2 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 40 - 22 - - - - background:none; - - - 1 - - - 100 - - - 5 - - - 2 - - - - - - - - 35 - 0 - - - - - 30 - 16777215 - - - - - - - frames - - - - - - - - 45 - 15 - - - - 1 - - - 100 - - - 10 - - - 10 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 40 - 22 + 204 - background:none; - - - 1 - - - 100 - - - 5 - - - 10 - - - - - - - - 35 - 0 - - - - - 30 - 16777215 - + background-color: rgb(214, 214, 214); +border-color: rgb(0, 0, 0); - - + + QFrame::Box - frames - - - - - - - - 45 - 15 - - - - 1 - - - 100 - - - 10 - - - 10 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 40 - 22 - - - - background:none; - - - 100 - - + <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> +<html><head><meta name="qrichtext" content="1" /><style type="text/css"> +p, li { white-space: pre-wrap; } +</style></head><body style=" font-family:'MS Shell Dlg 2'; font-size:8.25pt; font-weight:400; font-style:normal;"> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Min. frames:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Defines the way the filter responds to fast movements;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Higher value: slower response;</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Max. frames:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Defines the way the filter responds to slow movements;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Higher value: slower response;</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Pow:</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Defines the filters 'readiness' to respond to speed changes;</span></p> +<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><span style=" font-size:10pt;">Higher value = </span><span style=" font-size:10pt; font-weight:600;">higher</span><span style=" font-size:10pt;"> response;</span></p> +<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px; font-size:10pt;"></p></body></html> + + 5 - - 10 - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - - - - pow - @@ -332,34 +383,6 @@ - - - - - - The filter-settings may need some explanation... - - - - - - - ... - - - true - - - - - - - ... - - - - - diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h index f335eb47..bd90c1f8 100644 --- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h +++ b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h @@ -45,9 +45,9 @@ public: void StartFilter(); void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); - void getFilterFullName(QString *strToBeFilled); - void getFilterShortName(QString *strToBeFilled); - void getFilterDescription(QString *strToBeFilled); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); private: void loadSettings(); // Load the settings from the INI-file @@ -86,9 +86,9 @@ public: void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent, IFilterPtr ptr); - void getFilterFullName(QString *strToBeFilled); - void getFilterShortName(QString *strToBeFilled); - void getFilterDescription(QString *strToBeFilled); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); void getIcon(QIcon *icon); private: diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp index 179db04c..99a4bd98 100644 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp +++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp @@ -226,19 +226,19 @@ void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, T return; } -void FTNoIR_Filter::getFilterFullName(QString *strToBeFilled) +void FTNoIR_Filter::getFullName(QString *strToBeFilled) { *strToBeFilled = filterFullName; }; -void FTNoIR_Filter::getFilterShortName(QString *strToBeFilled) +void FTNoIR_Filter::getShortName(QString *strToBeFilled) { *strToBeFilled = filterShortName; }; -void FTNoIR_Filter::getFilterDescription(QString *strToBeFilled) +void FTNoIR_Filter::getDescription(QString *strToBeFilled) { *strToBeFilled = filterDescription; }; diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp index fd24d552..7ffe8bb9 100644 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp +++ b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp @@ -187,19 +187,19 @@ void FilterControls::save() { settingsDirty = false; } -void FilterControls::getFilterFullName(QString *strToBeFilled) +void FilterControls::getFullName(QString *strToBeFilled) { *strToBeFilled = filterFullName; }; -void FilterControls::getFilterShortName(QString *strToBeFilled) +void FilterControls::getShortName(QString *strToBeFilled) { *strToBeFilled = filterShortName; }; -void FilterControls::getFilterDescription(QString *strToBeFilled) +void FilterControls::getDescription(QString *strToBeFilled) { *strToBeFilled = filterDescription; }; diff --git a/FTNoIR_Protocol_Base/ftnoir_protocol_base.h b/FTNoIR_Protocol_Base/ftnoir_protocol_base.h index 2dd03b82..c9fbdd1c 100644 --- a/FTNoIR_Protocol_Base/ftnoir_protocol_base.h +++ b/FTNoIR_Protocol_Base/ftnoir_protocol_base.h @@ -2,10 +2,13 @@ #define FTNOIR_PROTOCOL_BASE_H #include "ftnoir_protocol_base_global.h" -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "..\ftnoir_tracker_base\ftnoir_tracker_types.h" #include #include +//#include "winbase.h" + #include "windows.h" +#include "winable.h" // COM-Like abstract interface. // This interface doesn't require __declspec(dllexport/dllimport) specifier. diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp index f799d015..0713f557 100644 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp +++ b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp @@ -34,7 +34,7 @@ #include "ftnoir_protocol_fg.h" #include -// For Todd +// For Todd and Arda Kutlu //#define SEND_ASCII_DATA //#define LOG_OUTPUT @@ -122,7 +122,7 @@ char data[100]; // #ifdef SEND_ASCII_DATA - sprintf_s(data, "%.2f %.2f %.2f %.2f %.2f %.2f;\n\0", FlightData.x, FlightData.y, FlightData.z, FlightData.p, FlightData.h, FlightData.r); + sprintf_s(data, "%.2f %.2f %.2f %.2f %.2f %.2f\n\0", FlightData.x, FlightData.y, FlightData.z, FlightData.p, FlightData.h, FlightData.r); if (outSocket != 0) { no_bytes = outSocket->writeDatagram((const char *) &data, strlen( data ), destIP, destPort); diff --git a/FTNoIR_Protocol_FTIR/FTIRTypes.h b/FTNoIR_Protocol_FTIR/FTIRTypes.h index f238762c..fcf2d458 100644 --- a/FTNoIR_Protocol_FTIR/FTIRTypes.h +++ b/FTNoIR_Protocol_FTIR/FTIRTypes.h @@ -97,6 +97,9 @@ typedef enum tagNPResult static const char* FTIR_REGISTER_PROGRAMHANDLE = "FT_Register_Program_Handle"; static const char* FTIR_UNREGISTER_PROGRAMHANDLE = "FT_UnRegister_Program_Handle"; + static const char* FTIR_SIG1 = "precise head tracking\n put your head into the game\n now go look around\n\n Copyright EyeControl Technologies\0\0"; + static const char* FTIR_SIG2 = "hardware camera\n software processing data\n track user movement\n\n Copyright EyeControl Technologies\0\0"; + typedef struct tagTrackIRData { unsigned short wNPStatus; @@ -152,7 +155,7 @@ typedef NPRESULT (__stdcall *PF_NOTIFYCALLBACK)( unsigned short, unsigned short //typedef NPRESULT (__stdcall *PF_NP_REGISTERPROGRAMPROFILEID)( unsigned short ); //typedef NPRESULT (__stdcall *PF_NP_QUERYVERSION)( unsigned short* ); //typedef NPRESULT (__stdcall *PF_NP_REQUESTDATA)( unsigned short ); -//typedef NPRESULT (__stdcall *PF_NP_GETDATA)( LPTRACKIRDATA ); +typedef NPRESULT (__stdcall *PF_NP_GETDATA)( LPTRACKIRDATA ); //typedef NPRESULT (__stdcall *PF_NP_REGISTERNOTIFY)( PF_NOTIFYCALLBACK ); //typedef NPRESULT (__stdcall *PF_NP_UNREGISTERNOTIFY)( void ); //typedef NPRESULT (__stdcall *PF_NP_STARTCURSOR)( void ); diff --git a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp index 82857745..096b957a 100644 --- a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp +++ b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.cpp @@ -133,6 +133,8 @@ float virtRotX; float virtRotY; float virtRotZ; +TRACKIRDATA localdata; + // // Copy the Raw measurements directly to the client. // @@ -148,8 +150,31 @@ float virtRotZ; // Check if the pointer is OK and wait for the Mutex. // Use the setposition in the (special) DLL, to write the headpose-data. // +// qDebug() << "FTIRCreateMapping says: sendHeadpose"; if ( (pMemData != NULL) && (WaitForSingleObject(hFTIRMutex, 100) == WAIT_OBJECT_0) ) { - setposition (virtPosX, virtPosY, virtPosZ, virtRotZ, virtRotX, virtRotY ); +// qDebug() << "FTIRCreateMapping says: Calling setposition" << setdata; + + //localdata.fNPX = virtPosX; + //localdata.fNPY = virtPosY; + //localdata.fNPZ = virtPosZ; + //localdata.fNPRoll = virtRotZ; + //localdata.fNPPitch = virtRotX; + //localdata.fNPYaw = virtRotY; + //localdata.wPFrameSignature = localdata.wPFrameSignature + 1; + + //setdata(&localdata); + // +// setposition ( virtPosX, virtPosY, virtPosZ, virtRotZ, virtRotX, virtRotY ); + pMemData->data.fNPX = virtPosX; + pMemData->data.fNPY = virtPosY; + pMemData->data.fNPZ = virtPosZ; + pMemData->data.fNPRoll = virtRotZ; + pMemData->data.fNPPitch = virtRotX; + pMemData->data.fNPYaw = virtRotY; + pMemData->data.wPFrameSignature +=1; + if ((pMemData->data.wPFrameSignature < 0) || (pMemData->data.wPFrameSignature > 1000)){ + pMemData->data.wPFrameSignature = 0; + } ReleaseMutex(hFTIRMutex); } } @@ -185,6 +210,7 @@ bool FTNoIR_Protocol_FTIR::checkServerInstallationOK( HANDLE handle ) // aFileName = aLocation; aFileName.append(FTIR_CLIENT_FILENAME); +// aFileName.append("TIR5.dll"); qDebug() << "FTCheckClientDLL says: Full path of DLL =" << aFileName; if ( QFile::exists( aFileName ) ) { @@ -240,16 +266,17 @@ bool FTNoIR_Protocol_FTIR::checkServerInstallationOK( HANDLE handle ) // // Find the functions in the DLL's // - // Get the setposition function from the DLL and use it! - // - setposition = (importSetPosition) FTIRClientLib.resolve("SetPosition"); - if (setposition == NULL) { - qDebug() << "FTIRServer::run() says: SetPosition function not found in DLL!"; - return false; - } - else { - setposition (7.0f, 1.0f, 2.0f, 3.0f, 4.0f, 5.0f); - } + //// Get the setposition function from the DLL and use it! + //// + ////setposition = (importSetPosition) FTIRClientLib.resolve("SetPosition"); + ////if (setdata == NULL) { + //// qDebug() << "FTIRServer::run() says: SetPosition function not found in DLL!"; + //// return false; + ////} + ////else { + //// qDebug() << "FTIRCreateMapping says: Calling setposition" << setposition; + //// setposition ( 1.0f, 2.0f, 3.0f, 4.0f, 5.0f, 6.0f ); + ////} // // Load the Start function from TIRViews.dll and call it, to start compatibility with older games @@ -291,26 +318,32 @@ bool FTNoIR_Protocol_FTIR::FTIRCreateMapping( HANDLE handle ) // If one already exists: close it. // hFTIRMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , - sizeof( TRACKIRDATA ) + sizeof( HANDLE ) + 100, + sizeof( FTIRMemMap ), +// sizeof( TRACKIRDATA ) + sizeof( HANDLE ) + 100, (LPCSTR) FTIR_MM_DATA ); if ( hFTIRMemMap != 0 ) { - qDebug() << "FTIRCreateMapping says: FileMapping Created!" << hFTIRMemMap; - } - - if ( ( hFTIRMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) { - CloseHandle( hFTIRMemMap ); - hFTIRMemMap = 0; + if ( (long) GetLastError == ERROR_ALREADY_EXISTS ) { + qDebug() << "FTIRCreateMapping says: FileMapping already exists!" << hFTIRMemMap; + CloseHandle( hFTIRMemMap ); + hFTIRMemMap = 0; + } + else { + qDebug() << "FTIRCreateMapping says: FileMapping newly created!" << hFTIRMemMap; + } } // - // Create a new FileMapping, Read/Write access + // Open the FileMapping, Read/Write access // + pMemData = 0; hFTIRMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FTIR_MM_DATA ); if ( ( hFTIRMemMap != 0 ) ) { - qDebug() << "FTIRCreateMapping says: FileMapping Created again:" << hFTIRMemMap; - pMemData = (FTIRMemMap *) MapViewOfFile(hFTIRMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TRACKIRDATA) + sizeof(hFTIRMemMap) + 100); + qDebug() << "FTIRCreateMapping says: FileMapping opened: " << hFTIRMemMap; +// pMemData = (FTIRMemMap *) MapViewOfFile(hFTIRMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TRACKIRDATA) + sizeof(hFTIRMemMap) + 100); + pMemData = (FTIRMemMap *) MapViewOfFile(hFTIRMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(FTIRMemMap)); if (pMemData != NULL) { + qDebug() << "FTIRCreateMapping says: View of File mapped: " << pMemData; pMemData->RegisteredHandle = handle; // The game uses the handle, to send a message that the Program-Name was set! } hFTIRMutex = CreateMutexA(NULL, false, FTIR_MUTEX); diff --git a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h index 6307c6a1..90518394 100644 --- a/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h +++ b/FTNoIR_Protocol_FTIR/FTNoIR_Protocol_FTIR.h @@ -40,7 +40,8 @@ #include "Windows.h" //#include "math.h" -typedef void (WINAPI *importSetPosition)(float x, float y, float z, float xRot, float yRot, float zRot); +//typedef void (WINAPI *importSetPosition)(float, float, float, float, float, float); +typedef int (WINAPI *importSetData)(TRACKIRDATA*); typedef void (WINAPI *importTIRViewsStart)(void); typedef void (WINAPI *importTIRViewsStop)(void); @@ -62,7 +63,8 @@ private: bool FTIRCreateMapping(HANDLE handle); void FTIRDestroyMapping(); - importSetPosition setposition; // Function inside NPClient.dll +// importSetPosition setposition; // Function inside NPClient.dll (old style) + importSetData setdata; // Function inside NPClient.dll importTIRViewsStart viewsStart; // Functions inside TIRViews.dll importTIRViewsStop viewsStop; diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h index ce267d87..af9574ca 100644 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h +++ b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h @@ -30,6 +30,7 @@ #ifndef INCLUDED_MOUSESERVER_H #define INCLUDED_MOUSESERVER_H +//#include #include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" #include "ui_FTNoIR_MOUSEcontrols.h" #include @@ -38,7 +39,6 @@ #include #include #include -#include "Windows.h" #define MOUSE_AXIS_MIN 0 #define MOUSE_AXIS_MAX 65535 diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h index 1b0116e3..1b98fab4 100644 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h +++ b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h @@ -35,6 +35,7 @@ // This is necessary to run FaceTrackNoIR on a PC without FSX // #define SIMCONNECT_H_NOMANIFEST +#define _WIN32_WINNT 0x0502 #include "Windows.h" #include "SimConnect.h" diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj index 6fa50fdf..141f3266 100644 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj +++ b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.vcproj @@ -57,7 +57,7 @@ Name="VCLinkerTool" AdditionalDependencies="qtmain.lib QtCore4.lib QtGui4.lib" OutputFile="$(OutDir)\$(ProjectName).dll" - AdditionalLibraryDirectories="$(QTDIR)\lib" + AdditionalLibraryDirectories=""$(QTDIR)\lib";"C:\Program Files (x86)\Microsoft Games\Microsoft Flight Simulator X SDK\SDK\Core Utilities Kit\SimConnect SDK\lib"" GenerateDebugInformation="false" SubSystem="2" /> diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_base.h b/FTNoIR_Tracker_Base/ftnoir_tracker_base.h index debd58e5..e2585ecf 100644 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_base.h +++ b/FTNoIR_Tracker_Base/ftnoir_tracker_base.h @@ -30,63 +30,10 @@ #define FTNOIR_TRACKER_BASE_H #include "ftnoir_tracker_base_global.h" +#include "ftnoir_tracker_types.h" #include #include -// -// x,y,z position in centimetres, yaw, pitch and roll in degrees... -// -#pragma pack(push, 2) -struct THeadPoseData { - double x, y, z, yaw, pitch, roll; - long frame_number; -}; -#pragma pack(pop) - -// -// Structure to hold all 6 DOF's -// -class T6DOF { -public: - T6DOF( double x, double y, double z, - double yaw, double pitch, double roll ) { - position.x = x; - position.y = y; - position.z = z; - position.yaw = yaw; - position.pitch = pitch; - position.roll = roll; - } - - void initHeadPoseData(){ - position.x = 0.0f; - position.y = 0.0f; - position.z = 0.0f; - position.yaw = 0.0f; - position.pitch = 0.0f; - position.roll = 0.0f; - position.frame_number = 0; - } - T6DOF operator-( T6DOF &other ) { - return T6DOF(position.x - other.position.x, position.y - other.position.y, position.z - other.position.z, - position.yaw - other.position.yaw, position.pitch - other.position.pitch, position.roll - other.position.roll); - } - T6DOF operator-=( T6DOF &other ) { - return T6DOF(position.x - other.position.x, position.y - other.position.y, position.z - other.position.z, - position.yaw - other.position.yaw, position.pitch - other.position.pitch, position.roll - other.position.roll); - } - T6DOF operator+( T6DOF &other ) { - return T6DOF(position.x + other.position.x, position.y + other.position.y, position.z + other.position.z, - position.yaw + other.position.yaw, position.pitch + other.position.pitch, position.roll + other.position.roll); - } - T6DOF operator+=( T6DOF &other ) { - return T6DOF(position.x + other.position.x, position.y + other.position.y, position.z + other.position.z, - position.yaw + other.position.yaw, position.pitch + other.position.pitch, position.roll + other.position.roll); - } - - THeadPoseData position; -}; - // COM-Like abstract interface. // This interface doesn't require __declspec(dllexport/dllimport) specifier. // Method calls are dispatched via virtual table. @@ -99,6 +46,15 @@ struct ITracker virtual void StartTracker( HWND parent_window ) = 0; virtual void StopTracker(bool exit) = 0; virtual bool GiveHeadPoseData(THeadPoseData *data) = 0; + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + + virtual bool notifyZeroed() { + return false; + } + virtual void refreshVideo() {} }; // Handle type. In C++ language the iterface type is used. @@ -130,6 +86,11 @@ struct ITrackerDialog { virtual void Release() = 0; // Member required to enable Auto-remove virtual void Initialize(QWidget *parent) = 0; + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; }; // Handle type. In C++ language the iterface type is used. 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 @@ + + + UICFDClientControls + + + Qt::ApplicationModal + + + + 0 + 0 + 283 + 151 + + + + + 0 + 0 + + + + FaceDetect tracker settings + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + QLayout::SetFixedSize + + + + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Changes take effect after tracker restart. + + + + + + + Camera (indices from 0) + + + + + + + 100 + + + + + + + Haar detection timeout (ms) + + + + + + + 2000 + + + 50 + + + 200 + + + + + + + Video Widget + + + + + + + Qt::RightToLeft + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h new file mode 100644 index 00000000..ddb9afde --- /dev/null +++ b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h @@ -0,0 +1,108 @@ +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "face-detect.h" +#include "ui_FTNoIR_FD_controls.h" + +#include +#include +#include + +#include +#include +#include +#include "math.h" +#include + +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 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 setParameterValue(const int index, const float newvalue); + bool notifyZeroed(); + void refreshVideo(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + +private: + bool activep; + //QList> parameterRange; + //QList parameterValueAsFloat; + void TerminateTracker(); + HANDLE hMutex, hMapFile; + struct face_detect_shm* shm; + PROCESS_INFORMATION procInfo; + VideoWidget* ctrl; + QFrame* qframe; + + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; + +}; + +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 NotifyZeroing(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + Ui::UICFDClientControls ui; + void loadSettings(); + void save(); + + bool settingsDirty; + HANDLE hMapFile, hMutex; + struct face_detect_shm* shm; + + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void doSetRedetectMs(int val); + void doSetCameraId(int val); + void doSetVideoWidget(bool val); +signals: +}; \ No newline at end of file diff --git a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.vcproj b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.vcproj new file mode 100644 index 00000000..293e1ebf --- /dev/null +++ b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.vcproj @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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 @@ + + + images/FaceDetect.ico + + 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..7f1c1529 --- /dev/null +++ b/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect.cpp @@ -0,0 +1,251 @@ +/* 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 +#include +#include + +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"); + ////allocate memory for the parameters + //parameterValueAsFloat.clear(); + //parameterRange.clear(); + + //// Add the parameters to the list + //parameterRange.append(std::pair(1000.0f,9999.0f)); + //parameterValueAsFloat.append(0.0f); + ////setParameterValue(kPortAddress,5551.0f); + + 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; + + //populate the description strings + trackerFullName = "faceDetect V1.0.0"; + trackerShortName = "faceDetect"; + trackerDescription = "Stans' faceDetect V1.0.0"; + +} + +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::Release() +{ + qDebug("FTNoIR_Tracker::Release says: Starting "); + delete this; +} + +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; +} + +void FTNoIR_Tracker::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + + +void FTNoIR_Tracker::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + + +void FTNoIR_Tracker::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +// +// 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 TRACKERHANDLE __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..a39d8bf2 --- /dev/null +++ b/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp @@ -0,0 +1,208 @@ +/* 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 +#include +#include + +//******************************************************************************************************* +// 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))); + + //populate the description strings + trackerFullName = "faceDetect V1.0.0"; + trackerShortName = "faceDetect"; + trackerDescription = "Stans' faceDetect V1.0.0"; + +} + +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(); + } +} + +void TrackerControls::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + + +void TrackerControls::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + + +void TrackerControls::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +void TrackerControls::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/SeeingMachines.ico"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// 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 TRACKERDIALOGHANDLE __stdcall GetTrackerDialog( ) +{ + return new TrackerControls; +} diff --git a/FTNoIR_Tracker_FD/images/FaceDetect.ico b/FTNoIR_Tracker_FD/images/FaceDetect.ico new file mode 100644 index 00000000..8e862cee Binary files /dev/null and b/FTNoIR_Tracker_FD/images/FaceDetect.ico differ diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h index 4a26a824..a4933c35 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h +++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h @@ -1,3 +1,27 @@ +/******************************************************************************** +* 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: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* 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 . * +* * +********************************************************************************/ #include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" #include "..\ftnoir_tracker_base\ftnoir_tracker_sm_types.h" #include "ui_FTNoIR_SM_controls.h" @@ -10,11 +34,11 @@ using namespace std; -class FTNoIR_Tracker_SM : public ITracker +class FTNoIR_Tracker : public ITracker { public: - FTNoIR_Tracker_SM(); - ~FTNoIR_Tracker_SM(); + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); void Release(); void Initialize( QFrame *videoframe ); @@ -24,7 +48,9 @@ public: void loadSettings(); bool SMCreateMapping(); - bool setParameterValue(const int index, const float newvalue); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); private: // @@ -33,32 +59,32 @@ private: 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> parameterRange; - QList parameterValueAsFloat; + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; }; // Widget that has controls for SMoIR protocol client-settings. -class SMClientControls: public QWidget, Ui::UICSMClientControls, public ITrackerDialog +class TrackerControls: public QWidget, Ui::UICSMClientControls, public ITrackerDialog { Q_OBJECT public: - explicit SMClientControls(); - virtual ~SMClientControls(); + explicit TrackerControls(); + virtual ~TrackerControls(); void showEvent ( QShowEvent * event ); void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + private: Ui::UICSMClientControls ui; void loadSettings(); @@ -80,6 +106,10 @@ private: smEngineHandle *engine_handle; QTimer *timUpdateSettings; // Timer to display current settings + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; + private slots: void doOK(); void doCancel(); diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj index b174725d..b5a3e5f4 100644 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj +++ b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj @@ -171,12 +171,24 @@ RelativePath=".\ftnoir_tracker_faceapi.cpp" > + + + + + + @@ -203,6 +215,10 @@ /> + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp index 181a0e1d..c9b3bc0b 100644 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp +++ b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp @@ -1,20 +1,39 @@ +/******************************************************************************** +* 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: http://facetracknoir.sourceforge.net/home/default.htm * +* * +* 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 . * +* * +********************************************************************************/ #include "ftnoir_tracker_sm.h" -//#include "sm_api_headtrackerv2controls.h" #include -FTNoIR_Tracker_SM::FTNoIR_Tracker_SM() +FTNoIR_Tracker::FTNoIR_Tracker() { - //allocate memory for the parameters - parameterValueAsFloat.clear(); - parameterRange.clear(); - - // Add the parameters to the list - parameterRange.append(std::pair(1000.0f,9999.0f)); - parameterValueAsFloat.append(0.0f); - setParameterValue(kPortAddress,5551.0f); + //populate the description strings + trackerFullName = "faceAPI V3.2.6"; + trackerShortName = "faceAPI"; + trackerDescription = "SeeingMachines faceAPI V3.2.6"; } -FTNoIR_Tracker_SM::~FTNoIR_Tracker_SM() +FTNoIR_Tracker::~FTNoIR_Tracker() { qDebug() << "stopTracker says: terminating"; @@ -27,9 +46,9 @@ FTNoIR_Tracker_SM::~FTNoIR_Tracker_SM() hSMMemMap = 0; } -void FTNoIR_Tracker_SM::Release() +void FTNoIR_Tracker::Release() { - qDebug() << "FTNoIR_Tracker_SM::Release says: Starting "; + qDebug() << "FTNoIR_Tracker::Release says: Starting "; if ( pMemData != NULL ) { pMemData->command = FT_SM_EXIT; // Issue 'exit' command @@ -37,12 +56,12 @@ void FTNoIR_Tracker_SM::Release() delete this; } -void FTNoIR_Tracker_SM::Initialize( QFrame *videoframe ) +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) { - qDebug() << "FTNoIR_Tracker_SM::Initialize says: Starting "; + qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; if (SMCreateMapping()) { - qDebug() << "FTNoIR_Tracker_SM::Initialize Mapping created."; + qDebug() << "FTNoIR_Tracker::Initialize Mapping created."; } else { QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); @@ -63,13 +82,13 @@ void FTNoIR_Tracker_SM::Initialize( QFrame *videoframe ) faceAPI->start(program); // Show the video widget - qDebug() << "FTNoIR_Tracker_SM::Initialize says: videoframe = " << videoframe; + qDebug() << "FTNoIR_Tracker::Initialize says: videoframe = " << videoframe; videoframe->show(); return; } -void FTNoIR_Tracker_SM::StartTracker( HWND parent_window ) +void FTNoIR_Tracker::StartTracker( HWND parent_window ) { if ( pMemData != NULL ) { pMemData->command = FT_SM_START; // Start command @@ -77,10 +96,10 @@ void FTNoIR_Tracker_SM::StartTracker( HWND parent_window ) return; } -void FTNoIR_Tracker_SM::StopTracker( bool exit ) +void FTNoIR_Tracker::StopTracker( bool exit ) { - qDebug() << "FTNoIR_Tracker_SM::StopTracker says: Starting "; + qDebug() << "FTNoIR_Tracker::StopTracker says: Starting "; // stops the faceapi engine if ( pMemData != NULL ) { // if (exit == true) { @@ -93,14 +112,14 @@ void FTNoIR_Tracker_SM::StopTracker( bool exit ) return; } -bool FTNoIR_Tracker_SM::GiveHeadPoseData(THeadPoseData *data) +bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) { // // Check if the pointer is OK and wait for the Mutex. // if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { -// qDebug() << "FTNoIR_Tracker_SM::GiveHeadPoseData says: Retrieving data."; +// qDebug() << "FTNoIR_Tracker::GiveHeadPoseData says: Retrieving data."; // // Copy the measurements to FaceTrackNoIR. @@ -123,46 +142,35 @@ bool FTNoIR_Tracker_SM::GiveHeadPoseData(THeadPoseData *data) return false; } -bool FTNoIR_Tracker_SM::setParameterValue(const int index, const float newvalue) +void FTNoIR_Tracker::getFullName(QString *strToBeFilled) { - if ((index >= 0) && (index < parameterValueAsFloat.size())) - { - // - // Limit the new value, using the defined range. - // - if (newvalue < parameterRange[index].first) { - parameterValueAsFloat[index] = parameterRange[index].first; - } - else { - if (newvalue > parameterRange[index].second) { - parameterValueAsFloat[index] = parameterRange[index].second; - } - else { - parameterValueAsFloat[index] = newvalue; - } - } + *strToBeFilled = trackerFullName; +}; -// updateParameterString(index); - return true; - } - else - { - return false; - } + +void FTNoIR_Tracker::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + + +void FTNoIR_Tracker::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; }; // // Load the current Settings from the currently 'active' INI-file. // -void FTNoIR_Tracker_SM::loadSettings() { +void FTNoIR_Tracker::loadSettings() { - qDebug() << "FTNoIR_Tracker_SM::loadSettings says: Starting "; + qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; 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) - qDebug() << "FTNoIR_Tracker_SM::loadSettings says: iniFile = " << currentFile; + qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; iniFile.beginGroup ( "SMTracker" ); if (pMemData) { @@ -176,9 +184,9 @@ void FTNoIR_Tracker_SM::loadSettings() { // It contains the tracking data, a command-code from FaceTrackNoIR // // -bool FTNoIR_Tracker_SM::SMCreateMapping() +bool FTNoIR_Tracker::SMCreateMapping() { - qDebug() << "FTNoIR_Tracker_SM::FTCreateMapping says: Starting Function"; + qDebug() << "FTNoIR_Tracker::FTCreateMapping says: Starting Function"; // // A FileMapping is used to create 'shared memory' between the faceAPI and FaceTrackNoIR. @@ -191,7 +199,7 @@ bool FTNoIR_Tracker_SM::SMCreateMapping() (LPCSTR) SM_MM_DATA ); if ( hSMMemMap != 0 ) { - qDebug() << "FTNoIR_Tracker_SM::FTCreateMapping says: FileMapping Created!"; + qDebug() << "FTNoIR_Tracker::FTCreateMapping says: FileMapping Created!"; } if ( ( hSMMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) { @@ -204,16 +212,16 @@ bool FTNoIR_Tracker_SM::SMCreateMapping() // hSMMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) SM_MM_DATA ); if ( ( hSMMemMap != 0 ) ) { - qDebug() << "FTNoIR_Tracker_SM::FTCreateMapping says: FileMapping Created again..." << hSMMemMap; + qDebug() << "FTNoIR_Tracker::FTCreateMapping says: FileMapping Created again..." << hSMMemMap; pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFaceData)); if (pMemData != NULL) { - qDebug() << "FTNoIR_Tracker_SM::FTCreateMapping says: MapViewOfFile OK."; + qDebug() << "FTNoIR_Tracker::FTCreateMapping says: MapViewOfFile OK."; // pMemData->handle = handle; // The game uses the handle, to send a message that the Program-Name was set! } hSMMutex = CreateMutexA(NULL, false, SM_MUTEX); } else { - qDebug() << "FTNoIR_Tracker_SM::FTCreateMapping says: Error creating Shared Memory for faceAPI!"; + qDebug() << "FTNoIR_Tracker::FTCreateMapping says: Error creating Shared Memory for faceAPI!"; return false; } @@ -239,294 +247,5 @@ bool FTNoIR_Tracker_SM::SMCreateMapping() FTNOIR_TRACKER_BASE_EXPORT TRACKERHANDLE __stdcall GetTracker() { - return new FTNoIR_Tracker_SM; -} - -//******************************************************************************************************* -// faceAPI Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -SMClientControls::SMClientControls() : -QWidget() -{ - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.btnEngineStart, SIGNAL(clicked()), this, SLOT(doStartEngine())); - connect(ui.btnEngineStop, SIGNAL(clicked()), this, SLOT(doStopEngine())); - - ui.cbxFilterSetting->addItem("None"); - ui.cbxFilterSetting->addItem("Normal"); - ui.cbxFilterSetting->addItem("High"); - connect(ui.cbxFilterSetting, SIGNAL(currentIndexChanged(int)), this, SLOT(doSetFilter( int ))); - connect(ui.btnCameraSettings, SIGNAL(clicked()), this, SLOT(doShowCam())); - - if (SMCreateMapping()) { - qDebug() << "SMClientControls::Initialize Mapping created."; - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); - } - - // Load the settings from the current .INI-file - loadSettings(); - - //Setup the timer for showing the headpose. - timUpdateSettings = new QTimer(this); - connect(timUpdateSettings, SIGNAL(timeout()), this, SLOT(doTimUpdate())); - timUpdateSettings->start(100); - connect(this, SIGNAL(stateChanged( int )), this, SLOT(showSettings( int ))); - -} - -// -// Destructor for server-dialog -// -SMClientControls::~SMClientControls() { - qDebug() << "~SMClientControls() says: started"; -} - -void SMClientControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void SMClientControls::Initialize(QWidget *parent) { - - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void SMClientControls::doOK() { - save(); - this->close(); -} - -// override show event -void SMClientControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void SMClientControls::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 ); - - qDebug() << "doCancel says: answer =" << ret; - - 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(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void SMClientControls::loadSettings() { - -// qDebug() << "loadSettings says: Starting "; - 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) - -// qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "SMTracker" ); - ui.cbxFilterSetting->setCurrentIndex(iniFile.value ( "FilterLevel", 1 ).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void SMClientControls::save() { - - 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 ( "SMTracker" ); - iniFile.setValue ( "FilterLevel", ui.cbxFilterSetting->currentIndex() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Create a memory-mapping to the faceAPI data. -// It contains the tracking data, a command-code from FaceTrackNoIR -// -// -bool SMClientControls::SMCreateMapping() -{ - qDebug() << "SMClientControls::FTCreateMapping says: Starting Function"; - - // - // A FileMapping is used to create 'shared memory' between the faceAPI and FaceTrackNoIR. - // - // Try to create a FileMapping to the Shared Memory. - // If one already exists: close it. - // - hSMMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , - sizeof( TFaceData ) + sizeof( HANDLE ) + 100, - (LPCSTR) SM_MM_DATA ); - - if ( hSMMemMap != 0 ) { - qDebug() << "SMClientControls::FTCreateMapping says: FileMapping Created!"; - } - - if ( ( hSMMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) { - CloseHandle( hSMMemMap ); - hSMMemMap = 0; - } - - // - // Create a new FileMapping, Read/Write access - // - hSMMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) SM_MM_DATA ); - if ( ( hSMMemMap != 0 ) ) { - qDebug() << "SMClientControls::FTCreateMapping says: FileMapping Created again..." << hSMMemMap; - pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFaceData)); - if (pMemData != NULL) { - qDebug() << "SMClientControls::FTCreateMapping says: MapViewOfFile OK."; -// pMemData->handle = handle; // The game uses the handle, to send a message that the Program-Name was set! - } - hSMMutex = CreateMutexA(NULL, false, SM_MUTEX); - } - else { - qDebug() << "SMClientControls::FTCreateMapping says: Error creating Shared Memory for faceAPI!"; - return false; - } - - //if (pMemData != NULL) { - // pMemData->data.DataID = 1; - // pMemData->data.CamWidth = 100; - // pMemData->data.CamHeight = 250; - //} - - return true; -} - -// -// Show the current engine-settings etc. -// -void SMClientControls::doTimUpdate() -{ - int state = pMemData->state; - if ( state != prev_state) { - emit stateChanged(state); - prev_state = state; - } -} - -// -// Show the current engine-settings etc. -// -void SMClientControls::showSettings( int newState ) -{ - qDebug() << "SMClientControls::showSettings says: Starting Function"; - switch (newState) - { - case SM_API_ENGINE_STATE_TERMINATED: - ui._engine_state_label->setText("TERMINATED"); - break; - case SM_API_ENGINE_STATE_INVALID: - ui._engine_state_label->setText("INVALID"); - break; - case SM_API_ENGINE_STATE_IDLE: - ui._engine_state_label->setText("IDLE"); - break; - case SM_API_ENGINE_STATE_HT_INITIALIZING: - ui._engine_state_label->setText("INITIALIZING"); - break; - case SM_API_ENGINE_STATE_HT_TRACKING: - ui._engine_state_label->setText("TRACKING"); - break; - case SM_API_ENGINE_STATE_HT_SEARCHING: - ui._engine_state_label->setText("SEARCHING"); - break; - default: - ui._engine_state_label->setText("Unknown State!"); - break; - } - - ui.cbxFilterSetting->setEnabled( (newState == SM_API_ENGINE_STATE_IDLE) ); -} - -// -// Send a command without parameter-value to the tracking Engine. -// -void SMClientControls::doCommand(int command) -{ - if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { - pMemData->command = command; // Send command - ReleaseMutex(hSMMutex); - } - return; -} - -// -// Send a command with integer parameter-value to the tracking Engine. -// -void SMClientControls::doCommand(int command, int value) -{ - if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { - pMemData->command = command; // Send command - pMemData->par_val_int = value; - ReleaseMutex(hSMMutex); - } - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// 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 TRACKERDIALOGHANDLE __stdcall GetTrackerDialog( ) -{ - return new SMClientControls; + return new FTNoIR_Tracker; } diff --git a/FTNoIR_Tracker_SM/images/SeeingMachines.ico b/FTNoIR_Tracker_SM/images/SeeingMachines.ico new file mode 100644 index 00000000..19b24c84 Binary files /dev/null and b/FTNoIR_Tracker_SM/images/SeeingMachines.ico differ diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h index 51c22027..4cae5e62 100644 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h +++ b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h @@ -7,11 +7,11 @@ #include "Windows.h" #include "math.h" -class FTNoIR_Tracker_UDP : public ITracker, QThread +class FTNoIR_Tracker : public ITracker, QThread { public: - FTNoIR_Tracker_UDP(); - ~FTNoIR_Tracker_UDP(); + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); void Release(); void Initialize( QFrame *videoframe ); @@ -20,7 +20,9 @@ public: bool GiveHeadPoseData(THeadPoseData *data); void loadSettings(); - bool setParameterValue(const int index, const float newvalue); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); protected: void run(); // qthread override run method @@ -40,30 +42,39 @@ private: THeadPoseData newHeadPose; // Structure with new headpose - //parameter list for the filter-function(s) - enum - { - kPortAddress=0, // Index in QList - kNumFilterParameters // Indicate number of parameters used - }; - QList> parameterRange; - QList parameterValueAsFloat; - + ////parameter list for the filter-function(s) + //enum + //{ + // kPortAddress=0, // Index in QList + // kNumFilterParameters // Indicate number of parameters used + //}; + //QList> parameterRange; + //QList parameterValueAsFloat; + + float portAddress; // Port-number + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; }; // Widget that has controls for FTNoIR protocol client-settings. -class FTNClientControls: public QWidget, Ui::UICFTNClientControls, public ITrackerDialog +class TrackerControls: public QWidget, Ui::UICFTNClientControls, public ITrackerDialog { Q_OBJECT public: - explicit FTNClientControls(); - virtual ~FTNClientControls(); + explicit TrackerControls(); + virtual ~TrackerControls(); void showEvent ( QShowEvent * event ); void Release(); // Member functions which are accessible from outside the DLL void Initialize(QWidget *parent); + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + private: Ui::UICFTNClientControls ui; void loadSettings(); @@ -72,6 +83,10 @@ private: /** helper **/ bool settingsDirty; + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; + private slots: void doOK(); void doCancel(); diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj index b1b383c0..a1533b0a 100644 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj +++ b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.vcproj @@ -171,6 +171,10 @@ RelativePath=".\ftnoir_tracker_udp.cpp" > + + . * +* * +********************************************************************************/ #include "ftnoir_tracker_udp.h" -FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP() +FTNoIR_Tracker::FTNoIR_Tracker() { inSocket = 0; outSocket = 0; @@ -9,14 +33,21 @@ FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP() m_StopThread = CreateEvent(0, TRUE, FALSE, 0); m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); - //allocate memory for the parameters - parameterValueAsFloat.clear(); - parameterRange.clear(); + ////allocate memory for the parameters + //parameterValueAsFloat.clear(); + //parameterRange.clear(); - // Add the parameters to the list - parameterRange.append(std::pair(1000.0f,9999.0f)); - parameterValueAsFloat.append(0.0f); - setParameterValue(kPortAddress,5551.0f); + //// Add the parameters to the list + //parameterRange.append(std::pair(1000.0f,9999.0f)); + //parameterValueAsFloat.append(0.0f); + //setParameterValue(kPortAddress,5551.0f); + + portAddress = 5551; + + //populate the description strings + trackerFullName = "FaceTrackNoIR UDP"; + trackerShortName = "UDP"; + trackerDescription = "FaceTrackNoIR UDP"; newHeadPose.x = 0.0f; newHeadPose.y = 0.0f; @@ -26,7 +57,7 @@ FTNoIR_Tracker_UDP::FTNoIR_Tracker_UDP() newHeadPose.roll = 0.0f; } -FTNoIR_Tracker_UDP::~FTNoIR_Tracker_UDP() +FTNoIR_Tracker::~FTNoIR_Tracker() { // Trigger thread to stop ::SetEvent(m_StopThread); @@ -52,7 +83,7 @@ FTNoIR_Tracker_UDP::~FTNoIR_Tracker_UDP() } /** QThread run @override **/ -void FTNoIR_Tracker_UDP::run() { +void FTNoIR_Tracker::run() { int no_bytes; QHostAddress sender; @@ -68,7 +99,7 @@ quint16 senderPort; { // Set event ::SetEvent(m_WaitThread); - qDebug() << "FTNoIR_Tracker_UDP::run() terminated run()"; + qDebug() << "FTNoIR_Tracker::run() terminated run()"; return; } @@ -82,7 +113,7 @@ quint16 senderPort; } } else { - qDebug() << "FTNoIR_Tracker_UDP::run() insocket not ready: exit run()"; + qDebug() << "FTNoIR_Tracker::run() insocket not ready: exit run()"; return; } @@ -92,26 +123,26 @@ quint16 senderPort; } } -void FTNoIR_Tracker_UDP::Release() +void FTNoIR_Tracker::Release() { delete this; } -void FTNoIR_Tracker_UDP::Initialize( QFrame *videoframe ) +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) { - qDebug() << "FTNoIR_Tracker_UDP::Initialize says: Starting "; + qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; loadSettings(); // // Create UDP-sockets if they don't exist already. - // They must be created here, because they must be in the new thread (FTNoIR_Tracker_UDP::run()) + // They must be created here, because they must be in the new thread (FTNoIR_Tracker::run()) // if (inSocket == 0) { - qDebug() << "FTNoIR_Tracker_UDP::Initialize() creating insocket"; + qDebug() << "FTNoIR_Tracker::Initialize() creating insocket"; inSocket = new QUdpSocket(); // Connect the inSocket to the port, to receive messages - if (!inSocket->bind(QHostAddress::Any, (int) parameterValueAsFloat[kPortAddress], QUdpSocket::ShareAddress )) { + if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress )) { QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); delete inSocket; inSocket = 0; @@ -121,13 +152,13 @@ void FTNoIR_Tracker_UDP::Initialize( QFrame *videoframe ) return; } -void FTNoIR_Tracker_UDP::StartTracker( HWND parent_window ) +void FTNoIR_Tracker::StartTracker( HWND parent_window ) { start( QThread::TimeCriticalPriority ); return; } -void FTNoIR_Tracker_UDP::StopTracker( bool exit ) +void FTNoIR_Tracker::StopTracker( bool exit ) { // // OK, the thread is not stopped, doing this. That might be dangerous anyway... @@ -136,7 +167,7 @@ void FTNoIR_Tracker_UDP::StopTracker( bool exit ) return; } -bool FTNoIR_Tracker_UDP::GiveHeadPoseData(THeadPoseData *data) +bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) { data->x = newHeadPose.x; data->y = newHeadPose.y; @@ -147,49 +178,38 @@ bool FTNoIR_Tracker_UDP::GiveHeadPoseData(THeadPoseData *data) return true; } -bool FTNoIR_Tracker_UDP::setParameterValue(const int index, const float newvalue) +void FTNoIR_Tracker::getFullName(QString *strToBeFilled) { - if ((index >= 0) && (index < parameterValueAsFloat.size())) - { - // - // Limit the new value, using the defined range. - // - if (newvalue < parameterRange[index].first) { - parameterValueAsFloat[index] = parameterRange[index].first; - } - else { - if (newvalue > parameterRange[index].second) { - parameterValueAsFloat[index] = parameterRange[index].second; - } - else { - parameterValueAsFloat[index] = newvalue; - } - } + *strToBeFilled = trackerFullName; +}; -// updateParameterString(index); - return true; - } - else - { - return false; - } + +void FTNoIR_Tracker::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + + +void FTNoIR_Tracker::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; }; // // Load the current Settings from the currently 'active' INI-file. // -void FTNoIR_Tracker_UDP::loadSettings() { +void FTNoIR_Tracker::loadSettings() { - qDebug() << "FTNoIR_Tracker_UDP::loadSettings says: Starting "; + qDebug() << "FTNoIR_Tracker::loadSettings says: Starting "; 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) - qDebug() << "FTNoIR_Tracker_UDP::loadSettings says: iniFile = " << currentFile; + qDebug() << "FTNoIR_Tracker::loadSettings says: iniFile = " << currentFile; iniFile.beginGroup ( "FTNClient" ); - setParameterValue(kPortAddress, (float) iniFile.value ( "PortNumber", 5550 ).toInt()); + portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); iniFile.endGroup (); } @@ -205,159 +225,5 @@ void FTNoIR_Tracker_UDP::loadSettings() { FTNOIR_TRACKER_BASE_EXPORT TRACKERHANDLE __stdcall GetTracker() { - return new FTNoIR_Tracker_UDP; -} - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTNClientControls::FTNClientControls() : -QWidget() -{ - ui.setupUi( this ); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - //connect(ui.spinIPFirstNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - //connect(ui.spinIPSecondNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - //connect(ui.spinIPThirdNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - //connect(ui.spinIPFourthNibble, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - connect(ui.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FTNClientControls::~FTNClientControls() { - qDebug() << "~FTNClientControls() says: started"; -} - -void FTNClientControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FTNClientControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTNClientControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTNClientControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTNClientControls::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 ); - - qDebug() << "doCancel says: answer =" << ret; - - 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(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNClientControls::loadSettings() { - -// qDebug() << "loadSettings says: Starting "; - 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) - -// qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTNClient" ); - //ui.spinIPFirstNibble->setValue( iniFile.value ( "IP-1", 192 ).toInt() ); - //ui.spinIPSecondNibble->setValue( iniFile.value ( "IP-2", 168 ).toInt() ); - //ui.spinIPThirdNibble->setValue( iniFile.value ( "IP-3", 2 ).toInt() ); - //ui.spinIPFourthNibble->setValue( iniFile.value ( "IP-4", 1 ).toInt() ); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTNClientControls::save() { - - 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 ( "FTNClient" ); - //iniFile.setValue ( "IP-1", ui.spinIPFirstNibble->value() ); - //iniFile.setValue ( "IP-2", ui.spinIPSecondNibble->value() ); - //iniFile.setValue ( "IP-3", ui.spinIPThirdNibble->value() ); - //iniFile.setValue ( "IP-4", ui.spinIPFourthNibble->value() ); - iniFile.setValue ( "PortNumber", ui.spinPortNumber->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} -//////////////////////////////////////////////////////////////////////////////// -// 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 TRACKERDIALOGHANDLE __stdcall GetTrackerDialog( ) -{ - return new FTNClientControls; + return new FTNoIR_Tracker; } diff --git a/FaceTrackNoIR.sln b/FaceTrackNoIR.sln index d01e19c9..ac8bfd14 100644 --- a/FaceTrackNoIR.sln +++ b/FaceTrackNoIR.sln @@ -35,7 +35,9 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FaceTrackNoIR", "FaceTrackN EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "SetupFTN_Update", "SetupFTN_Update\SetupFTN_Update.vdproj", "{49C224BA-751A-4D15-90B6-E496C43DE308}" EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_dz1", "FTNoIR_Filter_DZ1\FTNoIR_Filter_DZ1.vcproj", "{2212857A-7634-4E30-BA83-539EC70176E6}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_FD", "FTNoIR_Tracker_FD\FTNoIR_Tracker_FD.vcproj", "{0FE16301-240D-42B9-9141-12294BA08AC4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_Accela", "FTNoIR_Filter_Accela\FTNoIR_Filter_accela.vcproj", "{2212857A-7634-4E30-BA83-539EC70176E6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -107,6 +109,10 @@ Global {49C224BA-751A-4D15-90B6-E496C43DE308}.Debug|Win32.ActiveCfg = Debug {49C224BA-751A-4D15-90B6-E496C43DE308}.Debug|Win32.Build.0 = Debug {49C224BA-751A-4D15-90B6-E496C43DE308}.Release|Win32.ActiveCfg = Release + {0FE16301-240D-42B9-9141-12294BA08AC4}.Debug|Win32.ActiveCfg = Debug|Win32 + {0FE16301-240D-42B9-9141-12294BA08AC4}.Debug|Win32.Build.0 = Debug|Win32 + {0FE16301-240D-42B9-9141-12294BA08AC4}.Release|Win32.ActiveCfg = Release|Win32 + {0FE16301-240D-42B9-9141-12294BA08AC4}.Release|Win32.Build.0 = Release|Win32 {2212857A-7634-4E30-BA83-539EC70176E6}.Debug|Win32.ActiveCfg = Debug|Win32 {2212857A-7634-4E30-BA83-539EC70176E6}.Debug|Win32.Build.0 = Debug|Win32 {2212857A-7634-4E30-BA83-539EC70176E6}.Release|Win32.ActiveCfg = Release|Win32 diff --git a/FaceTrackNoIR.suo b/FaceTrackNoIR.suo index b10483b5..e5797c80 100644 Binary files a/FaceTrackNoIR.suo and b/FaceTrackNoIR.suo differ diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp index 7e7800bf..bb078b07 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ b/FaceTrackNoIR/FaceTrackNoIR.cpp @@ -23,6 +23,10 @@ *********************************************************************************/ /* Modifications (last one on top): + 20120317 - WVR: The Filter and Tracker-code was moved to separate DLL's. The calling-method + was changed accordingly. The save() and LoadSettings() functions were adapted. + The face-tracker member-functions NotifyZeroed and refreshVideo were added, as + requested by Stanislaw. 20110813 - WVR: Changed the presentation of the raw inputs: now a decimal digit will even show when '0'. 20110404 - WVR: Migrated the FlightGear protocol to a separate DLL. The rest must follow... 20110401 - WVR: The about-dialog was shown 'misplaced'. It was corrected. @@ -223,6 +227,22 @@ QFrame *FaceTrackNoIR::getVideoWidget() { return ui.video_frame; } +// +// Return the name of the Filter-DLL +// +QString FaceTrackNoIR::getCurrentFilterName() +{ + return filterFileList.at(ui.iconcomboFilter->currentIndex()); +} + +// +// Return the name of the Tracker-DLL +// +QString FaceTrackNoIR::getCurrentTrackerName() +{ + return trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); +} + /** read the name of the first video-capturing device at start up **/ /** FaceAPI can only use this first one... **/ void FaceTrackNoIR::GetCameraNameDX() { @@ -341,6 +361,14 @@ void FaceTrackNoIR::save() { iniFile.beginGroup ( "TrackerSource" ); iniFile.setValue ( "Selection", ui.iconcomboTrackerSource->currentIndex() ); + iniFile.setValue ( "DLL", getCurrentTrackerName() ); + iniFile.endGroup (); + + // + // Save the name of the filter in the INI-file. + // + iniFile.beginGroup ( "Filter" ); + iniFile.setValue ( "DLL", getCurrentFilterName() ); iniFile.endGroup (); settingsDirty = false; @@ -458,16 +486,42 @@ void FaceTrackNoIR::loadSettings() { setIcon( ui.iconcomboBox->currentIndex() ); iniFile.endGroup (); + // + // Read the currently selected Tracker from the INI-file. + // If the setting "DLL" isn't found (pre-1.7 version), then the setting 'Selection' is evaluated. + // iniFile.beginGroup ( "TrackerSource" ); - ui.iconcomboTrackerSource->setCurrentIndex(iniFile.value ( "Selection", 0 ).toInt()); - trackingSourceSelected( ui.iconcomboTrackerSource->currentIndex() ); + QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); + qDebug() << "createIconGroupBox says: selectedTrackerName = " << selectedTrackerName; + if (selectedTrackerName.length() == 0) { + int index = iniFile.value ( "Selection", 0 ).toInt(); + switch ( index ) { + case 0: // Face API + selectedTrackerName = "FTNoIR_Tracker_SM.dll"; + break; + case 1: // FTNoir server + selectedTrackerName = "FTNoIR_Tracker_UDP.dll"; + break; + default: + selectedTrackerName = "FTNoIR_Tracker_SM.dll"; + break; + } + } iniFile.endGroup (); + disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + for ( int i = 0; i < trackerFileList.size(); i++) { + if (trackerFileList.at(i) == selectedTrackerName) { + ui.iconcomboTrackerSource->setCurrentIndex( i ); + } + } + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + // // Read the currently selected Filter from the INI-file. // iniFile.beginGroup ( "Filter" ); - QString selectedFilterName = iniFile.value ( "Selection", "FTNoIR_Filter_EWMA2.dll" ).toString(); + QString selectedFilterName = iniFile.value ( "DLL", "FTNoIR_Filter_EWMA2.dll" ).toString(); qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; iniFile.endGroup (); @@ -542,22 +596,23 @@ void FaceTrackNoIR::startTracker( ) { ui.btnStartTracker->setEnabled ( false ); ui.btnStopTracker->setEnabled ( true ); - // Engine controls - switch (ui.iconcomboTrackerSource->currentIndex()) { - case FT_SM_FACEAPI: // Face API - ui.btnShowEngineControls->setEnabled ( true ); // Active only when started! - break; - case FT_FTNOIR: // FTNoir server - ui.btnShowEngineControls->setEnabled ( false ); - break; - default: - break; - } + //// Engine controls + //switch (ui.iconcomboTrackerSource->currentIndex()) { + //case FT_SM_FACEAPI: // Face API + // ui.btnShowEngineControls->setEnabled ( true ); // Active only when started! + // break; + //case FT_FTNOIR: // FTNoir server + // ui.btnShowEngineControls->setEnabled ( false ); + // break; + //default: + // break; + //} // Enable/disable Protocol-server Settings ui.iconcomboTrackerSource->setEnabled ( false ); ui.iconcomboBox->setEnabled ( false ); ui.btnShowServerControls->setEnabled ( false ); + ui.iconcomboFilter->setEnabled ( false ); // // Update the camera-name, FaceAPI can only use the 1st one found! @@ -642,24 +697,25 @@ void FaceTrackNoIR::stopTracker( ) { } ui.btnStartTracker->setEnabled ( true ); ui.btnStopTracker->setEnabled ( false ); - ui.btnShowEngineControls->setEnabled ( false ); +// ui.btnShowEngineControls->setEnabled ( false ); ui.iconcomboBox->setEnabled ( true ); ui.iconcomboTrackerSource->setEnabled ( true ); + ui.iconcomboFilter->setEnabled ( true ); // Enable/disable Protocol-server Settings ui.btnShowServerControls->setEnabled ( true ); - // Engine controls - switch (ui.iconcomboTrackerSource->currentIndex()) { - case FT_SM_FACEAPI: // Face API - ui.btnShowEngineControls->setEnabled ( false ); // Active only when started! - break; - case FT_FTNOIR: // FTNoir server - ui.btnShowEngineControls->setEnabled ( true ); - break; - default: - break; - } + //// Engine controls + //switch (ui.iconcomboTrackerSource->currentIndex()) { + //case FT_SM_FACEAPI: // Face API + // ui.btnShowEngineControls->setEnabled ( false ); // Active only when started! + // break; + //case FT_FTNOIR: // FTNoir server + // ui.btnShowEngineControls->setEnabled ( true ); + // break; + //default: + // break; + //} // // Stop the timer, so it won't go off again... @@ -745,6 +801,13 @@ THeadPoseData newdata; ui.lcdNumOutputRotY->display(QString("%1").arg(newdata.pitch, 0, 'f', 1)); ui.lcdNumOutputRotZ->display(QString("%1").arg(newdata.roll, 0, 'f', 1)); } + + // + // Update the video-widget. + // Requested by Stanislaw + // + Tracker::doRefreshVideo(); + } /** set the smoothing from the slider **/ @@ -793,21 +856,21 @@ QString libName; // Show the appropriate Tracker Settings libName.clear(); + libName = getCurrentTrackerName(); - switch (ui.iconcomboTrackerSource->currentIndex()) { - case FT_SM_FACEAPI: // Face API - qDebug() << "FaceTrackNoIR::showEngineControls case FT_SM_FACEAPI."; - libName = QString("FTNoIR_Tracker_SM.dll"); - break; + //switch (ui.iconcomboTrackerSource->currentIndex()) { + // case FT_SM_FACEAPI: // Face API + // qDebug() << "FaceTrackNoIR::showEngineControls case FT_SM_FACEAPI."; + // break; - case FT_FTNOIR: // FTNoir server - qDebug() << "FaceTrackNoIR::showEngineControls case FT_FTNOIR."; - libName = QString("FTNoIR_Tracker_UDP.dll"); - break; + // case FT_FTNOIR: // FTNoir server + // qDebug() << "FaceTrackNoIR::showEngineControls case FT_FTNOIR."; + // libName = QString("FTNoIR_Tracker.dll"); + // break; - default: - break; - } + // default: + // break; + //} // // Load the Server-settings dialog (if any) and show it. @@ -1013,7 +1076,8 @@ void FaceTrackNoIR::exit() { // void FaceTrackNoIR::createIconGroupBox() { -importGetFilterDialog getIT; +importGetFilterDialog getFilter; +importGetTrackerDialog getTracker; QLibrary *filterLib; QString *filterName; QIcon *filterIcon; @@ -1032,14 +1096,6 @@ QIcon *filterIcon; ui.iconcomboBox->addItem(QIcon(":/images/FS9.ico"), tr("FS2002/FS2004")); ui.iconcomboBox->addItem(QIcon(":/images/Mouse.ico"), tr("Mouse look")); - ui.iconcomboTrackerSource->addItem(QIcon(":/images/SeeingMachines.ico"), tr("Face API")); - ui.iconcomboTrackerSource->addItem(QIcon(":/images/FaceTrackNoIR.ico"), tr("FTNoir server")); - -# ifdef USE_VISAGE - ui.iconcomboTrackerSource->addItem(QIcon(":/images/Visage.ico"), tr("Visage Tracker")); -# endif - - // // Get a List of all the Filter-DLL-files in the Program-folder. // @@ -1070,13 +1126,13 @@ QIcon *filterIcon; filterName = new QString(""); filterIcon = new QIcon(); - getIT = (importGetFilterDialog) filterLib->resolve("GetFilterDialog"); - if (getIT) { - IFilterDialogPtr ptrXyz(getIT()); + getFilter = (importGetFilterDialog) filterLib->resolve("GetFilterDialog"); + if (getFilter) { + IFilterDialogPtr ptrXyz(getFilter()); if (ptrXyz) { pFilterDialog = ptrXyz; - pFilterDialog->getFilterFullName( filterName ); + pFilterDialog->getFullName( filterName ); pFilterDialog->getIcon( filterIcon ); qDebug() << "FaceTrackNoIR::showServerControls GetFilterDialog Function Resolved!"; } @@ -1085,13 +1141,65 @@ QIcon *filterIcon; } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded, please check if the DLL is version 1.7",QMessageBox::Ok,QMessageBox::NoButton); } ui.iconcomboFilter->addItem(*filterIcon, *filterName ); } connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + // + // Get a List of all the Filter-DLL-files in the Program-folder. + // + filters.clear(); + filters << "FTNoIR_Tracker_*.dll"; + trackerFileList.clear(); + trackerFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + + // + // Add strings to the Listbox. + // + disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + ui.iconcomboTrackerSource->clear(); + for ( int i = 0; i < trackerFileList.size(); i++) { + + qDebug() << "createIconGroupBox says: TrackerName = " << trackerFileList.at(i); + + // + // Delete the existing QDialog + // + if (pTrackerDialog) { + pTrackerDialog.Release(); + } + + // Show the appropriate Protocol-server Settings + filterLib = new QLibrary(trackerFileList.at(i)); + filterName = new QString(""); + filterIcon = new QIcon(); + + getTracker = (importGetTrackerDialog) filterLib->resolve("GetTrackerDialog"); + if (getTracker) { + ITrackerDialogPtr ptrXyz(getTracker()); + if (ptrXyz) + { + pTrackerDialog = ptrXyz; + pTrackerDialog->getFullName( filterName ); + pTrackerDialog->getIcon( filterIcon ); + qDebug() << "FaceTrackNoIR::showServerControls GetTrackerDialog Function Resolved!"; + } + else { + qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Facetracker-DLL not loaded, please check if the DLL is version 1.7",QMessageBox::Ok,QMessageBox::NoButton); + } + + ui.iconcomboTrackerSource->addItem(*filterIcon, *filterName ); + } + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + + } // @@ -1195,18 +1303,18 @@ void FaceTrackNoIR::iconActivated(QSystemTrayIcon::ActivationReason reason) void FaceTrackNoIR::trackingSourceSelected(int index) { settingsDirty = true; - switch ( index ) { - case FT_SM_FACEAPI: // Face API - ui.btnShowEngineControls->setEnabled ( false ); - break; - case FT_FTNOIR: // FTNoir server - ui.video_frame->hide(); - ui.headPoseWidget->show(); - ui.btnShowEngineControls->setEnabled ( true ); - break; - default: - break; - } + //switch ( index ) { + // case FT_SM_FACEAPI: // Face API + // ui.btnShowEngineControls->setEnabled ( false ); + // break; + // case FT_FTNOIR: // FTNoir server + // ui.video_frame->hide(); + // ui.headPoseWidget->show(); + ui.btnShowEngineControls->setEnabled ( true ); + // break; + // default: + // break; + //} } // @@ -1233,17 +1341,12 @@ void FaceTrackNoIR::profileSelected(int index) // void FaceTrackNoIR::filterSelected(int index) { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + settingsDirty = true; - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) + //QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - // - // Save the name of the filter in the INI-file. Do this immediately, so the Tracker can just read it from the INI-file to load the filter. - // - iniFile.beginGroup ( "Filter" ); - iniFile.setValue ( "Selection", filterFileList.at(ui.iconcomboFilter->currentIndex()) ); - iniFile.endGroup (); + //QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + //QSettings iniFile( currentFile, QSettings::IniFormat ); // Application settings (in INI-file) ui.btnShowFilterControls->setEnabled ( true ); } diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h index f39062bc..1bc2d7b7 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ b/FaceTrackNoIR/FaceTrackNoIR.h @@ -78,6 +78,8 @@ public: void updateSettings(); // Update the settings (let Tracker read INI-file). QFrame *getVideoWidget(); // Get a pointer to the video-widget, to use in the DLL + QString getCurrentFilterName(); // Get the name of the selected filter + QString getCurrentTrackerName(); // Get the name of the selected face-tracker private: Ui::FaceTrackNoIRClass ui; @@ -86,6 +88,7 @@ private: QTimer *timUpdateHeadPose; // Timer to display headpose QStringList iniFileList; // List of INI-files, that are present in the Settings folder QStringList filterFileList; // List of Filter-DLL-files, that are present in the program-folder + QStringList trackerFileList; // List of Tracker-DLL-files, that are present in the program-folder ITrackerDialogPtr pTrackerDialog; // Pointer to Tracker dialog instance (in DLL) IProtocolDialogPtr pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) diff --git a/FaceTrackNoIR/FaceTrackNoIR.qrc b/FaceTrackNoIR/FaceTrackNoIR.qrc index b24c4e2f..bc1b34f4 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.qrc +++ b/FaceTrackNoIR/FaceTrackNoIR.qrc @@ -10,7 +10,6 @@ images/330px-6DOF_en.png images/Freetrack.ico images/FaceTrackNoIR.ico - images/SeeingMachines.ico images/Mouse.ico images/FS9.ico images/FSX.ico diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui index 7fa1f42c..3e367e4e 100644 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ b/FaceTrackNoIR/FaceTrackNoIR.ui @@ -1786,12 +1786,12 @@ background:none; -1 - 3 + 5 - false + true @@ -1855,7 +1855,7 @@ background:none; - + 190 @@ -1872,9 +1872,9 @@ background:none; - Game protocol + Filter - + 10 @@ -1893,7 +1893,7 @@ background:none; 7 - + true @@ -1918,7 +1918,7 @@ background:none; - + 190 @@ -1935,9 +1935,9 @@ background:none; - Filter + Game protocol - + 10 @@ -1956,7 +1956,7 @@ background:none; 7 - + true diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp index cb3a5b79..e529b243 100644 --- a/FaceTrackNoIR/tracker.cpp +++ b/FaceTrackNoIR/tracker.cpp @@ -3,10 +3,10 @@ * gamers from Holland, who don't like to pay much for * * head-tracking. * * * -* Copyright (C) 2010 Wim Vriend (Developing) * +* Copyright (C) 2012 Wim Vriend (Developing) * * Ron Hendriks (Researching and Testing) * * * -* Homepage * +* Homepage: http://facetracknoir.sourceforge.net/home/default.htm * * * * 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 * @@ -23,6 +23,10 @@ *********************************************************************************/ /* Modifications (last one on top): + 20120317 - WVR: The Filter and Tracker-code was moved to separate DLL's. The calling-method + was changed accordingly. + The face-tracker member-functions NotifyZeroed and refreshVideo were added, as + requested by Stanislaw. 20110411 - WVR: Finished moving all Protocols to separate C++ projects. Every protocol now has it's own Class, that's inside it's own DLL. This reduces the size of the program, makes it more structured and enables a more sophisticated installer. @@ -120,7 +124,7 @@ QFrame *video_frame; // Remember the selected client, from the ListBox // If the Tracker runs, this can NOT be changed... selectedClient = (FTNoIR_Client) clientID; - selectedTracker = (FTNoIR_Face_Tracker) facetrackerID; +// selectedTracker = (FTNoIR_Face_Tracker) facetrackerID; // Create events m_StopThread = CreateEvent(0, TRUE, FALSE, 0); @@ -145,29 +149,30 @@ QFrame *video_frame; video_frame = mainApp->getVideoWidget(); qDebug() << "Tracker::setup VideoFrame = " << video_frame; - // - // Select the Tracker-engine DLL - // - switch (selectedTracker) { - case FT_SM_FACEAPI: - libName = QString("FTNoIR_Tracker_SM.dll"); - break; + //// + //// Select the Tracker-engine DLL + //// + //switch (selectedTracker) { + // case FT_SM_FACEAPI: + // libName = QString("FTNoIR_Tracker_SM.dll"); + // break; - case FT_FTNOIR: - libName = QString("FTNoIR_Tracker_UDP.dll"); - break; + // case FT_FTNOIR: + // libName = QString("FTNoIR_Tracker_UDP.dll"); + // break; - case FT_VISAGE: - libName = QString("FTNoIR_Tracker_Visage.dll"); - break; + // case FT_VISAGE: + // libName = QString("FTNoIR_Tracker_Visage.dll"); + // break; - default: - break; - } + // default: + // break; + //} // // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... // + libName = mainApp->getCurrentTrackerName(); if (!libName.isEmpty()) { trackerLib = new QLibrary(libName); getIT = (importGetTracker) trackerLib->resolve("GetTracker"); @@ -182,7 +187,7 @@ QFrame *video_frame; } } else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + QMessageBox::warning(0,"FaceTrackNoIR Error", "Facetracker DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); } } @@ -255,18 +260,8 @@ QFrame *video_frame; // // Load the DLL with the filter-logic and retrieve a pointer to the Filter-class. - // The name of the filter can be found in the INI-file... - libName.clear(); - 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 ( "Filter" ); - libName = iniFile.value ( "Selection", "FTNoIR_Filter_EWMA2.dll" ).toString(); - qDebug() << "Tracker::Tracker() says: selectedFilterName = " << libName; - iniFile.endGroup (); - + // + libName = mainApp->getCurrentFilterName(); filterLib = new QLibrary(libName); getFilter = (importGetFilter) filterLib->resolve("GetFilter"); @@ -380,7 +375,7 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); // if (pFilter) { QString filterName; - pFilter->getFilterFullName(&filterName); + pFilter->getFullName(&filterName); qDebug() << "Tracker::run() FilterName = " << filterName; } @@ -553,9 +548,12 @@ T6DOF gameoutput_camera(0,0,0,0,0,0); // // If Set Game Zero is pressed, copy the current values to the offsets. + // Change requested by Stanislaw // if (Tracker::confid && Tracker::do_game_zero) { - gamezero_camera.position = gameoutput_camera.position; + if (!pTracker->notifyZeroed()) + gamezero_camera.position = gameoutput_camera.position; +// gamezero_camera.position = gameoutput_camera.position; Tracker::do_game_zero = false; } diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h index b9a39eba..fa0c5111 100644 --- a/FaceTrackNoIR/tracker.h +++ b/FaceTrackNoIR/tracker.h @@ -76,11 +76,11 @@ enum FTNoIR_Client { MOUSE = 7 }; -enum FTNoIR_Face_Tracker { - FT_SM_FACEAPI = 0, - FT_FTNOIR = 1, - FT_VISAGE = 2 -}; +//enum FTNoIR_Face_Tracker { +// FT_SM_FACEAPI = 0, +// FT_FTNOIR = 1, +// FT_VISAGE = 2 +//}; enum FTNoIR_Tracker_Status { TRACKER_OFF = 0, @@ -148,7 +148,7 @@ private: HANDLE m_WaitThread; FTNoIR_Client selectedClient; - FTNoIR_Face_Tracker selectedTracker; +// FTNoIR_Face_Tracker selectedTracker; static T6DOF current_camera; // Used for filtering static T6DOF target_camera; @@ -231,6 +231,11 @@ public: static void getHeadPose(THeadPoseData *data); // Return the current headpose data static void getOutputHeadPose(THeadPoseData *data); // Return the current (processed) headpose data static IFilterPtr getFilterPtr() { return pFilter; } + static void doRefreshVideo() { // Call the face-tracker-function RefreshVideo + if (pTracker) { + pTracker->refreshVideo(); + } + }; static float getSmoothFromList ( QList *rawList ); static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } diff --git a/List of compatible games.xls b/List of compatible games.xls index 8b3896e9..1cfdcba3 100644 Binary files a/List of compatible games.xls and b/List of compatible games.xls differ diff --git a/List of compatible webcams.xls b/List of compatible webcams.xls index 733464cb..13cde610 100644 Binary files a/List of compatible webcams.xls and b/List of compatible webcams.xls differ diff --git a/bin/QBezierConfigurator.dll b/bin/QBezierConfigurator.dll index 48fa2679..a550b132 100644 Binary files a/bin/QBezierConfigurator.dll and b/bin/QBezierConfigurator.dll differ diff --git a/bin/Settings/ArmA.ini b/bin/Settings/ArmA.ini index cb6471d1..e7ef044c 100644 --- a/bin/Settings/ArmA.ini +++ b/bin/Settings/ArmA.ini @@ -20,7 +20,7 @@ redRoll=60 redX=71 redY=70 redZ=70 -minSmooth=20 +minSmooth=30 powCurve=5 maxSmooth=70 @@ -74,6 +74,14 @@ Inhibit_Y=false Inhibit_Z=false SetZero=false SetEngineStop=false +Keycode_GameZero=0 +Shift_GameZero=false +Ctrl_GameZero=false +Alt_GameZero=false +Enable_ReverseAxis=true +RA_Yaw=40 +RA_ZPos=0 +RA_ToZPos=100 [TrackerSource] Selection=0 diff --git a/bin/Settings/FF5.ini b/bin/Settings/FF5.ini index 85d0502c..4ed8d77a 100644 --- a/bin/Settings/FF5.ini +++ b/bin/Settings/FF5.ini @@ -65,8 +65,8 @@ Keycode_StartStop=207 Shift_StartStop=false Ctrl_StartStop=false Alt_StartStop=false -SetZero=false -SetEngineStop=false +SetZero=true +SetEngineStop=true Keycode_Inhibit=0 Shift_Inhibit=false Ctrl_Inhibit=false @@ -77,3 +77,11 @@ Inhibit_Roll=false Inhibit_X=false Inhibit_Y=false Inhibit_Z=false +Keycode_GameZero=0 +Shift_GameZero=false +Ctrl_GameZero=false +Alt_GameZero=false +Enable_ReverseAxis=false +RA_Yaw=40 +RA_ZPos=-20 +RA_ToZPos=50 diff --git a/bin/Settings/FreeFalcon.ini b/bin/Settings/FreeFalcon.ini index cedef248..5b486b11 100644 --- a/bin/Settings/FreeFalcon.ini +++ b/bin/Settings/FreeFalcon.ini @@ -51,7 +51,7 @@ Z_point3=@Variant(\0\0\0\x1a@\x10\0\0\0\0\0\0@G\0\0\0\0\0\0) Z_point4=@Variant(\0\0\0\x1a@Q\xc0\0\0\0\0\0@I\0\0\0\0\0\0) [KB_Shortcuts] -Keycode_Center=0 +Keycode_Center=199 Shift_Center=false Ctrl_Center=false Alt_Center=false @@ -59,3 +59,23 @@ Keycode_StartStop=62 Shift_StartStop=false Ctrl_StartStop=false Alt_StartStop=false +Keycode_GameZero=0 +Shift_GameZero=false +Ctrl_GameZero=false +Alt_GameZero=false +SetZero=true +SetEngineStop=true +Keycode_Inhibit=0 +Shift_Inhibit=false +Ctrl_Inhibit=false +Alt_Inhibit=false +Inhibit_Pitch=false +Inhibit_Yaw=false +Inhibit_Roll=false +Inhibit_X=false +Inhibit_Y=false +Inhibit_Z=false +Enable_ReverseAxis=false +RA_Yaw=40 +RA_ZPos=-20 +RA_ToZPos=50 diff --git a/bin/Settings/IL2.ini b/bin/Settings/IL2.ini index cdf491c3..7b3a7eca 100644 --- a/bin/Settings/IL2.ini +++ b/bin/Settings/IL2.ini @@ -20,9 +20,49 @@ redRoll=75 redX=75 redY=75 redZ=75 +minSmooth=15 +powCurve=10 +maxSmooth=50 [GameProtocol] -Selection=3 +Selection=4 [PPJoy] Selection=1 + +[FTIR] +useTIRViews=false +useDummyExe=false + +[TrackerSource] +Selection=0 + +[KB_Shortcuts] +Keycode_Center=0 +Shift_Center=false +Ctrl_Center=false +Alt_Center=false +Keycode_GameZero=0 +Shift_GameZero=false +Ctrl_GameZero=false +Alt_GameZero=false +Keycode_StartStop=0 +Shift_StartStop=false +Ctrl_StartStop=false +Alt_StartStop=false +SetZero=true +SetEngineStop=true +Keycode_Inhibit=0 +Shift_Inhibit=false +Ctrl_Inhibit=false +Alt_Inhibit=false +Inhibit_Pitch=false +Inhibit_Yaw=false +Inhibit_Roll=false +Inhibit_X=false +Inhibit_Y=false +Inhibit_Z=false +Enable_ReverseAxis=true +RA_Yaw=40 +RA_ZPos=-20 +RA_ToZPos=50 diff --git a/bin/Settings/Mouse Look.ini b/bin/Settings/Mouse Look.ini index ef04fa3b..4f03dd8d 100644 --- a/bin/Settings/Mouse Look.ini +++ b/bin/Settings/Mouse Look.ini @@ -47,21 +47,22 @@ Inhibit_X=false Inhibit_Y=false Inhibit_Z=false SetZero=true -SetEngineStop=false +SetEngineStop=true Keycode_GameZero=210 Shift_GameZero=false Ctrl_GameZero=false Alt_GameZero=false +Enable_ReverseAxis=false [Curves] -Yaw_point1=@Variant(\0\0\0\x1a@\x10\0\0\0\0\0\0@\x14\0\0\0\0\0\0) +Yaw_point1=@Variant(\0\0\0\x1a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0) Yaw_point2=@Variant(\0\0\0\x1a@`\xe0\0\0\0\0\0@A\x80\0\0\0\0\0) Yaw_point3=@Variant(\0\0\0\x1a@f\0\0\0\0\0\0@:\0\0\0\0\0\0) Yaw_point4=@Variant(\0\0\0\x1a@f\x80\0\0\0\0\0@I\0\0\0\0\0\0) -Pitch_point1=@Variant(\0\0\0\x1a@\x18\0\0\0\0\0\0@\x18\0\0\0\0\0\0) -Pitch_point2=@Variant(\0\0\0\x1a@M@\0\0\0\0\0@0\0\0\0\0\0\0) +Pitch_point1=@Variant(\0\0\0\x1a\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0) +Pitch_point2=@Variant(\0\0\0\x1a@M\x80\0\0\0\0\0@0\0\0\0\0\0\0) Pitch_point3=@Variant(\0\0\0\x1a@R\x80\0\0\0\0\0@7\0\0\0\0\0\0) -Pitch_point4=@Variant(\0\0\0\x1a@W \0\0\0\0\0@I\0\0\0\0\0\0) +Pitch_point4=@Variant(\0\0\0\x1a@W@\0\0\0\0\0@I\0\0\0\0\0\0) Roll_point1=@Variant(\0\0\0\x1a@\x10\0\0\0\0\0\0@\x14\0\0\0\0\0\0) Roll_point2=@Variant(\0\0\0\x1a@^\xc0\0\0\0\0\0@?\0\0\0\0\0\0) Roll_point3=@Variant(\0\0\0\x1a@d@\0\0\0\0\0@B\0\0\0\0\0\0) @@ -91,6 +92,9 @@ Mouse_X=3 Mouse_Y=2 Mouse_Wheel=7 SensX=23 -SensY=22 +SensY=40 SensWheel=20 useVirtualDesk=false + +[SMTracker] +FilterLevel=2 diff --git a/bin/Settings/SimConnect.ini b/bin/Settings/SimConnect.ini index 0abc2676..1c323bb6 100644 --- a/bin/Settings/SimConnect.ini +++ b/bin/Settings/SimConnect.ini @@ -78,3 +78,11 @@ IP-2=0 IP-3=0 IP-4=1 PortNumber=5550 + +[FG] +LocalPCOnly=true +IP-1=127 +IP-2=0 +IP-3=0 +IP-4=1 +PortNumber=5550 diff --git a/bin/UIElements/SetupFaceTrackNoIR.jpg b/bin/UIElements/SetupFaceTrackNoIR.jpg index 1f110875..8778c6d5 100644 Binary files a/bin/UIElements/SetupFaceTrackNoIR.jpg and b/bin/UIElements/SetupFaceTrackNoIR.jpg differ -- cgit v1.2.3