From 3089c4bbc10e98d18f43e8a70e7a3d0c0eaf0900 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Fri, 22 Mar 2013 20:48:17 +0100 Subject: Downcase. PLEASE TURN OFF IGNORING CASE IN GIT CONFIG!!! .git/config: [core] ignorecase = false --- FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui | 363 --- FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h | 150 -- .../FTNoIR_Filter_accela_vc8.vcproj | 387 ---- .../FTNoIR_Filter_accela_vc9.vcproj | 381 ---- FTNoIR_Filter_Accela/Filter.qrc | 5 - FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp | 176 -- .../ftnoir_filter_accela_dialog.cpp | 210 -- FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp | 56 - FTNoIR_Filter_Accela/images/filter-16-ac.png | Bin 725 -> 0 bytes FTNoIR_Filter_Base/ftnoir_filter_base.h | 91 - FTNoIR_Filter_Base/ftnoir_filter_base_global.h | 12 - FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui | 586 ----- FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h | 119 - FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc8.vcproj | 388 ---- FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc9.vcproj | 380 ---- FTNoIR_Filter_EWMA2/Filter.qrc | 5 - FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp | 236 -- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp | 197 -- FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp | 56 - FTNoIR_Filter_EWMA2/images/filter-16.png | Bin 642 -> 0 bytes FTNoIR_Filter_EWMA2/images/filter-32.png | Bin 1904 -> 0 bytes FTNoIR_PoseWidget/PoseWidget.qrc | 10 - FTNoIR_PoseWidget/glwidget.cpp | 210 -- FTNoIR_PoseWidget/glwidget.h | 72 - FTNoIR_PoseWidget/images/side1.bmp | Bin 44950 -> 0 bytes FTNoIR_PoseWidget/images/side1.png | Bin 9018 -> 0 bytes FTNoIR_PoseWidget/images/side2.png | Bin 2922 -> 0 bytes FTNoIR_PoseWidget/images/side3.png | Bin 2922 -> 0 bytes FTNoIR_PoseWidget/images/side4.png | Bin 2922 -> 0 bytes FTNoIR_PoseWidget/images/side5.png | Bin 2922 -> 0 bytes FTNoIR_PoseWidget/images/side6.png | Bin 4768 -> 0 bytes FTNoIR_Protocol_Base/ftnoir_protocol_base.h | 124 - FTNoIR_Protocol_Base/ftnoir_protocol_base_global.h | 12 - FTNoIR_Protocol_FG/FGTypes.h | 28 - FTNoIR_Protocol_FG/FTNoIR_FGcontrols.ui | 279 --- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp | 257 --- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h | 127 -- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc8.vcproj | 380 ---- FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc9.vcproj | 385 ---- FTNoIR_Protocol_FG/Protocol.qrc | 5 - FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp | 225 -- FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp | 56 - FTNoIR_Protocol_FG/images/FlightGear.ico | Bin 13094 -> 0 bytes FTNoIR_Protocol_FSUIPC/FTNoIR_FSUIPCcontrols.ui | 228 -- FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp | 233 -- FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h | 139 -- .../FTNoIR_Protocol_FSUIPC_vc8.vcproj | 377 ---- .../FTNoIR_Protocol_FSUIPC_vc9.vcproj | 382 ---- FTNoIR_Protocol_FSUIPC/Protocol.qrc | 5 - .../ftnoir_protocol_FSUIPC_dialog.cpp | 197 -- .../ftnoir_protocol_FSUIPC_dll.cpp | 56 - FTNoIR_Protocol_FSUIPC/images/FS9.ico | Bin 29926 -> 0 bytes FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui | 437 ---- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp | 513 ----- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h | 143 -- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc8.vcproj | 393 ---- FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc9.vcproj | 385 ---- FTNoIR_Protocol_FT/FTTypes.h | 104 - FTNoIR_Protocol_FT/Protocol.qrc | 5 - FTNoIR_Protocol_FT/csv.cpp | 99 - FTNoIR_Protocol_FT/csv.h | 38 - FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp | 235 -- FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp | 56 - FTNoIR_Protocol_FT/images/Freetrack.ico | Bin 17542 -> 0 bytes FTNoIR_Protocol_FTN/FTNoIR_FTNControls.ui | 261 --- FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp | 200 -- FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h | 119 - FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc8.vcproj | 381 ---- FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc9.vcproj | 381 ---- FTNoIR_Protocol_FTN/Protocol.qrc | 5 - FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp | 56 - FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp | 194 -- FTNoIR_Protocol_FTN/images/FaceTrackNoIR.ico | Bin 23558 -> 0 bytes FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp | 294 --- FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h | 151 -- .../FTNoIR_Protocol_MOUSE_vc8.vcproj | 381 ---- .../FTNoIR_Protocol_MOUSE_vc9.vcproj | 381 ---- FTNoIR_Protocol_MOUSE/FTNoIR_mousecontrols.ui | 512 ----- FTNoIR_Protocol_MOUSE/Protocol.qrc | 5 - .../ftnoir_protocol_MOUSE_dialog.cpp | 235 -- .../ftnoir_protocol_MOUSE_dll.cpp | 56 - FTNoIR_Protocol_MOUSE/images/Mouse.ico | Bin 17542 -> 0 bytes FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp | 393 ---- FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h | 183 -- FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc8.vcproj | 377 ---- FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc9.vcproj | 382 ---- FTNoIR_Protocol_SC/FTNoIR_SCcontrols.ui | 162 -- FTNoIR_Protocol_SC/Protocol.qrc | 5 - FTNoIR_Protocol_SC/SCServer.manifest | 13 - FTNoIR_Protocol_SC/SimConnect.aps | Bin 1264 -> 0 bytes FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp | 157 -- FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp | 56 - FTNoIR_Protocol_SC/images/FSX.ico | Bin 87910 -> 0 bytes FTNoIR_Tracker_Base/ftnoir_tracker_base.h | 128 -- FTNoIR_Tracker_Base/ftnoir_tracker_base_global.h | 12 - FTNoIR_Tracker_Base/ftnoir_tracker_ma_types.h | 33 - FTNoIR_Tracker_Base/ftnoir_tracker_sm_types.h | 35 - FTNoIR_Tracker_Base/ftnoir_tracker_types.h | 51 - FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui | 152 -- FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h | 114 - FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc8.vcproj | 379 ---- FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc9.vcproj | 376 ---- FTNoIR_Tracker_FD/Tracker.qrc | 5 - FTNoIR_Tracker_FD/face-detect.h | 39 - FTNoIR_Tracker_FD/ftnoir_tracker_facedetect.cpp | 214 -- .../ftnoir_tracker_facedetect_dialog.cpp | 180 -- .../ftnoir_tracker_facedetect_dll.cpp | 85 - FTNoIR_Tracker_FD/images/FaceDetect.ico | Bin 5430 -> 0 bytes FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj | 398 ---- FTNoIR_Tracker_HT/Tracker.qrc | 5 - FTNoIR_Tracker_HT/TrackerControls.ui | 295 --- FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp | 422 ---- FTNoIR_Tracker_HT/ftnoir_tracker_ht.h | 80 - FTNoIR_Tracker_HT/ftnoir_tracker_ht_dll.h | 20 - FTNoIR_Tracker_HT/headtracker-ftnoir.h | 24 - FTNoIR_Tracker_HT/ht-api.h | 85 - FTNoIR_Tracker_HT/images/HT.ico | Bin 15086 -> 0 bytes FTNoIR_Tracker_HT/stdafx.h | 14 - FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui | 1764 --------------- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc | 61 - FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj | 559 ----- FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc9.vcproj | 524 ----- FTNoIR_Tracker_PT/Resources/Logo_IR.png | Bin 10386 -> 0 bytes FTNoIR_Tracker_PT/Resources/cap_front.png | Bin 1164 -> 0 bytes FTNoIR_Tracker_PT/Resources/cap_side.png | Bin 1733 -> 0 bytes FTNoIR_Tracker_PT/Resources/clip_front.png | Bin 571 -> 0 bytes FTNoIR_Tracker_PT/Resources/clip_side.png | Bin 2677 -> 0 bytes FTNoIR_Tracker_PT/Resources/icon.ico | Bin 4286 -> 0 bytes FTNoIR_Tracker_PT/camera.cpp | 226 -- FTNoIR_Tracker_PT/camera.h | 116 - FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp | 257 --- FTNoIR_Tracker_PT/ftnoir_tracker_pt.h | 86 - FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc | 10 - FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp | 336 --- FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h | 102 - FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp | 40 - FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h | 19 - FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp | 150 -- FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h | 84 - FTNoIR_Tracker_PT/point_extractor.cpp | 97 - FTNoIR_Tracker_PT/point_extractor.h | 31 - FTNoIR_Tracker_PT/point_tracker.cpp | 352 --- FTNoIR_Tracker_PT/point_tracker.h | 114 - FTNoIR_Tracker_PT/resource.h | 14 - FTNoIR_Tracker_PT/timer.cpp | 66 - FTNoIR_Tracker_PT/timer.h | 44 - FTNoIR_Tracker_PT/trans_calib.cpp | 44 - FTNoIR_Tracker_PT/trans_calib.h | 39 - FTNoIR_Tracker_PT/videoInput/videoInput.h | 385 ---- FTNoIR_Tracker_PT/videoInput/videoInput_vc8.lib | Bin 2145206 -> 0 bytes FTNoIR_Tracker_PT/videoInput/videoInput_vc9.lib | Bin 2119546 -> 0 bytes FTNoIR_Tracker_PT/video_widget.cpp | 98 - FTNoIR_Tracker_PT/video_widget.h | 40 - FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui | 405 ---- FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h | 157 -- .../FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user | 65 - FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc8.vcproj | 413 ---- FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc9.vcproj | 405 ---- FTNoIR_Tracker_SM/Tracker.qrc | 5 - FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp | 254 --- .../ftnoir_tracker_faceapi_dialog.cpp | 346 --- FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dll.cpp | 85 - FTNoIR_Tracker_SM/images/SeeingMachines.ico | Bin 37798 -> 0 bytes FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui | 381 ---- FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h | 99 - FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc8.vcproj | 338 --- FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc9.vcproj | 335 --- FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp | 217 -- FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp | 181 -- FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dll.cpp | 85 - FaceTrackNoIR/ClientFiles/CFS3/Readme.txt | 27 - FaceTrackNoIR/ClientFiles/CFS3/TIRViews.dll | Bin 109568 -> 0 bytes .../ClientFiles/FS2002 and FS2004/FSUIPC.dll | Bin 210880 -> 0 bytes .../ClientFiles/FlightGear/Nasal/headtracker.xml | 83 - .../FlightGear/Protocol/headtracker.xml | 67 - FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt | 19 - .../ClientFiles/FlightGear/Win32/start_fg.bat | 1 - .../ClientFiles/FreeTrackTest/FreeTrackTest.exe | Bin 398848 -> 0 bytes FaceTrackNoIR/ClientFiles/FreeTrackTest/Readme.txt | 20 - .../ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE | 16 - FaceTrackNoIR/ClientFiles/GlovePIE/Readme.txt | 24 - .../PPJoy/PPJoy mapping for FaceTrackNoIR.jpg | Bin 155205 -> 0 bytes FaceTrackNoIR/ClientFiles/PPJoy/Readme.txt | 24 - FaceTrackNoIR/ClientFiles/Tir4Fun/NPClient.dll | Bin 53248 -> 0 bytes FaceTrackNoIR/ClientFiles/Tir4Fun/readme.txt | 9 - FaceTrackNoIR/ClientFiles/Tir4Fun/tir4fun.exe | Bin 36864 -> 0 bytes FaceTrackNoIR/FSUIPCServer.cpp | 308 --- FaceTrackNoIR/FSUIPCServer.h | 121 - FaceTrackNoIR/FTNServer.cpp | 294 --- FaceTrackNoIR/FTNServer.h | 107 - FaceTrackNoIR/FTNoIR_Curves.ui | 608 ----- FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui | 228 -- FaceTrackNoIR/FTNoIR_FTNServerControls.ui | 261 --- FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui | 1018 --------- FaceTrackNoIR/FTNoIR_Preferences.ui | 240 -- FaceTrackNoIR/FaceApp.cpp | 60 - FaceTrackNoIR/FaceApp.h | 27 - FaceTrackNoIR/FaceTrackNoIR.cpp | 2220 ------------------ FaceTrackNoIR/FaceTrackNoIR.h | 249 -- FaceTrackNoIR/FaceTrackNoIR.ico | Bin 23558 -> 0 bytes FaceTrackNoIR/FaceTrackNoIR.qrc | 14 - FaceTrackNoIR/FaceTrackNoIR.rc | 84 - FaceTrackNoIR/FaceTrackNoIR.ui | 2375 -------------------- FaceTrackNoIR/FaceTrackNoIR_vc8.vcproj | 892 -------- FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj | 886 -------- FaceTrackNoIR/Readme.txt | 31 - FaceTrackNoIR/Readme_Update_20100615.txt | 51 - FaceTrackNoIR/Readme_Update_20100716.txt | 35 - FaceTrackNoIR/Readme_Update_20100822.txt | 32 - FaceTrackNoIR/UIElements/ButtonIcoBlack.bmp | Bin 6966 -> 0 bytes FaceTrackNoIR/UIElements/Curves.png | Bin 2850 -> 0 bytes FaceTrackNoIR/UIElements/Donate.png | Bin 778 -> 0 bytes FaceTrackNoIR/UIElements/FaceTrackNoIR.ico | Bin 23558 -> 0 bytes .../UIElements/Logo_FaceTrackNoIR_32px.jpg | Bin 1082 -> 0 bytes .../UIElements/Logo_FaceTrackNoIR_32px.png | Bin 2822 -> 0 bytes FaceTrackNoIR/UIElements/Logo_NoIR.png | Bin 26173 -> 0 bytes FaceTrackNoIR/UIElements/Logo_NoIR_small.png | Bin 6384 -> 0 bytes .../UIElements/Logo_NoIR_small_target.png | Bin 5971 -> 0 bytes .../UIElements/Logo_NoIR_small_target90px.png | Bin 5582 -> 0 bytes FaceTrackNoIR/UIElements/Tools.png | Bin 3053 -> 0 bytes FaceTrackNoIR/UIElements/aboutFaceTrackNoIR.png | Bin 30557 -> 0 bytes FaceTrackNoIR/UIElements/bubble_1_small.png | Bin 5849 -> 0 bytes FaceTrackNoIR/UIElements/bubble_2_big.png | Bin 6480 -> 0 bytes FaceTrackNoIR/UIElements/logoFaceTrackNoIR.png | Bin 5437 -> 0 bytes FaceTrackNoIR/UIElements/logoFaceTrackNoIR60px.png | Bin 3369 -> 0 bytes FaceTrackNoIR/images/330px-6DOF_en.png | Bin 34182 -> 0 bytes FaceTrackNoIR/images/FaceTrackNoIR.ico | Bin 23558 -> 0 bytes FaceTrackNoIR/images/Settings16.png | Bin 711 -> 0 bytes FaceTrackNoIR/images/SettingsOpen16.png | Bin 686 -> 0 bytes FaceTrackNoIR/images/rotation_DOFs.png | Bin 21601 -> 0 bytes FaceTrackNoIR/images/translation_DOFs.png | Bin 23237 -> 0 bytes FaceTrackNoIR/main.cpp | 59 - FaceTrackNoIR/paintwidget.h | 0 FaceTrackNoIR/postbuild.bat | 27 - FaceTrackNoIR/resource.h | 16 - FaceTrackNoIR/rotation.cpp | 48 - FaceTrackNoIR/rotation.h | 31 - FaceTrackNoIR/spot.h | 27 - FaceTrackNoIR/tracker.cpp | 1081 --------- FaceTrackNoIR/tracker.h | 282 --- FaceTrackNoIR/tracker_types.cpp | 44 - FaceTrackNoIR/tracker_types.h | 45 - FaceTrackNoIR_vc8.sln | 82 - FaceTrackNoIR_vc9.sln | 119 - FreeTrackClient/FTClient.cpp | 119 - FreeTrackClient/FTClient.h | 30 - FreeTrackClient/FreeTrackClient.sln | 26 - .../FreeTrackClient/FreeTrackClient.cpp | 294 --- FreeTrackClient/FreeTrackClient/FreeTrackClient.rc | 103 - .../FreeTrackClient/FreeTrackClient.vcproj | 556 ----- FreeTrackClient/FreeTrackClient/postbuild.bat | 15 - FreeTrackClient/FreeTrackClient/resource.h | 15 - List of compatible games.xls | Bin 41984 -> 0 bytes List of compatible webcams.xls | Bin 32768 -> 0 bytes ...erequisites for using widget in Qt Designer.png | Bin 21422 -> 0 bytes QFunctionConfigurator/QFunctionConfigurator.sln | 20 - .../QFunctionConfigurator/FunctionConfig.cpp | Bin 17350 -> 0 bytes .../QFunctionConfigurator/FunctionConfig.h | Bin 3888 -> 0 bytes .../QFunctionConfigurator.vcproj | 355 --- .../QFunctionConfigurator_vc9.vcproj | 354 --- .../QFunctionConfigurator/postbuild.bat | 30 - .../qfunctionconfigurator.cpp | 721 ------ .../QFunctionConfigurator/qfunctionconfigurator.h | 206 -- .../qfunctionconfiguratorplugin.cpp | 146 -- .../qfunctionconfiguratorplugin.h | 30 - .../QFunctionConfigurator_vc9.sln | 20 - ReadMe.txt | 48 - faceAPI/FaceAPI2FSX_vc8.vcproj | 233 -- faceAPI/FaceAPI2FSX_vc9.vcproj | 232 -- faceAPI/build_options.h | 8 - faceAPI/lock.h | 35 - faceAPI/lockfree.h | 65 - faceAPI/main.cpp | 543 ----- faceAPI/mutex.h | 44 - faceAPI/stdafx.cpp | 8 - faceAPI/stdafx.h | 21 - faceAPI/utils.h | 346 --- faceapi/FaceAPI2FSX_vc8.vcproj | 233 ++ faceapi/FaceAPI2FSX_vc9.vcproj | 232 ++ faceapi/build_options.h | 8 + faceapi/lock.h | 35 + faceapi/lockfree.h | 65 + faceapi/main.cpp | 543 +++++ faceapi/mutex.h | 44 + faceapi/stdafx.cpp | 8 + faceapi/stdafx.h | 21 + faceapi/utils.h | 346 +++ facetracknoir/ClientFiles/CFS3/Readme.txt | 27 + facetracknoir/ClientFiles/CFS3/TIRViews.dll | Bin 0 -> 109568 bytes .../ClientFiles/FS2002 and FS2004/FSUIPC.dll | Bin 0 -> 210880 bytes .../ClientFiles/FlightGear/Nasal/headtracker.xml | 83 + .../FlightGear/Protocol/headtracker.xml | 67 + facetracknoir/ClientFiles/FlightGear/Readme.txt | 19 + .../ClientFiles/FlightGear/Win32/start_fg.bat | 1 + .../ClientFiles/FreeTrackTest/FreeTrackTest.exe | Bin 0 -> 398848 bytes facetracknoir/ClientFiles/FreeTrackTest/Readme.txt | 20 + .../ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE | 16 + facetracknoir/ClientFiles/GlovePIE/Readme.txt | 24 + .../PPJoy/PPJoy mapping for FaceTrackNoIR.jpg | Bin 0 -> 155205 bytes facetracknoir/ClientFiles/PPJoy/Readme.txt | 24 + facetracknoir/ClientFiles/Tir4Fun/NPClient.dll | Bin 0 -> 53248 bytes facetracknoir/ClientFiles/Tir4Fun/readme.txt | 9 + facetracknoir/ClientFiles/Tir4Fun/tir4fun.exe | Bin 0 -> 36864 bytes facetracknoir/FSUIPCServer.cpp | 308 +++ facetracknoir/FSUIPCServer.h | 121 + facetracknoir/FTNServer.cpp | 294 +++ facetracknoir/FTNServer.h | 107 + facetracknoir/FTNoIR_Curves.ui | 608 +++++ facetracknoir/FTNoIR_FSUIPCcontrols.ui | 228 ++ facetracknoir/FTNoIR_FTNServerControls.ui | 261 +++ facetracknoir/FTNoIR_KeyboardShortcuts.ui | 1018 +++++++++ facetracknoir/FTNoIR_Preferences.ui | 240 ++ facetracknoir/FaceApp.cpp | 60 + facetracknoir/FaceApp.h | 27 + facetracknoir/FaceTrackNoIR.cpp | 2220 ++++++++++++++++++ facetracknoir/FaceTrackNoIR.h | 249 ++ facetracknoir/FaceTrackNoIR.ico | Bin 0 -> 23558 bytes facetracknoir/FaceTrackNoIR.qrc | 14 + facetracknoir/FaceTrackNoIR.rc | 84 + facetracknoir/FaceTrackNoIR.ui | 2375 ++++++++++++++++++++ facetracknoir/FaceTrackNoIR_vc8.vcproj | 892 ++++++++ facetracknoir/FaceTrackNoIR_vc9.vcproj | 886 ++++++++ facetracknoir/Readme.txt | 31 + facetracknoir/Readme_Update_20100615.txt | 51 + facetracknoir/Readme_Update_20100716.txt | 35 + facetracknoir/Readme_Update_20100822.txt | 32 + facetracknoir/UIElements/ButtonIcoBlack.bmp | Bin 0 -> 6966 bytes facetracknoir/UIElements/Curves.png | Bin 0 -> 2850 bytes facetracknoir/UIElements/Donate.png | Bin 0 -> 778 bytes facetracknoir/UIElements/FaceTrackNoIR.ico | Bin 0 -> 23558 bytes .../UIElements/Logo_FaceTrackNoIR_32px.jpg | Bin 0 -> 1082 bytes .../UIElements/Logo_FaceTrackNoIR_32px.png | Bin 0 -> 2822 bytes facetracknoir/UIElements/Logo_NoIR.png | Bin 0 -> 26173 bytes facetracknoir/UIElements/Logo_NoIR_small.png | Bin 0 -> 6384 bytes .../UIElements/Logo_NoIR_small_target.png | Bin 0 -> 5971 bytes .../UIElements/Logo_NoIR_small_target90px.png | Bin 0 -> 5582 bytes facetracknoir/UIElements/Tools.png | Bin 0 -> 3053 bytes facetracknoir/UIElements/aboutFaceTrackNoIR.png | Bin 0 -> 30557 bytes facetracknoir/UIElements/bubble_1_small.png | Bin 0 -> 5849 bytes facetracknoir/UIElements/bubble_2_big.png | Bin 0 -> 6480 bytes facetracknoir/UIElements/logoFaceTrackNoIR.png | Bin 0 -> 5437 bytes facetracknoir/UIElements/logoFaceTrackNoIR60px.png | Bin 0 -> 3369 bytes facetracknoir/images/330px-6DOF_en.png | Bin 0 -> 34182 bytes facetracknoir/images/FaceTrackNoIR.ico | Bin 0 -> 23558 bytes facetracknoir/images/Settings16.png | Bin 0 -> 711 bytes facetracknoir/images/SettingsOpen16.png | Bin 0 -> 686 bytes facetracknoir/images/rotation_DOFs.png | Bin 0 -> 21601 bytes facetracknoir/images/translation_DOFs.png | Bin 0 -> 23237 bytes facetracknoir/main.cpp | 59 + facetracknoir/paintwidget.h | 0 facetracknoir/postbuild.bat | 27 + facetracknoir/resource.h | 16 + facetracknoir/rotation.cpp | 48 + facetracknoir/rotation.h | 31 + facetracknoir/spot.h | 27 + facetracknoir/tracker.cpp | 1081 +++++++++ facetracknoir/tracker.h | 282 +++ facetracknoir/tracker_types.cpp | 44 + facetracknoir/tracker_types.h | 45 + facetracknoir_vc8.sln | 82 + facetracknoir_vc9.sln | 119 + freetrackclient/FTClient.cpp | 119 + freetrackclient/FTClient.h | 30 + freetrackclient/FreeTrackClient.sln | 26 + .../FreeTrackClient/FreeTrackClient.cpp | 294 +++ freetrackclient/FreeTrackClient/FreeTrackClient.rc | 103 + .../FreeTrackClient/FreeTrackClient.vcproj | 556 +++++ freetrackclient/FreeTrackClient/postbuild.bat | 15 + freetrackclient/FreeTrackClient/resource.h | 15 + ftnoir_filter_accela/FTNoIR_FilterControls.ui | 363 +++ ftnoir_filter_accela/FTNoIR_Filter_accela.h | 150 ++ .../FTNoIR_Filter_accela_vc8.vcproj | 387 ++++ .../FTNoIR_Filter_accela_vc9.vcproj | 381 ++++ ftnoir_filter_accela/Filter.qrc | 5 + ftnoir_filter_accela/ftnoir_filter_accela.cpp | 176 ++ .../ftnoir_filter_accela_dialog.cpp | 210 ++ ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp | 56 + ftnoir_filter_accela/images/filter-16-ac.png | Bin 0 -> 725 bytes ftnoir_filter_base/ftnoir_filter_base.h | 91 + ftnoir_filter_base/ftnoir_filter_base_global.h | 12 + ftnoir_filter_ewma2/FTNoIR_FilterControls.ui | 586 +++++ ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2.h | 119 + ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc8.vcproj | 388 ++++ ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc9.vcproj | 380 ++++ ftnoir_filter_ewma2/Filter.qrc | 5 + ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp | 236 ++ ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp | 197 ++ ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp | 56 + ftnoir_filter_ewma2/images/filter-16.png | Bin 0 -> 642 bytes ftnoir_filter_ewma2/images/filter-32.png | Bin 0 -> 1904 bytes ftnoir_posewidget/PoseWidget.qrc | 10 + ftnoir_posewidget/glwidget.cpp | 210 ++ ftnoir_posewidget/glwidget.h | 72 + ftnoir_posewidget/images/side1.bmp | Bin 0 -> 44950 bytes ftnoir_posewidget/images/side1.png | Bin 0 -> 9018 bytes ftnoir_posewidget/images/side2.png | Bin 0 -> 2922 bytes ftnoir_posewidget/images/side3.png | Bin 0 -> 2922 bytes ftnoir_posewidget/images/side4.png | Bin 0 -> 2922 bytes ftnoir_posewidget/images/side5.png | Bin 0 -> 2922 bytes ftnoir_posewidget/images/side6.png | Bin 0 -> 4768 bytes ftnoir_protocol_base/ftnoir_protocol_base.h | 124 + ftnoir_protocol_base/ftnoir_protocol_base_global.h | 12 + ftnoir_protocol_fg/FGTypes.h | 28 + ftnoir_protocol_fg/FTNoIR_FGcontrols.ui | 279 +++ ftnoir_protocol_fg/FTNoIR_Protocol_FG.cpp | 257 +++ ftnoir_protocol_fg/FTNoIR_Protocol_FG.h | 127 ++ ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc8.vcproj | 380 ++++ ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc9.vcproj | 385 ++++ ftnoir_protocol_fg/Protocol.qrc | 5 + ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp | 225 ++ ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp | 56 + ftnoir_protocol_fg/images/FlightGear.ico | Bin 0 -> 13094 bytes ftnoir_protocol_fsuipc/FTNoIR_FSUIPCcontrols.ui | 228 ++ ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.cpp | 233 ++ ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.h | 139 ++ .../FTNoIR_Protocol_FSUIPC_vc8.vcproj | 377 ++++ .../FTNoIR_Protocol_FSUIPC_vc9.vcproj | 382 ++++ ftnoir_protocol_fsuipc/Protocol.qrc | 5 + .../ftnoir_protocol_FSUIPC_dialog.cpp | 197 ++ .../ftnoir_protocol_FSUIPC_dll.cpp | 56 + ftnoir_protocol_fsuipc/images/FS9.ico | Bin 0 -> 29926 bytes ftnoir_protocol_ft/FTNoIR_FTcontrols.ui | 437 ++++ ftnoir_protocol_ft/FTNoIR_Protocol_FT.cpp | 513 +++++ ftnoir_protocol_ft/FTNoIR_Protocol_FT.h | 143 ++ ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc8.vcproj | 393 ++++ ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc9.vcproj | 385 ++++ ftnoir_protocol_ft/FTTypes.h | 104 + ftnoir_protocol_ft/Protocol.qrc | 5 + ftnoir_protocol_ft/csv.cpp | 99 + ftnoir_protocol_ft/csv.h | 38 + ftnoir_protocol_ft/ftnoir_protocol_FT_dialog.cpp | 235 ++ ftnoir_protocol_ft/ftnoir_protocol_FT_dll.cpp | 56 + ftnoir_protocol_ft/images/Freetrack.ico | Bin 0 -> 17542 bytes ftnoir_protocol_ftn/FTNoIR_FTNControls.ui | 261 +++ ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.cpp | 200 ++ ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.h | 119 + ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc8.vcproj | 381 ++++ ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc9.vcproj | 381 ++++ ftnoir_protocol_ftn/Protocol.qrc | 5 + ftnoir_protocol_ftn/ftnoir_protocol_FTN_dll.cpp | 56 + ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp | 194 ++ ftnoir_protocol_ftn/images/FaceTrackNoIR.ico | Bin 0 -> 23558 bytes ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.cpp | 294 +++ ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.h | 151 ++ .../FTNoIR_Protocol_MOUSE_vc8.vcproj | 381 ++++ .../FTNoIR_Protocol_MOUSE_vc9.vcproj | 381 ++++ ftnoir_protocol_mouse/FTNoIR_mousecontrols.ui | 512 +++++ ftnoir_protocol_mouse/Protocol.qrc | 5 + .../ftnoir_protocol_MOUSE_dialog.cpp | 235 ++ .../ftnoir_protocol_MOUSE_dll.cpp | 56 + ftnoir_protocol_mouse/images/Mouse.ico | Bin 0 -> 17542 bytes ftnoir_protocol_sc/FTNoIR_Protocol_SC.cpp | 393 ++++ ftnoir_protocol_sc/FTNoIR_Protocol_SC.h | 183 ++ ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc8.vcproj | 377 ++++ ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc9.vcproj | 382 ++++ ftnoir_protocol_sc/FTNoIR_SCcontrols.ui | 162 ++ ftnoir_protocol_sc/Protocol.qrc | 5 + ftnoir_protocol_sc/SCServer.manifest | 13 + ftnoir_protocol_sc/SimConnect.aps | Bin 0 -> 1264 bytes ftnoir_protocol_sc/ftnoir_protocol_SC_dialog.cpp | 157 ++ ftnoir_protocol_sc/ftnoir_protocol_SC_dll.cpp | 56 + ftnoir_protocol_sc/images/FSX.ico | Bin 0 -> 87910 bytes ftnoir_tracker_base/ftnoir_tracker_base.h | 128 ++ ftnoir_tracker_base/ftnoir_tracker_base_global.h | 12 + ftnoir_tracker_base/ftnoir_tracker_ma_types.h | 33 + ftnoir_tracker_base/ftnoir_tracker_sm_types.h | 35 + ftnoir_tracker_base/ftnoir_tracker_types.h | 51 + ftnoir_tracker_fd/FTNoIR_FD_Controls.ui | 152 ++ ftnoir_tracker_fd/FTNoIR_Tracker_FD.h | 114 + ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj | 379 ++++ ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj | 376 ++++ ftnoir_tracker_fd/Tracker.qrc | 5 + ftnoir_tracker_fd/face-detect.h | 39 + ftnoir_tracker_fd/ftnoir_tracker_facedetect.cpp | 214 ++ .../ftnoir_tracker_facedetect_dialog.cpp | 180 ++ .../ftnoir_tracker_facedetect_dll.cpp | 85 + ftnoir_tracker_fd/images/FaceDetect.ico | Bin 0 -> 5430 bytes ftnoir_tracker_ht/FTNoIR_Tracker_HT_vc8.vcproj | 398 ++++ ftnoir_tracker_ht/Tracker.qrc | 5 + ftnoir_tracker_ht/TrackerControls.ui | 295 +++ ftnoir_tracker_ht/ftnoir_tracker_ht.cpp | 422 ++++ ftnoir_tracker_ht/ftnoir_tracker_ht.h | 80 + ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h | 20 + ftnoir_tracker_ht/headtracker-ftnoir.h | 24 + ftnoir_tracker_ht/ht-api.h | 85 + ftnoir_tracker_ht/images/HT.ico | Bin 0 -> 15086 bytes ftnoir_tracker_ht/stdafx.h | 14 + ftnoir_tracker_pt/FTNoIR_PT_Controls.ui | 1764 +++++++++++++++ ftnoir_tracker_pt/FTNoIR_Tracker_PT.rc | 61 + ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc8.vcproj | 559 +++++ ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc9.vcproj | 524 +++++ ftnoir_tracker_pt/Resources/Logo_IR.png | Bin 0 -> 10386 bytes ftnoir_tracker_pt/Resources/cap_front.png | Bin 0 -> 1164 bytes ftnoir_tracker_pt/Resources/cap_side.png | Bin 0 -> 1733 bytes ftnoir_tracker_pt/Resources/clip_front.png | Bin 0 -> 571 bytes ftnoir_tracker_pt/Resources/clip_side.png | Bin 0 -> 2677 bytes ftnoir_tracker_pt/Resources/icon.ico | Bin 0 -> 4286 bytes ftnoir_tracker_pt/camera.cpp | 226 ++ ftnoir_tracker_pt/camera.h | 116 + ftnoir_tracker_pt/ftnoir_tracker_pt.cpp | 257 +++ ftnoir_tracker_pt/ftnoir_tracker_pt.h | 86 + ftnoir_tracker_pt/ftnoir_tracker_pt.qrc | 10 + ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp | 336 +++ ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h | 102 + ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp | 40 + ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h | 19 + ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp | 150 ++ ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h | 84 + ftnoir_tracker_pt/point_extractor.cpp | 97 + ftnoir_tracker_pt/point_extractor.h | 31 + ftnoir_tracker_pt/point_tracker.cpp | 352 +++ ftnoir_tracker_pt/point_tracker.h | 114 + ftnoir_tracker_pt/resource.h | 14 + ftnoir_tracker_pt/timer.cpp | 66 + ftnoir_tracker_pt/timer.h | 44 + ftnoir_tracker_pt/trans_calib.cpp | 44 + ftnoir_tracker_pt/trans_calib.h | 39 + ftnoir_tracker_pt/videoInput/videoInput.h | 385 ++++ ftnoir_tracker_pt/videoInput/videoInput_vc8.lib | Bin 0 -> 2145206 bytes ftnoir_tracker_pt/videoInput/videoInput_vc9.lib | Bin 0 -> 2119546 bytes ftnoir_tracker_pt/video_widget.cpp | 98 + ftnoir_tracker_pt/video_widget.h | 40 + ftnoir_tracker_sm/FTNoIR_SM_Controls.ui | 405 ++++ ftnoir_tracker_sm/FTNoIR_Tracker_SM.h | 157 ++ .../FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user | 65 + ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc8.vcproj | 413 ++++ ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc9.vcproj | 405 ++++ ftnoir_tracker_sm/Tracker.qrc | 5 + ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp | 254 +++ .../ftnoir_tracker_faceapi_dialog.cpp | 346 +++ ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp | 85 + ftnoir_tracker_sm/images/SeeingMachines.ico | Bin 0 -> 37798 bytes ftnoir_tracker_udp/FTNoIR_FTNClientControls.ui | 381 ++++ ftnoir_tracker_udp/FTNoIR_Tracker_UDP.h | 99 + ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc8.vcproj | 338 +++ ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc9.vcproj | 335 +++ ftnoir_tracker_udp/ftnoir_tracker_udp.cpp | 217 ++ ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp | 181 ++ ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp | 85 + list of compatible games.xls | Bin 0 -> 41984 bytes list of compatible webcams.xls | Bin 0 -> 32768 bytes ...erequisites for using widget in Qt Designer.png | Bin 0 -> 21422 bytes qfunctionconfigurator/QFunctionConfigurator.sln | 20 + .../QFunctionConfigurator/FunctionConfig.cpp | Bin 0 -> 17350 bytes .../QFunctionConfigurator/FunctionConfig.h | Bin 0 -> 3888 bytes .../QFunctionConfigurator.vcproj | 355 +++ .../QFunctionConfigurator_vc9.vcproj | 354 +++ .../QFunctionConfigurator/postbuild.bat | 30 + .../qfunctionconfigurator.cpp | 721 ++++++ .../QFunctionConfigurator/qfunctionconfigurator.h | 206 ++ .../qfunctionconfiguratorplugin.cpp | 146 ++ .../qfunctionconfiguratorplugin.h | 30 + .../QFunctionConfigurator_vc9.sln | 20 + readme.txt | 48 + 554 files changed, 44823 insertions(+), 44823 deletions(-) delete mode 100644 FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui delete mode 100644 FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h delete mode 100644 FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc8.vcproj delete mode 100644 FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc9.vcproj delete mode 100644 FTNoIR_Filter_Accela/Filter.qrc delete mode 100644 FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp delete mode 100644 FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp delete mode 100644 FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp delete mode 100644 FTNoIR_Filter_Accela/images/filter-16-ac.png delete mode 100644 FTNoIR_Filter_Base/ftnoir_filter_base.h delete mode 100644 FTNoIR_Filter_Base/ftnoir_filter_base_global.h delete mode 100644 FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui delete mode 100644 FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h delete mode 100644 FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc8.vcproj delete mode 100644 FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc9.vcproj delete mode 100644 FTNoIR_Filter_EWMA2/Filter.qrc delete mode 100644 FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp delete mode 100644 FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp delete mode 100644 FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp delete mode 100644 FTNoIR_Filter_EWMA2/images/filter-16.png delete mode 100644 FTNoIR_Filter_EWMA2/images/filter-32.png delete mode 100644 FTNoIR_PoseWidget/PoseWidget.qrc delete mode 100644 FTNoIR_PoseWidget/glwidget.cpp delete mode 100644 FTNoIR_PoseWidget/glwidget.h delete mode 100644 FTNoIR_PoseWidget/images/side1.bmp delete mode 100644 FTNoIR_PoseWidget/images/side1.png delete mode 100644 FTNoIR_PoseWidget/images/side2.png delete mode 100644 FTNoIR_PoseWidget/images/side3.png delete mode 100644 FTNoIR_PoseWidget/images/side4.png delete mode 100644 FTNoIR_PoseWidget/images/side5.png delete mode 100644 FTNoIR_PoseWidget/images/side6.png delete mode 100644 FTNoIR_Protocol_Base/ftnoir_protocol_base.h delete mode 100644 FTNoIR_Protocol_Base/ftnoir_protocol_base_global.h delete mode 100644 FTNoIR_Protocol_FG/FGTypes.h delete mode 100644 FTNoIR_Protocol_FG/FTNoIR_FGcontrols.ui delete mode 100644 FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp delete mode 100644 FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h delete mode 100644 FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc8.vcproj delete mode 100644 FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc9.vcproj delete mode 100644 FTNoIR_Protocol_FG/Protocol.qrc delete mode 100644 FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp delete mode 100644 FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp delete mode 100644 FTNoIR_Protocol_FG/images/FlightGear.ico delete mode 100644 FTNoIR_Protocol_FSUIPC/FTNoIR_FSUIPCcontrols.ui delete mode 100644 FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp delete mode 100644 FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h delete mode 100644 FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc8.vcproj delete mode 100644 FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc9.vcproj delete mode 100644 FTNoIR_Protocol_FSUIPC/Protocol.qrc delete mode 100644 FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dialog.cpp delete mode 100644 FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp delete mode 100644 FTNoIR_Protocol_FSUIPC/images/FS9.ico delete mode 100644 FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui delete mode 100644 FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp delete mode 100644 FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h delete mode 100644 FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc8.vcproj delete mode 100644 FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc9.vcproj delete mode 100644 FTNoIR_Protocol_FT/FTTypes.h delete mode 100644 FTNoIR_Protocol_FT/Protocol.qrc delete mode 100644 FTNoIR_Protocol_FT/csv.cpp delete mode 100644 FTNoIR_Protocol_FT/csv.h delete mode 100644 FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp delete mode 100644 FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp delete mode 100644 FTNoIR_Protocol_FT/images/Freetrack.ico delete mode 100644 FTNoIR_Protocol_FTN/FTNoIR_FTNControls.ui delete mode 100644 FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp delete mode 100644 FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h delete mode 100644 FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc8.vcproj delete mode 100644 FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc9.vcproj delete mode 100644 FTNoIR_Protocol_FTN/Protocol.qrc delete mode 100644 FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp delete mode 100644 FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp delete mode 100644 FTNoIR_Protocol_FTN/images/FaceTrackNoIR.ico delete mode 100644 FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp delete mode 100644 FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h delete mode 100644 FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc8.vcproj delete mode 100644 FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc9.vcproj delete mode 100644 FTNoIR_Protocol_MOUSE/FTNoIR_mousecontrols.ui delete mode 100644 FTNoIR_Protocol_MOUSE/Protocol.qrc delete mode 100644 FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp delete mode 100644 FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp delete mode 100644 FTNoIR_Protocol_MOUSE/images/Mouse.ico delete mode 100644 FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp delete mode 100644 FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h delete mode 100644 FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc8.vcproj delete mode 100644 FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc9.vcproj delete mode 100644 FTNoIR_Protocol_SC/FTNoIR_SCcontrols.ui delete mode 100644 FTNoIR_Protocol_SC/Protocol.qrc delete mode 100644 FTNoIR_Protocol_SC/SCServer.manifest delete mode 100644 FTNoIR_Protocol_SC/SimConnect.aps delete mode 100644 FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp delete mode 100644 FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp delete mode 100644 FTNoIR_Protocol_SC/images/FSX.ico delete mode 100644 FTNoIR_Tracker_Base/ftnoir_tracker_base.h delete mode 100644 FTNoIR_Tracker_Base/ftnoir_tracker_base_global.h delete mode 100644 FTNoIR_Tracker_Base/ftnoir_tracker_ma_types.h delete mode 100644 FTNoIR_Tracker_Base/ftnoir_tracker_sm_types.h delete mode 100644 FTNoIR_Tracker_Base/ftnoir_tracker_types.h delete mode 100644 FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui delete mode 100644 FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h delete mode 100644 FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc8.vcproj delete mode 100644 FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc9.vcproj delete mode 100644 FTNoIR_Tracker_FD/Tracker.qrc delete mode 100644 FTNoIR_Tracker_FD/face-detect.h delete mode 100644 FTNoIR_Tracker_FD/ftnoir_tracker_facedetect.cpp delete mode 100644 FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp delete mode 100644 FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dll.cpp delete mode 100644 FTNoIR_Tracker_FD/images/FaceDetect.ico delete mode 100644 FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj delete mode 100644 FTNoIR_Tracker_HT/Tracker.qrc delete mode 100644 FTNoIR_Tracker_HT/TrackerControls.ui delete mode 100644 FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp delete mode 100644 FTNoIR_Tracker_HT/ftnoir_tracker_ht.h delete mode 100644 FTNoIR_Tracker_HT/ftnoir_tracker_ht_dll.h delete mode 100644 FTNoIR_Tracker_HT/headtracker-ftnoir.h delete mode 100644 FTNoIR_Tracker_HT/ht-api.h delete mode 100644 FTNoIR_Tracker_HT/images/HT.ico delete mode 100644 FTNoIR_Tracker_HT/stdafx.h delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj delete mode 100644 FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc9.vcproj delete mode 100644 FTNoIR_Tracker_PT/Resources/Logo_IR.png delete mode 100644 FTNoIR_Tracker_PT/Resources/cap_front.png delete mode 100644 FTNoIR_Tracker_PT/Resources/cap_side.png delete mode 100644 FTNoIR_Tracker_PT/Resources/clip_front.png delete mode 100644 FTNoIR_Tracker_PT/Resources/clip_side.png delete mode 100644 FTNoIR_Tracker_PT/Resources/icon.ico delete mode 100644 FTNoIR_Tracker_PT/camera.cpp delete mode 100644 FTNoIR_Tracker_PT/camera.h delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt.h delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp delete mode 100644 FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h delete mode 100644 FTNoIR_Tracker_PT/point_extractor.cpp delete mode 100644 FTNoIR_Tracker_PT/point_extractor.h delete mode 100644 FTNoIR_Tracker_PT/point_tracker.cpp delete mode 100644 FTNoIR_Tracker_PT/point_tracker.h delete mode 100644 FTNoIR_Tracker_PT/resource.h delete mode 100644 FTNoIR_Tracker_PT/timer.cpp delete mode 100644 FTNoIR_Tracker_PT/timer.h delete mode 100644 FTNoIR_Tracker_PT/trans_calib.cpp delete mode 100644 FTNoIR_Tracker_PT/trans_calib.h delete mode 100644 FTNoIR_Tracker_PT/videoInput/videoInput.h delete mode 100644 FTNoIR_Tracker_PT/videoInput/videoInput_vc8.lib delete mode 100644 FTNoIR_Tracker_PT/videoInput/videoInput_vc9.lib delete mode 100644 FTNoIR_Tracker_PT/video_widget.cpp delete mode 100644 FTNoIR_Tracker_PT/video_widget.h delete mode 100644 FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui delete mode 100644 FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h delete mode 100644 FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user delete mode 100644 FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc8.vcproj delete mode 100644 FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc9.vcproj delete mode 100644 FTNoIR_Tracker_SM/Tracker.qrc delete mode 100644 FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp delete mode 100644 FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp delete mode 100644 FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dll.cpp delete mode 100644 FTNoIR_Tracker_SM/images/SeeingMachines.ico delete mode 100644 FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui delete mode 100644 FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h delete mode 100644 FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc8.vcproj delete mode 100644 FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc9.vcproj delete mode 100644 FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp delete mode 100644 FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp delete mode 100644 FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dll.cpp delete mode 100644 FaceTrackNoIR/ClientFiles/CFS3/Readme.txt delete mode 100644 FaceTrackNoIR/ClientFiles/CFS3/TIRViews.dll delete mode 100644 FaceTrackNoIR/ClientFiles/FS2002 and FS2004/FSUIPC.dll delete mode 100644 FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml delete mode 100644 FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml delete mode 100644 FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt delete mode 100644 FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat delete mode 100644 FaceTrackNoIR/ClientFiles/FreeTrackTest/FreeTrackTest.exe delete mode 100644 FaceTrackNoIR/ClientFiles/FreeTrackTest/Readme.txt delete mode 100644 FaceTrackNoIR/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE delete mode 100644 FaceTrackNoIR/ClientFiles/GlovePIE/Readme.txt delete mode 100644 FaceTrackNoIR/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg delete mode 100644 FaceTrackNoIR/ClientFiles/PPJoy/Readme.txt delete mode 100644 FaceTrackNoIR/ClientFiles/Tir4Fun/NPClient.dll delete mode 100644 FaceTrackNoIR/ClientFiles/Tir4Fun/readme.txt delete mode 100644 FaceTrackNoIR/ClientFiles/Tir4Fun/tir4fun.exe delete mode 100644 FaceTrackNoIR/FSUIPCServer.cpp delete mode 100644 FaceTrackNoIR/FSUIPCServer.h delete mode 100644 FaceTrackNoIR/FTNServer.cpp delete mode 100644 FaceTrackNoIR/FTNServer.h delete mode 100644 FaceTrackNoIR/FTNoIR_Curves.ui delete mode 100644 FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui delete mode 100644 FaceTrackNoIR/FTNoIR_FTNServerControls.ui delete mode 100644 FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui delete mode 100644 FaceTrackNoIR/FTNoIR_Preferences.ui delete mode 100644 FaceTrackNoIR/FaceApp.cpp delete mode 100644 FaceTrackNoIR/FaceApp.h delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.cpp delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.h delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.ico delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.qrc delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.rc delete mode 100644 FaceTrackNoIR/FaceTrackNoIR.ui delete mode 100644 FaceTrackNoIR/FaceTrackNoIR_vc8.vcproj delete mode 100644 FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj delete mode 100644 FaceTrackNoIR/Readme.txt delete mode 100644 FaceTrackNoIR/Readme_Update_20100615.txt delete mode 100644 FaceTrackNoIR/Readme_Update_20100716.txt delete mode 100644 FaceTrackNoIR/Readme_Update_20100822.txt delete mode 100644 FaceTrackNoIR/UIElements/ButtonIcoBlack.bmp delete mode 100644 FaceTrackNoIR/UIElements/Curves.png delete mode 100644 FaceTrackNoIR/UIElements/Donate.png delete mode 100644 FaceTrackNoIR/UIElements/FaceTrackNoIR.ico delete mode 100644 FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.jpg delete mode 100644 FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.png delete mode 100644 FaceTrackNoIR/UIElements/Logo_NoIR.png delete mode 100644 FaceTrackNoIR/UIElements/Logo_NoIR_small.png delete mode 100644 FaceTrackNoIR/UIElements/Logo_NoIR_small_target.png delete mode 100644 FaceTrackNoIR/UIElements/Logo_NoIR_small_target90px.png delete mode 100644 FaceTrackNoIR/UIElements/Tools.png delete mode 100644 FaceTrackNoIR/UIElements/aboutFaceTrackNoIR.png delete mode 100644 FaceTrackNoIR/UIElements/bubble_1_small.png delete mode 100644 FaceTrackNoIR/UIElements/bubble_2_big.png delete mode 100644 FaceTrackNoIR/UIElements/logoFaceTrackNoIR.png delete mode 100644 FaceTrackNoIR/UIElements/logoFaceTrackNoIR60px.png delete mode 100644 FaceTrackNoIR/images/330px-6DOF_en.png delete mode 100644 FaceTrackNoIR/images/FaceTrackNoIR.ico delete mode 100644 FaceTrackNoIR/images/Settings16.png delete mode 100644 FaceTrackNoIR/images/SettingsOpen16.png delete mode 100644 FaceTrackNoIR/images/rotation_DOFs.png delete mode 100644 FaceTrackNoIR/images/translation_DOFs.png delete mode 100644 FaceTrackNoIR/main.cpp delete mode 100644 FaceTrackNoIR/paintwidget.h delete mode 100644 FaceTrackNoIR/postbuild.bat delete mode 100644 FaceTrackNoIR/resource.h delete mode 100644 FaceTrackNoIR/rotation.cpp delete mode 100644 FaceTrackNoIR/rotation.h delete mode 100644 FaceTrackNoIR/spot.h delete mode 100644 FaceTrackNoIR/tracker.cpp delete mode 100644 FaceTrackNoIR/tracker.h delete mode 100644 FaceTrackNoIR/tracker_types.cpp delete mode 100644 FaceTrackNoIR/tracker_types.h delete mode 100644 FaceTrackNoIR_vc8.sln delete mode 100644 FaceTrackNoIR_vc9.sln delete mode 100644 FreeTrackClient/FTClient.cpp delete mode 100644 FreeTrackClient/FTClient.h delete mode 100644 FreeTrackClient/FreeTrackClient.sln delete mode 100644 FreeTrackClient/FreeTrackClient/FreeTrackClient.cpp delete mode 100644 FreeTrackClient/FreeTrackClient/FreeTrackClient.rc delete mode 100644 FreeTrackClient/FreeTrackClient/FreeTrackClient.vcproj delete mode 100644 FreeTrackClient/FreeTrackClient/postbuild.bat delete mode 100644 FreeTrackClient/FreeTrackClient/resource.h delete mode 100644 List of compatible games.xls delete mode 100644 List of compatible webcams.xls delete mode 100644 QFunctionConfigurator/Prerequisites for using widget in Qt Designer.png delete mode 100644 QFunctionConfigurator/QFunctionConfigurator.sln delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.cpp delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.h delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/postbuild.bat delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp delete mode 100644 QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h delete mode 100644 QFunctionConfigurator/QFunctionConfigurator_vc9.sln delete mode 100644 ReadMe.txt delete mode 100644 faceAPI/FaceAPI2FSX_vc8.vcproj delete mode 100644 faceAPI/FaceAPI2FSX_vc9.vcproj delete mode 100644 faceAPI/build_options.h delete mode 100644 faceAPI/lock.h delete mode 100644 faceAPI/lockfree.h delete mode 100644 faceAPI/main.cpp delete mode 100644 faceAPI/mutex.h delete mode 100644 faceAPI/stdafx.cpp delete mode 100644 faceAPI/stdafx.h delete mode 100644 faceAPI/utils.h create mode 100644 faceapi/FaceAPI2FSX_vc8.vcproj create mode 100644 faceapi/FaceAPI2FSX_vc9.vcproj create mode 100644 faceapi/build_options.h create mode 100644 faceapi/lock.h create mode 100644 faceapi/lockfree.h create mode 100644 faceapi/main.cpp create mode 100644 faceapi/mutex.h create mode 100644 faceapi/stdafx.cpp create mode 100644 faceapi/stdafx.h create mode 100644 faceapi/utils.h create mode 100644 facetracknoir/ClientFiles/CFS3/Readme.txt create mode 100644 facetracknoir/ClientFiles/CFS3/TIRViews.dll create mode 100644 facetracknoir/ClientFiles/FS2002 and FS2004/FSUIPC.dll create mode 100644 facetracknoir/ClientFiles/FlightGear/Nasal/headtracker.xml create mode 100644 facetracknoir/ClientFiles/FlightGear/Protocol/headtracker.xml create mode 100644 facetracknoir/ClientFiles/FlightGear/Readme.txt create mode 100644 facetracknoir/ClientFiles/FlightGear/Win32/start_fg.bat create mode 100644 facetracknoir/ClientFiles/FreeTrackTest/FreeTrackTest.exe create mode 100644 facetracknoir/ClientFiles/FreeTrackTest/Readme.txt create mode 100644 facetracknoir/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE create mode 100644 facetracknoir/ClientFiles/GlovePIE/Readme.txt create mode 100644 facetracknoir/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg create mode 100644 facetracknoir/ClientFiles/PPJoy/Readme.txt create mode 100644 facetracknoir/ClientFiles/Tir4Fun/NPClient.dll create mode 100644 facetracknoir/ClientFiles/Tir4Fun/readme.txt create mode 100644 facetracknoir/ClientFiles/Tir4Fun/tir4fun.exe create mode 100644 facetracknoir/FSUIPCServer.cpp create mode 100644 facetracknoir/FSUIPCServer.h create mode 100644 facetracknoir/FTNServer.cpp create mode 100644 facetracknoir/FTNServer.h create mode 100644 facetracknoir/FTNoIR_Curves.ui create mode 100644 facetracknoir/FTNoIR_FSUIPCcontrols.ui create mode 100644 facetracknoir/FTNoIR_FTNServerControls.ui create mode 100644 facetracknoir/FTNoIR_KeyboardShortcuts.ui create mode 100644 facetracknoir/FTNoIR_Preferences.ui create mode 100644 facetracknoir/FaceApp.cpp create mode 100644 facetracknoir/FaceApp.h create mode 100644 facetracknoir/FaceTrackNoIR.cpp create mode 100644 facetracknoir/FaceTrackNoIR.h create mode 100644 facetracknoir/FaceTrackNoIR.ico create mode 100644 facetracknoir/FaceTrackNoIR.qrc create mode 100644 facetracknoir/FaceTrackNoIR.rc create mode 100644 facetracknoir/FaceTrackNoIR.ui create mode 100644 facetracknoir/FaceTrackNoIR_vc8.vcproj create mode 100644 facetracknoir/FaceTrackNoIR_vc9.vcproj create mode 100644 facetracknoir/Readme.txt create mode 100644 facetracknoir/Readme_Update_20100615.txt create mode 100644 facetracknoir/Readme_Update_20100716.txt create mode 100644 facetracknoir/Readme_Update_20100822.txt create mode 100644 facetracknoir/UIElements/ButtonIcoBlack.bmp create mode 100644 facetracknoir/UIElements/Curves.png create mode 100644 facetracknoir/UIElements/Donate.png create mode 100644 facetracknoir/UIElements/FaceTrackNoIR.ico create mode 100644 facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.jpg create mode 100644 facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.png create mode 100644 facetracknoir/UIElements/Logo_NoIR.png create mode 100644 facetracknoir/UIElements/Logo_NoIR_small.png create mode 100644 facetracknoir/UIElements/Logo_NoIR_small_target.png create mode 100644 facetracknoir/UIElements/Logo_NoIR_small_target90px.png create mode 100644 facetracknoir/UIElements/Tools.png create mode 100644 facetracknoir/UIElements/aboutFaceTrackNoIR.png create mode 100644 facetracknoir/UIElements/bubble_1_small.png create mode 100644 facetracknoir/UIElements/bubble_2_big.png create mode 100644 facetracknoir/UIElements/logoFaceTrackNoIR.png create mode 100644 facetracknoir/UIElements/logoFaceTrackNoIR60px.png create mode 100644 facetracknoir/images/330px-6DOF_en.png create mode 100644 facetracknoir/images/FaceTrackNoIR.ico create mode 100644 facetracknoir/images/Settings16.png create mode 100644 facetracknoir/images/SettingsOpen16.png create mode 100644 facetracknoir/images/rotation_DOFs.png create mode 100644 facetracknoir/images/translation_DOFs.png create mode 100644 facetracknoir/main.cpp create mode 100644 facetracknoir/paintwidget.h create mode 100644 facetracknoir/postbuild.bat create mode 100644 facetracknoir/resource.h create mode 100644 facetracknoir/rotation.cpp create mode 100644 facetracknoir/rotation.h create mode 100644 facetracknoir/spot.h create mode 100644 facetracknoir/tracker.cpp create mode 100644 facetracknoir/tracker.h create mode 100644 facetracknoir/tracker_types.cpp create mode 100644 facetracknoir/tracker_types.h create mode 100644 facetracknoir_vc8.sln create mode 100644 facetracknoir_vc9.sln create mode 100644 freetrackclient/FTClient.cpp create mode 100644 freetrackclient/FTClient.h create mode 100644 freetrackclient/FreeTrackClient.sln create mode 100644 freetrackclient/FreeTrackClient/FreeTrackClient.cpp create mode 100644 freetrackclient/FreeTrackClient/FreeTrackClient.rc create mode 100644 freetrackclient/FreeTrackClient/FreeTrackClient.vcproj create mode 100644 freetrackclient/FreeTrackClient/postbuild.bat create mode 100644 freetrackclient/FreeTrackClient/resource.h create mode 100644 ftnoir_filter_accela/FTNoIR_FilterControls.ui create mode 100644 ftnoir_filter_accela/FTNoIR_Filter_accela.h create mode 100644 ftnoir_filter_accela/FTNoIR_Filter_accela_vc8.vcproj create mode 100644 ftnoir_filter_accela/FTNoIR_Filter_accela_vc9.vcproj create mode 100644 ftnoir_filter_accela/Filter.qrc create mode 100644 ftnoir_filter_accela/ftnoir_filter_accela.cpp create mode 100644 ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp create mode 100644 ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp create mode 100644 ftnoir_filter_accela/images/filter-16-ac.png create mode 100644 ftnoir_filter_base/ftnoir_filter_base.h create mode 100644 ftnoir_filter_base/ftnoir_filter_base_global.h create mode 100644 ftnoir_filter_ewma2/FTNoIR_FilterControls.ui create mode 100644 ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2.h create mode 100644 ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc8.vcproj create mode 100644 ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc9.vcproj create mode 100644 ftnoir_filter_ewma2/Filter.qrc create mode 100644 ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp create mode 100644 ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp create mode 100644 ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp create mode 100644 ftnoir_filter_ewma2/images/filter-16.png create mode 100644 ftnoir_filter_ewma2/images/filter-32.png create mode 100644 ftnoir_posewidget/PoseWidget.qrc create mode 100644 ftnoir_posewidget/glwidget.cpp create mode 100644 ftnoir_posewidget/glwidget.h create mode 100644 ftnoir_posewidget/images/side1.bmp create mode 100644 ftnoir_posewidget/images/side1.png create mode 100644 ftnoir_posewidget/images/side2.png create mode 100644 ftnoir_posewidget/images/side3.png create mode 100644 ftnoir_posewidget/images/side4.png create mode 100644 ftnoir_posewidget/images/side5.png create mode 100644 ftnoir_posewidget/images/side6.png create mode 100644 ftnoir_protocol_base/ftnoir_protocol_base.h create mode 100644 ftnoir_protocol_base/ftnoir_protocol_base_global.h create mode 100644 ftnoir_protocol_fg/FGTypes.h create mode 100644 ftnoir_protocol_fg/FTNoIR_FGcontrols.ui create mode 100644 ftnoir_protocol_fg/FTNoIR_Protocol_FG.cpp create mode 100644 ftnoir_protocol_fg/FTNoIR_Protocol_FG.h create mode 100644 ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc8.vcproj create mode 100644 ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc9.vcproj create mode 100644 ftnoir_protocol_fg/Protocol.qrc create mode 100644 ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp create mode 100644 ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp create mode 100644 ftnoir_protocol_fg/images/FlightGear.ico create mode 100644 ftnoir_protocol_fsuipc/FTNoIR_FSUIPCcontrols.ui create mode 100644 ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.cpp create mode 100644 ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.h create mode 100644 ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc8.vcproj create mode 100644 ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc9.vcproj create mode 100644 ftnoir_protocol_fsuipc/Protocol.qrc create mode 100644 ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dialog.cpp create mode 100644 ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dll.cpp create mode 100644 ftnoir_protocol_fsuipc/images/FS9.ico create mode 100644 ftnoir_protocol_ft/FTNoIR_FTcontrols.ui create mode 100644 ftnoir_protocol_ft/FTNoIR_Protocol_FT.cpp create mode 100644 ftnoir_protocol_ft/FTNoIR_Protocol_FT.h create mode 100644 ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc8.vcproj create mode 100644 ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc9.vcproj create mode 100644 ftnoir_protocol_ft/FTTypes.h create mode 100644 ftnoir_protocol_ft/Protocol.qrc create mode 100644 ftnoir_protocol_ft/csv.cpp create mode 100644 ftnoir_protocol_ft/csv.h create mode 100644 ftnoir_protocol_ft/ftnoir_protocol_FT_dialog.cpp create mode 100644 ftnoir_protocol_ft/ftnoir_protocol_FT_dll.cpp create mode 100644 ftnoir_protocol_ft/images/Freetrack.ico create mode 100644 ftnoir_protocol_ftn/FTNoIR_FTNControls.ui create mode 100644 ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.cpp create mode 100644 ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.h create mode 100644 ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc8.vcproj create mode 100644 ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc9.vcproj create mode 100644 ftnoir_protocol_ftn/Protocol.qrc create mode 100644 ftnoir_protocol_ftn/ftnoir_protocol_FTN_dll.cpp create mode 100644 ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp create mode 100644 ftnoir_protocol_ftn/images/FaceTrackNoIR.ico create mode 100644 ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.cpp create mode 100644 ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.h create mode 100644 ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc8.vcproj create mode 100644 ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc9.vcproj create mode 100644 ftnoir_protocol_mouse/FTNoIR_mousecontrols.ui create mode 100644 ftnoir_protocol_mouse/Protocol.qrc create mode 100644 ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dialog.cpp create mode 100644 ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dll.cpp create mode 100644 ftnoir_protocol_mouse/images/Mouse.ico create mode 100644 ftnoir_protocol_sc/FTNoIR_Protocol_SC.cpp create mode 100644 ftnoir_protocol_sc/FTNoIR_Protocol_SC.h create mode 100644 ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc8.vcproj create mode 100644 ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc9.vcproj create mode 100644 ftnoir_protocol_sc/FTNoIR_SCcontrols.ui create mode 100644 ftnoir_protocol_sc/Protocol.qrc create mode 100644 ftnoir_protocol_sc/SCServer.manifest create mode 100644 ftnoir_protocol_sc/SimConnect.aps create mode 100644 ftnoir_protocol_sc/ftnoir_protocol_SC_dialog.cpp create mode 100644 ftnoir_protocol_sc/ftnoir_protocol_SC_dll.cpp create mode 100644 ftnoir_protocol_sc/images/FSX.ico create mode 100644 ftnoir_tracker_base/ftnoir_tracker_base.h create mode 100644 ftnoir_tracker_base/ftnoir_tracker_base_global.h create mode 100644 ftnoir_tracker_base/ftnoir_tracker_ma_types.h create mode 100644 ftnoir_tracker_base/ftnoir_tracker_sm_types.h create mode 100644 ftnoir_tracker_base/ftnoir_tracker_types.h 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_vc8.vcproj create mode 100644 ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.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/ftnoir_tracker_facedetect_dll.cpp create mode 100644 ftnoir_tracker_fd/images/FaceDetect.ico create mode 100644 ftnoir_tracker_ht/FTNoIR_Tracker_HT_vc8.vcproj create mode 100644 ftnoir_tracker_ht/Tracker.qrc create mode 100644 ftnoir_tracker_ht/TrackerControls.ui create mode 100644 ftnoir_tracker_ht/ftnoir_tracker_ht.cpp create mode 100644 ftnoir_tracker_ht/ftnoir_tracker_ht.h create mode 100644 ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h create mode 100644 ftnoir_tracker_ht/headtracker-ftnoir.h create mode 100644 ftnoir_tracker_ht/ht-api.h create mode 100644 ftnoir_tracker_ht/images/HT.ico create mode 100644 ftnoir_tracker_ht/stdafx.h create mode 100644 ftnoir_tracker_pt/FTNoIR_PT_Controls.ui create mode 100644 ftnoir_tracker_pt/FTNoIR_Tracker_PT.rc create mode 100644 ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc8.vcproj create mode 100644 ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc9.vcproj create mode 100644 ftnoir_tracker_pt/Resources/Logo_IR.png create mode 100644 ftnoir_tracker_pt/Resources/cap_front.png create mode 100644 ftnoir_tracker_pt/Resources/cap_side.png create mode 100644 ftnoir_tracker_pt/Resources/clip_front.png create mode 100644 ftnoir_tracker_pt/Resources/clip_side.png create mode 100644 ftnoir_tracker_pt/Resources/icon.ico create mode 100644 ftnoir_tracker_pt/camera.cpp create mode 100644 ftnoir_tracker_pt/camera.h create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.cpp create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.h create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt.qrc create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp create mode 100644 ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h create mode 100644 ftnoir_tracker_pt/point_extractor.cpp create mode 100644 ftnoir_tracker_pt/point_extractor.h create mode 100644 ftnoir_tracker_pt/point_tracker.cpp create mode 100644 ftnoir_tracker_pt/point_tracker.h create mode 100644 ftnoir_tracker_pt/resource.h create mode 100644 ftnoir_tracker_pt/timer.cpp create mode 100644 ftnoir_tracker_pt/timer.h create mode 100644 ftnoir_tracker_pt/trans_calib.cpp create mode 100644 ftnoir_tracker_pt/trans_calib.h create mode 100644 ftnoir_tracker_pt/videoInput/videoInput.h create mode 100644 ftnoir_tracker_pt/videoInput/videoInput_vc8.lib create mode 100644 ftnoir_tracker_pt/videoInput/videoInput_vc9.lib create mode 100644 ftnoir_tracker_pt/video_widget.cpp create mode 100644 ftnoir_tracker_pt/video_widget.h create mode 100644 ftnoir_tracker_sm/FTNoIR_SM_Controls.ui create mode 100644 ftnoir_tracker_sm/FTNoIR_Tracker_SM.h create mode 100644 ftnoir_tracker_sm/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user create mode 100644 ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc8.vcproj create mode 100644 ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc9.vcproj create mode 100644 ftnoir_tracker_sm/Tracker.qrc create mode 100644 ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp create mode 100644 ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp create mode 100644 ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp create mode 100644 ftnoir_tracker_sm/images/SeeingMachines.ico create mode 100644 ftnoir_tracker_udp/FTNoIR_FTNClientControls.ui create mode 100644 ftnoir_tracker_udp/FTNoIR_Tracker_UDP.h create mode 100644 ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc8.vcproj create mode 100644 ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc9.vcproj create mode 100644 ftnoir_tracker_udp/ftnoir_tracker_udp.cpp create mode 100644 ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp create mode 100644 ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp create mode 100644 list of compatible games.xls create mode 100644 list of compatible webcams.xls create mode 100644 qfunctionconfigurator/Prerequisites for using widget in Qt Designer.png create mode 100644 qfunctionconfigurator/QFunctionConfigurator.sln create mode 100644 qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.cpp create mode 100644 qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.h create mode 100644 qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj create mode 100644 qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj create mode 100644 qfunctionconfigurator/QFunctionConfigurator/postbuild.bat create mode 100644 qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp create mode 100644 qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.h create mode 100644 qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp create mode 100644 qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h create mode 100644 qfunctionconfigurator/QFunctionConfigurator_vc9.sln create mode 100644 readme.txt diff --git a/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui b/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui deleted file mode 100644 index af6522ce..00000000 --- a/FTNoIR_Filter_Accela/FTNoIR_FilterControls.ui +++ /dev/null @@ -1,363 +0,0 @@ - - - UICFilterControls - - - Qt::ApplicationModal - - - - 0 - 0 - 880 - 673 - - - - Filter settings - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - true - - - - 0 - 0 - - - - - 850 - 574 - - - - - 300 - 574 - - - - 0 - - - - Rotation - - - - - 20 - 20 - 819 - 510 - - - - 4 - - - 6 - - - 191 - - - 75 - - - 1 - - - 1 - - - - 255 - 170 - 0 - - - - - 192 - 192 - 192 - - - - Input - - - Output - - - Translation - - - - - - Translation - - - - - 20 - 20 - 819 - 510 - - - - 4 - - - 6 - - - 191 - - - 75 - - - 1 - - - 1 - - - - 85 - 255 - 0 - - - - - 192 - 192 - 192 - - - - Input - - - Output - - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#0; -background:none; - - - Reduction factor: - - - - - - - - 50 - 15 - - - - 1 - - - 100 - - - 5 - - - 100 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 35 - 22 - - - - background:none; - - - 1 - - - 100 - - - 100 - - - - - - - - 25 - 0 - - - - - 400 - 16777215 - - - - color:#0; -background:none; - - - (lowering this value will speed up response (in exchange for stability) - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - OK - - - - - - - Cancel - - - - - - - - - - QFunctionConfigurator - QWidget -
qfunctionconfigurator.h
-
-
- - - - slideReduction - valueChanged(int) - spinReduction - setValue(int) - - - 219 - 620 - - - 310 - 622 - - - - - spinReduction - valueChanged(int) - slideReduction - setValue(int) - - - 315 - 613 - - - 170 - 621 - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h deleted file mode 100644 index 77aa59ea..00000000 --- a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela.h +++ /dev/null @@ -1,150 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTN_FILTER_H -#define INCLUDED_FTN_FILTER_H - -#include "..\ftnoir_filter_base\ftnoir_filter_base.h" -#include "ui_FTNoIR_FilterControls.h" -#include - -const QPointF defScaleRotation[] = -{ - QPointF(0, 0), - QPointF(0.308900523560209, 0.0666666666666667), - QPointF(0.565445026178011, 0.226666666666667), - QPointF(0.769633507853403, 0.506666666666667), - QPointF(0.994764397905759, 1), - QPointF(1.23560209424084, 1.61333333333333), - QPointF(1.47643979057592, 2.37333333333333), - QPointF(1.66492146596859, 3.12), - QPointF(1.80628272251309, 3.92), - QPointF(1.91623036649215, 4.70666666666667), - QPointF(2.00523560209424, 5.44), - QPointF(2.07329842931937, 6) -}; - -const QPointF defScaleTranslation[] = -{ - QPointF(0, 0), - QPointF(0.282722513089005, 0.08), - QPointF(0.492146596858639, 0.306666666666667), - QPointF(0.764397905759162, 0.84), - QPointF(1.00523560209424, 1.62666666666667), - QPointF(1.17277486910995, 2.78666666666667), - QPointF(1.25130890052356, 3.6), - QPointF(1.31937172774869, 4.29333333333333), - QPointF(1.38219895287958, 4.90666666666667), - QPointF(1.43455497382199, 5.65333333333333) -}; - -// -// Macro to determine array-size -// -#define NUM_OF(x) (sizeof (x) / sizeof *(x)) - -//******************************************************************************************************* -// FaceTrackNoIR Filter class. -//******************************************************************************************************* -class FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - ~FTNoIR_Filter(); - - void Release(); - void Initialize(); - void StartFilter(); - void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); - -private: - void loadSettings(); // Load the settings from the INI-file - THeadPoseData newHeadPose; // Structure with new headpose - - bool first_run; - double kFactor, kFactorTranslation; - double kSensitivity, kSensitivityTranslation; - double kMagicNumber; // Stanislaws' magic number (should be 100 according to him...) - - FunctionConfig functionConfig; - FunctionConfig translationFunctionConfig; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* - -// Widget that has controls for FTNoIR protocol filter-settings. -class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog -{ - Q_OBJECT -public: - - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent, IFilterPtr ptr); - -private: - Ui::UICFilterControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - - IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance - FunctionConfig functionConfig; - FunctionConfig translationFunctionConfig; - -private slots: - void doOK(); - void doCancel(); - void settingChanged(bool) { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter -//******************************************************************************************************* -class FTNoIR_FilterDll : public IFilterDll -{ -public: - FTNoIR_FilterDll(); - ~FTNoIR_FilterDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk2"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk2"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk2"); }; - - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; -}; - - -#endif //INCLUDED_FTN_FILTER_H -//END - diff --git a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc8.vcproj b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc8.vcproj deleted file mode 100644 index e20c5ba0..00000000 --- a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc8.vcproj +++ /dev/null @@ -1,387 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc9.vcproj b/FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc9.vcproj deleted file mode 100644 index 3999ca41..00000000 --- a/FTNoIR_Filter_Accela/FTNoIR_Filter_accela_vc9.vcproj +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Filter_Accela/Filter.qrc b/FTNoIR_Filter_Accela/Filter.qrc deleted file mode 100644 index 9a7d75fa..00000000 --- a/FTNoIR_Filter_Accela/Filter.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/filter-16-ac.png - - diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp deleted file mode 100644 index 3e4c3bf6..00000000 --- a/FTNoIR_Filter_Accela/ftnoir_filter_accela.cpp +++ /dev/null @@ -1,176 +0,0 @@ -/* 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. - */ -/* - Modifications (last one on top): - 20120807 - WVR: FunctionConfig is now also used for the Filter. The extrapolation was adapted from Stanislaw. - Additional changes: I have added two parameters to the constructor of FunctionConfig and - renamed 3 member-functions (getFilterFullName is now called getFullName). -*/ -#include "ftnoir_filter_Accela.h" -#include "math.h" -#include -#include -#include - -FTNoIR_Filter::FTNoIR_Filter() : - functionConfig("Accela-Scaling-Rotation", 4, 6), - translationFunctionConfig("Accela-Scaling-Translation", 4, 6) -{ - first_run = true; - kMagicNumber = 100.0f; - loadSettings(); // Load the Settings -} - -FTNoIR_Filter::~FTNoIR_Filter() -{ - -} - -void FTNoIR_Filter::Initialize() -{ - loadSettings(); - return; -} - -void FTNoIR_Filter::loadSettings() { - QList defPoints; - - 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) - - defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleRotation); i++) { // Get the default points (hardcoded!) - defPoints.append(defScaleRotation[i]); - } - functionConfig.loadSettings(iniFile, defPoints); - - defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleTranslation); i++) { // Get the default points (hardcoded!) - defPoints.append(defScaleTranslation[i]); - } - translationFunctionConfig.loadSettings(iniFile, defPoints); - - iniFile.beginGroup ( "Accela" ); - kMagicNumber = iniFile.value ( "Reduction", 100 ).toFloat(); - iniFile.endGroup (); - -} - -void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) -{ - double target[6]; - double prev_output[6]; - float output[6]; - int i=0; - - prev_output[0]=current_camera_position->x; - prev_output[1]=current_camera_position->y; - prev_output[2]=current_camera_position->z; - prev_output[3]=current_camera_position->yaw; - prev_output[4]=current_camera_position->pitch; - prev_output[5]=current_camera_position->roll; - - target[0]=target_camera_position->x; - target[1]=target_camera_position->y; - target[2]=target_camera_position->z; - target[3]=target_camera_position->yaw; - target[4]=target_camera_position->pitch; - target[5]=target_camera_position->roll; - - if (first_run) - { - functionConfig.setTrackingActive(true); - translationFunctionConfig.setTrackingActive(true); - new_camera_position->x=target[0]; - new_camera_position->y=target[1]; - new_camera_position->z=target[2]; - new_camera_position->yaw=target[3]; - new_camera_position->pitch=target[4]; - new_camera_position->roll=target[5]; - - first_run=false; - return; - } - - for (i=0;i<6;i++) - { - if (_isnan(target[i])) - return; - - if (_isnan(prev_output[i])) - return; - - double e2 = target[i]; - double start = prev_output[i]; - double vec = e2 - start; - int sign = vec < 0 ? -1 : 1; - double x = fabs(vec); - QList points = (i >= 3 ? functionConfig : translationFunctionConfig).getPoints(); - int extrapolatep = 0; - double ratio; - double maxx; - double add; - // extrapolation of a spline - if (points.size() > 1) { - QPointF last = points[points.size() - 1]; - QPointF penultimate = points[points.size() - 2]; - ratio = (last.y() - penultimate.y()) / (last.x() - penultimate.x()); - extrapolatep = 1; - add = last.y(); - maxx = last.x(); - } - double foo = extrapolatep && x > maxx ? add + ratio * (x - maxx) : (i >= 3 ? functionConfig : translationFunctionConfig).getValue(x); - // the idea is that "empty" updates without new head pose data are still - // useful for filtering, as skipping them would result in jerky output. - // the magic "100" is the amount of calls to the filter by FTNOIR per sec. - // WVR: Added kMagicNumber for Patrick - double velocity = foo / 100.0; - if (kMagicNumber > 0.0f) { - double velocity = foo / kMagicNumber; - } - double sum = start + velocity * sign; - bool done = (sign > 0 ? sum >= e2 : sum <= e2); - if (done) { - output[i] = e2; - } else { - output[i] = sum; - } - - if (_isnan(output[i])) - return; - } - - new_camera_position->x=output[0]; - new_camera_position->y=output[1]; - new_camera_position->z=output[2]; - new_camera_position->yaw=output[3]; - new_camera_position->pitch=output[4]; - new_camera_position->roll=output[5]; - - current_camera_position->x=output[0]; - current_camera_position->y=output[1]; - current_camera_position->z=output[2]; - current_camera_position->yaw=output[3]; - current_camera_position->pitch=output[4]; - current_camera_position->roll=output[5]; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilter - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilter@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilter=_GetFilter@0") - -FTNOIR_FILTER_BASE_EXPORT IFilterPtr __stdcall GetFilter() -{ - return new FTNoIR_Filter; -} diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp deleted file mode 100644 index c230eed8..00000000 --- a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dialog.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************** -* 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) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20130102 - WVR: Added 'reduction factor' to accommodate Patrick's need for speed. -*/ -#include "ftnoir_filter_Accela.h" -#include "math.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// -FilterControls::FilterControls() : - QWidget(), - functionConfig("Accela-Scaling-Rotation", 4, 8), - translationFunctionConfig("Accela-Scaling-Translation", 4, 8) -{ - ui.setupUi( this ); - - // Load the settings from the current .INI-file - loadSettings(); - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.scalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); - connect(ui.translationScalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); - - // Connect slider for reduction - connect(ui.slideReduction, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - qDebug() << "FilterControls() says: started"; -} - -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; -} - -void FilterControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { - - // - // The dialog can be opened, while the Tracker is running. - // In that case, ptr will point to the active Filter-instance. - // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... - // - pFilter = ptr; - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FilterControls::doOK() { - save(); - if (pFilter) { - pFilter->Initialize(); - } - this->close(); -} - -// override show event -void FilterControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FilterControls::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 FilterControls::loadSettings() { -QList defPoints; - - 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_Filter::loadSettings2 says: iniFile = " << currentFile; - - - qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); - - defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleRotation); i++) { // Get the default points (hardcoded!) - defPoints.append(defScaleRotation[i]); - } - functionConfig.loadSettings(iniFile, defPoints); - - defPoints.clear(); - for (int i = 0; i < NUM_OF(defScaleTranslation); i++) { // Get the default points (hardcoded!) - defPoints.append(defScaleTranslation[i]); - } - translationFunctionConfig.loadSettings(iniFile, defPoints); - - ui.translationScalingConfig->setConfig(&translationFunctionConfig, currentFile); - ui.scalingConfig->setConfig(&functionConfig, currentFile); - - iniFile.beginGroup ( "Accela" ); - ui.slideReduction->setValue (iniFile.value ( "Reduction", 100 ).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FilterControls::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) - - qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Accela" ); - iniFile.setValue ( "Reduction", ui.slideReduction->value() ); - iniFile.endGroup (); - - functionConfig.saveSettings(iniFile); - translationFunctionConfig.saveSettings(iniFile); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - -FTNOIR_FILTER_BASE_EXPORT IFilterDialogPtr __stdcall GetFilterDialog( ) -{ - return new FilterControls; -} diff --git a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp b/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp deleted file mode 100644 index e1452bf2..00000000 --- a/FTNoIR_Filter_Accela/ftnoir_filter_accela_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The FilterDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_filter_Accela.h" -#include - -FTNoIR_FilterDll::FTNoIR_FilterDll() { -} - -FTNoIR_FilterDll::~FTNoIR_FilterDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") - -FTNOIR_FILTER_BASE_EXPORT IFilterDllPtr __stdcall GetFilterDll() -{ - return new FTNoIR_FilterDll; -} diff --git a/FTNoIR_Filter_Accela/images/filter-16-ac.png b/FTNoIR_Filter_Accela/images/filter-16-ac.png deleted file mode 100644 index d263db2d..00000000 Binary files a/FTNoIR_Filter_Accela/images/filter-16-ac.png and /dev/null differ diff --git a/FTNoIR_Filter_Base/ftnoir_filter_base.h b/FTNoIR_Filter_Base/ftnoir_filter_base.h deleted file mode 100644 index 44ce3d72..00000000 --- a/FTNoIR_Filter_Base/ftnoir_filter_base.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef FTNOIR_FILTER_BASE_H -#define FTNOIR_FILTER_BASE_H - -#include "ftnoir_filter_base_global.h" -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include -#include -#include -#include -#include -#include - -//////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif // __cplusplus - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IFilter -{ - virtual ~IFilter() {} - virtual void Initialize() = 0; - virtual void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) = 0; -}; - -typedef IFilter* IFilterPtr; -//typedef IFilter *(__stdcall *importGetFilter)(void); - -// Factory function that creates instances of the Filter object. -EXTERN_C -FTNOIR_FILTER_BASE_EXPORT -IFilterPtr -__stdcall -GetFilter(void); - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IFilterDialog -{ - virtual ~IFilterDialog() {} - virtual void Initialize(QWidget *parent, IFilterPtr ptr) = 0; -}; - -typedef IFilterDialog* IFilterDialogPtr; - - -// Factory function that creates instances of the Filter object. -EXTERN_C -FTNOIR_FILTER_BASE_EXPORT -IFilterDialogPtr -__stdcall -GetFilterDialog(void); - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IFilterDll -{ - virtual ~IFilterDll() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - -typedef IFilterDll* IFilterDllPtr; - -// Factory function that creates instances of the Filter object. -EXTERN_C -FTNOIR_FILTER_BASE_EXPORT -IFilterDllPtr -__stdcall -GetFilterDll(void); - - -#endif // FTNOIR_FILTER_BASE_H diff --git a/FTNoIR_Filter_Base/ftnoir_filter_base_global.h b/FTNoIR_Filter_Base/ftnoir_filter_base_global.h deleted file mode 100644 index aac4048e..00000000 --- a/FTNoIR_Filter_Base/ftnoir_filter_base_global.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef FTNOIR_FILTER_BASE_GLOBAL_H -#define FTNOIR_FILTER_BASE_GLOBAL_H - -#include - -#ifdef FTNOIR_FILTER_BASE_LIB -# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT -#else -# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT -#endif - -#endif // FTNOIR_FILTER_BASE_GLOBAL_H diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui b/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui deleted file mode 100644 index e9419a73..00000000 --- a/FTNoIR_Filter_EWMA2/FTNoIR_FilterControls.ui +++ /dev/null @@ -1,586 +0,0 @@ - - - UICFilterControls - - - - 0 - 0 - 371 - 380 - - - - - 0 - 380 - - - - EWMA2 Filter settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 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 - 204 - - - - background-color: rgb(214, 214, 214); -border-color: rgb(0, 0, 0); - - - QFrame::Box - - - <!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 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 52 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 52 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - btnOK - btnCancel - - - - - minSmooth - valueChanged(int) - spinMinSmooth - setValue(int) - - - 199 - 22 - - - 337 - 23 - - - - - spinMinSmooth - valueChanged(int) - minSmooth - setValue(int) - - - 330 - 12 - - - 185 - 17 - - - - - maxSmooth - valueChanged(int) - spinMaxSmooth - setValue(int) - - - 181 - 48 - - - 335 - 54 - - - - - spinMaxSmooth - valueChanged(int) - maxSmooth - setValue(int) - - - 324 - 42 - - - 259 - 43 - - - - - powCurve - valueChanged(int) - spinPowCurve - setValue(int) - - - 145 - 74 - - - 339 - 78 - - - - - spinPowCurve - valueChanged(int) - powCurve - setValue(int) - - - 330 - 69 - - - 176 - 76 - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h deleted file mode 100644 index 18afe3bd..00000000 --- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2.h +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTN_FILTER_H -#define INCLUDED_FTN_FILTER_H - -#include "..\ftnoir_filter_base\ftnoir_filter_base.h" -#include "ui_FTNoIR_FilterControls.h" - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -class FTNoIR_Filter : public IFilter -{ -public: - FTNoIR_Filter(); - ~FTNoIR_Filter(); - - void Release(); - void Initialize(); - void StartFilter(); - void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); - -private: - void loadSettings(); // Load the settings from the INI-file - THeadPoseData newHeadPose; // Structure with new headpose - - bool first_run; - float smoothing_frames_range; - float alpha_smoothing; - float prev_alpha[6]; - float alpha[6]; - float smoothed_alpha[6]; - - float kMinSmoothing; - float kMaxSmoothing; - float kSmoothingScaleCurve; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* - -// Widget that has controls for FTNoIR protocol filter-settings. -class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog -{ - Q_OBJECT -public: - - explicit FilterControls(); - virtual ~FilterControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent, IFilterPtr ptr); - -private: - Ui::UICFilterControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - - IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged( int ) { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter -//******************************************************************************************************* -class FTNoIR_FilterDll : public IFilterDll -{ -public: - FTNoIR_FilterDll(); - ~FTNoIR_FilterDll(); - - void Release(); - void Initialize(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); }; - - void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; -}; - -#endif //INCLUDED_FTN_FILTER_H -//END - diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc8.vcproj b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc8.vcproj deleted file mode 100644 index 3a185272..00000000 --- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc8.vcproj +++ /dev/null @@ -1,388 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc9.vcproj b/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc9.vcproj deleted file mode 100644 index d692d8cd..00000000 --- a/FTNoIR_Filter_EWMA2/FTNoIR_Filter_EWMA2_vc9.vcproj +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Filter_EWMA2/Filter.qrc b/FTNoIR_Filter_EWMA2/Filter.qrc deleted file mode 100644 index e64ec35a..00000000 --- a/FTNoIR_Filter_EWMA2/Filter.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/filter-16.png - - diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp deleted file mode 100644 index fac0e13c..00000000 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2.cpp +++ /dev/null @@ -1,236 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_ewma2.h" -#include "math.h" -#include - -//#define LOG_OUTPUT - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -FTNoIR_Filter::FTNoIR_Filter() -{ - first_run = true; - alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later - loadSettings(); // Load the Settings - -} - -FTNoIR_Filter::~FTNoIR_Filter() -{ - -} - -void FTNoIR_Filter::Release() -{ - delete this; -} - -void FTNoIR_Filter::Initialize() -{ - qDebug() << "FTNoIR_Filter::Initialize says: Starting "; - loadSettings(); - return; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Filter::loadSettings() { - qDebug() << "FTNoIR_Filter::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_Filter::loadSettings says: iniFile = " << currentFile; - - // - // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR - // - iniFile.beginGroup ( "Tracking" ); - kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt(); - kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt(); - kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt(); - iniFile.endGroup (); - -} - -void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) -{ - //non-optimised version for clarity - float prev_output[6]; - float target[6]; - float output_delta[6]; - float scale[]={0.025f,0.025f,0.025f,6.0f,6.0f,6.0f}; - float norm_output_delta[6]; - float output[6]; - int i=0; - - #if PRE_FILTER_SCALING - //compensate for any prefilter scaling - scale[0]*=X_POS_SCALE; - scale[1]*=Y_POS_SCALE; - scale[2]*=Z_POS_SCALE; - scale[3]*=X_ROT_SCALE; - scale[4]*=Y_ROT_SCALE; - scale[5]*=Z_ROT_SCALE; - #endif - - //find out how far the head has moved - prev_output[0]=current_camera_position->x; - prev_output[1]=current_camera_position->y; - prev_output[2]=current_camera_position->z; - prev_output[3]=current_camera_position->yaw; - prev_output[4]=current_camera_position->pitch; - prev_output[5]=current_camera_position->roll; - - target[0]=target_camera_position->x; - target[1]=target_camera_position->y; - target[2]=target_camera_position->z; - target[3]=target_camera_position->yaw; - target[4]=target_camera_position->pitch; - target[5]=target_camera_position->roll; - - if (first_run==true) - { - //on the first run, output=target - for (i=0;i<6;i++) - { - output[i]=target[i]; - prev_alpha[i] = 0.0f; - } - - new_camera_position->x=target[0]; - new_camera_position->y=target[1]; - new_camera_position->z=target[2]; - new_camera_position->yaw=target[3]; - new_camera_position->pitch=target[4]; - new_camera_position->roll=target[5]; - - first_run=false; - - //we can bail - return; - } - - //how far does the camera need to move to catch up? - for (i=0;i<6;i++) - { - output_delta[i]=(target[i]-prev_output[i]); - } - - //normalise the deltas - for (i=0;i<6;i++) - { - norm_output_delta[i]=std::min(std::max(fabs(output_delta[i])/scale[i],0.0f),1.0f); - } - - //calculate the alphas - //work out the dynamic smoothing factors -// if (newTarget) { - for (i=0;i<6;i++) - { - alpha[i]=1.0f/(kMinSmoothing+((1.0f-pow(norm_output_delta[i],kSmoothingScaleCurve))*smoothing_frames_range)); - smoothed_alpha[i]=(alpha_smoothing*alpha[i])+((1.0f-alpha_smoothing)*prev_alpha[i]); - } -// } - - //qDebug() << "FTNoIR_Filter::FilterHeadPoseData() smoothing frames = " << smoothing_frames_range; - //qDebug() << "FTNoIR_Filter::FilterHeadPoseData() alpha[3] = " << alpha[3]; - - //use the same (largest) smoothed alpha for each channel - //NB: larger alpha = *less* lag (opposite to what you'd expect) - float largest_alpha=0.0f; - for (i=0;i<6;i++) - { - if (smoothed_alpha[i]>=largest_alpha) - { - largest_alpha=smoothed_alpha[i]; - } - } - - //move the camera - for (i=0;i<6;i++) - { - output[i]=(largest_alpha*target[i])+((1.0f-largest_alpha)*prev_output[i]); -// output[i]=(smoothed_alpha[i]*target[i])+((1.0f-smoothed_alpha[i])*prev_output[i]); - } - - - #ifdef LOG_OUTPUT - // Use this for some debug-output to file... - QFile data(QCoreApplication::applicationDirPath() + "\\EWMA_output.txt"); - if (data.open(QFile::WriteOnly | QFile::Append)) { - QTextStream out(&data); - out << "output:\t" << output[0] << "\t" << output[1] << "\t" << output[2] << "\t" << output[3] << "\t" << output[4] << "\t" << output[5] << '\n'; - out << "target:\t" << target[0] << "\t" << target[1] << "\t" << target[2] << "\t" << target[3] << "\t" << target[4] << "\t" << target[5] << '\n'; - out << "prev_output:\t" << prev_output[0] << "\t" << prev_output[1] << "\t" << prev_output[2] << "\t" << prev_output[3] << "\t" << prev_output[4] << "\t" << prev_output[5] << '\n'; - out << "largest_alpha:\t" << largest_alpha << '\n'; - } - #endif - - new_camera_position->x=output[0]; - new_camera_position->y=output[1]; - new_camera_position->z=output[2]; - new_camera_position->yaw=output[3]; - new_camera_position->pitch=output[4]; - new_camera_position->roll=output[5]; - - // - // Also update the 'current' position, for the next iteration. - // - current_camera_position->x=output[0]; - current_camera_position->y=output[1]; - current_camera_position->z=output[2]; - current_camera_position->yaw=output[3]; - current_camera_position->pitch=output[4]; - current_camera_position->roll=output[5]; - - //update filter memories ready for next sample - for (i=0;i<6;i++) - { - prev_alpha[i]=smoothed_alpha[i]; - } - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilter - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilter@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilter=_GetFilter@0") - -FTNOIR_FILTER_BASE_EXPORT IFilterPtr __stdcall GetFilter() -{ - return new FTNoIR_Filter; -} diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp deleted file mode 100644 index c7798ac0..00000000 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma2_dialog.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "ftnoir_filter_EWMA2.h" -#include "math.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Filter Settings-dialog. -//******************************************************************************************************* -// -// Constructor for server-settings-dialog -// -FilterControls::FilterControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - // Connect sliders for reduction factor - connect(ui.minSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.maxSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.powCurve, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - qDebug() << "FilterControls() says: started"; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FilterControls::~FilterControls() { - qDebug() << "~FilterControls() says: started"; -} - -void FilterControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { - - // - // The dialog can be opened, while the Tracker is running. - // In that case, ptr will point to the active Filter-instance. - // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... - // - pFilter = ptr; - - // - // - // - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FilterControls::doOK() { - save(); - if (pFilter) { - pFilter->Initialize(); - } - this->close(); -} - -// override show event -void FilterControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FilterControls::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 FilterControls::loadSettings() { - qDebug() << "FilterControls::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() << "FilterControls::loadSettings says: iniFile = " << currentFile; - - // - // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR - // - iniFile.beginGroup ( "Tracking" ); - ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt()); - ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt()); - ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FilterControls::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 ( "Tracking" ); - iniFile.setValue ( "minSmooth", ui.minSmooth->value() ); - iniFile.setValue ( "powCurve", ui.powCurve->value() ); - iniFile.setValue ( "maxSmooth", ui.maxSmooth->value() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter-settings dialog object. - -// Export both decorated and undecorated names. -// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") - -FTNOIR_FILTER_BASE_EXPORT IFilterDialogPtr __stdcall GetFilterDialog( ) -{ - return new FilterControls; -} diff --git a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp b/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp deleted file mode 100644 index 4e644446..00000000 --- a/FTNoIR_Filter_EWMA2/ftnoir_filter_ewma_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The FilterDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_filter_ewma2.h" -#include - -FTNoIR_FilterDll::FTNoIR_FilterDll() { -} - -FTNoIR_FilterDll::~FTNoIR_FilterDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Filter object. - -// Export both decorated and undecorated names. -// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") - -FTNOIR_FILTER_BASE_EXPORT IFilterDllPtr __stdcall GetFilterDll() -{ - return new FTNoIR_FilterDll; -} diff --git a/FTNoIR_Filter_EWMA2/images/filter-16.png b/FTNoIR_Filter_EWMA2/images/filter-16.png deleted file mode 100644 index ecde6a10..00000000 Binary files a/FTNoIR_Filter_EWMA2/images/filter-16.png and /dev/null differ diff --git a/FTNoIR_Filter_EWMA2/images/filter-32.png b/FTNoIR_Filter_EWMA2/images/filter-32.png deleted file mode 100644 index 12b02caf..00000000 Binary files a/FTNoIR_Filter_EWMA2/images/filter-32.png and /dev/null differ diff --git a/FTNoIR_PoseWidget/PoseWidget.qrc b/FTNoIR_PoseWidget/PoseWidget.qrc deleted file mode 100644 index 65038eba..00000000 --- a/FTNoIR_PoseWidget/PoseWidget.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - images/side1.png - images/side2.png - images/side3.png - images/side4.png - images/side5.png - images/side6.png - - diff --git a/FTNoIR_PoseWidget/glwidget.cpp b/FTNoIR_PoseWidget/glwidget.cpp deleted file mode 100644 index 55b65619..00000000 --- a/FTNoIR_PoseWidget/glwidget.cpp +++ /dev/null @@ -1,210 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -#include -#include - -#include "glwidget.h" - -GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) - : QGLWidget(parent, shareWidget) -{ - clearColor = Qt::black; - xRot = 0; - yRot = 0; - zRot = 0; - -#ifdef QT_OPENGL_ES_2 - program = 0; -#endif -} - -GLWidget::~GLWidget() -{ -} - -QSize GLWidget::minimumSizeHint() const -{ - return QSize(60, 60); -} - -QSize GLWidget::sizeHint() const -{ - return QSize(90, 90); -} - -void GLWidget::rotateBy(int xAngle, int yAngle, int zAngle) -{ - xRot = xAngle; - yRot = yAngle; - zRot = zAngle; - updateGL(); -} - -void GLWidget::setClearColor(const QColor &color) -{ - clearColor = color; - updateGL(); -} - -void GLWidget::initializeGL() -{ - makeObject(); - - glEnable(GL_DEPTH_TEST); - glEnable(GL_CULL_FACE); -#ifndef QT_OPENGL_ES_2 - glEnable(GL_TEXTURE_2D); -#endif - -#ifdef QT_OPENGL_ES_2 - -#define PROGRAM_VERTEX_ATTRIBUTE 0 -#define PROGRAM_TEXCOORD_ATTRIBUTE 1 - - QGLShader *vshader = new QGLShader(QGLShader::Vertex, this); - const char *vsrc = - "attribute highp vec4 vertex;\n" - "attribute mediump vec4 texCoord;\n" - "varying mediump vec4 texc;\n" - "uniform mediump mat4 matrix;\n" - "void main(void)\n" - "{\n" - " gl_Position = matrix * vertex;\n" - " texc = texCoord;\n" - "}\n"; - vshader->compileSourceCode(vsrc); - - QGLShader *fshader = new QGLShader(QGLShader::Fragment, this); - const char *fsrc = - "uniform sampler2D texture;\n" - "varying mediump vec4 texc;\n" - "void main(void)\n" - "{\n" - " gl_FragColor = texture2D(texture, texc.st);\n" - "}\n"; - fshader->compileSourceCode(fsrc); - - program = new QGLShaderProgram(this); - program->addShader(vshader); - program->addShader(fshader); - program->bindAttributeLocation("vertex", PROGRAM_VERTEX_ATTRIBUTE); - program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); - program->link(); - - program->bind(); - program->setUniformValue("texture", 0); - -#endif -} - -void GLWidget::paintGL() -{ - qglClearColor(clearColor); - glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - -#if !defined(QT_OPENGL_ES_2) - - glLoadIdentity(); - glTranslatef(0.0f, 0.0f, -10.0f); - - glRotatef(xRot, 1.0f, 0.0f, 0.0f); - glRotatef(yRot, 0.0f, 1.0f, 0.0f); - glRotatef(-1.0f * zRot, 0.0f, 0.0f, 1.0f); - - glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); - glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); - glEnableClientState(GL_VERTEX_ARRAY); - glEnableClientState(GL_TEXTURE_COORD_ARRAY); - -#else - - QMatrix4x4 m; - m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f); - m.translate(0.0f, 0.0f, -10.0f); - m.rotate(xRot / 16.0f, 1.0f, 0.0f, 0.0f); - m.rotate(yRot / 16.0f, 0.0f, 1.0f, 0.0f); - m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); - - program->setUniformValue("matrix", m); - program->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE); - program->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE); - program->setAttributeArray - (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); - program->setAttributeArray - (PROGRAM_TEXCOORD_ATTRIBUTE, texCoords.constData()); - -#endif - - for (int i = 0; i < 6; ++i) { - glBindTexture(GL_TEXTURE_2D, textures[i]); - glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); - } -} - -void GLWidget::resizeGL(int width, int height) -{ - int side = qMin(width, height); - glViewport((width - side) / 2, (height - side) / 2, side, side); - -#if !defined(QT_OPENGL_ES_2) - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); -#ifndef QT_OPENGL_ES - glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); -#else - glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); -#endif - glMatrixMode(GL_MODELVIEW); -#endif -} - -void GLWidget::makeObject() -{ - static const int coords[6][4][3] = { - { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, - { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } }, - { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } }, - { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } }, - { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } }, - { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } - }; - - for (int j=0; j < 6; ++j) { - textures[j] = bindTexture - (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); - } - - for (int i = 0; i < 6; ++i) { - for (int j = 0; j < 4; ++j) { - texCoords.append - (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); - vertices.append - (QVector3D(0.4 * coords[i][j][0], 0.4 * coords[i][j][1], - 0.02 * coords[i][j][2])); - } - } -} diff --git a/FTNoIR_PoseWidget/glwidget.h b/FTNoIR_PoseWidget/glwidget.h deleted file mode 100644 index cff8cb83..00000000 --- a/FTNoIR_PoseWidget/glwidget.h +++ /dev/null @@ -1,72 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -#ifndef GLWIDGET_H -#define GLWIDGET_H - -#include -#include - -class QGLShaderProgram; - -class GLWidget : public QGLWidget -{ - Q_OBJECT - -public: - GLWidget(QWidget *parent = 0, QGLWidget *shareWidget = 0); - ~GLWidget(); - - QSize minimumSizeHint() const; - QSize sizeHint() const; - void rotateBy(int xAngle, int yAngle, int zAngle); - void setClearColor(const QColor &color); - -signals: - void clicked(); - -protected: - void initializeGL(); - void paintGL(); - void resizeGL(int width, int height); - -private: - void makeObject(); - - QColor clearColor; - QPoint lastPos; - int xRot; - int yRot; - int zRot; - GLuint textures[6]; - QVector vertices; - QVector texCoords; -#ifdef QT_OPENGL_ES_2 - QGLShaderProgram *program; -#endif -}; - -#endif diff --git a/FTNoIR_PoseWidget/images/side1.bmp b/FTNoIR_PoseWidget/images/side1.bmp deleted file mode 100644 index 29c28d80..00000000 Binary files a/FTNoIR_PoseWidget/images/side1.bmp and /dev/null differ diff --git a/FTNoIR_PoseWidget/images/side1.png b/FTNoIR_PoseWidget/images/side1.png deleted file mode 100644 index e0315b77..00000000 Binary files a/FTNoIR_PoseWidget/images/side1.png and /dev/null differ diff --git a/FTNoIR_PoseWidget/images/side2.png b/FTNoIR_PoseWidget/images/side2.png deleted file mode 100644 index 67eb060b..00000000 Binary files a/FTNoIR_PoseWidget/images/side2.png and /dev/null differ diff --git a/FTNoIR_PoseWidget/images/side3.png b/FTNoIR_PoseWidget/images/side3.png deleted file mode 100644 index 67eb060b..00000000 Binary files a/FTNoIR_PoseWidget/images/side3.png and /dev/null differ diff --git a/FTNoIR_PoseWidget/images/side4.png b/FTNoIR_PoseWidget/images/side4.png deleted file mode 100644 index 67eb060b..00000000 Binary files a/FTNoIR_PoseWidget/images/side4.png and /dev/null differ diff --git a/FTNoIR_PoseWidget/images/side5.png b/FTNoIR_PoseWidget/images/side5.png deleted file mode 100644 index 67eb060b..00000000 Binary files a/FTNoIR_PoseWidget/images/side5.png and /dev/null differ diff --git a/FTNoIR_PoseWidget/images/side6.png b/FTNoIR_PoseWidget/images/side6.png deleted file mode 100644 index f4160001..00000000 Binary files a/FTNoIR_PoseWidget/images/side6.png and /dev/null differ diff --git a/FTNoIR_Protocol_Base/ftnoir_protocol_base.h b/FTNoIR_Protocol_Base/ftnoir_protocol_base.h deleted file mode 100644 index 3f598d35..00000000 --- a/FTNoIR_Protocol_Base/ftnoir_protocol_base.h +++ /dev/null @@ -1,124 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* This class implements a tracker-base * -*********************************************************************************/ -/* - Modifications (last one on top): - - 20121115 - WVR: Added RegisterProtocol() and unRegisterProtocol() to Dialog Class - 20110415 - WVR: Added overloaded operator - and -= -*/ - -#ifndef FTNOIR_PROTOCOL_BASE_H -#define FTNOIR_PROTOCOL_BASE_H - -#include "ftnoir_protocol_base_global.h" -#include "..\ftnoir_tracker_base\ftnoir_tracker_types.h" -#include -#include -//#include "winbase.h" - -#include "windows.h" -//#include "winable.h" - -//////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif // __cplusplus - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IProtocol -{ - virtual ~IProtocol() {} - virtual void Initialize() = 0; - virtual bool checkServerInstallationOK ( HANDLE handle ) = 0; - virtual void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) = 0; - virtual void getNameFromGame( char *dest ) = 0; // Take care dest can handle up to 100 chars... -}; - -typedef IProtocol* IProtocolPtr; - -// Factory function that creates instances of the Protocol object. -EXTERN_C -FTNOIR_PROTOCOL_BASE_EXPORT -IProtocolPtr -__stdcall -GetProtocol(void); - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IProtocolDialog -{ - virtual ~IProtocolDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void registerProtocol(IProtocol *protocol) = 0; - virtual void unRegisterProtocol() = 0; -}; - -typedef IProtocolDialog* IProtocolDialogPtr; - -// Factory function that creates instances of the Protocol object. -EXTERN_C -FTNOIR_PROTOCOL_BASE_EXPORT -IProtocolDialogPtr -__stdcall -GetProtocolDialog(void); - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct IProtocolDll -{ - virtual ~IProtocolDll() {} - - virtual void getFullName(QString *strToBeFilled) = 0; - virtual void getShortName(QString *strToBeFilled) = 0; - virtual void getDescription(QString *strToBeFilled) = 0; - virtual void getIcon(QIcon *icon) = 0; -}; - -typedef IProtocolDll* IProtocolDllPtr; - -// Factory function that creates instances of the Protocol object. -EXTERN_C -FTNOIR_PROTOCOL_BASE_EXPORT -IProtocolDllPtr -__stdcall -GetProtocolDll(void); - - -#endif // FTNOIR_PROTOCOL_BASE_H diff --git a/FTNoIR_Protocol_Base/ftnoir_protocol_base_global.h b/FTNoIR_Protocol_Base/ftnoir_protocol_base_global.h deleted file mode 100644 index 3527bad7..00000000 --- a/FTNoIR_Protocol_Base/ftnoir_protocol_base_global.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef FTNOIR_PROTOCOL_BASE_GLOBAL_H -#define FTNOIR_PROTOCOL_BASE_GLOBAL_H - -#include - -#ifdef FTNOIR_PROTOCOL_BASE_LIB -# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT -#else -# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT -#endif - -#endif // FTNOIR_PROTOCOL_BASE_GLOBAL_H diff --git a/FTNoIR_Protocol_FG/FGTypes.h b/FTNoIR_Protocol_FG/FGTypes.h deleted file mode 100644 index 949dc213..00000000 --- a/FTNoIR_Protocol_FG/FGTypes.h +++ /dev/null @@ -1,28 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* Type definitions for the FlightGear server. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FGTYPES_H -#define INCLUDED_FGTYPES_H - -#include "Windows.h" - -// -// x,y,z position in metres, heading, pitch and roll in degrees... -// -#pragma pack(2) -struct TFlightGearData { - double x, y, z, h, p, r; - int status; -}; - -#endif//INCLUDED_FGTYPES_H diff --git a/FTNoIR_Protocol_FG/FTNoIR_FGcontrols.ui b/FTNoIR_Protocol_FG/FTNoIR_FGcontrols.ui deleted file mode 100644 index 3469e7aa..00000000 --- a/FTNoIR_Protocol_FG/FTNoIR_FGcontrols.ui +++ /dev/null @@ -1,279 +0,0 @@ - - - UICFGControls - - - - 0 - 0 - 411 - 194 - - - - FlightGear settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Qt::RightToLeft - - - Local PC only - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - If FlightGear is on the same PC as FaceTrackNoIR, tick the 'Local PC only' box. - - - - - - - Otherwise: enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - btnOK - btnCancel - chkLocalPC - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp deleted file mode 100644 index 5506f534..00000000 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FGServer FGServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "ftnoir_protocol_fg.h" -#include - -// For Todd and Arda Kutlu -//#define SEND_ASCII_DATA -//#define LOG_OUTPUT - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - blnConnectionActive = false; - hMainWindow = NULL; - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (inSocket != 0) { - inSocket->close(); - delete inSocket; - } - - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } -} - -/** helper to Auto-destruct **/ -void FTNoIR_Protocol::Release() -{ - delete this; -} - -void FTNoIR_Protocol::Initialize() -{ - return; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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 ( "FG" ); - - bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool(); - if (blnLocalPC) { - destIP = QHostAddress::LocalHost; - } - else { - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - } - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); - - iniFile.endGroup (); - -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { -int no_bytes; -QHostAddress sender; -quint16 senderPort; -PDWORD_PTR MsgResult = 0; - -#ifdef SEND_ASCII_DATA -char data[100]; -#endif - - // - // Copy the Raw measurements directly to the client. - // - FlightData.x = headpose->x; - FlightData.y = headpose->y; - FlightData.z = headpose->z; - FlightData.p = headpose->pitch; - FlightData.h = headpose->yaw; - FlightData.r = headpose->roll; - FlightData.status = fg_cmd; - - // - // Try to send an UDP-message to the FlightGear - // - -#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); - - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &data, strlen( data ), destIP, destPort); - if ( no_bytes > 0) { - qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << data; - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; - } - } - -#endif - - #ifdef LOG_OUTPUT - // Use this for some debug-output to file... - QFile datafile(QCoreApplication::applicationDirPath() + "\\FG_output.txt"); - if (datafile.open(QFile::WriteOnly | QFile::Append)) { - QTextStream out(&datafile); - out << "output:\t" << FlightData.x << "\t" << FlightData.y << "\t" << FlightData.z << "\t" << FlightData.p << "\t" << FlightData.h << "\t" << FlightData.r << '\n'; - } - #endif - - #ifndef SEND_ASCII_DATA - //! [1] -// no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), QHostAddress::LocalHost, 5550); - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), destIP, destPort); - if ( no_bytes > 0) { - // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; - } - } - #endif - - // - // FlightGear keeps sending data, so we must read that here. - // - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - - inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); - - fg_cmd = cmd; // Let's just accept that command for now... - if ( cmd > 0 ) { - qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; -// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle - } - - if (!blnConnectionActive) { - blnConnectionActive = true; - if (hMainWindow != NULL) { - SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); - } - } - } - } -} - -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) -{ - // Init. the data - FlightData.x = 0.0f; - FlightData.y = 0.0f; - FlightData.z = 0.0f; - FlightData.h = 0.0f; - FlightData.p = 0.0f; - FlightData.r = 0.0f; - FlightData.status = 0; - fg_cmd = 1; - - inSocket = 0; - outSocket = 0; - - hMainWindow = handle; - - // - // Create UDP-sockets. - // - if (inSocket == 0) { - qDebug() << "FGServer::sendHeadposeToGame creating insocket"; - inSocket = new QUdpSocket(); - - // Connect the inSocket to the port, to receive messages - if (!inSocket->bind(QHostAddress::Any, destPort+1)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - return false; - } - } - - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - return true; -} - -// -// Return a name, if present the name from the Game, that is connected... -// -void FTNoIR_Protocol::getNameFromGame( char *dest ) -{ - sprintf_s(dest, 99, "FlightGear"); - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() -{ - return new FTNoIR_Protocol; -} diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h deleted file mode 100644 index 34773540..00000000 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG.h +++ /dev/null @@ -1,127 +0,0 @@ -/******************************************************************************** -* 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) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FGServer FGServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FGSERVER_H -#define INCLUDED_FGSERVER_H - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_FGcontrols.h" -#include "FGTypes.h" -#include -#include -#include -#include -#include "Windows.h" -#include "math.h" - -static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - - void Release(); - void Initialize(); - - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); - void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - -private: - - bool blnConnectionActive; - HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window - - // Tracker *headTracker; // For upstream messages... - TFlightGearData FlightData; - QUdpSocket *inSocket; // Receive from FligthGear - QUdpSocket *outSocket; // Send to FligthGear - qint32 cmd; - qint32 fg_cmd; // Command from FlightGear - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); - -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FGControls: public QWidget, Ui::UICFGControls, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FGControls(); - virtual ~FGControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - }; - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - }; - -private: - Ui::UICFGControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void chkLocalPCOnlyChanged(); - void settingChanged() { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public IProtocolDll -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FlightGear.ico"); }; -}; - - -#endif//INCLUDED_FGSERVER_H -//END diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc8.vcproj b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc8.vcproj deleted file mode 100644 index 47da021d..00000000 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc8.vcproj +++ /dev/null @@ -1,380 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc9.vcproj b/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc9.vcproj deleted file mode 100644 index 9dd85008..00000000 --- a/FTNoIR_Protocol_FG/FTNoIR_Protocol_FG_vc9.vcproj +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FG/Protocol.qrc b/FTNoIR_Protocol_FG/Protocol.qrc deleted file mode 100644 index 1e715ac9..00000000 --- a/FTNoIR_Protocol_FG/Protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/FlightGear.ico - - diff --git a/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp b/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp deleted file mode 100644 index 0138a4c1..00000000 --- a/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dialog.cpp +++ /dev/null @@ -1,225 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FGServer FGServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "ftnoir_protocol_fg.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FGControls::FGControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); - 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())); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FGControls::~FGControls() { - qDebug() << "~FGControls() says: started"; -} - -void FGControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FGControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FGControls::doOK() { - save(); - this->close(); -} - -// override show event -void FGControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FGControls::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 FGControls::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 ( "FG" ); - ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); - - 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 (); - - chkLocalPCOnlyChanged(); - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FGControls::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 ( "FG" ); - iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); - 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; -} - -// -// Handle change of the checkbox. -// -void FGControls::chkLocalPCOnlyChanged() { - - if ( ui.chkLocalPC->isChecked() ) { - ui.spinIPFirstNibble->setValue( 127 ); - ui.spinIPFirstNibble->setEnabled ( false ); - ui.spinIPSecondNibble->setValue( 0 ); - ui.spinIPSecondNibble->setEnabled ( false ); - ui.spinIPThirdNibble->setValue( 0 ); - ui.spinIPThirdNibble->setEnabled ( false ); - ui.spinIPFourthNibble->setValue( 1 ); - ui.spinIPFourthNibble->setEnabled ( false ); - } - else { - ui.spinIPFirstNibble->setEnabled ( true ); - ui.spinIPSecondNibble->setEnabled ( true ); - ui.spinIPThirdNibble->setEnabled ( true ); - ui.spinIPFourthNibble->setEnabled ( true ); - } - - settingsDirty = true; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FGControls; -} \ No newline at end of file diff --git a/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp b/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp deleted file mode 100644 index ca71063b..00000000 --- a/FTNoIR_Protocol_FG/ftnoir_protocol_fg_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_fg.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() -{ - return new FTNoIR_ProtocolDll; -} diff --git a/FTNoIR_Protocol_FG/images/FlightGear.ico b/FTNoIR_Protocol_FG/images/FlightGear.ico deleted file mode 100644 index f96c0f88..00000000 Binary files a/FTNoIR_Protocol_FG/images/FlightGear.ico and /dev/null differ diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_FSUIPCcontrols.ui b/FTNoIR_Protocol_FSUIPC/FTNoIR_FSUIPCcontrols.ui deleted file mode 100644 index b6120378..00000000 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_FSUIPCcontrols.ui +++ /dev/null @@ -1,228 +0,0 @@ - - - UICFSUIPCControls - - - - 0 - 0 - 541 - 127 - - - - FSUIPC settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 0 - 0 - - - - Location of FSUIPC.dll: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - - 35 - 16777215 - - - - ... - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - The DLL should be placed in the Modules folder of MS Flight Simulator - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp deleted file mode 100644 index 5a4663a1..00000000 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.cpp +++ /dev/null @@ -1,233 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * -* to games, using the FSUIPC.dll. * -********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "ftnoir_protocol_fsuipc.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); - ProgramName = "Microsoft FS2004"; - - blnConnectionActive = false; - hMainWindow = NULL; - - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - // - // Free the DLL - // - FSUIPCLib.unload(); -} - -/** helper to Auto-destruct **/ -void FTNoIR_Protocol::Release() -{ - delete this; -} - -void FTNoIR_Protocol::Initialize() -{ - return; -} - -// -// Scale the measured value to the Joystick values -// -int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; - - local_x = x; - if (local_x > max_x) { - local_x = max_x; - } - if (local_x < min_x) { - local_x = min_x; - } - y = ( 16383 * local_x ) / max_x; - - return (int) y; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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 ( "FSUIPC" ); - LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); - qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL; - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { -DWORD result; -TFSState pitch; -TFSState yaw; -TFSState roll; -WORD FSZoom; - -float virtPosX; -float virtPosY; -float virtPosZ; - -float virtRotX; -float virtRotY; -float virtRotZ; - -PDWORD_PTR MsgResult = 0; - -// qDebug() << "FSUIPCServer::run() says: started!"; - - virtRotX = -1.0f * headpose->pitch; // degrees - virtRotY = headpose->yaw; - virtRotZ = headpose->roll; - - virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! - virtPosY = 0.0f; - virtPosZ = -1.0f * headpose->z; - - // - // Init. the FSUIPC offsets (derived from Free-track...) - // - pitch.Control = 66503; - yaw.Control = 66504; - roll.Control = 66505; - - // - // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || - (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { - // - // Open the connection - // - FSUIPC_Open(SIM_ANY, &result); - - // - // Check the FS-version - // - if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && - ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { -// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; - // - // Write the 4! DOF-data to FS. Only rotations and zoom are possible. - // - pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); - FSUIPC_Write(0x3110, 8, &pitch, &result); - - yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); - FSUIPC_Write(0x3110, 8, &yaw, &result); - - roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); - FSUIPC_Write(0x3110, 8, &roll, &result); - - FSZoom = (WORD) (64/50) * virtPosZ + 64; - FSUIPC_Write(0x832E, 2, &FSZoom, &result); - - // - // Write the data, in one go! - // - FSUIPC_Process(&result); - if (result == FSUIPC_ERR_SENDMSG) { - FSUIPC_Close(); //timeout (1 second) so assume FS closed - } - - if (!blnConnectionActive) { - blnConnectionActive = true; - if (hMainWindow != NULL) { - SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); - } - } - - } - } - - prevPosX = virtPosX; - prevPosY = virtPosY; - prevPosZ = virtPosZ; - prevRotX = virtRotX; - prevRotY = virtRotY; - prevRotZ = virtRotZ; -} - -// -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) -{ - qDebug() << "checkServerInstallationOK says: Starting Function"; - - hMainWindow = handle; - - return true; -} - -// -// Return a name, if present the name from the Game, that is connected... -// -void FTNoIR_Protocol::getNameFromGame( char *dest ) -{ - sprintf_s(dest, 99, "Microsoft FS2002/2004"); - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() -{ - return new FTNoIR_Protocol; -} diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h deleted file mode 100644 index 8503f6e7..00000000 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC.h +++ /dev/null @@ -1,139 +0,0 @@ -/******************************************************************************** -* 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) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * -* to games, using the FSUIPC.dll. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FSUIPCSERVER_H -#define INCLUDED_FSUIPCSERVER_H - -#include "Windows.h" -#include -#include "FSUIPC_User.h" - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_FSUIPCcontrols.h" -#include -#include -#include -#include -#include -#include -#include - -static const char* FSUIPC_FILENAME = "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll"; -static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. - -// -// Define the structures necessary for the FSUIPC_Write calls -// -#pragma pack(push,1) // All fields in structure must be byte aligned. -typedef struct -{ - int Control; // Control identifier - int Value; // Value of DOF -} TFSState; -#pragma pack(pop) - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - - void Release(); - void Initialize(); - - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); - void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - -private: - // Private properties - QString ProgramName; - QLibrary FSUIPCLib; - QString LocationOfDLL; - float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - - bool blnConnectionActive; - HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window - - static int scale2AnalogLimits( float x, float min_x, float max_x ); - void loadSettings(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FSUIPCControls: public QWidget, Ui::UICFSUIPCControls, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FSUIPCControls(); - virtual ~FSUIPCControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - }; - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - }; - -private: - Ui::UICFSUIPCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void getLocationOfDLL(); -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public IProtocolDll -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FS9.ico"); }; -}; - - -#endif//INCLUDED_FSUIPCSERVER_H -//END diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc8.vcproj b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc8.vcproj deleted file mode 100644 index 9bcd5580..00000000 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc8.vcproj +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc9.vcproj b/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc9.vcproj deleted file mode 100644 index ff7d27d3..00000000 --- a/FTNoIR_Protocol_FSUIPC/FTNoIR_Protocol_FSUIPC_vc9.vcproj +++ /dev/null @@ -1,382 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FSUIPC/Protocol.qrc b/FTNoIR_Protocol_FSUIPC/Protocol.qrc deleted file mode 100644 index 2830d09a..00000000 --- a/FTNoIR_Protocol_FSUIPC/Protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/FS9.ico - - diff --git a/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dialog.cpp b/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dialog.cpp deleted file mode 100644 index 08c13c08..00000000 --- a/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dialog.cpp +++ /dev/null @@ -1,197 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_fsuipc.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FSUIPCControls::FSUIPCControls() : -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.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FSUIPCControls::~FSUIPCControls() { - qDebug() << "~FSUIPCControls() says: started"; -} - -void FSUIPCControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FSUIPCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FSUIPCControls::doOK() { - save(); - this->close(); -} - -// override show event -void FSUIPCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FSUIPCControls::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 FSUIPCControls::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 ( "FSUIPC" ); - ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FSUIPCControls::save() { - - qDebug() << "save() says: started"; - - 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 ( "FSUIPC" ); - iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Show the Dialog to set the DLL's location -// -void FSUIPCControls::getLocationOfDLL() -{ - // - // Get the new filename of the INI-file. - // - QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), - ui.txtLocationOfDLL->text(), - tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); - if (!fileName.isEmpty()) { - ui.txtLocationOfDLL->setText( fileName ); - settingsDirty = true; - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FSUIPCControls; -} diff --git a/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp b/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp deleted file mode 100644 index d61c2d83..00000000 --- a/FTNoIR_Protocol_FSUIPC/ftnoir_protocol_FSUIPC_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_fsuipc.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() -{ - return new FTNoIR_ProtocolDll; -} diff --git a/FTNoIR_Protocol_FSUIPC/images/FS9.ico b/FTNoIR_Protocol_FSUIPC/images/FS9.ico deleted file mode 100644 index 9afd1953..00000000 Binary files a/FTNoIR_Protocol_FSUIPC/images/FS9.ico and /dev/null differ diff --git a/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui b/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui deleted file mode 100644 index fc5abbcf..00000000 --- a/FTNoIR_Protocol_FT/FTNoIR_FTcontrols.ui +++ /dev/null @@ -1,437 +0,0 @@ - - - UICFTControls - - - - 0 - 0 - 645 - 416 - - - - - 645 - 0 - - - - FreeTrack 2.0 settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 0 - 70 - - - - TIRViews - - - - - 80 - 30 - 88 - 17 - - - - Qt::RightToLeft - - - Use TIRViews - - - - - - 189 - 10 - 421 - 16 - - - - TIRViews is only required for some older games (like CFS3). For it to work, TIRViews.dll - - - - - - 189 - 30 - 421 - 16 - - - - must be placed in the FaceTrackNoIR program folder. If the checkbox is disabled, the - - - true - - - - - - 189 - 50 - 411 - 16 - - - - the DLL was not found. You can get it from NaturalPoint. - - - - - - - - - 0 - 70 - - - - TrackIR.exe - - - - - 20 - 30 - 145 - 17 - - - - Qt::RightToLeft - - - Start dummy TrackIR.exe - - - - - - 189 - 10 - 351 - 16 - - - - Some programs check, to see if a process called TrackIR.exe is running, - - - - - - 189 - 30 - 261 - 16 - - - - before enabling head-tracking (EZCA is one of them). - - - true - - - - - - 189 - 50 - 231 - 16 - - - - Check the checkbox, to overcome this problem. - - - - - - - - - 0 - 70 - - - - Select interface - - - - - 189 - 10 - 351 - 16 - - - - Some games support both FreeTrack and TrackIR and may get confused, - - - - - - 189 - 30 - 261 - 16 - - - - when both interfaces are visible. - - - true - - - - - - 189 - 50 - 381 - 16 - - - - Try to disable one interface, if you experience problems. - - - - - - 6 - 30 - 168 - 22 - - - - - - - - - - 0 - 70 - - - - Repair NPClient location - - - - - 188 - 10 - 381 - 20 - - - - Users who use other software with an NPClient DLL (like TrackIR, FreeTrack or - - - - - - 184 - 30 - 411 - 20 - - - - GlovePIE) may need to repair the location of the DLL, after running FaceTrackNoIR. - - - true - - - - - - 187 - 50 - 391 - 20 - - - - Use this button to locate the desired NPClient DLL. - - - - - - 4 - 30 - 171 - 23 - - - - Locate DLL - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp deleted file mode 100644 index b8461993..00000000 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.cpp +++ /dev/null @@ -1,513 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTServer FTServer is the Class, that communicates headpose-data * -* to games, using the FreeTrackClient.dll. * -********************************************************************************/ -/* - Modifications (last one on top): - 20130209 - WVR: Some games support both interfaces and cause trouble. Added ComboBox to fix this (hide one interface - by clearing the appropriate Registry-setting). - 20130203 - WVR: Added Tirviews and dummy checkboxes to the Settings dialog. This is necessary for CFS3 etc. - 20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games. - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp - 20100601 - WVR: Added Mutex-bit in run(). Thought it wasn't so important (still do...). - 20100523 - WVR: Implemented the Freetrack-protocol just like Freetrack does. Earlier - FaceTrackNoIR only worked with an adapted DLL, with a putdata function. - Now it works direcly in shared memory! -*/ -#include "ftnoir_protocol_ft.h" -#include "csv.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - comhandle = 0; - useTIRViews = false; - useDummyExe = false; - intUsedInterface = 0; - - // - // Load the INI-settings. - // - loadSettings(); - - ProgramName = ""; - intGameID = 0; - - dummyTrackIR = 0; - viewsStart = 0; - viewsStop = 0; - -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - - qDebug()<< "~FTNoIR_Protocol: Destructor started."; - - // - // Stop if started - // - if (viewsStop != NULL) { - qDebug()<< "~FTNoIR_Protocol: Stopping TIRViews."; - viewsStop(); - FTIRViewsLib.unload(); - } - - // - // Kill the dummy TrackIR process. - // - qDebug() << "~FTNoIR_Protocol() about to kill TrackIR.exe process"; - try { - if (dummyTrackIR) { - qDebug() << "FTServer::~FTServer() about to kill TrackIR.exe process"; -// dummyTrackIR->close(); - dummyTrackIR->kill(); - } - } - catch (...) - { - qDebug() << "~FTServer says: some error occurred"; - } - - // - // Destroy the File-mapping - // - FTDestroyMapping(); -} - -void FTNoIR_Protocol::Initialize() -{ - return; -} - -// -// Read the game-data from CSV -// -bool FTNoIR_Protocol::getGameData( QString gameID ){ -QStringList gameLine; - - qDebug() << "getGameData, ID = " << gameID; - - // - // Open the supported games list, to get the Name. - // - QFile file(QCoreApplication::applicationDirPath() + "/Settings/FaceTrackNoIR Supported Games.csv"); - if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ - QString strError( "Cannot load file: FaceTrackNoIR Supported Games.csv" ); - sprintf_s(pMemData->ProgramName, 99, strError.toAscii()); - sprintf_s(pMemData->FTNVERSION, 9, "V160"); - - // - // Return true anyway, because maybe it's V160 compatible. - // - return true; - } - CSV csv(&file); - gameLine = csv.parseLine(); - - while (gameLine.count() > 2) { - //qDebug() << "Column 0: " << gameLine.at(0); // No. - //qDebug() << "Column 1: " << gameLine.at(1); // Game Name - //qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol - //qDebug() << "Column 3: " << gameLine.at(3); // Supported since version - //qDebug() << "Column 4: " << gameLine.at(4); // Verified - //qDebug() << "Column 5: " << gameLine.at(5); // By - //qDebug() << "Column 6: " << gameLine.at(6); // International ID - //qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID - - // - // If the gameID was found, fill the shared memory - // - if (gameLine.count() > 6) { - if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { - if (pMemData != NULL) { - sprintf_s(pMemData->ProgramName, 99, gameLine.at(1).toAscii()); - sprintf_s(pMemData->FTNVERSION, 9, gameLine.at(3).toAscii()); - sprintf_s(pMemData->FTNID, 24, gameLine.at(7).toAscii()); - } - file.close(); - return true; - } - } - - gameLine = csv.parseLine(); - } - - // - // If the gameID was NOT found, fill only the name "Unknown game connected" - // - QString strUnknown("Unknown game connected (ID = " + gameID + ")"); - sprintf_s(pMemData->ProgramName, 99, strUnknown.toAscii()); - file.close(); - return true; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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 ( "FT" ); - intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt(); - iniFile.endGroup (); - - // - // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there. - // - iniFile.beginGroup ( "FTIR" ); - useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool(); - useDummyExe = iniFile.value ( "useDummyExe", 1 ).toBool(); - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { -float virtPosX; -float virtPosY; -float virtPosZ; - -float virtRotX; -float virtRotY; -float virtRotZ; - -float headPosX; -float headPosY; -float headPosZ; - -float headRotX; -float headRotY; -float headRotZ; - -PDWORD_PTR MsgResult = 0; - - - // - // Scale the Raw measurements to the client measurements. - // - headRotX = getRadsFromDegrees(headpose->pitch); - headRotY = getRadsFromDegrees(headpose->yaw); - headRotZ = getRadsFromDegrees(headpose->roll); - headPosX = headpose->x * 10; - headPosY = headpose->y * 10; - headPosZ = headpose->z * 10; - - virtRotX = getRadsFromDegrees(headpose->pitch); - virtRotY = getRadsFromDegrees(headpose->yaw); - virtRotZ = getRadsFromDegrees(headpose->roll); - virtPosX = headpose->x * 10; - virtPosY = headpose->y * 10; - virtPosZ = headpose->z * 10; - - // - // Check if the pointer is OK and wait for the Mutex. - // - if ( (pMemData != NULL) && (WaitForSingleObject(hFTMutex, 100) == WAIT_OBJECT_0) ) { - - // - // Copy the Raw measurements directly to the client. - // - pMemData->data.RawX = headPosX; - pMemData->data.RawY = headPosY; - pMemData->data.RawZ = headPosZ; - pMemData->data.RawPitch = headRotX; - pMemData->data.RawYaw = headRotY; - pMemData->data.RawRoll = headRotZ; - - // - // - pMemData->data.X = virtPosX; - pMemData->data.Y = virtPosY; - pMemData->data.Z = virtPosZ; - pMemData->data.Pitch = virtRotX; - pMemData->data.Yaw = virtRotY; - pMemData->data.Roll = virtRotZ; - - // - // Leave some values 0 yet... - // - pMemData->data.X1 = pMemData->data.DataID + 10; - pMemData->data.X2 = 0; - pMemData->data.X3 = 0; - pMemData->data.X4 = 0; - pMemData->data.Y1 = 0; - pMemData->data.Y2 = 0; - pMemData->data.Y3 = 0; - pMemData->data.Y4 = 0; - - // - // Check if the handle that was sent to the Game, was changed (on x64, this will be done by the ED-API) - // If the "Report Program Name" command arrives (which is a '1', for now), raise the event from here! - // - if (hMainWindow != pMemData->handle) { // Handle in memory-mapping was changed! - comhandle = (__int32) pMemData->handle; // Get the command from the Game. - if (comhandle == 1) { // "Report Program Name" - SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); - pMemData->handle = 0; // Reset the command, to enable future commands... - } - } - - // - // The game-ID was changed? - // - QString gameID = QString(pMemData->GameID); - //QString gameID = QString("9999"); - -// qDebug() << "sendHeadposeToGame: gameID = " << gameID; - if (gameID.length() > 0) { - if ( gameID.toInt() != intGameID ) { - if (getGameData( gameID ) ) { - SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); - } - intGameID = gameID.toInt(); - } - } - else { - intGameID = 0; - pMemData->ProgramName[0] = NULL; - pMemData->FTNID[0] = NULL; - pMemData->FTNVERSION[0] = NULL; - } - - ReleaseMutex(hFTMutex); - } - - pMemData->data.DataID += 1; -} - -// -// Set the Path variables and load the memory-mapping. -// Simplified function: No need to check if the DLL's actually exist. The are installed by the installer. -// If they are absent, something went terribly wrong anyway... -// -// Returns 'true' if all seems OK. -// -// -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) -{ - QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER) - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation; // Location of Client DLL - - qDebug() << "checkServerInstallationOK says: Starting Function"; - - try { - - // - // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). - // - aLocation = QCoreApplication::applicationDirPath() + "/"; - - qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; - switch (intUsedInterface) { - case 0: // Use both interfaces - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , aLocation ); - break; - case 1: // Use FreeTrack, disable TrackIR - settings.setValue( "Path" , aLocation ); - settingsTIR.setValue( "Path" , "" ); - break; - case 2: // Use TrackIR, disable FreeTrack - settings.setValue( "Path" , "" ); - settingsTIR.setValue( "Path" , aLocation ); - break; - default: - // should never be reached - break; - } - - // - // TIRViews must be started first, or the NPClient DLL will never be loaded. - // - if (useTIRViews) { - - QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( QFile::exists( aFileName ) ) { - - FTIRViewsLib.setFileName(aFileName); - FTIRViewsLib.load(); - - viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart"); - if (viewsStart == NULL) { - qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!"; - } - else { - qDebug() << "FTServer::run() says: TIRViewsStart executed!"; - viewsStart(); - } - - // - // Load the Stop function from TIRViews.dll. Call it when terminating the thread. - // - viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop"); - if (viewsStop == NULL) { - qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!"; - } - } - } - - // - // Check if TIRViews or dummy TrackIR.exe is required for this game - // - if (useDummyExe) { - QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; - dummyTrackIR = new QProcess(); - dummyTrackIR->start(program); - - qDebug() << "FTServer::run() says: TrackIR.exe executed!"; - } - - - } catch(...) { - settings.~QSettings(); - } - return FTCreateMapping( handle ); -} - -// -// Create a memory-mapping to the FreeTrack data. -// It contains the tracking data, a handle to the main-window and the program-name of the Game! -// -// -bool FTNoIR_Protocol::FTCreateMapping( HANDLE handle ) -{ -bool bFirst = false; - - qDebug() << "FTCreateMapping says: Starting Function"; - - // - // A FileMapping is used to create 'shared memory' between the FTServer and the FTClient. - // - // Try to create a FileMapping to the Shared Memory. - // If one already exists: close it. - // - hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , -// sizeof( TFreeTrackData ) + sizeof( HANDLE ) + 100, - sizeof( FTMemMap ), - (LPCSTR) FT_MM_DATA ); - - if ( hFTMemMap != 0 ) { - bFirst = true; - qDebug() << "FTCreateMapping says: FileMapping Created!" << hFTMemMap; - } - - if ( ( hFTMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) { - bFirst = false; - qDebug() << "FTCreateMapping says: FileMapping already exists!" << hFTMemMap; - CloseHandle( hFTMemMap ); - hFTMemMap = 0; - } - - // - // Create a new FileMapping, Read/Write access - // - hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA ); - if ( ( hFTMemMap != 0 ) ) { - qDebug() << "FTCreateMapping says: FileMapping Opened:" << hFTMemMap; - pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, -// sizeof(TFreeTrackData) + sizeof(hFTMemMap) + 100); - sizeof(FTMemMap)); - if (pMemData != NULL) { - if (bFirst) { - memset(pMemData, 0, sizeof(FTMemMap)); // Write zero's, if first... - } - pMemData->handle = handle; // The game uses the handle, to send a message that the Program-Name was set! - hMainWindow = handle; - } - hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); - } - else { - QMessageBox::information(0, "FaceTrackNoIR error", QString("FTServer Error! \n")); - return false; - } - - if (pMemData != NULL) { - pMemData->data.DataID = 1; - pMemData->data.CamWidth = 100; - pMemData->data.CamHeight = 250; - } - - return true; -} - -// -// Destory the FileMapping to the shared memory -// -void FTNoIR_Protocol::FTDestroyMapping() -{ - if ( pMemData != NULL ) { - UnmapViewOfFile ( pMemData ); - } - - CloseHandle( hFTMutex ); - CloseHandle( hFTMemMap ); - hFTMemMap = 0; - -} - -// -// Return a name, if present the name from the Game, that is connected... -// -void FTNoIR_Protocol::getNameFromGame( char *dest ) -{ - sprintf_s(dest, 99, "FreeTrack interface"); - - qDebug() << "FTNoIR_Protocol::getNameFromGame says: Started, pMemData = " << pMemData << ", mutex = " << hFTMutex; - - // - // Check if the pointer is OK and wait for the Mutex. - // -// if ( (pMemData != NULL) && (WaitForSingleObject(hFTMutex, 100) == WAIT_OBJECT_0) ) { - if (pMemData != NULL) { - qDebug() << "FTNoIR_Protocol::getNameFromGame says: Inside MemData"; - sprintf_s(dest, 99, "%s", pMemData->ProgramName); - } - - return; -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() -{ - return new FTNoIR_Protocol; -} diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h deleted file mode 100644 index c82c3e79..00000000 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT.h +++ /dev/null @@ -1,143 +0,0 @@ -/******************************************************************************** -* 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) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTServer FTServer is the Class, that communicates headpose-data * -* to games, using the FreeTrackClient.dll. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTSERVER_H -#define INCLUDED_FTSERVER_H - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_FTcontrols.h" -#include "FTTypes.h" -#include -#include -#include -#include -#include -#include -#include "Windows.h" -//#include "math.h" - -//typedef char *(WINAPI *importProvider)(void); -typedef void (WINAPI *importTIRViewsStart)(void); -typedef void (WINAPI *importTIRViewsStop)(void); - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - - void Release(); - void Initialize(); - - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); - void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - -private: - bool FTCreateMapping(HANDLE handle); - void FTDestroyMapping(); - - importTIRViewsStart viewsStart; // Functions inside TIRViews.dll - importTIRViewsStop viewsStop; - - HANDLE hFTMemMap; - FTMemMap *pMemData; - HANDLE hFTMutex; - - HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window - __int32 comhandle; // Handle on x32, command on x64 - - // Private properties - QString ProgramName; - QLibrary FTIRViewsLib; - QProcess *dummyTrackIR; - int intGameID; - int intUsedInterface; // Determine which interface to use (or to hide from the game) - bool useTIRViews; // Needs to be in the Settings dialog - bool useDummyExe; - - float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } - bool getGameData( QString gameID ); - void loadSettings(); - -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FTControls: public QWidget, Ui::UICFTControls, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FTControls(); - virtual ~FTControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - }; - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - }; - -private: - Ui::UICFTControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void selectDLL(); - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public IProtocolDll -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/Freetrack.ico"); }; -}; - - -#endif//INCLUDED_FTSERVER_H -//END diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc8.vcproj b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc8.vcproj deleted file mode 100644 index f8f80412..00000000 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc8.vcproj +++ /dev/null @@ -1,393 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc9.vcproj b/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc9.vcproj deleted file mode 100644 index e5146727..00000000 --- a/FTNoIR_Protocol_FT/FTNoIR_Protocol_FT_vc9.vcproj +++ /dev/null @@ -1,385 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FT/FTTypes.h b/FTNoIR_Protocol_FT/FTTypes.h deleted file mode 100644 index 1f389711..00000000 --- a/FTNoIR_Protocol_FT/FTTypes.h +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************************** -* FTTypes FTTypes contains th specific type definitions for the * -* FreeTrack protocol. * -* It was loosely translated from FTTypes.pas * -* which was created by the FreeTrack-team. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* We would like to extend our grattitude to the creators of SweetSpotter, * -* which has become the basis of this program: "Great work guys!" * -********************************************************************************/ -/* - Modifications (last one on top): - 20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games. The memory-mapping was expanded for this purpose. -*/ -#pragma once -#ifndef INCLUDED_FTTYPES_H -#define INCLUDED_FTTYPES_H - -#include "Windows.h" -#include -#include - -//#include "Registry.h" - -// static const char* FT_CLIENT_LOCATION = "Software\\Freetrack\\FreetrackClient"; - static const char* FT_CLIENT_FILENAME = "FreeTrackClient.Dll"; - static const char* FT_MM_DATA = "FT_SharedMem"; - static const char* FREETRACK = "Freetrack"; - static const char* FREETRACK_MUTEX = "FT_Mutext"; - static const char* FT_PROGRAMID = "FT_ProgramID"; - - -struct TFreeTrackData { - int DataID; - int CamWidth; - int CamHeight; - // virtual pose - float Yaw; // positive yaw to the left - float Pitch; // positive pitch up - float Roll; // positive roll to the left - float X; - float Y; - float Z; - // raw pose with no smoothing, sensitivity, response curve etc. - float RawYaw; - float RawPitch; - float RawRoll; - float RawX; - float RawY; - float RawZ; - // raw points, sorted by Y, origin top left corner - float X1; - float Y1; - float X2; - float Y2; - float X3; - float Y3; - float X4; - float Y4; -}; -typedef TFreeTrackData * PFreetrackData; - -struct FTMemMap { - TFreeTrackData data; - -#ifdef WIN64 - __int32 command; -#else - HANDLE handle; -#endif - char ProgramName[100]; // The name of the game - char GameID[10]; // The international game-ID - char FTNID[30]; // The FaceTrackNoIR game-ID - char FTNVERSION[10]; // The version of FaceTrackNoIR, in which the game was first supported -}; -typedef FTMemMap * PFTMemMap; - -//extern bool (*FTGetData) (PFreetrackData data); -// DLL function signatures -// These match those given in FTTypes.pas -// WINAPI is macro for __stdcall defined somewhere in the depths of windows.h -typedef bool (WINAPI *importGetData)(TFreeTrackData * data); -typedef char *(WINAPI *importGetDllVersion)(void); -typedef void (WINAPI *importReportID)(int name); -typedef char *(WINAPI *importProvider)(void); - -#endif//INCLUDED_FTTYPES_H diff --git a/FTNoIR_Protocol_FT/Protocol.qrc b/FTNoIR_Protocol_FT/Protocol.qrc deleted file mode 100644 index 25ecc6fe..00000000 --- a/FTNoIR_Protocol_FT/Protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/Freetrack.ico - - diff --git a/FTNoIR_Protocol_FT/csv.cpp b/FTNoIR_Protocol_FT/csv.cpp deleted file mode 100644 index 22852f89..00000000 --- a/FTNoIR_Protocol_FT/csv.cpp +++ /dev/null @@ -1,99 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -#include "csv.h" -#include - -CSV::CSV(QIODevice * device) -{ - m_device = device; - m_codec = QTextCodec::codecForLocale(); - m_pos = 0; - m_rx = QRegExp("((?:(?:[^;\\n]*;?)|(?:\"[^\"]*\";?))*)\\n"); -} -CSV::CSV(QString &string){ - m_device = NULL; - m_codec = QTextCodec::codecForLocale(); - m_string = string; - m_pos = 0; - m_rx = QRegExp("((?:(?:[^;\\n]*;?)|(?:\"[^\"]*\";?))*)\\n"); -} - -CSV::~CSV() -{ - //delete m_codec; -} - - -void CSV::setCodec(const char* codecName){ - //delete m_codec; - m_codec = QTextCodec::codecForName(codecName); -} - -QString CSV::readLine(){ - QString line; - - if(m_string.isNull()){ - //READ DATA FROM DEVICE - if(m_device && m_device->isReadable()){ - QTextDecoder dec(m_codec); - m_string = dec.toUnicode(m_device->readAll()); - }else{ - return QString(); - } - } - - //PARSE - if((m_pos = m_rx.indexIn(m_string,m_pos)) != -1) { - line = m_rx.cap(1); - m_pos += m_rx.matchedLength(); - } - return line; - -} -QStringList CSV::parseLine(){ - return parseLine(readLine()); -} -QStringList CSV::parseLine(QString line){ - QStringList list; - int pos2 = 0; - QRegExp rx2("(?:\"([^\"]*)\";?)|(?:([^;]*);?)"); - if(line.size()<1){ - list << ""; - }else while (line.size()>pos2 && (pos2 = rx2.indexIn(line, pos2)) != -1) { - QString col; - if(rx2.cap(1).size()>0) - col = rx2.cap(1); - else if(rx2.cap(2).size()>0) - col = rx2.cap(2); - - list << col; - - if(col.size()) - pos2 += rx2.matchedLength(); - else - pos2++; - } - return list; -} \ No newline at end of file diff --git a/FTNoIR_Protocol_FT/csv.h b/FTNoIR_Protocol_FT/csv.h deleted file mode 100644 index 13231293..00000000 --- a/FTNoIR_Protocol_FT/csv.h +++ /dev/null @@ -1,38 +0,0 @@ -/*dummy CSV reader for QT4*/ -/*version 0.1*/ -/*11.1.2009*/ -#ifndef CSV_H -#define CSV_H - -//#include "myclass_api.h" - -#include -#include -#include -#include -#include - -class /*MYCLASS_API*/ CSV /*: public QObject*/ -{ - /*Q_OBJECT*/ - -public: - CSV(QIODevice * device); - CSV(QString &string); - ~CSV(); - - QString readLine(); - QStringList parseLine(); - static QStringList parseLine(QString line); - - void setCodec(const char* codecName); -private: - QIODevice *m_device; - QTextCodec *m_codec; - QString m_string; - int m_pos; - QRegExp m_rx; - -}; - -#endif // CSV_H diff --git a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp deleted file mode 100644 index 2e6c91f7..00000000 --- a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dialog.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_ft.h" -#include -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTControls::FTControls() : -QWidget() -{ - QString aFileName; // File Path and Name - - 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.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); - connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); - connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - - ui.cbxSelectInterface->addItem("Enable both"); - ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); - ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); - - - aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; - if ( !QFile::exists( aFileName ) ) { - ui.chkTIRViews->setChecked( false ); - ui.chkTIRViews->setEnabled ( false ); - - // - // Best do this save() last, or it will continually reset the settings... :-( - // - save(); - } - else { - ui.chkTIRViews->setEnabled ( true ); - } - - -} - -// -// Destructor for server-dialog -// -FTControls::~FTControls() { - qDebug() << "~FTControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void FTControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTControls::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 FTControls::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 ( "FT" ); - ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "FTIR" ); - ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); - ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FTControls::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 ( "FT" ); - iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex()); - iniFile.endGroup (); - - iniFile.beginGroup ( "FTIR" ); - iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); - iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Select a NPClient.dll file, to repair the Location in the Registry. -// Several program distribute their own version of this file. -// -void FTControls::selectDLL() { - QFileDialog::Options options; - QFileDialog::FileMode mode; - - options |= QFileDialog::DontUseNativeDialog; - mode = QFileDialog::ExistingFile; - QString selectedFilter; - QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); - - // - // Write the location of the file in the required Registry-key. - // - if (! fileName.isEmpty() ) { - if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { - QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) - QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL - - settingsTIR.setValue( "Path" , aLocation ); - } - } -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FTControls; -} diff --git a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp b/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp deleted file mode 100644 index 4513c6ba..00000000 --- a/FTNoIR_Protocol_FT/ftnoir_protocol_FT_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_ft.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() -{ - return new FTNoIR_ProtocolDll; -} diff --git a/FTNoIR_Protocol_FT/images/Freetrack.ico b/FTNoIR_Protocol_FT/images/Freetrack.ico deleted file mode 100644 index 02554c3d..00000000 Binary files a/FTNoIR_Protocol_FT/images/Freetrack.ico and /dev/null differ diff --git a/FTNoIR_Protocol_FTN/FTNoIR_FTNControls.ui b/FTNoIR_Protocol_FTN/FTNoIR_FTNControls.ui deleted file mode 100644 index 56983fbe..00000000 --- a/FTNoIR_Protocol_FTN/FTNoIR_FTNControls.ui +++ /dev/null @@ -1,261 +0,0 @@ - - - UICFTNControls - - - - 0 - 0 - 411 - 156 - - - - FTNoIR protocol settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Port-number - - - - - - - 1000 - - - 10000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - btnOK - btnCancel - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp deleted file mode 100644 index cfb6c618..00000000 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.cpp +++ /dev/null @@ -1,200 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNServer FTNServer is the Class, that communicates headpose-data * -* to another FaceTrackNoIR program, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "ftnoir_protocol_ftn.h" -#include - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - if (inSocket != 0) { - inSocket->close(); - delete inSocket; - } - - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } -} - -/** helper to Auto-destruct **/ -void FTNoIR_Protocol::Release() -{ - delete this; -} - -void FTNoIR_Protocol::Initialize() -{ - return; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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 ( "FTN" ); - - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); - - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { -int no_bytes; -QHostAddress sender; -quint16 senderPort; - - // - // Copy the Raw measurements directly to the client. - // - frame_counter += 1; - TestData = *headpose; - TestData.frame_number = frame_counter; - - // - // Try to send an UDP-message to the receiver - // - - //! [1] - if (outSocket != 0) { - no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort); - if ( no_bytes > 0) { -// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; - } - } - - // - // Receiver may send data, so we must read that here. - // - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - - inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); - - fg_cmd = cmd; // Let's just accept that command for now... - if ( cmd > 0 ) { - qDebug() << "FTNServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; -// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle - } - } - } -} - -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) -{ - // Init. the data - TestData.x = 0.0f; - TestData.y = 0.0f; - TestData.z = 0.0f; - TestData.yaw = 0.0f; - TestData.pitch = 0.0f; - TestData.roll = 0.0f; - fg_cmd = 1; - - inSocket = 0; - outSocket = 0; - - frame_counter = 0; - - // - // Create UDP-sockets. - // - if (inSocket == 0) { - qDebug() << "FGServer::sendHeadposeToGame creating insocket"; - inSocket = new QUdpSocket(); - - // Connect the inSocket to the port, to receive messages - if (!inSocket->bind(QHostAddress::Any, destPort+1, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - return false; - } - } - - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - return true; -} - -// -// Return a name, if present the name from the Game, that is connected... -// -void FTNoIR_Protocol::getNameFromGame( char *dest ) -{ - sprintf_s(dest, 99, "FaceTrackNoIR"); - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() -{ - return new FTNoIR_Protocol; -} diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h deleted file mode 100644 index 24f760c5..00000000 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN.h +++ /dev/null @@ -1,119 +0,0 @@ -/******************************************************************************** -* 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) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNServer FTNServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTNSERVER_H -#define INCLUDED_FTNSERVER_H - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include "ui_FTNoIR_FTNcontrols.h" -#include -#include -#include -#include -#include "Windows.h" -#include "math.h" - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - - void Release(); - void Initialize(); - - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); - void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - -private: - THeadPoseData TestData; - long frame_counter; - QUdpSocket *inSocket; // Receive from FaceTrackNoIR - QUdpSocket *outSocket; // Send to FaceTrackNoIR - qint32 cmd; - qint32 fg_cmd; // Command from FlightGear - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); - -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class FTNControls: public QWidget, Ui::UICFTNControls, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit FTNControls(); - virtual ~FTNControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - }; - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - }; - -private: - Ui::UICFTNControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public IProtocolDll -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FaceTrackNoIR.ico"); }; -}; - -#endif//INCLUDED_FTNSERVER_H -//END diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc8.vcproj b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc8.vcproj deleted file mode 100644 index 1133119f..00000000 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc8.vcproj +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc9.vcproj b/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc9.vcproj deleted file mode 100644 index d1955180..00000000 --- a/FTNoIR_Protocol_FTN/FTNoIR_Protocol_FTN_vc9.vcproj +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_FTN/Protocol.qrc b/FTNoIR_Protocol_FTN/Protocol.qrc deleted file mode 100644 index b69d1f3f..00000000 --- a/FTNoIR_Protocol_FTN/Protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/FaceTrackNoIR.ico - - diff --git a/FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp b/FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp deleted file mode 100644 index 00badedf..00000000 --- a/FTNoIR_Protocol_FTN/ftnoir_protocol_FTN_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_ftn.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() -{ - return new FTNoIR_ProtocolDll; -} diff --git a/FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp b/FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp deleted file mode 100644 index 58dbfbad..00000000 --- a/FTNoIR_Protocol_FTN/ftnoir_protocol_ftn_dialog.cpp +++ /dev/null @@ -1,194 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_ftn.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -FTNControls::FTNControls() : -QWidget() -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - //if (parent) { - // this->move(parent->pos() + offsetpos); - //} - - // 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())); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FTNControls::~FTNControls() { - qDebug() << "~FTNControls() says: started"; -} - -void FTNControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void FTNControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void FTNControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTNControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTNControls::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 FTNControls::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 ( "FTN" ); - 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 FTNControls::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 ( "FTN" ); - 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 Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new FTNControls; -} diff --git a/FTNoIR_Protocol_FTN/images/FaceTrackNoIR.ico b/FTNoIR_Protocol_FTN/images/FaceTrackNoIR.ico deleted file mode 100644 index 5115066c..00000000 Binary files a/FTNoIR_Protocol_FTN/images/FaceTrackNoIR.ico and /dev/null differ diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp deleted file mode 100644 index f81a38f7..00000000 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * -* generating Mouse commands. * -* Many games (like FPS's) support Mouse-look features, * -* but no face-tracking. * -********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "ftnoir_protocol_mouse.h" - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - prev_fMouse_X = 0.0f; - prev_fMouse_Y = 0.0f; - prev_fMouse_Wheel = 0.0f; - frame_delay = 0; - - loadSettings(); -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ -} - -/** helper to Auto-destruct **/ -void FTNoIR_Protocol::Release() -{ - delete this; -} - -void FTNoIR_Protocol::Initialize() -{ -int ScreenX, ScreenY; - - ScreenX = GetSystemMetrics(SM_CXSCREEN); - ScreenY = GetSystemMetrics(SM_CYSCREEN); - - qDebug() << "Initialize(): Screen width (x) = " << ScreenX << ", height (y) = " << ScreenY; - - return; -} - -// -// Scale the measured value to the Joystick values -// -long FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; - - y = ((MOUSE_AXIS_MAX - MOUSE_AXIS_MIN)/(max_x - min_x)) * x + ((MOUSE_AXIS_MAX - MOUSE_AXIS_MIN)/2) + MOUSE_AXIS_MIN; - return (long) y; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { - 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 ( "Mouse" ); - Mouse_Style = (FTN_MouseStyle) (iniFile.value ( "Style", 1 ).toInt() - 1); - Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 1 ).toInt() - 1); - Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 1 ).toInt() - 1); - Mouse_Wheel = (FTN_AngleName) (iniFile.value ( "Mouse_Wheel", 1 ).toInt() - 1); - - mouse_X_factor = iniFile.value("SensX", 10).toFloat() / 10.0f; - mouse_Y_factor = iniFile.value("SensY", 10).toFloat() / 10.0f; - mouse_Wheel_factor = iniFile.value("SensWheel", 10).toFloat() / 10.0f; - - useVirtualDesk = iniFile.value ( "useVirtualDesk", 0 ).toBool(); - - iniFile.endGroup (); -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { -float fMouse_X; // The actual value -float fMouse_Y; -float fMouse_Wheel; - - - // - // Determine which of the 6DOF's is used. - // The rotations are from -180 to +180 and the translations from -50cm to +50cm. - // Let's scale the translations to the degrees for simplicity sake... - // - switch (Mouse_X) { - case FTN_PITCH: - fMouse_X = headpose->pitch; - break; - - case FTN_YAW: - fMouse_X = headpose->yaw; - break; - - case FTN_ROLL: - fMouse_X = headpose->roll; - break; - - case FTN_X: - fMouse_X = headpose->x * 3.0f; - break; - - case FTN_Y: - fMouse_X = headpose->y * 3.0f; - break; - - case FTN_Z: - fMouse_X = headpose->z * 3.0f; - break; - - default: - break; - } - - // - // Determine which of the 6DOF's is used. - // The rotations are from -180 to +180 and the translations from -50cm to +50cm. - // Let's scale the translations to the degrees for simplicity sake... - // - switch (Mouse_Y) { - case FTN_PITCH: - fMouse_Y = headpose->pitch; - break; - - case FTN_YAW: - fMouse_Y = headpose->yaw; - break; - - case FTN_ROLL: - fMouse_Y = headpose->roll; - break; - - case FTN_X: - fMouse_Y = headpose->x * 3.0f; - break; - - case FTN_Y: - fMouse_Y = headpose->y * 3.0f; - break; - - case FTN_Z: - fMouse_Y = headpose->z * 3.0f; - break; - - default: - break; - } - - // - // Determine which of the 6DOF's is used. - // The rotations are from -180 to +180 and the translations from -50cm to +50cm. - // Let's scale the translations to the degrees for simplicity sake... - // - switch (Mouse_Wheel) { - case FTN_PITCH: - fMouse_Wheel = headpose->pitch; - break; - - case FTN_YAW: - fMouse_Wheel = headpose->yaw; - break; - - case FTN_ROLL: - fMouse_Wheel = headpose->roll; - break; - - case FTN_X: - fMouse_Wheel = headpose->x * 3.0f; - break; - - case FTN_Y: - fMouse_Wheel = headpose->y * 3.0f; - break; - - case FTN_Z: - fMouse_Wheel = headpose->z * 3.0f; - break; - - default: - break; - } - - // - // Determine which style is used. - // - SecureZeroMemory(&MouseStruct, sizeof(MouseStruct)); - MouseStruct.type = INPUT_MOUSE; - switch (Mouse_Style) { - case FTN_ABSOLUTE: - MouseStruct.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_WHEEL | MOUSEEVENTF_ABSOLUTE; - if (useVirtualDesk) { - MouseStruct.mi.dwFlags |= MOUSEEVENTF_VIRTUALDESK; - } - MouseStruct.mi.dx = scale2AnalogLimits(-1.0f * fMouse_X * mouse_X_factor, -150, 150); - MouseStruct.mi.dy = scale2AnalogLimits(fMouse_Y * mouse_Y_factor, -150, 150); - MouseStruct.mi.mouseData = mouse_Wheel_factor * (fMouse_Wheel - prev_fMouse_Wheel); - - frame_delay = 9999; // Seems no problem with Absolute positioning - break; - - case FTN_RELATIVE: - MouseStruct.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_WHEEL; - MouseStruct.mi.dx = -1.0f * mouse_X_factor * (fMouse_X - prev_fMouse_X); - MouseStruct.mi.dy = mouse_Y_factor * (fMouse_Y - prev_fMouse_Y); - MouseStruct.mi.mouseData = - 1.0f * mouse_Wheel_factor * (fMouse_Wheel - prev_fMouse_Wheel); - - frame_delay += 1; // Add 1 to the counter - qDebug() << "sendHeadposeToGame(): FTN_RELATIVE x = " << MouseStruct.mi.dx << ", y = " << MouseStruct.mi.dy; - break; - - default: - Mouse_Style = FTN_ABSOLUTE; // Force to a valid value... - break; - } - - // - // Only send Input, when it has changed. - // This releases the Mouse, when tracking is stopped (for a while). - // - if (frame_delay > 10) { - if ((prev_fMouse_X != fMouse_X) || (prev_fMouse_Y != fMouse_Y) || (prev_fMouse_Wheel != fMouse_Wheel)) { - SendInput(1, &MouseStruct, sizeof(MouseStruct)); - } - - prev_fMouse_X = fMouse_X; - prev_fMouse_Y = fMouse_Y; - prev_fMouse_Wheel = fMouse_Wheel; - } -} - -// -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) -{ - - return true; -} - -// -// Return a name, if present the name from the Game, that is connected... -// -void FTNoIR_Protocol::getNameFromGame( char *dest ) -{ - sprintf_s(dest, 99, "Mouse"); - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() -{ - return new FTNoIR_Protocol; -} diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h deleted file mode 100644 index b7765b96..00000000 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE.h +++ /dev/null @@ -1,151 +0,0 @@ -/******************************************************************************** -* 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) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* 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 . * -* * -* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * -* generating Mouse commands. * -* Many games (like FPS's) support Mouse-look features, * -* but no face-tracking. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_MOUSESERVER_H -#define INCLUDED_MOUSESERVER_H - -//#include -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_MOUSEcontrols.h" -#include -#include -#include -#include -#include -#include - -#include "winable.h" - -#define MOUSE_AXIS_MIN 0 -#define MOUSE_AXIS_MAX 65535 - -enum FTN_AngleName { - FTN_PITCH = 1, - FTN_YAW = 2, - FTN_ROLL = 3, - FTN_X = 4, - FTN_Y = 5, - FTN_Z = 6 -}; - -enum FTN_MouseStyle { - FTN_ABSOLUTE = 0, - FTN_RELATIVE = 1 -}; - - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - - void Release(); - void Initialize(); - - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); - void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - -private: - HANDLE h; - INPUT MouseStruct; - - FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction - FTN_AngleName Mouse_Y; - FTN_AngleName Mouse_Wheel; - FTN_MouseStyle Mouse_Style; // AutoPan, Absolute or Relative? - bool useVirtualDesk; // Extend the mouse-range beyond the standard - float prev_fMouse_X; // The previous value(s) - float mouse_X_factor; // Sensitivity factor - float prev_fMouse_Y; - float mouse_Y_factor; // Sensitivity factor - float prev_fMouse_Wheel; - float mouse_Wheel_factor; // Sensitivity factor - - int frame_delay; // Number of frames to delay SendInput (too fast, too furious?) - - long scale2AnalogLimits( float x, float min_x, float max_x ); - void loadSettings(); - -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class MOUSEControls: public QWidget, Ui::UICMOUSEControls, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit MOUSEControls(); - virtual ~MOUSEControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - }; - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - }; - -private: - Ui::UICMOUSEControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged( int setting ) { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public IProtocolDll -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/Mouse.ico"); }; -}; - - -#endif//INCLUDED_MOUSESERVER_H -//END diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc8.vcproj b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc8.vcproj deleted file mode 100644 index 82e93d35..00000000 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc8.vcproj +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc9.vcproj b/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc9.vcproj deleted file mode 100644 index 625e88de..00000000 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_Protocol_MOUSE_vc9.vcproj +++ /dev/null @@ -1,381 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_MOUSE/FTNoIR_mousecontrols.ui b/FTNoIR_Protocol_MOUSE/FTNoIR_mousecontrols.ui deleted file mode 100644 index 4a6cc3b9..00000000 --- a/FTNoIR_Protocol_MOUSE/FTNoIR_mousecontrols.ui +++ /dev/null @@ -1,512 +0,0 @@ - - - UICMOUSEControls - - - - 0 - 0 - 462 - 299 - - - - MouseLook settings FaceTrackNoIR - - - - :/images/Mouse.ico:/images/Mouse.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 0 - 0 - - - - Mouse style: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Map mouse X to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Map mouse Y to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 0 - 0 - - - - Map mouse Wheel to: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 80 - 16777215 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 150 - 16777215 - - - - 50 - - - Qt::Horizontal - - - - - - - - 150 - 16777215 - - - - 50 - - - Qt::Horizontal - - - - - - - - 150 - 16777215 - - - - 50 - - - Qt::Horizontal - - - - - - - Sensitivity (10=1x): - - - - - - - 50 - - - - - - - 50 - - - - - - - 50 - - - - - - - - 0 - 0 - - - - Use Virtual Desk: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - 0 - 20 - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Most games (like First Person Shooters) support 'relative' mouse look. - - - - - - - - - - - Mouse sensitivity can also be influenced via the Windows Mouse settings. - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - - - slideSensX - valueChanged(int) - spinSensX - setValue(int) - - - 334 - 44 - - - 445 - 46 - - - - - slideSensY - valueChanged(int) - spinSensY - setValue(int) - - - 338 - 73 - - - 450 - 70 - - - - - slideSensWheel - valueChanged(int) - spinSensWheel - setValue(int) - - - 334 - 98 - - - 445 - 96 - - - - - spinSensX - valueChanged(int) - slideSensX - setValue(int) - - - 440 - 37 - - - 364 - 41 - - - - - spinSensY - valueChanged(int) - slideSensY - setValue(int) - - - 441 - 69 - - - 347 - 73 - - - - - spinSensWheel - valueChanged(int) - slideSensWheel - setValue(int) - - - 459 - 99 - - - 350 - 99 - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Protocol_MOUSE/Protocol.qrc b/FTNoIR_Protocol_MOUSE/Protocol.qrc deleted file mode 100644 index 0e5e11d9..00000000 --- a/FTNoIR_Protocol_MOUSE/Protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/Mouse.ico - - diff --git a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp b/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp deleted file mode 100644 index b8d7d7ee..00000000 --- a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dialog.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_MOUSE.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -MOUSEControls::MOUSEControls() : -QWidget() -{ - ui.setupUi( this ); - - // - // Setup the choices - // - ui.cbxSelectMouseStyle->addItem("Absolute"); - ui.cbxSelectMouseStyle->addItem("Relative"); - - ui.cbxSelectMouse_X->addItem("None"); - ui.cbxSelectMouse_X->addItem("Pitch"); - ui.cbxSelectMouse_X->addItem("Yaw"); - ui.cbxSelectMouse_X->addItem("Roll"); - ui.cbxSelectMouse_X->addItem("X"); - ui.cbxSelectMouse_X->addItem("Y"); - ui.cbxSelectMouse_X->addItem("Z"); - - ui.cbxSelectMouse_Y->addItem("None"); - ui.cbxSelectMouse_Y->addItem("Pitch"); - ui.cbxSelectMouse_Y->addItem("Yaw"); - ui.cbxSelectMouse_Y->addItem("Roll"); - ui.cbxSelectMouse_Y->addItem("X"); - ui.cbxSelectMouse_Y->addItem("Y"); - ui.cbxSelectMouse_Y->addItem("Z"); - - ui.cbxSelectMouse_Wheel->addItem("None"); - ui.cbxSelectMouse_Wheel->addItem("Pitch"); - ui.cbxSelectMouse_Wheel->addItem("Yaw"); - ui.cbxSelectMouse_Wheel->addItem("Roll"); - ui.cbxSelectMouse_Wheel->addItem("X"); - ui.cbxSelectMouse_Wheel->addItem("Y"); - ui.cbxSelectMouse_Wheel->addItem("Z"); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - connect(ui.cbxSelectMouse_Wheel, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); - - connect(ui.spinSensX, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.spinSensY, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.spinSensWheel, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); - - connect(ui.chkUseVirtualDesk, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -MOUSEControls::~MOUSEControls() { - qDebug() << "~MOUSEControls() says: started"; -} - -void MOUSEControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void MOUSEControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void MOUSEControls::doOK() { - save(); - this->close(); -} - -// override show event -void MOUSEControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void MOUSEControls::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 MOUSEControls::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 ( "Mouse" ); - ui.cbxSelectMouseStyle->setCurrentIndex(iniFile.value ( "Style", 1 ).toInt() - 1); - ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 1 ).toInt() - 1); - ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 1 ).toInt() - 1); - ui.cbxSelectMouse_Wheel->setCurrentIndex(iniFile.value ( "Mouse_Wheel", 1 ).toInt() - 1); - - ui.slideSensX->setValue(iniFile.value("SensX", 10).toInt()); - ui.slideSensY->setValue(iniFile.value("SensY", 10).toInt()); - ui.slideSensWheel->setValue(iniFile.value("SensWheel", 10).toInt()); - - ui.chkUseVirtualDesk->setChecked( iniFile.value ( "useVirtualDesk", 0 ).toBool() ); - - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void MOUSEControls::save() { - qDebug() << "save() says: started"; - - 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 ( "Mouse" ); - iniFile.setValue ( "Style", ui.cbxSelectMouseStyle->currentIndex() + 1 ); - iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() + 1 ); - iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() + 1 ); - iniFile.setValue ( "Mouse_Wheel", ui.cbxSelectMouse_Wheel->currentIndex() + 1 ); - - iniFile.setValue ( "SensX", ui.slideSensX->value() ); - iniFile.setValue ( "SensY", ui.slideSensY->value() ); - iniFile.setValue ( "SensWheel", ui.slideSensWheel->value() ); - - iniFile.setValue( "useVirtualDesk", ui.chkUseVirtualDesk->isChecked() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new MOUSEControls; -} diff --git a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp b/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp deleted file mode 100644 index cc6ddc17..00000000 --- a/FTNoIR_Protocol_MOUSE/ftnoir_protocol_MOUSE_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_MOUSE.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() -{ - return new FTNoIR_ProtocolDll; -} diff --git a/FTNoIR_Protocol_MOUSE/images/Mouse.ico b/FTNoIR_Protocol_MOUSE/images/Mouse.ico deleted file mode 100644 index 1151ab2b..00000000 Binary files a/FTNoIR_Protocol_MOUSE/images/Mouse.ico and /dev/null differ diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp deleted file mode 100644 index 7ca38e64..00000000 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.cpp +++ /dev/null @@ -1,393 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNoIR_Protocol: the Class, that communicates headpose-data * -* to games, using the SimConnect.dll. * -* SimConnect.dll is a so called 'side-by-side' assembly, so it * -* must be treated as such... * -********************************************************************************/ -/* - Modifications (last one on top): - 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "ftnoir_protocol_sc.h" - -importSimConnect_CameraSetRelative6DOF FTNoIR_Protocol::simconnect_set6DOF; -HANDLE FTNoIR_Protocol::hSimConnect = 0; // Handle to SimConnect - -float FTNoIR_Protocol::virtSCPosX = 0.0f; // Headpose -float FTNoIR_Protocol::virtSCPosY = 0.0f; -float FTNoIR_Protocol::virtSCPosZ = 0.0f; - -float FTNoIR_Protocol::virtSCRotX = 0.0f; -float FTNoIR_Protocol::virtSCRotY = 0.0f; -float FTNoIR_Protocol::virtSCRotZ = 0.0f; - -float FTNoIR_Protocol::prevSCPosX = 0.0f; // previous Headpose -float FTNoIR_Protocol::prevSCPosY = 0.0f; -float FTNoIR_Protocol::prevSCPosZ = 0.0f; - -float FTNoIR_Protocol::prevSCRotX = 0.0f; -float FTNoIR_Protocol::prevSCRotY = 0.0f; -float FTNoIR_Protocol::prevSCRotZ = 0.0f; - -/** constructor **/ -FTNoIR_Protocol::FTNoIR_Protocol() -{ - ProgramName = "Microsoft FSX"; - blnSimConnectActive = false; - hSimConnect = 0; - hMainWindow = 0; -} - -/** destructor **/ -FTNoIR_Protocol::~FTNoIR_Protocol() -{ - qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect; - - if (hSimConnect != 0) { - qDebug() << "~FTNoIR_Protocol says: before simconnect_close"; - if (SUCCEEDED( simconnect_close( FTNoIR_Protocol::hSimConnect ) ) ) { - qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED"; - } - } -// SCClientLib.unload(); Generates crash when tracker is ended... -} - -/** helper to Auto-destruct **/ -void FTNoIR_Protocol::Release() -{ - delete this; -} - -void FTNoIR_Protocol::Initialize() -{ - return; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Protocol::loadSettings() { -// None yet... -} - -// -// Update Headpose in Game. -// -void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { -PDWORD_PTR MsgResult = 0; - - - virtSCRotX = -1.0f * headpose->pitch; // degrees - virtSCRotY = -1.0f * headpose->yaw; - virtSCRotZ = headpose->roll; - - virtSCPosX = headpose->x/100.f; // cm to meters - virtSCPosY = headpose->y/100.f; - virtSCPosZ = -1.0f * headpose->z/100.f; - - // - // It's only useful to send data, if the connection was made. - // - if (!blnSimConnectActive) { - if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!"; - - //set up the events we want to listen for - HRESULT hr; - - simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); - - hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); - hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); - hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); - ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT); - ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON); - - blnSimConnectActive = true; - if (hMainWindow != NULL) { - SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); - } - } - } - else { - // - // Write the 6DOF-data to FSX -// // -// // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. -// // -// if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || -// (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { -//// if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) { -//// qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; -//// } -// } -// -// prevPosX = virtPosX; -// prevPosY = virtPosY; -// prevPosZ = virtPosZ; -// prevRotX = virtRotX; -// prevRotY = virtRotY; -// prevRotZ = virtRotZ; - - if SUCCEEDED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL)) { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Dispatching"; - } - else { - qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Error Dispatching!"; - } - } -} - -// -// Returns 'true' if all seems OK. -// -bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) -{ - QString aFileName; // File Path and Name - - // Code to activate the context for the SimConnect DLL - ACTCTX act = { 0 }; - HANDLE hctx; - ULONG_PTR ulCookie; - - hMainWindow = handle; - - qDebug() << "SCCheckClientDLL says: Starting Function"; - - try { - - act.cbSize = sizeof(act); - act.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; - - QString manifest(QCoreApplication::applicationDirPath()); -// manifest += "\\FaceTrackNoIR.exe"; - manifest += "\\FTNoIR_Protocol_SC.dll"; - const wchar_t * encodedName = reinterpret_cast(manifest.utf16()); - - act.lpSource = encodedName; - act.lpResourceName = MAKEINTRESOURCE(101); - - hctx = CreateActCtx (&act); - - if (hctx != INVALID_HANDLE_VALUE) { - if (!ActivateActCtx(hctx, &ulCookie)) { - ReleaseActCtx(hctx); - qDebug() << "SCCheckClientDLL says: Error activating SimConnect manifest"; - } - } - else { - qDebug() << "SCCheckClientDLL says: Error INVALID_HANDLE: " << GetLastError(); - return false; - } - - // - // Just try to load the DLL. Let Windows handle the PATH's and such trivialities... - // - aFileName = SC_CLIENT_FILENAME; - - // - // Load the DLL. - // - SCClientLib.setFileName(aFileName); - if (SCClientLib.load() != true) { - qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL"; - return false; - } - - // - // Deactivate the context again: the function-references should stay in-tact... - // - DeactivateActCtx(0, ulCookie); - ReleaseActCtx(hctx); - - } catch(...) { - qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL"; - return false; - } - - // - // Get the functions from the DLL. - // - simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); - if (simconnect_open == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Open function not found in DLL!"; - return false; - } - simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); - if (simconnect_set6DOF == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; - return false; - } - simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); - if (simconnect_close == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Close function not found in DLL!"; - return false; - } - - //return true; - - simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); - if (simconnect_calldispatch == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CallDispatch function not found in DLL!"; - return false; - } - - simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; - return false; - } - - simconnect_mapclienteventtosimevent = (importSimConnect_MapClientEventToSimEvent) SCClientLib.resolve("SimConnect_MapClientEventToSimEvent"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_MapClientEventToSimEvent function not found in DLL!"; - return false; - } - - simconnect_addclienteventtonotificationgroup = (importSimConnect_AddClientEventToNotificationGroup) SCClientLib.resolve("SimConnect_AddClientEventToNotificationGroup"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_AddClientEventToNotificationGroup function not found in DLL!"; - return false; - } - - simconnect_setnotificationgrouppriority = (importSimConnect_SetNotificationGroupPriority) SCClientLib.resolve("SimConnect_SetNotificationGroupPriority"); - if (simconnect_subscribetosystemevent == NULL) { - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SetNotificationGroupPriority function not found in DLL!"; - return false; - } - - qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect functions resolved in DLL!"; - - return true; -} - -void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) -{ -// HRESULT hr; - - switch(pData->dwID) - { - case SIMCONNECT_RECV_ID_EVENT: - { - SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData; - - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: SimConnect active!"; - //switch(evt->uEventID) - //{ - // //case EVENT_CAMERA_RIGHT: - - // // cameraBank = normalize180( cameraBank + 5.0f); - - // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, - // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); - - // // printf("\nCamera Bank = %f", cameraBank); - // // break; - - // //case EVENT_CAMERA_LEFT: - // // - // // cameraBank = normalize180( cameraBank - 5.0f); - - // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, - // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); - // // - // // printf("\nCamera Bank = %f", cameraBank); - // // break; - - // //default: - // // break; - //} - //break; - } - case SIMCONNECT_RECV_ID_EVENT_FRAME: - { -// qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Frame event!"; - if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || - (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { - if (S_OK == simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY)) { - // qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; - } - } - prevSCPosX = virtSCPosX; - prevSCPosY = virtSCPosY; - prevSCPosZ = virtSCPosZ; - prevSCRotX = virtSCRotX; - prevSCRotY = virtSCRotY; - prevSCRotZ = virtSCRotZ; - } - - case SIMCONNECT_RECV_ID_EXCEPTION: - { - SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; - - switch (except->dwException) - { - case SIMCONNECT_EXCEPTION_ERROR: - printf("\nCamera error"); - break; - - default: - printf("\nException"); - break; - } - break; - } - - case SIMCONNECT_RECV_ID_QUIT: - { - qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!"; -// quit = 1; - break; - } - - default: - break; - } -} - -// -// Return a name, if present the name from the Game, that is connected... -// -void FTNoIR_Protocol::getNameFromGame( char *dest ) -{ - sprintf_s(dest, 99, "Microsoft FSX"); - return; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocol - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() -{ - return new FTNoIR_Protocol; -} diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h deleted file mode 100644 index 42eca457..00000000 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC.h +++ /dev/null @@ -1,183 +0,0 @@ -/******************************************************************************** -* 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) 2010-2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* SCServer SCServer is the Class, that communicates headpose-data * -* to games, using the SimConnect.dll. * -* SimConnect.dll is a so called 'side-by-side' assembly, so it * -* must be treated as such... * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_SCSERVER_H -#define INCLUDED_SCSERVER_H - -// -// Prevent the SimConnect manifest from being merged in the application-manifest -// 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" - -#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" -#include "ui_FTNoIR_SCcontrols.h" -#include -#include -#include -#include -#include -#include -//#include "math.h" - -typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); -typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); -typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); -typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext); -typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * SystemEventName); -typedef HRESULT (WINAPI *importSimConnect_MapClientEventToSimEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * EventName); -typedef HRESULT (WINAPI *importSimConnect_AddClientEventToNotificationGroup)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, SIMCONNECT_CLIENT_EVENT_ID EventID, BOOL bMaskable); -typedef HRESULT (WINAPI *importSimConnect_SetNotificationGroupPriority)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, DWORD uPriority); - -static const char* SC_CLIENT_FILENAME = "SimConnect.dll"; -static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. - -enum GROUP_ID -{ - GROUP0=0, -}; - -enum EVENT_ID -{ - EVENT_PING=0, - EVENT_INIT, -}; - -enum INPUT_ID -{ - INPUT0=0, -}; - -class FTNoIR_Protocol : public IProtocol -{ -public: - FTNoIR_Protocol(); - ~FTNoIR_Protocol(); - - void Release(); - void Initialize(); - - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); - void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... - -private: - // Private properties - QString ProgramName; - QLibrary SCClientLib; - - static float virtSCPosX; - static float virtSCPosY; - static float virtSCPosZ; - - static float virtSCRotX; - static float virtSCRotY; - static float virtSCRotZ; - - static float prevSCPosX; - static float prevSCPosY; - static float prevSCPosZ; - - static float prevSCRotX; - static float prevSCRotY; - static float prevSCRotZ; - - bool blnSimConnectActive; - HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window - - importSimConnect_Open simconnect_open; // SimConnect function(s) in DLL - importSimConnect_Close simconnect_close; - static importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; - importSimConnect_CallDispatch simconnect_calldispatch; - importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; - importSimConnect_MapClientEventToSimEvent simconnect_mapclienteventtosimevent; - importSimConnect_AddClientEventToNotificationGroup simconnect_addclienteventtonotificationgroup; - importSimConnect_SetNotificationGroupPriority simconnect_setnotificationgrouppriority; - - static HANDLE hSimConnect; // Handle to SimConnect - static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); - void loadSettings(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class SCControls: public QWidget, Ui::UICSCControls, public IProtocolDialog -{ - Q_OBJECT -public: - - explicit SCControls(); - virtual ~SCControls(); - void showEvent ( QShowEvent * event ); - - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerProtocol(IProtocol *protocol) { - theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol - }; - void unRegisterProtocol() { - theProtocol = NULL; // Reset the pointer - }; - -private: - Ui::UICSCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FTNoIR_Protocol *theProtocol; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol -//******************************************************************************************************* -class FTNoIR_ProtocolDll : public IProtocolDll -{ -public: - FTNoIR_ProtocolDll(); - ~FTNoIR_ProtocolDll(); - - void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; - void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; - void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; - - void getIcon(QIcon *icon) { *icon = QIcon(":/images/FSX.ico"); }; -}; - -#endif//INCLUDED_SCSERVER_H -//END diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc8.vcproj b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc8.vcproj deleted file mode 100644 index 0f3cfdb3..00000000 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc8.vcproj +++ /dev/null @@ -1,377 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc9.vcproj b/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc9.vcproj deleted file mode 100644 index cd779d2b..00000000 --- a/FTNoIR_Protocol_SC/FTNoIR_Protocol_SC_vc9.vcproj +++ /dev/null @@ -1,382 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_SC/FTNoIR_SCcontrols.ui b/FTNoIR_Protocol_SC/FTNoIR_SCcontrols.ui deleted file mode 100644 index 3e7a5062..00000000 --- a/FTNoIR_Protocol_SC/FTNoIR_SCcontrols.ui +++ /dev/null @@ -1,162 +0,0 @@ - - - UICSCControls - - - - 0 - 0 - 346 - 104 - - - - SimConnect settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 0 - 0 - - - - There are no setting necessary for SimConnect - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Protocol_SC/Protocol.qrc b/FTNoIR_Protocol_SC/Protocol.qrc deleted file mode 100644 index de6018af..00000000 --- a/FTNoIR_Protocol_SC/Protocol.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/FSX.ico - - diff --git a/FTNoIR_Protocol_SC/SCServer.manifest b/FTNoIR_Protocol_SC/SCServer.manifest deleted file mode 100644 index 19b123ba..00000000 --- a/FTNoIR_Protocol_SC/SCServer.manifest +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - diff --git a/FTNoIR_Protocol_SC/SimConnect.aps b/FTNoIR_Protocol_SC/SimConnect.aps deleted file mode 100644 index 89c5a65a..00000000 Binary files a/FTNoIR_Protocol_SC/SimConnect.aps and /dev/null differ diff --git a/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp b/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp deleted file mode 100644 index 9047fa61..00000000 --- a/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dialog.cpp +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_SC.h" -#include - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -SCControls::SCControls() : -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.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); - - theProtocol = NULL; - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -SCControls::~SCControls() { - qDebug() << "~SCControls() says: started"; -} - -void SCControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void SCControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void SCControls::doOK() { - save(); - this->close(); -} - -// override show event -void SCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void SCControls::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 SCControls::loadSettings() { - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void SCControls::save() { - - settingsDirty = false; -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol-settings dialog object. - -// Export both decorated and undecorated names. -// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) -{ - return new SCControls; -} diff --git a/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp b/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp deleted file mode 100644 index f67f95db..00000000 --- a/FTNoIR_Protocol_SC/ftnoir_protocol_SC_dll.cpp +++ /dev/null @@ -1,56 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The ProtocolDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_protocol_SC.h" -#include - -FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { -} - -FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() -{ - -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Protocol object. - -// Export both decorated and undecorated names. -// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") - -FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() -{ - return new FTNoIR_ProtocolDll; -} diff --git a/FTNoIR_Protocol_SC/images/FSX.ico b/FTNoIR_Protocol_SC/images/FSX.ico deleted file mode 100644 index 1c71d409..00000000 Binary files a/FTNoIR_Protocol_SC/images/FSX.ico and /dev/null differ diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_base.h b/FTNoIR_Tracker_Base/ftnoir_tracker_base.h deleted file mode 100644 index 396df4d1..00000000 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_base.h +++ /dev/null @@ -1,128 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* This class implements a tracker-base * -*********************************************************************************/ -/* - Modifications (last one on top): - 20122109 - C14: Replaced Release with virtual destructor - 20120009 - WVR: Removed AutoClosePtr (seemed like it didn't work OK) - 20110415 - WVR: Added overloaded operator - and -= -*/ -#ifndef FTNOIR_TRACKER_BASE_H -#define FTNOIR_TRACKER_BASE_H - -#include "ftnoir_tracker_base_global.h" -#include "ftnoir_tracker_types.h" -#include -#include - -//////////////////////////////////////////////////////////////////////////////// -#ifdef __cplusplus -# define EXTERN_C extern "C" -#else -# define EXTERN_C -#endif // __cplusplus - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct ITracker -{ - virtual ~ITracker() {} - virtual void Initialize( QFrame *videoframe ) = 0; - virtual void StartTracker( HWND parent_window ) = 0; - virtual void StopTracker(bool exit) = 0; - virtual bool GiveHeadPoseData(THeadPoseData *data) = 0; - - virtual bool notifyZeroed() { - return false; - } - virtual void refreshVideo() {} - virtual void notifyCenter() { - return; - } -}; - -typedef ITracker* ITrackerPtr; - -// Factory function that creates instances of the Tracker object. -EXTERN_C -FTNOIR_TRACKER_BASE_EXPORT -ITrackerPtr -__stdcall -GetTracker(void); - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct ITrackerDialog -{ - virtual ~ITrackerDialog() {} - virtual void Initialize(QWidget *parent) = 0; - virtual void registerTracker(ITracker *tracker) = 0; - virtual void unRegisterTracker() = 0; -}; - -typedef ITrackerDialog* ITrackerDialogPtr; - -// Factory function that creates instances of the Tracker object. -EXTERN_C -FTNOIR_TRACKER_BASE_EXPORT -ITrackerDialogPtr -__stdcall -GetTrackerDialog(void); - -//////////////////////////////////////////////////////////////////////////////// -// COM-Like abstract interface. -// This interface doesn't require __declspec(dllexport/dllimport) specifier. -// Method calls are dispatched via virtual table. -// Any C++ compiler can use it. -// Instances are obtained via factory function. -struct ITrackerDll -{ - virtual ~ITrackerDll() {} - virtual void Initialize() = 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; -}; - -typedef ITrackerDll* ITrackerDllPtr; - -// Factory function that creates instances of the Tracker object. -EXTERN_C -FTNOIR_TRACKER_BASE_EXPORT -ITrackerDllPtr -__stdcall -GetTrackerDll(void); - - -#endif // FTNOIR_TRACKER_BASE_H diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_base_global.h b/FTNoIR_Tracker_Base/ftnoir_tracker_base_global.h deleted file mode 100644 index 9f4a6118..00000000 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_base_global.h +++ /dev/null @@ -1,12 +0,0 @@ -#ifndef FTNOIR_TRACKER_BASE_GLOBAL_H -#define FTNOIR_TRACKER_BASE_GLOBAL_H - -#include - -#ifdef FTNOIR_TRACKER_BASE_LIB -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT -#else -# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT -#endif - -#endif // FTNOIR_TRACKER_BASE_GLOBAL_H diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_ma_types.h b/FTNoIR_Tracker_Base/ftnoir_tracker_ma_types.h deleted file mode 100644 index bc663056..00000000 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_ma_types.h +++ /dev/null @@ -1,33 +0,0 @@ -// -// Definitions for the Shared Memory to send the data to FaceTrackNoIR -// -static const char* MA_MM_DATA = "MA_SharedMem"; -static const char* MA_FACEAPI = "MA_FaceAPI"; -static const char* MA_MUTEX = "MA_Mutex"; - -struct TFaceData { - int DataID; -// smEngineHeadPoseData new_pose; -}; -typedef TFaceData * PFaceData; - -struct SMMemMap { - int command; // Command from FaceTrackNoIR - int status; // Status from faceAPI - TFaceData data; - HANDLE handle; - int state; - int par_val_int; // Value of parameter, indicated by 'command' - int par_val_float; - int initial_filter_level; // Internal faceAPI Filter level - int handshake; -}; -typedef SMMemMap * PSMMemMap; - -enum FTNoIR_Tracker_Command { - FT_MA_START = 10, - FT_MA_STOP = 20, - FT_MA_SHOW_CAM = 30, - FT_MA_SET_PAR_FILTER = 50, - FT_MA_EXIT = 100 -}; diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_sm_types.h b/FTNoIR_Tracker_Base/ftnoir_tracker_sm_types.h deleted file mode 100644 index a8802e4a..00000000 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_sm_types.h +++ /dev/null @@ -1,35 +0,0 @@ -// -// Definitions for the Shared Memory to send the data to FaceTrackNoIR -// -static const char* SM_MM_DATA = "SM_SharedMem"; -static const char* SM_FACEAPI = "SM_FaceAPI"; -static const char* SM_MUTEX = "SM_Mutex"; - -#include - -struct TFaceData { - int DataID; - smEngineHeadPoseData new_pose; -}; -typedef TFaceData * PFaceData; - -struct SMMemMap { - int command; // Command from FaceTrackNoIR - int status; // Status from faceAPI - TFaceData data; - HANDLE handle; - int state; - int par_val_int; // Value of parameter, indicated by 'command' - int par_val_float; - int initial_filter_level; // Internal faceAPI Filter level - int handshake; -}; -typedef SMMemMap * PSMMemMap; - -enum FTNoIR_Tracker_Command { - FT_SM_START = 10, - FT_SM_STOP = 20, - FT_SM_SHOW_CAM = 30, - FT_SM_SET_PAR_FILTER = 50, - FT_SM_EXIT = 100 -}; diff --git a/FTNoIR_Tracker_Base/ftnoir_tracker_types.h b/FTNoIR_Tracker_Base/ftnoir_tracker_types.h deleted file mode 100644 index ace7a6e3..00000000 --- a/FTNoIR_Tracker_Base/ftnoir_tracker_types.h +++ /dev/null @@ -1,51 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* This class implements a tracker-base * -*********************************************************************************/ -/* - Modifications (last one on top): - 20120924 - C14: Moved T6DOF to separate file (not pulic interface) - 20110415 - WVR: Added overloaded operator - and -= -*/ -#ifndef FTNOIR_TRACKER_TYPES_H -#define FTNOIR_TRACKER_TYPES_H - -// -// x,y,z position in centimetres, yaw, pitch and roll in degrees... -// -#pragma pack(push, 2) -struct THeadPoseData { - - THeadPoseData() - : x(0.0), y(0.0), z(0.0), yaw(0.0), pitch(0.0), roll(0.0), frame_number(0) {} - - THeadPoseData(double x, double y, double z, - double yaw, double pitch, double roll ) - : x(x), y(y), z(z), yaw(yaw), pitch(pitch), roll(roll), frame_number(0) {} - - double x, y, z, yaw, pitch, roll; - long frame_number; -}; -#pragma pack(pop) - -#endif // FTNOIR_TRACKER_TYPES_H diff --git a/FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui b/FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui deleted file mode 100644 index 0bb8028f..00000000 --- a/FTNoIR_Tracker_FD/FTNoIR_FD_Controls.ui +++ /dev/null @@ -1,152 +0,0 @@ - - - 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 deleted file mode 100644 index 02e95bb4..00000000 --- a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD.h +++ /dev/null @@ -1,114 +0,0 @@ -#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 Initialize( QFrame *videoframe ); - void StartTracker( HWND parent_window ); - void StopTracker( bool exit ); - bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good - - void loadSettings(); -// bool setParameterValue(const int index, const float newvalue); - bool notifyZeroed(); - void refreshVideo(); - -private: - bool activep; - //QList> parameterRange; - //QList parameterValueAsFloat; - void TerminateTracker(); - HANDLE hMutex, hMapFile; - struct face_detect_shm* shm; - PROCESS_INFORMATION procInfo; - VideoWidget* ctrl; - QFrame* qframe; -}; - -class TrackerControls: public QWidget, Ui::UICFDClientControls, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void Release(); // Member functions which are accessible from outside the DLL - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; - void NotifyZeroing(); - -private: - Ui::UICFDClientControls ui; - void loadSettings(); - void save(); - - bool settingsDirty; - HANDLE hMapFile, hMutex; - struct face_detect_shm* shm; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void doSetRedetectMs(int val); - void doSetCameraId(int val); - void doSetVideoWidget(bool val); -signals: -}; - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class FTNoIR_TrackerDll : public ITrackerDll -{ -public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - - void Initialize(); - - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; -}; diff --git a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc8.vcproj b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc8.vcproj deleted file mode 100644 index 74fa6fec..00000000 --- a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc8.vcproj +++ /dev/null @@ -1,379 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc9.vcproj b/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc9.vcproj deleted file mode 100644 index a37729e1..00000000 --- a/FTNoIR_Tracker_FD/FTNoIR_Tracker_FD_vc9.vcproj +++ /dev/null @@ -1,376 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_FD/Tracker.qrc b/FTNoIR_Tracker_FD/Tracker.qrc deleted file mode 100644 index d988ba71..00000000 --- a/FTNoIR_Tracker_FD/Tracker.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/FaceDetect.ico - - diff --git a/FTNoIR_Tracker_FD/face-detect.h b/FTNoIR_Tracker_FD/face-detect.h deleted file mode 100644 index fc359c53..00000000 --- a/FTNoIR_Tracker_FD/face-detect.h +++ /dev/null @@ -1,39 +0,0 @@ -#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 deleted file mode 100644 index 620fb9fd..00000000 --- a/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect.cpp +++ /dev/null @@ -1,214 +0,0 @@ -/* 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"); - - hMutex = CreateMutex(NULL, false, fd_mutex_name); - hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(struct face_detect_shm), fd_shm_name); - shm = (struct face_detect_shm*) MapViewOfFile(hMapFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, sizeof(struct face_detect_shm)); - memset(shm, 0, sizeof(struct face_detect_shm)); - activep = 0; - procInfo.hProcess = INVALID_HANDLE_VALUE; - ctrl = NULL; - qframe = NULL; -} - -void FTNoIR_Tracker::TerminateTracker() { - if (procInfo.hProcess != INVALID_HANDLE_VALUE) { - shm->settings.quit = 1; - //TerminateProcess(procInfo.hProcess, 42); - CloseHandle(procInfo.hProcess); - CloseHandle(procInfo.hThread); - procInfo.hProcess = INVALID_HANDLE_VALUE; - } -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - WaitForSingleObject(hMutex, INFINITE); - TerminateTracker(); - UnmapViewOfFile(shm); - //CloseHandle(hMapFile); - ReleaseMutex(hMutex); - //CloseHandle(hMutex); -} - -void FTNoIR_Tracker::Initialize( QFrame *videoframe ) -{ - qDebug("FTNoIR_Tracker::Initialize()"); - WaitForSingleObject(hMutex, INFINITE); - videoframe->setAttribute(Qt::WA_NativeWindow); - videoframe->show(); - ctrl = new VideoWidget(hMutex, shm->pixels, shm); - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(ctrl); - videoframe->setLayout(layout); - ctrl->resize(FD_VIDEO_WIDTH, FD_VIDEO_HEIGHT); - qframe = videoframe; - loadSettings(); - ReleaseMutex(hMutex); -} - -void FTNoIR_Tracker::refreshVideo() { - QWidget* w; - WaitForSingleObject(hMutex, INFINITE); - w = ctrl; - ReleaseMutex(hMutex); - if (w != NULL) - w->update(); -} - -void FTNoIR_Tracker::StartTracker( HWND parent_window ) -{ - WaitForSingleObject(hMutex, INFINITE); - qDebug("* tracker starting"); - activep = true; - ReleaseMutex(hMutex); -} - -void FTNoIR_Tracker::StopTracker( bool exit ) -{ - WaitForSingleObject(hMutex, INFINITE); - qDebug("* tracker stopping"); - activep = false; - if (exit) { - TerminateTracker(); - if (qframe && qframe->layout()) { - delete qframe->layout(); - qframe = NULL; - } - if (ctrl) { - delete ctrl; - ctrl = NULL; - } - } - ReleaseMutex(hMutex); -} - -bool FTNoIR_Tracker::notifyZeroed() { - qDebug("notifying of zero"); - WaitForSingleObject(hMutex, INFINITE); - shm->zerop = 1; - ReleaseMutex(hMutex); - return true; -} - -bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) -{ - WaitForSingleObject(hMutex, INFINITE); - if (procInfo.hProcess == INVALID_HANDLE_VALUE) { - STARTUPINFO si; - SECURITY_ATTRIBUTES sa; - sa.bInheritHandle = 1; - sa.lpSecurityDescriptor = NULL; - sa.nLength = sizeof(SECURITY_ATTRIBUTES); - memset(&si, 0, sizeof(STARTUPINFO)); - si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; - si.cb = sizeof(STARTUPINFO); - si.hStdOutput = NULL; - si.hStdError = NULL; - si.hStdInput = NULL; - if (!CreateProcess(prog_cmdline, NULL, NULL, NULL, true, 0, NULL, NULL, &si, &procInfo)) { - qDebug("Badness! %d", GetLastError()); - } - } - - shm->received = 1; - - if (activep) { - shm->settings.newOutput = 0; - data->x = shm->data[3]; - data->y = shm->data[4]; - data->z = shm->data[5]; - data->yaw = shm->data[0]; - data->pitch = shm->data[1]; - data->roll = shm->data[2]; - ReleaseMutex(hMutex); - return true; - } - ReleaseMutex(hMutex); - return false; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Tracker::loadSettings() { - load_settings(&shm->settings); -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTracker - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTracker@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() -{ - return new FTNoIR_Tracker; -} diff --git a/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp b/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp deleted file mode 100644 index 71b19242..00000000 --- a/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dialog.cpp +++ /dev/null @@ -1,180 +0,0 @@ -/* 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))); -} - -void TrackerControls::save() { - save_settings(&shm->settings); - settingsDirty = false; -} - -void TrackerControls::doSetCameraId(int val) { - settingsDirty = true; - WaitForSingleObject(hMutex, INFINITE); - shm->settings.camera_id = val; - ReleaseMutex(hMutex); -} - -void TrackerControls::doSetVideoWidget(bool val) { - settingsDirty = true; - WaitForSingleObject(hMutex, INFINITE); - shm->settings.widgetp = val; - ReleaseMutex(hMutex); -} - -void TrackerControls::doSetRedetectMs(int val) { - settingsDirty = true; - WaitForSingleObject(hMutex, INFINITE); - shm->settings.redetect_ms = val; - ReleaseMutex(hMutex); -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - UnmapViewOfFile(shm); - //CloseHandle(hMutex); - //CloseHandle(hMapFile); -} - -void TrackerControls::Release() -{ - delete this; -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void TrackerControls::doOK() { - save(); - this->close(); -} - -// -// Cancel clicked on server-dialog -// -void TrackerControls::doCancel() { - // - // Ask if changed Settings should be saved - // - if (settingsDirty) { - int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); - - switch (ret) { - case QMessageBox::Save: - save(); - this->close(); - break; - case QMessageBox::Discard: - this->close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - this->close(); - } -} - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker-settings dialog object. - -// Export both decorated and undecorated names. -// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) -{ - return new TrackerControls; -} diff --git a/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dll.cpp b/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dll.cpp deleted file mode 100644 index 8e010e3e..00000000 --- a/FTNoIR_Tracker_FD/ftnoir_tracker_facedetect_dll.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The TrackerDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_tracker_fd.h" -#include - -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "faceDetect V1.0.0"; - trackerShortName = "faceDetect"; - trackerDescription = "Stans' faceDetect V1.0.0"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - -void FTNoIR_TrackerDll::Initialize() -{ - return; -} - -void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = trackerFullName; -}; - -void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = trackerShortName; -}; - -void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = trackerDescription; -}; - -void FTNoIR_TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/FaceDetect.ico"); -}; - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() -{ - return new FTNoIR_TrackerDll; -} diff --git a/FTNoIR_Tracker_FD/images/FaceDetect.ico b/FTNoIR_Tracker_FD/images/FaceDetect.ico deleted file mode 100644 index 8e862cee..00000000 Binary files a/FTNoIR_Tracker_FD/images/FaceDetect.ico and /dev/null differ diff --git a/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj b/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj deleted file mode 100644 index bf9b23c2..00000000 --- a/FTNoIR_Tracker_HT/FTNoIR_Tracker_HT_vc8.vcproj +++ /dev/null @@ -1,398 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_HT/Tracker.qrc b/FTNoIR_Tracker_HT/Tracker.qrc deleted file mode 100644 index 9627f700..00000000 --- a/FTNoIR_Tracker_HT/Tracker.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/HT.ico - - diff --git a/FTNoIR_Tracker_HT/TrackerControls.ui b/FTNoIR_Tracker_HT/TrackerControls.ui deleted file mode 100644 index 0a1bc3ae..00000000 --- a/FTNoIR_Tracker_HT/TrackerControls.ui +++ /dev/null @@ -1,295 +0,0 @@ - - - Form - - - Qt::NonModal - - - - 0 - 0 - 500 - 160 - - - - - 0 - 0 - - - - - 500 - 160 - - - - HT tracker settings - - - - - 10 - 10 - 141 - 16 - - - - Horizontal field of view - - - - - - 130 - 10 - 251 - 22 - - - - - - - 35.000000000000000 - - - 180.000000000000000 - - - 69.000000000000000 - - - - - - 10 - 40 - 101 - 16 - - - - Frames per second - - - - - - 130 - 40 - 251 - 22 - - - - - Default - - - - - 30 - - - - - 60 - - - - - 120 - - - - - - - 10 - 70 - 71 - 16 - - - - Camera name - - - - - - 340 - 130 - 75 - 23 - - - - OK - - - - - - 420 - 130 - 75 - 23 - - - - Cancel - - - - - - 390 - 10 - 101 - 81 - - - - Enable axes - - - - - 10 - 20 - 70 - 17 - - - - RX - - - - - - 10 - 40 - 70 - 17 - - - - RY - - - - - - 10 - 60 - 70 - 17 - - - - RZ - - - - - - 60 - 20 - 70 - 17 - - - - TX - - - - - - 60 - 40 - 70 - 17 - - - - TY - - - - - - 60 - 60 - 70 - 17 - - - - TZ - - - - - - - 130 - 70 - 251 - 22 - - - - - - - 10 - 100 - 61 - 16 - - - - Resolution - - - - - - 130 - 100 - 251 - 22 - - - - - 640x480 - - - - - 320x240 - - - - - 320x200 - - - - - Default (not recommended!) - - - - - - - diff --git a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp b/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp deleted file mode 100644 index 336ede2d..00000000 --- a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.cpp +++ /dev/null @@ -1,422 +0,0 @@ -#include "stdafx.h" -#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "headtracker-ftnoir.h" -#include "ftnoir_tracker_ht.h" -#include "ftnoir_tracker_ht_dll.h" -#include "ui_trackercontrols.h" -#include "../facetracknoir/global-settings.h" - -#define WIDGET_WIDTH 250 -#define WIDGET_HEIGHT 188 - -#if defined(_WIN32) || defined(__WIN32) -#include -#else -#include -#endif - -// delicious copypasta -static QList get_camera_names(void) { - QList ret; -#if defined(_WIN32) || defined(__WIN32) - // Create the System Device Enumerator. - HRESULT hr; - ICreateDevEnum *pSysDevEnum = NULL; - hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); - if (FAILED(hr)) - { - return ret; - } - // Obtain a class enumerator for the video compressor category. - IEnumMoniker *pEnumCat = NULL; - hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); - - if (hr == S_OK) { - // Enumerate the monikers. - IMoniker *pMoniker = NULL; - ULONG cFetched; - while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); - if (SUCCEEDED(hr)) { - // To retrieve the filter's friendly name, do the following: - VARIANT varName; - VariantInit(&varName); - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if (SUCCEEDED(hr)) - { - // Display the name in your UI somehow. - QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); - ret.append(str); - } - VariantClear(&varName); - - ////// To create an instance of the filter, do the following: - ////IBaseFilter *pFilter; - ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, - //// (void**)&pFilter); - // Now add the filter to the graph. - //Remember to release pFilter later. - pPropBag->Release(); - } - pMoniker->Release(); - } - pEnumCat->Release(); - } - pSysDevEnum->Release(); -#else - for (int i = 0; i < 16; i++) { - char buf[128]; - sprintf(buf, "/dev/video%d", i); - if (access(buf, R_OK | W_OK) == 0) { - ret.append(buf); - } else { - break; - } - } -#endif - return ret; -} - -typedef struct { - int width; - int height; -} resolution_tuple; - -static resolution_tuple resolution_choices[] = { - { 0, 0 }, - { 640, 480 }, - { 320, 240 }, - { 320, 200 }, - { 0, 0 } -}; - -static void load_settings(ht_config_t* config, Tracker* tracker) -{ - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "HT-Tracker" ); - config->classification_delay = 4000; - config->field_of_view = iniFile.value("fov", 69).toFloat(); - config->pyrlk_pyramids = 3; - config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; - config->max_keypoints = 250; - config->keypoint_quality = 12; - config->keypoint_distance = 2.3f; - config->keypoint_3distance = 6; - //config->force_width = 640; - //config->force_height = 480; - config->force_fps = iniFile.value("fps", 0).toInt(); - config->camera_index = iniFile.value("camera-index", -1).toInt(); - config->ransac_num_iters = 100; - config->ransac_max_reprojection_error = 6.5f; - config->ransac_max_inlier_error = 6.5f; - config->ransac_max_mean_error = 4.0f; - config->ransac_abs_max_mean_error = 7.0f; - config->debug = 0; - config->ransac_min_features = 0.75f; - int res = iniFile.value("resolution", 0).toInt(); - if (res < 0 || res >= (int)(sizeof(*resolution_choices) / sizeof(resolution_tuple))) - res = 0; - resolution_tuple r = resolution_choices[res]; - config->force_width = r.width; - config->force_height = r.height; - if (tracker) - { - tracker->enableRX = iniFile.value("enable-rx", true).toBool(); - tracker->enableRY = iniFile.value("enable-ry", true).toBool(); - tracker->enableRZ = iniFile.value("enable-rz", true).toBool(); - tracker->enableTX = iniFile.value("enable-tx", true).toBool(); - tracker->enableTY = iniFile.value("enable-ty", true).toBool(); - tracker->enableTZ = iniFile.value("enable-tz", true).toBool(); - } - iniFile.endGroup(); -} - -Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), fresh(false) -{ - videoWidget = NULL; - layout = NULL; - enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; - shm = (ht_shm_t*) lck_shm.mem; - shm->terminate = 0; - load_settings(&shm->config, this); - shm->result.filled = false; -} - -Tracker::~Tracker() -{ - subprocess.kill(); - if (shm) - shm->terminate = true; - if (layout) - delete layout; - if (videoWidget) - delete videoWidget; -} - -void Tracker::StartTracker(QFrame* videoframe) -{ - videoframe->setAttribute(Qt::WA_NativeWindow); - videoframe->show(); - videoWidget = new VideoWidget(videoframe); - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(videoWidget); - if (videoframe->layout()) - delete videoframe->layout(); - videoframe->setLayout(layout); - videoWidget->resize(WIDGET_WIDTH, WIDGET_HEIGHT); - videoWidget->show(); - this->layout = layout; - load_settings(&shm->config, this); - shm->frame.channels = shm->frame.width = shm->frame.height = 0; - shm->pause = shm->terminate = shm->running = false; - shm->timer = 0; - subprocess.setWorkingDirectory(QCoreApplication::applicationDirPath() + "/tracker-ht"); -#if defined(_WIN32) || defined(__WIN32) - subprocess.start("\"" + QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir" + "\""); -#else - subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir"); -#endif - connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); - timer.start(15); -} - -void Tracker::paint_widget() { - if (fresh) { - fresh = false; - videoWidget->update(); - } -} - -bool Tracker::GiveHeadPoseData(THeadPoseData* data) -{ - bool ret = false; - - lck_shm.lock(); - shm->timer = 0; - if (shm->frame.width > 0) - { - videoWidget->updateImage(shm->frame.frame, shm->frame.width, shm->frame.height); - //memcpy(foo, shm->frame.frame, shm->frame.width * shm->frame.height * 3); - fresh = true; - } - if (shm->result.filled) { - if (enableRX) - data->yaw = shm->result.rotx; - if (enableRY) - data->pitch = shm->result.roty; - if (enableRZ) - data->roll = shm->result.rotz; - if (enableTX) - data->x = shm->result.tx; - if (enableTY) - data->y = shm->result.ty; - if (enableTZ) - data->z = shm->result.tz; - ret = true; - } - lck_shm.unlock(); - - return ret; -} - -//----------------------------------------------------------------------------- -void TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = "HT 0.7"; -} - -void TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = "HT"; -} - -void TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = ""; -} - -void TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/ht.png"); -} - - -//----------------------------------------------------------------------------- -//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() -{ - return new TrackerDll; -} - -//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetConstructor() -{ - return (ITracker*) new Tracker; -} - -//////////////////////////////////////////////////////////////////////////////// -// 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") - -extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetDialog( ) -{ - return (ITrackerDialog*) new TrackerControls; -} - -TrackerControls::TrackerControls() -{ - ui.setupUi(this); - loadSettings(); - connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); - connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); - settingsDirty = false; -} - -TrackerControls::~TrackerControls() -{ -} - -void TrackerControls::showEvent(QShowEvent *event) -{ -} - -void TrackerControls::Initialize(QWidget* parent) -{ - show(); -} - -void TrackerControls::loadSettings() -{ - ui.cameraName->clear(); - QList names = get_camera_names(); - names.prepend("Any available"); - ui.cameraName->addItems(names); - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - iniFile.beginGroup( "HT-Tracker" ); - ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1); - ui.cameraFOV->setValue(iniFile.value("fov", 69).toFloat()); - int fps; - switch (iniFile.value("fps", 0).toInt()) - { - default: - case 0: - fps = 0; - break; - case 30: - fps = 1; - break; - case 60: - fps = 2; - break; - case 120: - fps = 3; - break; - } - ui.cameraFPS->setCurrentIndex(fps); - ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); - ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::save() -{ - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); - QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QSettings iniFile( currentFile, QSettings::IniFormat ); - - iniFile.beginGroup( "HT-Tracker" ); - iniFile.setValue("fov", ui.cameraFOV->value()); - int fps; - switch (ui.cameraFPS->currentIndex()) - { - case 0: - default: - fps = 0; - break; - case 1: - fps = 30; - break; - case 2: - fps = 60; - break; - case 3: - fps = 120; - break; - } - iniFile.setValue("fps", fps); - iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); - iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); - iniFile.setValue("resolution", ui.resolution->currentIndex()); - iniFile.endGroup(); - settingsDirty = false; -} - -void TrackerControls::doOK() -{ - save(); - this->close(); -} - -void TrackerControls::doCancel() -{ - 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(); - } -} diff --git a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.h b/FTNoIR_Tracker_HT/ftnoir_tracker_ht.h deleted file mode 100644 index 1a449dca..00000000 --- a/FTNoIR_Tracker_HT/ftnoir_tracker_ht.h +++ /dev/null @@ -1,80 +0,0 @@ -/* Copyright (c) 2013 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. - */ - -#ifndef FTNOIR_TRACKER_HT_H -#define FTNOIR_TRACKER_HT_H - -#include "stdafx.h" -#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" -#include "headtracker-ftnoir.h" -#include "ui_trackercontrols.h" -#include "video_widget.h" -#include "../compat/compat.h" -#include -#include - -class Tracker : public QObject, public ITracker -{ - Q_OBJECT -public: - Tracker(); - ~Tracker(); - void StartTracker(QFrame* frame); - bool GiveHeadPoseData(THeadPoseData *data); - bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; - ht_shm_t* shm; - bool NeedsTimeToFinish() { - return true; - } - void WaitForExit() { - if (shm) { - shm->terminate = true; - subprocess.waitForFinished(5000); - } - subprocess.kill(); - } -private: - QTimer timer; - PortableLockedShm lck_shm; - QProcess subprocess; - VideoWidget* videoWidget; - QHBoxLayout* layout; - volatile bool fresh; -private slots: - void paint_widget(); -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class TrackerControls : public QWidget, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; - -private: - Ui::Form ui; - void loadSettings(); - void save(); - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; - void settingChanged(double) { settingsDirty = true; }; -}; - -#endif - diff --git a/FTNoIR_Tracker_HT/ftnoir_tracker_ht_dll.h b/FTNoIR_Tracker_HT/ftnoir_tracker_ht_dll.h deleted file mode 100644 index f3bfd381..00000000 --- a/FTNoIR_Tracker_HT/ftnoir_tracker_ht_dll.h +++ /dev/null @@ -1,20 +0,0 @@ -/* Copyright (c) 2013 Stanis³aw 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_base/ftnoir_tracker_base.h" -#include "../facetracknoir/global-settings.h" - -//----------------------------------------------------------------------------- -class TrackerDll : public Metadata -{ - // ITrackerDll interface - void Initialize() {} - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); -}; diff --git a/FTNoIR_Tracker_HT/headtracker-ftnoir.h b/FTNoIR_Tracker_HT/headtracker-ftnoir.h deleted file mode 100644 index 48510997..00000000 --- a/FTNoIR_Tracker_HT/headtracker-ftnoir.h +++ /dev/null @@ -1,24 +0,0 @@ -#pragma once -#include -#include -#include "ht-api.h" - -#define HT_SHM_NAME "ftnoir-tracker-ht-shm" -#define HT_MUTEX_NAME "ftnoir-tracker-ht-mutex" - -#define HT_MAX_VIDEO_WIDTH 2048 -#define HT_MAX_VIDEO_HEIGHT 1536 -#define HT_MAX_VIDEO_CHANNELS 3 - -typedef struct { - int width, height, channels; - unsigned char frame[HT_MAX_VIDEO_WIDTH * HT_MAX_VIDEO_HEIGHT * HT_MAX_VIDEO_CHANNELS]; -} ht_video_t; - -typedef struct { - ht_video_t frame; - ht_config_t config; - ht_result_t result; - volatile int timer; - volatile bool pause, terminate, running; -} ht_shm_t; diff --git a/FTNoIR_Tracker_HT/ht-api.h b/FTNoIR_Tracker_HT/ht-api.h deleted file mode 100644 index ac8d45cf..00000000 --- a/FTNoIR_Tracker_HT/ht-api.h +++ /dev/null @@ -1,85 +0,0 @@ -#pragma once -#ifndef HT_API -#ifndef __cplusplus -# define HT_EXTERN -#else -# define HT_EXTERN extern "C" -#endif -# if defined(_WIN32) && !defined(MINGW) -# define HT_API(t) HT_EXTERN __declspec(dllexport) t __stdcall -# else -# define HT_API(t) HT_EXTERN t -# endif -#endif -#if !defined(_WIN32) && !defined(_isnan) -# define _isnan isnan -#endif -#include -struct ht_context; -typedef struct ht_context headtracker_t; - -typedef struct ht_config { - float field_of_view; - float classification_delay; - int pyrlk_pyramids; - int pyrlk_win_size_w; - int pyrlk_win_size_h; - float ransac_max_inlier_error; - float ransac_max_reprojection_error; - int max_keypoints; - int keypoint_quality; - float keypoint_distance; - float keypoint_3distance; - int force_width; - int force_height; - int force_fps; - int camera_index; - bool debug; - int ransac_num_iters; - float ransac_min_features; - float ransac_max_mean_error; - float ransac_abs_max_mean_error; -} ht_config_t; - -typedef struct { - double rotx, roty, rotz; - double tx, ty, tz; - bool filled; -} ht_result_t; - -typedef enum { - cfg_type_float = 0, - cfg_type_int = 1, - cfg_type_bool = 2, - cfg_type_double = 3 -} ht_cfg_type_t; - -typedef union -{ - double d; - float f; - int i; -} ht_cfg_value_t; - -typedef struct { - const char* name; - int offset; - ht_cfg_type_t type; - ht_cfg_value_t default_value; - ht_cfg_value_t min; - ht_cfg_value_t max; - const char* docstring; -} ht_reflection_t; - -typedef struct { - int rows, cols, channels; - unsigned char* data; -} ht_frame_t; - -HT_API(headtracker_t*) ht_make_context(const ht_config_t* config, const char* filename); -HT_API(void) ht_load_config(FILE* stream, ht_config_t* cfg); -HT_API(void) ht_free_context(headtracker_t* ctx); -HT_API(void) ht_get_bgr_frame(headtracker_t* ctx, ht_frame_t* ret); -HT_API(void) ht_make_config(ht_config_t* cfg); -HT_API(bool) ht_cycle(headtracker_t* ctx, ht_result_t* euler); -HT_API(void) ht_reset(headtracker_t* ctx); diff --git a/FTNoIR_Tracker_HT/images/HT.ico b/FTNoIR_Tracker_HT/images/HT.ico deleted file mode 100644 index 7555ce25..00000000 Binary files a/FTNoIR_Tracker_HT/images/HT.ico and /dev/null differ diff --git a/FTNoIR_Tracker_HT/stdafx.h b/FTNoIR_Tracker_HT/stdafx.h deleted file mode 100644 index 0e532c9f..00000000 --- a/FTNoIR_Tracker_HT/stdafx.h +++ /dev/null @@ -1,14 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include diff --git a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui b/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui deleted file mode 100644 index 0174df23..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_PT_Controls.ui +++ /dev/null @@ -1,1764 +0,0 @@ - - - UICPTClientControls - - - Qt::ApplicationModal - - - - 0 - 0 - 405 - 489 - - - - - 0 - 0 - - - - PointTracker Settings - - - - :/Resources/icon.ico:/Resources/icon.ico - - - Qt::LeftToRight - - - false - - - - QLayout::SetFixedSize - - - - - - 0 - 0 - - - - - 0 - 0 - - - - - - - 0 - - - - General - - - - - - Tracker Thread - - - - - - - - - - - Dynamic Pose Resolution - - - - - - - Sleep time - - - sleep_spin - - - - - - - - - Time the tracker thread sleeps after each processed frame - - - - - - 9999 - - - - - - - ms - - - - - - - - - Auto-reset time - - - reset_spin - - - - - - - - - Time until automatic reset of tracker's internal state when no valid tracking result is found - - - 9999 - - - - - - - ms - - - - - - - - - Whether to update the content of the VideoWidget - - - Show VideoWidget - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - false - - - Reset the tracker's internal state - - - Reset - - - - - - - - - - - - - 0 - 85 - - - - Enable Axis - - - - - - - - Roll: - - - chkEnableRoll - - - - - - - Pitch: - - - chkEnablePitch - - - - - - - Yaw: - - - chkEnableYaw - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - X: - - - chkEnableX - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Y: - - - chkEnableY - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Z: - - - chkEnableZ - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - Status - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Camera Info: - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - Extracted Points: - - - - - - - - 50 - 0 - - - - - - - - - - - - - - - - - Camera - - - - - - Camera Settings - - - - - - - - - - Index - - - camindex_spin - - - - - - - Capture device index - - - - - - - FPS - - - fps_spin - - - - - - - Desired capture framerate - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - Resolution - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - Desired capture width - - - 2000 - - - 10 - - - - - - - x - - - - - - - Desired capture height - - - 2000 - - - 10 - - - - - - - - - - - (Focal length)/(Sensor width) - - - f_dspin - - - - - - - The camera's focal length devided by its sensor width - - - 2 - - - 0.100000000000000 - - - - - - - - - - - - - - - Camera Pitch (upwards = positive) - - - campitch_spin - - - - - - - Qt::DefaultContextMenu - - - The angle the camera is facing upwards - - - -99 - - - - - - - deg - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - - Point Extraction - - - - - - - - Threshold - - - threshold_slider - - - - - - - Intensity threshold for point extraction - - - 255 - - - 127 - - - Qt::Horizontal - - - - - - - - - - - Min Diameter - - - mindiam_spin - - - - - - - Minimum point diameter - - - - - - - px - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Max Diameter - - - maxdiam_spin - - - - - - - Maximum point diameter - - - - - - - px - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - Status - - - - - - QFormLayout::AllNonFixedFieldsGrow - - - - - Camera Info: - - - - - - - - 0 - 0 - - - - - 120 - 0 - - - - - - - - - - - Extracted Points: - - - - - - - - 50 - 0 - - - - - - - - - - - - - - - - - Model - - - - - - QTabWidget::Rounded - - - 2 - - - false - - - false - - - false - - - - Clip - - - - - - Model Dimensions (mm) - - - - - - - 0 - 0 - - - - - 150 - 170 - - - - - - 30 - 30 - 71 - 111 - - - - - - - :/Resources/clip_side.png - - - - - - 100 - 50 - 46 - 22 - - - - 999 - - - - - - 60 - 10 - 46 - 22 - - - - 999 - - - - - - 100 - 90 - 46 - 22 - - - - 999 - - - - - - 10 - 10 - 46 - 13 - - - - Side - - - - - - 40 - 140 - 46 - 22 - - - - 999 - - - - - - 70 - 70 - 16 - 16 - - - - R - - - - - - - - - 0 - 0 - - - - - 100 - 140 - - - - - - 10 - 10 - 46 - 13 - - - - Front - - - - - - 40 - 30 - 21 - 111 - - - - - - - :/Resources/clip_front.png - - - - - - 60 - 70 - 16 - 16 - - - - R - - - - - - - - - - - - Cap - - - - - - Model Dimensions (mm) - - - - - - - 140 - 130 - - - - - - 20 - 50 - 111 - 81 - - - - - - - :/Resources/cap_side.png - - - - - - 30 - 80 - 46 - 22 - - - - 999 - - - - - - 130 - 50 - 16 - 16 - - - - R - - - - - - 10 - 10 - 46 - 13 - - - - Side - - - - - - 50 - 40 - 46 - 22 - - - - 999 - - - - - - - - - 0 - 0 - - - - - 100 - 130 - - - - - - 10 - 10 - 46 - 13 - - - - Front - - - - - - 30 - 50 - 16 - 16 - - - - R - - - - - - 10 - 50 - 81 - 81 - - - - - - - :/Resources/cap_front.png - - - - - - 50 - 30 - 46 - 22 - - - - 999 - - - - - - - - - - - - Custom - - - - - - Model Dimensions (mm) - - - - - - <html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p></body></html> - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - -999 - - - 999 - - - - - - - y: - - - - - - - -999 - - - 999 - - - - - - - z: - - - - - - - M1: - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - z: - - - - - - - -999 - - - 999 - - - - - - - y: - - - - - - - M2: - - - - - - - - - - -999 - - - 999 - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - Qt::Vertical - - - - 20 - 20 - - - - - - - - - - - - - - - Model Position (mm) - - - - - - <html><head/><body><p>Translation from head center to model reference point<br/> in default pose</p></body></html> - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - - -999 - - - 999 - - - - - - - x: - - - - - - - y: - - - - - - - z: - - - - - - - -999 - - - 999 - - - - - - - -999 - - - 999 - - - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - false - - - Calibrate - - - true - - - - - - - Qt::Horizontal - - - - 20 - 20 - - - - - - - - - - - - - - About - - - - - 30 - 30 - 161 - 111 - - - - <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> - - - true - - - - - - 200 - 30 - 141 - 141 - - - - - - - :/Resources/Logo_IR.png - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Ok - - - - - - - Cancel - - - - - - - - - tabWidget - sleep_spin - reset_spin - chkEnableRoll - chkEnablePitch - chkEnableYaw - chkEnableX - chkEnableY - chkEnableZ - camindex_spin - res_x_spin - res_y_spin - fps_spin - f_dspin - campitch_spin - threshold_slider - mindiam_spin - maxdiam_spin - model_tabs - clip_tlength_spin - clip_theight_spin - clip_bheight_spin - clip_blength_spin - cap_length_spin - cap_height_spin - cap_width_spin - m1x_spin - m1y_spin - m1z_spin - m2x_spin - m2y_spin - m2z_spin - tx_spin - ty_spin - tz_spin - tcalib_button - ok_button - cancel_button - - - - - - - dynpose_check - toggled(bool) - reset_spin - setEnabled(bool) - - - 285 - 105 - - - 139 - 111 - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc deleted file mode 100644 index 11c5d52f..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT.rc +++ /dev/null @@ -1,61 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// English (U.S.) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) -LANGUAGE 9, 1 -#pragma code_page(1252) - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // English (U.S.) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj deleted file mode 100644 index 5b70b459..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc8.vcproj +++ /dev/null @@ -1,559 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc9.vcproj b/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc9.vcproj deleted file mode 100644 index 95f5ac62..00000000 --- a/FTNoIR_Tracker_PT/FTNoIR_Tracker_PT_vc9.vcproj +++ /dev/null @@ -1,524 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_PT/Resources/Logo_IR.png b/FTNoIR_Tracker_PT/Resources/Logo_IR.png deleted file mode 100644 index 95032a25..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/Logo_IR.png and /dev/null differ diff --git a/FTNoIR_Tracker_PT/Resources/cap_front.png b/FTNoIR_Tracker_PT/Resources/cap_front.png deleted file mode 100644 index 14207a67..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/cap_front.png and /dev/null differ diff --git a/FTNoIR_Tracker_PT/Resources/cap_side.png b/FTNoIR_Tracker_PT/Resources/cap_side.png deleted file mode 100644 index 5ad4ee65..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/cap_side.png and /dev/null differ diff --git a/FTNoIR_Tracker_PT/Resources/clip_front.png b/FTNoIR_Tracker_PT/Resources/clip_front.png deleted file mode 100644 index 04880138..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/clip_front.png and /dev/null differ diff --git a/FTNoIR_Tracker_PT/Resources/clip_side.png b/FTNoIR_Tracker_PT/Resources/clip_side.png deleted file mode 100644 index 72667ac7..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/clip_side.png and /dev/null differ diff --git a/FTNoIR_Tracker_PT/Resources/icon.ico b/FTNoIR_Tracker_PT/Resources/icon.ico deleted file mode 100644 index c4b2aedc..00000000 Binary files a/FTNoIR_Tracker_PT/Resources/icon.ico and /dev/null differ diff --git a/FTNoIR_Tracker_PT/camera.cpp b/FTNoIR_Tracker_PT/camera.cpp deleted file mode 100644 index fc11c738..00000000 --- a/FTNoIR_Tracker_PT/camera.cpp +++ /dev/null @@ -1,226 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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 "camera.h" -#include - -using namespace cv; - -// ---------------------------------------------------------------------------- -void Camera::set_index(int index) -{ - if (desired_index != index) - { - desired_index = index; - _set_index(); - - // reset fps - dt_valid = 0; - dt_mean = 0; - active_index = index; - } -} - -void Camera::set_f(float f) -{ - if (cam_desired.f != f) - { - cam_desired.f = f; - _set_f(); - } -} -void Camera::set_fps(int fps) -{ - if (cam_desired.fps != fps) - { - cam_desired.fps = fps; - _set_fps(); - } -} - -void Camera::set_res(int x_res, int y_res) -{ - if (cam_desired.res_x != x_res || cam_desired.res_y != y_res) - { - cam_desired.res_x = x_res; - cam_desired.res_y = y_res; - _set_res(); - } -} - -bool Camera::get_frame(float dt, cv::Mat* frame) -{ - bool new_frame = _get_frame(frame); - // measure fps of valid frames - const float dt_smoothing_const = 0.9; - dt_valid += dt; - if (new_frame) - { - dt_mean = dt_smoothing_const * dt_mean + (1.0 - dt_smoothing_const) * dt_valid; - cam_info.fps = 1.0 / dt_mean; - dt_valid = 0; - } - return new_frame; -} - -// ---------------------------------------------------------------------------- -/* -void CVCamera::start() -{ - cap = cvCreateCameraCapture(desired_index); - // extract camera info - if (cap) - { - active = true; - active_index = desired_index; - cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH); - cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT); - } -} - -void CVCamera::stop() -{ - if (cap) cvReleaseCapture(&cap); - active = false; -} - -bool CVCamera::_get_frame(Mat* frame) -{ - if (cap && cvGrabFrame(cap) != 0) - { - // retrieve frame - IplImage* _img = cvRetrieveFrame(cap, 0); - if(_img) - { - if(_img->origin == IPL_ORIGIN_TL) - *frame = Mat(_img); - else - { - Mat temp(_img); - flip(temp, *frame, 0); - } - return true; - } - } - return false; -} - -void CVCamera::_set_index() -{ - if (active) restart(); -} - -void CVCamera::_set_f() -{ - cam_info.f = cam_desired.f; -} - -void CVCamera::_set_fps() -{ - if (cap) cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, cam_desired.fps); -} - -void CVCamera::_set_res() -{ - if (cap) - { - cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x); - cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y); - cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH); - cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT); - } -} -*/ - -// ---------------------------------------------------------------------------- -VICamera::VICamera() : frame_buffer(NULL) -{ - VI.listDevices(); -} - -void VICamera::start() -{ - if (desired_index >= 0) - { - - - if (cam_desired.res_x == 0 || cam_desired.res_y == 0) - VI.setupDevice(desired_index); - else - VI.setupDevice(desired_index, cam_desired.res_x, cam_desired.res_y); - - active = true; - active_index = desired_index; - - cam_info.res_x = VI.getWidth(active_index); - cam_info.res_y = VI.getHeight(active_index); - new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3); - // If matrix is not continuous we have to copy manually via frame_buffer - if (!new_frame.isContinuous()) { - unsigned int size = VI.getSize(active_index); - frame_buffer = new unsigned char[size]; - } - } -} - -void VICamera::stop() -{ - if (active) - { - VI.stopDevice(active_index); - } - if (frame_buffer) - { - delete[] frame_buffer; - frame_buffer = NULL; - } - active = false; -} - -bool VICamera::_get_frame(Mat* frame) -{ - if (active && VI.isFrameNew(active_index)) - { - if (new_frame.isContinuous()) - { - VI.getPixels(active_index, new_frame.data, false, true); - } - else - { - // If matrix is not continuous we have to copy manually via frame_buffer - VI.getPixels(active_index, frame_buffer, false, true); - new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3, frame_buffer).clone(); - } - *frame = new_frame; - return true; - } - return false; -} - -void VICamera::_set_index() -{ - if (active) restart(); -} - -void VICamera::_set_f() -{ - cam_info.f = cam_desired.f; -} - -void VICamera::_set_fps() -{ - bool was_active = active; - if (active) stop(); - VI.setIdealFramerate(desired_index, cam_desired.fps); - if (was_active) start(); -} - -void VICamera::_set_res() -{ - if (active) restart(); -} - diff --git a/FTNoIR_Tracker_PT/camera.h b/FTNoIR_Tracker_PT/camera.h deleted file mode 100644 index cd1f0842..00000000 --- a/FTNoIR_Tracker_PT/camera.h +++ /dev/null @@ -1,116 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef CAMERA_H -#define CAMERA_H - -#include -#include "videoInput/videoInput.h" - -// ---------------------------------------------------------------------------- -struct CamInfo -{ - CamInfo() : res_x(0), res_y(0), fps(0), f(1) {} - - int res_x; - int res_y; - int fps; - float f; // (focal length) / (sensor width) -}; - -// ---------------------------------------------------------------------------- -// base class for cameras -class Camera -{ -public: - Camera() : dt_valid(0), dt_mean(0), desired_index(0), active_index(-1), active(false) {} - virtual ~Camera() {} - - // start/stop capturing - virtual void start() = 0; - virtual void stop() = 0; - void restart() { stop(); start(); } - - void set_index(int index); - void set_f(float f); - void set_fps(int fps); - void set_res(int x_res, int y_res); - - // gets a frame from the camera, dt: time since last call in seconds - bool get_frame(float dt, cv::Mat* frame); - - // WARNING: returned references are valid as long as object - const CamInfo& get_info() const { return cam_info; } - const CamInfo& get_desired() const { return cam_desired; } - -protected: - // get a frame from the camera - virtual bool _get_frame(cv::Mat* frame) = 0; - - // update the camera - virtual void _set_index() = 0; - virtual void _set_f() = 0; - virtual void _set_fps() = 0; - virtual void _set_res() = 0; - - bool active; - int desired_index; - int active_index; - CamInfo cam_info; - CamInfo cam_desired; - float dt_valid; - float dt_mean; -}; - - -// ---------------------------------------------------------------------------- -// OpenCV camera -/* -class CVCamera : public Camera -{ -public: - CVCamera() : cap(NULL) {} - ~CVCamera() { stop(); } - - void start(); - void stop(); - -protected: - bool _get_frame(cv::Mat* frame); - void _set_index(); - void _set_f(); - void _set_fps(); - void _set_res(); - - CvCapture* cap; -}; -*/ - -// ---------------------------------------------------------------------------- -// videoInput camera -class VICamera : public Camera -{ -public: - VICamera(); - ~VICamera() { stop(); } - - void start(); - void stop(); - -protected: - bool _get_frame(cv::Mat* frame); - void _set_index(); - void _set_f(); - void _set_fps(); - void _set_res(); - - videoInput VI; - cv::Mat new_frame; - unsigned char* frame_buffer; -}; - -#endif //CAMERA_H diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp deleted file mode 100644 index 5b77da69..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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_pt.h" -#include -#include -#include -#include -#include - -using namespace std; -using namespace cv; -using namespace boost; - -//#define PT_PERF_LOG //log performance - -//----------------------------------------------------------------------------- -Tracker::Tracker() - : frame_count(0), commands(0), video_widget(NULL), tracking_valid(false) -{ - qDebug()<<"Tracker::Tracker"; - TrackerSettings settings; - settings.load_ini(); - apply(settings); - camera.start(); - start(); -} - -Tracker::~Tracker() -{ - qDebug()<<"Tracker::~Tracker"; - set_command(ABORT); - wait(); - if (video_widget) delete video_widget; -} - -void Tracker::set_command(Command command) -{ - QMutexLocker lock(&mutex); - commands |= command; -} - -void Tracker::reset_command(Command command) -{ - QMutexLocker lock(&mutex); - commands &= ~command; -} - -void Tracker::run() -{ - qDebug()<<"Tracker:: Thread started"; - -#ifdef PT_PERF_LOG - QFile log_file(QCoreApplication::applicationDirPath() + "/PointTrackerPerformance.txt"); - if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; - QTextStream log_stream(&log_file); -#endif - - time.start(); - float dt; - bool new_frame; - forever - { - { - QMutexLocker lock(&mutex); - - if (commands & ABORT) break; - if (commands & PAUSE) continue; - commands = 0; - - dt = time.elapsed() / 1000.0; - time.restart(); - - new_frame = camera.get_frame(dt, &frame); - if (new_frame && !frame.empty()) - { - const std::vector& points = point_extractor.extract_points(frame, dt, draw_frame); - tracking_valid = point_tracker.track(points, camera.get_info().f, dt); - frame_count++; - } -#ifdef PT_PERF_LOG - log_stream<<"dt: "<(new PointModel(settings.M01, settings.M02)); - point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; - sleep_time = settings.sleep_time; - point_tracker.dt_reset = settings.reset_time / 1000.0; - draw_frame = settings.video_widget; - cam_pitch = settings.cam_pitch; - - bEnableRoll = settings.bEnableRoll; - bEnablePitch = settings.bEnablePitch; - bEnableYaw = settings.bEnableYaw; - bEnableX = settings.bEnableX; - bEnableY = settings.bEnableY; - bEnableZ = settings.bEnableZ; - - t_MH = settings.t_MH; - qDebug()<<"Tracker::apply ends"; -} - -void Tracker::reset() -{ - QMutexLocker lock(&mutex); - point_tracker.reset(); -} - -void Tracker::center() -{ - point_tracker.reset(); // we also do a reset here since there is no reset shortkey yet - QMutexLocker lock(&mutex); - FrameTrafo X_CM_0 = point_tracker.get_pose(); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - X_CH_0 = X_CM_0 * X_MH; -} - -//----------------------------------------------------------------------------- -// ITracker interface -void Tracker::Initialize(QFrame *videoframe) -{ - const int VIDEO_FRAME_WIDTH = 252; - const int VIDEO_FRAME_HEIGHT = 189; - - qDebug("Tracker::Initialize"); - // setup video frame - videoframe->setAttribute(Qt::WA_NativeWindow); - videoframe->show(); - video_widget = new VideoWidget(videoframe); - QHBoxLayout* layout = new QHBoxLayout(); - layout->setContentsMargins(0, 0, 0, 0); - layout->addWidget(video_widget); - if (videoframe->layout()) delete videoframe->layout(); - videoframe->setLayout(layout); - video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); -} - -void Tracker::refreshVideo() -{ - if (video_widget) - { - Mat frame_copy; - shared_ptr< vector > points; - { - QMutexLocker lock(&mutex); - if (!draw_frame || frame.empty()) return; - - // copy the frame and points from the tracker thread - frame_copy = frame.clone(); - points = shared_ptr< vector >(new vector(point_extractor.get_points())); - } - - video_widget->update(frame_copy, points); - } -} - -void Tracker::StartTracker(HWND parent_window) -{ - reset_command(PAUSE); -} - -void Tracker::StopTracker(bool exit) -{ - set_command(PAUSE); -} - -bool Tracker::GiveHeadPoseData(THeadPoseData *data) -{ - const float rad2deg = 180.0/3.14159265; - const float deg2rad = 1.0/rad2deg; - { - QMutexLocker lock(&mutex); - - if (!tracking_valid) return false; - - FrameTrafo X_CM = point_tracker.get_pose(); - FrameTrafo X_MH(Matx33f::eye(), t_MH); - FrameTrafo X_CH = X_CM * X_MH; - - Matx33f R = X_CH.R * X_CH_0.R.t(); - Vec3f t = X_CH.t - X_CH_0.t; - - // correct for camera pitch - Matx33f R_CP( 1, 0, 0, - 0, cos(deg2rad*cam_pitch), sin(deg2rad*cam_pitch), - 0, -sin(deg2rad*cam_pitch), cos(deg2rad*cam_pitch)); - R = R_CP * R * R_CP.t(); - t = R_CP * t; - - // get translation(s) - if (bEnableX) { - data->x = t[0] / 10.0; // convert to cm - } - if (bEnableY) { - data->y = t[1] / 10.0; - } - if (bEnableZ) { - data->z = t[2] / 10.0; - } - - // translate rotation matrix from opengl (G) to roll-pitch-yaw (R) frame - // -z -> x, y -> z, x -> -y - Matx33f R_RG( 0, 0,-1, - -1, 0, 0, - 0, 1, 0); - R = R_RG * R * R_RG.t(); - - // extract rotation angles - float alpha, beta, gamma; - //beta = atan2( -R(2,0), sqrt(R(0,0)*R(0,0) + R(1,0)*R(1,0)) ); - beta = atan2( -R(2,0), sqrt(R(2,1)*R(2,1) + R(2,2)*R(2,2)) ); - alpha = atan2( R(1,0), R(0,0)); - gamma = atan2( R(2,1), R(2,2)); - - if (bEnableYaw) { - data->yaw = rad2deg * alpha; - } - if (bEnablePitch) { - data->pitch = rad2deg * beta; - } - if (bEnableRoll) { - data->roll = rad2deg * gamma; - } - } - return true; -} - -//----------------------------------------------------------------------------- -#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() -{ - return new Tracker; -} \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h deleted file mode 100644 index 2533a39b..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef FTNOIR_TRACKER_PT_H -#define FTNOIR_TRACKER_PT_H - -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include "ftnoir_tracker_pt_settings.h" -#include "camera.h" -#include "point_extractor.h" -#include "point_tracker.h" -#include "video_widget.h" -#include "timer.h" - -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -class Tracker : public ITracker, QThread -{ -public: - Tracker(); - ~Tracker(); - - // ITracker interface - void Initialize(QFrame *videoframe); - void StartTracker(HWND parent_window); - void StopTracker(bool exit); - bool GiveHeadPoseData(THeadPoseData *data); - - void refreshVideo(); - - void apply(const TrackerSettings& settings); - void center(); - void reset(); // reset the trackers internal state variables - void run(); - - void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); } - int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); } - void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); } - -protected: - FrameTrafo X_CH_0; // for centering - - QMutex mutex; - cv::Mat frame; // the output frame for display - - enum Command { - ABORT = 1<<0, - PAUSE = 1<<1 - }; - void set_command(Command command); - void reset_command(Command command); - int commands; - - VICamera camera; - PointExtractor point_extractor; - PointTracker point_tracker; - bool tracking_valid; - - cv::Vec3f t_MH; - int cam_pitch; - - bool draw_frame; - int sleep_time; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - long frame_count; - - VideoWidget* video_widget; - Timer time; -}; - -#endif // FTNOIR_TRACKER_PT_H diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc b/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc deleted file mode 100644 index eb1fba2c..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt.qrc +++ /dev/null @@ -1,10 +0,0 @@ - - - Resources/icon.ico - Resources/cap_front.png - Resources/cap_side.png - Resources/clip_front.png - Resources/clip_side.png - Resources/Logo_IR.png - - diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp deleted file mode 100644 index a1531dd7..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.cpp +++ /dev/null @@ -1,336 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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_pt_dialog.h" - -#include -#include - -//----------------------------------------------------------------------------- -TrackerDialog::TrackerDialog() - : settings_dirty(false), tracker(NULL), timer(this), trans_calib_running(false) -{ - qDebug()<<"TrackerDialog::TrackerDialog"; - setAttribute(Qt::WA_DeleteOnClose, false); - - ui.setupUi( this ); - - settings.load_ini(); - dialog_settings.load_ini(); - - // initialize ui values - ui.videowidget_check->setChecked(settings.video_widget); - ui.dynpose_check->setChecked(settings.dyn_pose_res); - ui.sleep_spin->setValue(settings.sleep_time); - ui.reset_spin->setValue(settings.reset_time); - ui.camindex_spin->setValue(settings.cam_index); - ui.f_dspin->setValue(settings.cam_f); - ui.res_x_spin->setValue(settings.cam_res_x); - ui.res_y_spin->setValue(settings.cam_res_y); - ui.fps_spin->setValue(settings.cam_fps); - ui.campitch_spin->setValue(settings.cam_pitch); - ui.threshold_slider->setValue(settings.threshold); - - ui.chkEnableRoll->setChecked(settings.bEnableRoll); - ui.chkEnablePitch->setChecked(settings.bEnablePitch); - ui.chkEnableYaw->setChecked(settings.bEnableYaw); - ui.chkEnableX->setChecked(settings.bEnableX); - ui.chkEnableY->setChecked(settings.bEnableY); - ui.chkEnableZ->setChecked(settings.bEnableZ); - - ui.mindiam_spin->setValue(settings.min_point_size); - ui.maxdiam_spin->setValue(settings.max_point_size); - ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel); - ui.clip_bheight_spin->setValue(dialog_settings.clip_by); - ui.clip_blength_spin->setValue(dialog_settings.clip_bz); - ui.clip_theight_spin->setValue(dialog_settings.clip_ty); - ui.clip_tlength_spin->setValue(dialog_settings.clip_tz); - ui.cap_width_spin->setValue(dialog_settings.cap_x); - ui.cap_height_spin->setValue(dialog_settings.cap_y); - ui.cap_length_spin->setValue(dialog_settings.cap_z); - ui.m1x_spin->setValue(dialog_settings.M01x); - ui.m1y_spin->setValue(dialog_settings.M01y); - ui.m1z_spin->setValue(dialog_settings.M01z); - ui.m2x_spin->setValue(dialog_settings.M02x); - ui.m2y_spin->setValue(dialog_settings.M02y); - ui.m2z_spin->setValue(dialog_settings.M02z); - ui.tx_spin->setValue(settings.t_MH[0]); - ui.ty_spin->setValue(settings.t_MH[1]); - ui.tz_spin->setValue(settings.t_MH[2]); - - // connect Qt signals and slots - connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) ); - connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(bool)) ); - connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) ); - connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) ); - connect( ui.camindex_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_index(int)) ); - connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) ); - connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) ); - connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) ); - connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) ); - connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); - connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); - - connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); - connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); - connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); - connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); - connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); - connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); - - connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) ); - connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) ); - connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) ); - connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) ); - connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) ); - connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) ); - connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) ); - connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) ); - connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) ); - connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) ); - connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) ); - connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) ); - connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) ); - connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) ); - connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) ); - connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) ); - connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) ); - connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) ); - connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) ); - - connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); - - connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); - //connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter())); - - connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); - - connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); - timer.start(100); -} - -TrackerDialog::~TrackerDialog() -{ - qDebug()<<"TrackerDialog::~TrackerDialog"; -} - -void TrackerDialog::set_clip() -{ - settings.M01[0] = 0; - settings.M01[1] = dialog_settings.clip_ty; - settings.M01[2] = -dialog_settings.clip_tz; - settings.M02[0] = 0; - settings.M02[1] = -dialog_settings.clip_by; - settings.M02[2] = -dialog_settings.clip_bz; - - settings_changed(); -} - -void TrackerDialog::set_cap() -{ - settings.M01[0] = -dialog_settings.cap_x; - settings.M01[1] = -dialog_settings.cap_y; - settings.M01[2] = -dialog_settings.cap_z; - settings.M02[0] = dialog_settings.cap_x; - settings.M02[1] = -dialog_settings.cap_y; - settings.M02[2] = -dialog_settings.cap_z; - - settings_changed(); -} - -void TrackerDialog::set_custom() -{ - settings.M01[0] = dialog_settings.M01x; - settings.M01[1] = dialog_settings.M01y; - settings.M01[2] = dialog_settings.M01z; - settings.M02[0] = dialog_settings.M02x; - settings.M02[1] = dialog_settings.M02y; - settings.M02[2] = dialog_settings.M02z; - - settings_changed(); -} - -void TrackerDialog::set_model(int val) -{ - dialog_settings.active_model_panel = val; - - switch (val) { - - case TrackerDialogSettings::MODEL_CLIP: - set_clip(); - break; - - case TrackerDialogSettings::MODEL_CAP: - set_cap(); - break; - - case TrackerDialogSettings::MODEL_CUSTOM: - set_custom(); - break; - - default: - break; - } -} - -void TrackerDialog::startstop_trans_calib(bool start) -{ - if (start) - { - qDebug()<<"TrackerDialog:: Starting translation calibration"; - trans_calib.reset(); - trans_calib_running = true; - } - else - { - qDebug()<<"TrackerDialog:: Stoppping translation calibration"; - trans_calib_running = false; - settings.t_MH = trans_calib.get_estimate(); - settings_changed(); - } -} - -void TrackerDialog::trans_calib_step() -{ - if (tracker) - { - FrameTrafo X_CM; - tracker->get_pose(&X_CM); - trans_calib.update(X_CM.R, X_CM.t); - cv::Vec3f t_MH = trans_calib.get_estimate(); - //qDebug()<<"TrackerDialog:: Current translation estimate: "<setValue(t_MH[0]); - ui.ty_spin->setValue(t_MH[1]); - ui.tz_spin->setValue(t_MH[2]); - } -} - -void TrackerDialog::settings_changed() -{ - settings_dirty = true; - if (tracker) tracker->apply(settings); -} - -void TrackerDialog::doCenter() -{ - if (tracker) tracker->center(); -} - -void TrackerDialog::doReset() -{ - if (tracker) tracker->reset(); -} - -void TrackerDialog::doOK() -{ - settings.save_ini(); - dialog_settings.save_ini(); - close(); -} - -void TrackerDialog::doCancel() -{ - if (settings_dirty) { - 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: - settings.save_ini(); - dialog_settings.save_ini(); - close(); - break; - case QMessageBox::Discard: - close(); - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } - else { - close(); - } -} - -void TrackerDialog::poll_tracker_info() -{ - if (tracker) - { - QString to_print; - - // display caminfo - CamInfo info; - tracker->get_cam_info(&info); - to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; - ui.caminfo_label->setText(to_print); - ui.caminfo_label_2->setText(to_print); - - // display pointinfo - int n_points = tracker->get_n_points(); - to_print = QString::number(n_points); - if (n_points == 3) - to_print += " OK!"; - else - to_print += " BAD!"; - ui.pointinfo_label->setText(to_print); - ui.pointinfo_label_2->setText(to_print); - - // update calibration - if (trans_calib_running) trans_calib_step(); - } - else - { - QString to_print = "Tracker offline"; - ui.caminfo_label->setText(to_print); - ui.caminfo_label_2->setText(to_print); - ui.pointinfo_label->setText(to_print); - ui.pointinfo_label_2->setText(to_print); - } -} - - -//----------------------------------------------------------------------------- -// ITrackerDialog interface -void TrackerDialog::Initialize(QWidget *parent) -{ - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -void TrackerDialog::registerTracker(ITracker *t) -{ - qDebug()<<"TrackerDialog:: Tracker registered"; - tracker = static_cast(t); - if (isVisible() && settings_dirty) tracker->apply(settings); - ui.tcalib_button->setEnabled(true); - //ui.center_button->setEnabled(true); - ui.reset_button->setEnabled(true); -} - -void TrackerDialog::unRegisterTracker() -{ - qDebug()<<"TrackerDialog:: Tracker un-registered"; - tracker = NULL; - ui.tcalib_button->setEnabled(false); - //ui.center_button->setEnabled(false); - ui.reset_button->setEnabled(false); -} - -//----------------------------------------------------------------------------- -#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) -{ - return new TrackerDialog; -} \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h deleted file mode 100644 index 0f836dfe..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dialog.h +++ /dev/null @@ -1,102 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef FTNOIR_TRACKER_PT_DIALOG_H -#define FTNOIR_TRACKER_PT_DIALOG_H - -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include "ftnoir_tracker_pt_settings.h" -#include "ftnoir_tracker_pt.h" -#include "ui_FTNoIR_PT_Controls.h" -#include "trans_calib.h" - -#include - -//----------------------------------------------------------------------------- -class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDialog -{ - Q_OBJECT -public: - TrackerDialog(); - ~TrackerDialog(); - - // ITrackerDialog interface - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker); - void unRegisterTracker(); - - void trans_calib_step(); - -protected slots: - // ugly qt stuff - void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); } - void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); } - void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); } - void set_reset_time(int val) { settings.reset_time = val; settings_changed(); } - void set_cam_index(int val) { settings.cam_index = val; settings_changed(); } - void set_cam_f(double val) { settings.cam_f = val; settings_changed(); } - void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); } - void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); } - void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); } - void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } - void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); } - void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); } - void set_threshold(int val) { settings.threshold = val; settings_changed(); } - void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); } - void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); } - void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); } - void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); } - void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); } - void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); } - - void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_clip(); } - void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_clip(); } - void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_clip(); } - void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_clip(); } - void set_cap_width(int val) { dialog_settings.cap_x = val; set_cap(); } - void set_cap_height(int val) { dialog_settings.cap_y = val; set_cap(); } - void set_cap_length(int val) { dialog_settings.cap_z = val; set_cap(); } - void set_m1x(int val) { dialog_settings.M01x = val; set_custom(); } - void set_m1y(int val) { dialog_settings.M01y = val; set_custom(); } - void set_m1z(int val) { dialog_settings.M01z = val; set_custom(); } - void set_m2x(int val) { dialog_settings.M02x = val; set_custom(); } - void set_m2y(int val) { dialog_settings.M02y = val; set_custom(); } - void set_m2z(int val) { dialog_settings.M02z = val; set_custom(); } - void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); } - void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); } - void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); } - void set_model(int model_id); - - void doCenter(); - void doReset(); - - void doOK(); - void doCancel(); - - void startstop_trans_calib(bool start); - - void poll_tracker_info(); - -protected: - void set_clip(); - void set_cap(); - void set_custom(); - - void settings_changed(); - - TrackerSettings settings; - TrackerDialogSettings dialog_settings; - bool settings_dirty; - - Tracker* tracker; - TranslationCalibrator trans_calib; - bool trans_calib_running; - QTimer timer; - Ui::UICPTClientControls ui; -}; - -#endif //FTNOIR_TRACKER_PT_DIALOG_H \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp deleted file mode 100644 index 7f58d77d..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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_pt_dll.h" - -#include - -//----------------------------------------------------------------------------- -void TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = "PointTracker 1.0"; -} - -void TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = "PointTracker"; -} - -void TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = "Tracks a 3-point model with know geometry like Freetrack / TrackIR"; -} - -void TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/Resources/icon.ico"); -} - - -//----------------------------------------------------------------------------- -#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() -{ - return new TrackerDll; -} diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h deleted file mode 100644 index 15ad63aa..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_dll.h +++ /dev/null @@ -1,19 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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_base\ftnoir_tracker_base.h" - -//----------------------------------------------------------------------------- -class TrackerDll : public ITrackerDll -{ - // ITrackerDll interface - void Initialize() {} - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); -}; \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp deleted file mode 100644 index 40d1bc4f..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.cpp +++ /dev/null @@ -1,150 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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_pt.h" -#include -#include - -//----------------------------------------------------------------------------- -void TrackerSettings::load_ini() -{ - qDebug("TrackerSettings::load_ini()"); - - 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( "PointTracker" ); - - cam_index = iniFile.value("CameraId", 0).toInt(); - cam_f = iniFile.value("CameraF", 1).toFloat(); - cam_res_x = iniFile.value("CameraResX", 640).toInt(); - cam_res_y = iniFile.value("CameraResY", 480).toInt(); - cam_fps = iniFile.value("CameraFPS", 30).toInt(); - cam_pitch = iniFile.value("CameraPitch", 0).toInt(); - threshold = iniFile.value("PointExtractThreshold", 128).toInt(); - min_point_size = iniFile.value("PointExtractMinSize", 2).toInt(); - max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt(); - M01[0] = iniFile.value("PointModelM01x", 0).toFloat(); - M01[1] = iniFile.value("PointModelM01y", 40).toFloat(); - M01[2] = iniFile.value("PointModelM01z", -30).toFloat(); - M02[0] = iniFile.value("PointModelM02x", 0).toFloat(); - M02[1] = iniFile.value("PointModelM02y", -70).toFloat(); - M02[2] = iniFile.value("PointModelM02z", -80).toFloat(); - t_MH[0] = iniFile.value("tMHx", 0).toFloat(); - t_MH[1] = iniFile.value("tMHy", 0).toFloat(); - t_MH[2] = iniFile.value("tMHz", 0).toFloat(); - dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool(); - video_widget = iniFile.value("VideoWidget", true).toBool(); - sleep_time = iniFile.value("SleepTime", 10).toInt(); - reset_time = iniFile.value("ResetTime", 1000).toInt(); - - bEnableRoll = iniFile.value( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value( "EnableYaw", 1 ).toBool(); - bEnableX = iniFile.value( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value( "EnableZ", 1 ).toBool(); - - iniFile.endGroup(); -} - -void TrackerSettings::save_ini() const -{ - qDebug("TrackerSettings::save_ini()"); - - 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 ( "PointTracker" ); - - iniFile.setValue("CameraId", cam_index); - iniFile.setValue("CameraF", cam_f); - iniFile.setValue("CameraResX", cam_res_x); - iniFile.setValue("CameraResY", cam_res_y); - iniFile.setValue("CameraFPS", cam_fps); - iniFile.setValue("CameraPitch", cam_pitch); - iniFile.setValue("PointExtractThreshold", threshold); - iniFile.setValue("PointExtractMinSize", min_point_size); - iniFile.setValue("PointExtractMaxSize", max_point_size); - iniFile.setValue("PointModelM01x", M01[0]); - iniFile.setValue("PointModelM01y", M01[1]); - iniFile.setValue("PointModelM01z", M01[2]); - iniFile.setValue("PointModelM02x", M02[0]); - iniFile.setValue("PointModelM02y", M02[1]); - iniFile.setValue("PointModelM02z", M02[2]); - iniFile.setValue("tMHx", t_MH[0]); - iniFile.setValue("tMHy", t_MH[1]); - iniFile.setValue("tMHz", t_MH[2]); - iniFile.setValue("DynamicPoseResolution", dyn_pose_res); - iniFile.setValue("VideoWidget", video_widget); - iniFile.setValue("SleepTime", sleep_time); - iniFile.setValue("ResetTime", reset_time); - - iniFile.setValue( "EnableRoll", bEnableRoll ); - iniFile.setValue( "EnablePitch", bEnablePitch ); - iniFile.setValue( "EnableYaw", bEnableYaw ); - iniFile.setValue( "EnableX", bEnableX ); - iniFile.setValue( "EnableY", bEnableY ); - iniFile.setValue( "EnableZ", bEnableZ ); - - iniFile.endGroup(); -} - -//----------------------------------------------------------------------------- -void TrackerDialogSettings::load_ini() -{ - qDebug("TrackerDialogSettings::load_ini()"); - - 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( "PointTrackerDialog" ); - - active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt(); - M01x = iniFile.value("CustomM01x", 0).toInt(); - M01y = iniFile.value("CustomM01y", 40).toInt(); - M01z = iniFile.value("CustomM01z", -30).toInt(); - M02x = iniFile.value("CustomM02x", 0).toInt(); - M02y = iniFile.value("CustomM02y", -70).toInt(); - M02z = iniFile.value("CustomM02z", -80).toInt(); - clip_ty = iniFile.value("ClipTopHeight", 40).toInt(); - clip_tz = iniFile.value("ClipTopLength", 30).toInt(); - clip_by = iniFile.value("ClipBottomHeight", 70).toInt(); - clip_bz = iniFile.value("ClipBottomLength", 80).toInt(); - cap_x = iniFile.value("CapHalfWidth", 40).toInt(); - cap_y = iniFile.value("CapHeight", 60).toInt(); - cap_z = iniFile.value("CapLength", 100).toInt(); -} - -void TrackerDialogSettings::save_ini() const -{ - qDebug("TrackerDialogSettings::save_ini()"); - - 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 ( "PointTrackerDialog" ); - - iniFile.setValue("ActiveModelPanel", active_model_panel); - iniFile.setValue("CustomM01x", M01x); - iniFile.setValue("CustomM01y", M01y); - iniFile.setValue("CustomM01z", M01z); - iniFile.setValue("CustomM02x", M02x); - iniFile.setValue("CustomM02y", M02y); - iniFile.setValue("CustomM02z", M02z); - iniFile.setValue("ClipTopHeight", clip_ty); - iniFile.setValue("ClipTopLength", clip_tz); - iniFile.setValue("ClipBottomHeight", clip_by); - iniFile.setValue("ClipBottomLength", clip_bz); - iniFile.setValue("CapHalfWidth", cap_x); - iniFile.setValue("CapHeight", cap_y); - iniFile.setValue("CapLength", cap_z); -} \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h b/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h deleted file mode 100644 index 88162c86..00000000 --- a/FTNoIR_Tracker_PT/ftnoir_tracker_pt_settings.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef FTNOIR_TRACKER_PT_SETTINGS_H -#define FTNOIR_TRACKER_PT_SETTINGS_H - -#include -#include "point_tracker.h" - - -//----------------------------------------------------------------------------- -struct TrackerSettings -{ - // camera - int cam_index; - float cam_f; - int cam_res_x; - int cam_res_y; - int cam_fps; - int cam_pitch; - - // point extraction - int threshold; - int min_point_size; - int max_point_size; - - // point tracking - cv::Vec3f M01; - cv::Vec3f M02; - bool dyn_pose_res; - - // head to model translation - cv::Vec3f t_MH; - - int sleep_time; // in ms - int reset_time; // in ms - bool video_widget; - - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; - - void load_ini(); - void save_ini() const; -}; - - -//----------------------------------------------------------------------------- -struct TrackerDialogSettings -{ - enum - { - MODEL_CLIP, - MODEL_CAP, - MODEL_CUSTOM - }; - int active_model_panel; - - int M01x; - int M01y; - int M01z; - int M02x; - int M02y; - int M02z; - int clip_ty; - int clip_tz; - int clip_by; - int clip_bz; - int cap_x; - int cap_y; - int cap_z; - - void load_ini(); - void save_ini() const; -}; - -#endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/point_extractor.cpp b/FTNoIR_Tracker_PT/point_extractor.cpp deleted file mode 100644 index 4aa1a658..00000000 --- a/FTNoIR_Tracker_PT/point_extractor.cpp +++ /dev/null @@ -1,97 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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 "point_extractor.h" -#include - -using namespace cv; -using namespace std; - -// ---------------------------------------------------------------------------- -const vector& PointExtractor::extract_points(Mat frame, float dt, bool draw_output) -{ - /* - // sensitivity test for tracker - static int n = 0; - if (points.size() == 3) - { - for (int i=0; i<3; ++i) - { - points[i][0] -= 1e-4*sin(n/100.0); - points[i][1] -= 1e-4*cos(n/100.0); - } - ++n; - return points; - } - */ - - // convert to grayscale - Mat frame_bw; - cvtColor(frame, frame_bw, CV_RGB2GRAY); - - // convert to binary - threshold(frame_bw, frame_bw, threshold_val, 255, THRESH_BINARY); - //erode(frame_bw, frame_bw, Mat(), Point(-1,-1), min_size); //destroys information -> bad for subpixel accurarcy - - // find connected components... - // extract blobs with floodfill - struct BlobInfo - { - BlobInfo() : m00(0), m10(0), m01(0) {} - long m00; - long m10; - long m01; - }; - vector blobs; - int blob_count = 1; - - for (int y=0; y < frame_bw.rows; y++) { - for (int x=0; x < frame_bw.cols; x++) { - if (frame_bw.at(y,x) != 255) continue; - Rect rect; - floodFill(frame_bw, Point(x,y), Scalar(blob_count), &rect, Scalar(0), Scalar(0), 4); - BlobInfo blob; - for (int i=rect.y; i < (rect.y+rect.height); i++) { - for (int j=rect.x; j < (rect.x+rect.width); j++) { - if (frame_bw.at(i,j) != blob_count) continue; - blob.m00++; - blob.m01+=i; - blob.m10+=j; - } - } - blobs.push_back(blob); - blob_count++; - if (blob_count >= 255) break; - } - if (blob_count >= 255) break; - } - - // extract points - Vec2f c; - points.clear(); - float m00_min = 3.14*min_size*min_size; - float m00_max = 3.14*max_size*max_size; - for (vector::iterator iter = blobs.begin(); - iter!= blobs.end(); - ++iter) - { - const BlobInfo& m = *iter; - if (m.m00 < m00_min || m.m00 > m00_max) continue; - // convert to centered camera coordinate system with y axis upwards - c[0] = (m.m10/float(m.m00) - frame.cols/2)/frame.cols; - c[1] = -(m.m01/float(m.m00) - frame.rows/2)/frame.cols; - points.push_back(c); - } - - // draw output image - if (draw_output) - { - frame.setTo(Scalar(255,0,0), frame_bw); - } - - return points; -} diff --git a/FTNoIR_Tracker_PT/point_extractor.h b/FTNoIR_Tracker_PT/point_extractor.h deleted file mode 100644 index b142d2bb..00000000 --- a/FTNoIR_Tracker_PT/point_extractor.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef POINTEXTRACTOR_H -#define POINTEXTRACTOR_H - -#include - -// ---------------------------------------------------------------------------- -// Extracts points from an opencv image -class PointExtractor -{ -public: - // extracts points from frame and draws some processing info into frame, if draw_output is set - // dt: time since last call in seconds - // WARNING: returned reference is valid as long as object - const std::vector& extract_points(cv::Mat frame, float dt, bool draw_output); - const std::vector& get_points() { return points; } - - int threshold_val; - int min_size, max_size; - -protected: - std::vector points; -}; - -#endif //POINTEXTRACTOR_H diff --git a/FTNoIR_Tracker_PT/point_tracker.cpp b/FTNoIR_Tracker_PT/point_tracker.cpp deleted file mode 100644 index d617de19..00000000 --- a/FTNoIR_Tracker_PT/point_tracker.cpp +++ /dev/null @@ -1,352 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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 "point_tracker.h" - -#include -#include -#include - -#include - -using namespace cv; -using namespace boost; -using namespace std; - -const float PI = 3.14159265358979323846f; - -// ---------------------------------------------------------------------------- -static void get_row(const Matx33f& m, int i, Vec3f& v) -{ - v[0] = m(i,0); - v[1] = m(i,1); - v[2] = m(i,2); -} - -static void set_row(Matx33f& m, int i, const Vec3f& v) -{ - m(i,0) = v[0]; - m(i,1) = v[1]; - m(i,2) = v[2]; -} - -// ---------------------------------------------------------------------------- -PointModel::PointModel(Vec3f M01, Vec3f M02) - : M01(M01), M02(M02) -{ - // calculate u - u = M01.cross(M02); - u /= norm(u); - - // calculate projection matrix on M01,M02 plane - float s11 = M01.dot(M01); - float s12 = M01.dot(M02); - float s22 = M02.dot(M02); - P = 1.0/(s11*s22-s12*s12) * Matx22f(s22, -s12, - -s12, s11); - - // calculate d and d_order for simple freetrack-like point correspondence - vector points; - points.push_back(Vec2f(0,0)); - points.push_back(Vec2f(M01[0], M01[1])); - points.push_back(Vec2f(M02[0], M02[1])); - // fit line to orthographically projected points - // ERROR: yields wrong results with colinear points?! - /* - Vec4f line; - fitLine(points, line, CV_DIST_L2, 0, 0.01, 0.01); - d[0] = line[0]; d[1] = line[1]; - */ - // TODO: fix this - d = Vec2f(M01[0]-M02[0], M01[1]-M02[1]); - - // sort model points - get_d_order(points, d_order); -} - -void PointModel::get_d_order(const std::vector& points, int d_order[]) const -{ - // get sort indices with respect to d scalar product - vector< pair > d_vals; - for (int i = 0; i(d.dot(points[i]), i)); - - struct - { - bool operator()(const pair& a, const pair& b) { return a.first < b.first; } - } comp; - sort(d_vals.begin(), d_vals.end(), comp); - - for (int i = 0; i& points, float f, float dt) -{ - if (!dynamic_pose_resolution) init_phase = true; - - dt_valid += dt; - // if there was no valid tracking result for too long, do a reset - if (dt_valid > dt_reset) - { - //qDebug()<<"dt_valid "< dt_reset "<& points, float f) -{ - if (init_phase) { - // We do a simple freetrack-like sorting in the init phase... - // sort points - int point_d_order[PointModel::N_POINTS]; - point_model->get_d_order(points, point_d_order); - - // set correspondences - for (int i=0; id_order[i]] = points[point_d_order[i]]; - } - } - else { - // ... otherwise we look at the distance to the projection of the expected model points - // project model points under current pose - p_exp[0] = project(Vec3f(0,0,0), f); - p_exp[1] = project(point_model->M01, f); - p_exp[2] = project(point_model->M02, f); - - // set correspondences by minimum distance to projected model point - bool point_taken[PointModel::N_POINTS]; - for (int i=0; iM01)/Z0; - epsilon_2 = k.dot(point_model->M02)/Z0; - - // vector of scalar products and - Vec2f I0_M0i(p[1][0]*(1.0 + epsilon_1) - p[0][0], - p[2][0]*(1.0 + epsilon_2) - p[0][0]); - Vec2f J0_M0i(p[1][1]*(1.0 + epsilon_1) - p[0][1], - p[2][1]*(1.0 + epsilon_2) - p[0][1]); - - // construct projection of I, J onto M0i plane: I0 and J0 - I0_coeff = point_model->P * I0_M0i; - J0_coeff = point_model->P * J0_M0i; - I0 = I0_coeff[0]*point_model->M01 + I0_coeff[1]*point_model->M02; - J0 = J0_coeff[0]*point_model->M01 + J0_coeff[1]*point_model->M02; - - // calculate u component of I, J - float II0 = I0.dot(I0); - float IJ0 = I0.dot(J0); - float JJ0 = J0.dot(J0); - float rho, theta; - if (JJ0 == II0) { - rho = sqrt(abs(2*IJ0)); - theta = -PI/4; - if (IJ0<0) theta *= -1; - } - else { - rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 )); - theta = atan( -2*IJ0 / (JJ0-II0) ); - if (JJ0 - II0 < 0) theta += PI; - theta /= 2; - } - - // construct the two solutions - I_1 = I0 + rho*cos(theta)*point_model->u; - I_2 = I0 - rho*cos(theta)*point_model->u; - - J_1 = J0 + rho*sin(theta)*point_model->u; - J_2 = J0 - rho*sin(theta)*point_model->u; - - float norm_const = 1.0/norm(I_1); // all have the same norm - - // create rotation matrices - I_1 *= norm_const; J_1 *= norm_const; - I_2 *= norm_const; J_2 *= norm_const; - - set_row(R_1, 0, I_1); - set_row(R_1, 1, J_1); - set_row(R_1, 2, I_1.cross(J_1)); - - set_row(R_2, 0, I_2); - set_row(R_2, 1, J_2); - set_row(R_2, 2, I_2.cross(J_2)); - - // the single translation solution - Z0 = norm_const * f; - - // pick the rotation solution closer to the expected one - // in simple metric d(A,B) = || I - A * B^T || - float R_1_deviation = norm(Matx33f::eye() - R_expected * R_1.t()); - float R_2_deviation = norm(Matx33f::eye() - R_expected * R_2.t()); - - if (R_1_deviation < R_2_deviation) - R_current = &R_1; - else - R_current = &R_2; - - get_row(*R_current, 2, k); - - // check for convergence condition - if (abs(epsilon_1 - old_epsilon_1) + abs(epsilon_2 - old_epsilon_2) < EPS_THRESHOLD) - break; - old_epsilon_1 = epsilon_1; - old_epsilon_2 = epsilon_2; - } - - // apply results - X_CM.R = *R_current; - X_CM.t[0] = p[0][0] * Z0/f; - X_CM.t[1] = p[0][1] * Z0/f; - X_CM.t[2] = Z0; - - return i; - - //Rodrigues(X_CM.R, r); - //qDebug()<<"iter: "< -#include -#include - -// ---------------------------------------------------------------------------- -// Afine frame trafo -class FrameTrafo -{ -public: - FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} - FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} - - cv::Matx33f R; - cv::Vec3f t; -}; - -inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) -{ - return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); -} - -inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) -{ - return X.R*v + X.t; -} - -// ---------------------------------------------------------------------------- -// Describes a 3-point model -// nomenclature as in -// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] -class PointModel -{ - friend class PointTracker; -public: - static const int N_POINTS = 3; - - PointModel(cv::Vec3f M01, cv::Vec3f M02); - - const cv::Vec3f& get_M01() const { return M01; }; - const cv::Vec3f& get_M02() const { return M02; }; - -protected: - cv::Vec3f M01; // M01 in model frame - cv::Vec3f M02; // M02 in model frame - - cv::Vec3f u; // unit vector perpendicular to M01,M02-plane - - cv::Matx22f P; - - cv::Vec2f d; // discrimant vector for point correspondence - int d_order[3]; // sorting of projected model points with respect to d scalar product - - void get_d_order(const std::vector& points, int d_order[]) const; -}; - -// ---------------------------------------------------------------------------- -// Tracks a 3-point model -// implementing the POSIT algorithm for coplanar points as presented in -// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] -class PointTracker -{ -public: - PointTracker(); - - // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) - // f : (focal length)/(sensor width) - // dt : time since last call - bool track(const std::vector& points, float f, float dt); - boost::shared_ptr point_model; - - bool dynamic_pose_resolution; - float dt_reset; - - FrameTrafo get_pose() const { return X_CM; } - void reset(); - -protected: - inline cv::Vec2f project(const cv::Vec3f& v_M, float f) - { - cv::Vec3f v_C = X_CM * v_M; - return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); - } - - bool find_correspondences(const std::vector& points, float f); - - cv::Vec2f p[PointModel::N_POINTS]; // the points in model order - cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions - - void predict(float dt); - void update_velocities(float dt); - void reset_velocities(); - - - int POSIT(float f); // The POSIT algorithm, returns the number of iterations - - bool init_phase; - float dt_valid; // time since last valid tracking result - cv::Vec3f v_t; // velocities - cv::Vec3f v_r; - FrameTrafo X_CM; // trafo from model to camera - FrameTrafo X_CM_old; -}; - -#endif //POINTTRACKER_H diff --git a/FTNoIR_Tracker_PT/resource.h b/FTNoIR_Tracker_PT/resource.h deleted file mode 100644 index c14e94ad..00000000 --- a/FTNoIR_Tracker_PT/resource.h +++ /dev/null @@ -1,14 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by FTNoIR_Tracker_PT.rc - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/FTNoIR_Tracker_PT/timer.cpp b/FTNoIR_Tracker_PT/timer.cpp deleted file mode 100644 index 363b5b09..00000000 --- a/FTNoIR_Tracker_PT/timer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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 "timer.h" - -#include - -// ---------------------------------------------------------------------------- -Timer::Timer() -: startTime(0), endTime(0), running(false) -{ -#ifdef WIN32 - QueryPerformanceFrequency(&frequency); - startCount.QuadPart = 0; - endCount.QuadPart = 0; -#else - startCount.tv_sec = startCount.tv_usec = 0; - endCount.tv_sec = endCount.tv_usec = 0; -#endif -} - - -void Timer::start() -{ -#ifdef WIN32 - QueryPerformanceCounter(&startCount); -#else - gettimeofday(&startCount, NULL); -#endif - running = true; -} - - -void Timer::stop() -{ -#ifdef WIN32 - QueryPerformanceCounter(&endCount); -#else - gettimeofday(&endCount, NULL); -#endif - running = false; -} - - -double Timer::elapsed() -{ -#ifdef WIN32 - if (running) - QueryPerformanceCounter(&endCount); - - startTime = startCount.QuadPart * (1e3 / frequency.QuadPart); - endTime = endCount.QuadPart * (1e3 / frequency.QuadPart); -#else - if(!stopped) - gettimeofday(&endCount, NULL); - - startTime = (startCount.tv_sec * 1e3) + startCount.tv_usec; - endTime = (endCount.tv_sec * 1e3) + endCount.tv_usec; -#endif - - return endTime - startTime; -} \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/timer.h b/FTNoIR_Tracker_PT/timer.h deleted file mode 100644 index 2aaf725a..00000000 --- a/FTNoIR_Tracker_PT/timer.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef PT_TIMER_H -#define PT_TIMER_H - -#ifdef WIN32 // Windows system specific -#include -#else // Unix based system specific -#include -#endif - -// ---------------------------------------------------------------------------- -// high resolution timer based on http://www.songho.ca/misc/timer/timer.html -class Timer -{ -public: - Timer(); - - void start(); - void stop(); - void restart() { start(); } // for Qt compatibility - double elapsed(); // get elapsed time in ms - -protected: - double startTime; // starting time in ms - double endTime; // ending time in ms - bool running; - -#ifdef WIN32 - LARGE_INTEGER frequency; // ticks per second - LARGE_INTEGER startCount; - LARGE_INTEGER endCount; -#else - timeval startCount; - timeval endCount; -#endif -}; - -#endif //PT_TIMER_H \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/trans_calib.cpp b/FTNoIR_Tracker_PT/trans_calib.cpp deleted file mode 100644 index 9b75a1b6..00000000 --- a/FTNoIR_Tracker_PT/trans_calib.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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 "trans_calib.h" - -using namespace cv; - -//----------------------------------------------------------------------------- -TranslationCalibrator::TranslationCalibrator() -{ - reset(); -} - -void TranslationCalibrator::reset() -{ - P = Matx66f::zeros(); - y = Vec6f(0,0,0, 0,0,0); -} - -void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) -{ - Matx H_k_T = Matx::zeros(); - for (int i=0; i<3; ++i) { - for (int j=0; j<3; ++j) { - H_k_T(i,j) = R_CM_k(j,i); - } - } - for (int i=0; i<3; ++i) - { - H_k_T(3+i,i) = 1.0; - } - P += H_k_T * H_k_T.t(); - y += H_k_T * t_CM_k; -} - -Vec3f TranslationCalibrator::get_estimate() -{ - Vec6f x = P.inv() * y; - return Vec3f(-x[0], -x[1], -x[2]); -} \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/trans_calib.h b/FTNoIR_Tracker_PT/trans_calib.h deleted file mode 100644 index 4024d011..00000000 --- a/FTNoIR_Tracker_PT/trans_calib.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef TRANSCALIB_H -#define TRANSCALIB_H - -#include - -//----------------------------------------------------------------------------- -// calibrates the translation from head to model = t_MH -// by recursive least squares / -// kalman filter in information form with identity noise covariance -// measurement equation when head position = t_CH is fixed: -// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k - -class TranslationCalibrator -{ -public: - TranslationCalibrator(); - - // reset the calibration process - void reset(); - - // update the current estimate - void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); - - // get the current estimate for t_MH - cv::Vec3f get_estimate(); - -protected: - cv::Matx66f P; // normalized precision matrix = inverse covariance - cv::Vec6f y; // P*(-t_MH, t_CH) -}; - -#endif //TRANSCALIB_H \ No newline at end of file diff --git a/FTNoIR_Tracker_PT/videoInput/videoInput.h b/FTNoIR_Tracker_PT/videoInput/videoInput.h deleted file mode 100644 index 4244902c..00000000 --- a/FTNoIR_Tracker_PT/videoInput/videoInput.h +++ /dev/null @@ -1,385 +0,0 @@ -#ifndef _VIDEOINPUT -#define _VIDEOINPUT - -//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -//THE SOFTWARE. - -////////////////////////////////////////////////////////// -//Written by Theodore Watson - theo.watson@gmail.com // -//Do whatever you want with this code but if you find // -//a bug or make an improvement I would love to know! // -// // -//Warning This code is experimental // -//use at your own risk :) // -////////////////////////////////////////////////////////// -///////////////////////////////////////////////////////// -/* Shoutouts - -Thanks to: - - Dillip Kumar Kara for crossbar code. - Zachary Lieberman for getting me into this stuff - and for being so generous with time and code. - The guys at Potion Design for helping me with VC++ - Josh Fisher for being a serious C++ nerd :) - Golan Levin for helping me debug the strangest - and slowest bug in the world! - - And all the people using this library who send in - bugs, suggestions and improvements who keep me working on - the next version - yeah thanks a lot ;) - -*/ -///////////////////////////////////////////////////////// - - - -#include -#include -#include -#include -#include - -//this is for TryEnterCriticalSection -#ifndef _WIN32_WINNT - # define _WIN32_WINNT 0x400 -#endif -#include - - -//Example Usage -/* - //create a videoInput object - videoInput VI; - - //Prints out a list of available devices and returns num of devices found - int numDevices = VI.listDevices(); - - int device1 = 0; //this could be any deviceID that shows up in listDevices - int device2 = 1; //this could be any deviceID that shows up in listDevices - - //if you want to capture at a different frame rate (default is 30) - //specify it here, you are not guaranteed to get this fps though. - //VI.setIdealFramerate(dev, 60); - - //setup the first device - there are a number of options: - - VI.setupDevice(device1); //setup the first device with the default settings - //VI.setupDevice(device1, VI_COMPOSITE); //or setup device with specific connection type - //VI.setupDevice(device1, 320, 240); //or setup device with specified video size - //VI.setupDevice(device1, 320, 240, VI_COMPOSITE); //or setup device with video size and connection type - - //VI.setFormat(device1, VI_NTSC_M); //if your card doesn't remember what format it should be - //call this with the appropriate format listed above - //NOTE: must be called after setupDevice! - - //optionally setup a second (or third, fourth ...) device - same options as above - VI.setupDevice(device2); - - //As requested width and height can not always be accomodated - //make sure to check the size once the device is setup - - int width = VI.getWidth(device1); - int height = VI.getHeight(device1); - int size = VI.getSize(device1); - - unsigned char * yourBuffer1 = new unsigned char[size]; - unsigned char * yourBuffer2 = new unsigned char[size]; - - //to get the data from the device first check if the data is new - if(VI.isFrameNew(device1)){ - VI.getPixels(device1, yourBuffer1, false, false); //fills pixels as a BGR (for openCV) unsigned char array - no flipping - VI.getPixels(device1, yourBuffer2, true, true); //fills pixels as a RGB (for openGL) unsigned char array - flipping! - } - - //same applies to device2 etc - - //to get a settings dialog for the device - VI.showSettingsWindow(device1); - - - //Shut down devices properly - VI.stopDevice(device1); - VI.stopDevice(device2); -*/ - - -////////////////////////////////////// VARS AND DEFS ////////////////////////////////// - - -//STUFF YOU CAN CHANGE - -//change for verbose debug info -static bool verbose = true; - -//if you need VI to use multi threaded com -//#define VI_COM_MULTI_THREADED - -//STUFF YOU DON'T CHANGE - -//videoInput defines -#define VI_VERSION 0.1995 -#define VI_MAX_CAMERAS 20 -#define VI_NUM_TYPES 18 //DON'T TOUCH -#define VI_NUM_FORMATS 18 //DON'T TOUCH - -//defines for setPhyCon - tuner is not as well supported as composite and s-video -#define VI_COMPOSITE 0 -#define VI_S_VIDEO 1 -#define VI_TUNER 2 -#define VI_USB 3 -#define VI_1394 4 - -//defines for formats -#define VI_NTSC_M 0 -#define VI_PAL_B 1 -#define VI_PAL_D 2 -#define VI_PAL_G 3 -#define VI_PAL_H 4 -#define VI_PAL_I 5 -#define VI_PAL_M 6 -#define VI_PAL_N 7 -#define VI_PAL_NC 8 -#define VI_SECAM_B 9 -#define VI_SECAM_D 10 -#define VI_SECAM_G 11 -#define VI_SECAM_H 12 -#define VI_SECAM_K 13 -#define VI_SECAM_K1 14 -#define VI_SECAM_L 15 -#define VI_NTSC_M_J 16 -#define VI_NTSC_433 17 - - -//allows us to directShow classes here with the includes in the cpp -struct ICaptureGraphBuilder2; -struct IGraphBuilder; -struct IBaseFilter; -struct IAMCrossbar; -struct IMediaControl; -struct ISampleGrabber; -struct IMediaEventEx; -struct IAMStreamConfig; -struct _AMMediaType; -class SampleGrabberCallback; -typedef _AMMediaType AM_MEDIA_TYPE; - -//keeps track of how many instances of VI are being used -//don't touch -static int comInitCount = 0; - - -//////////////////////////////////////// VIDEO DEVICE /////////////////////////////////// - -class videoDevice{ - - - public: - - videoDevice(); - void setSize(int w, int h); - void NukeDownstream(IBaseFilter *pBF); - void destroyGraph(); - ~videoDevice(); - - int videoSize; - int width; - int height; - int tryWidth; - int tryHeight; - - ICaptureGraphBuilder2 *pCaptureGraph; // Capture graph builder object - IGraphBuilder *pGraph; // Graph builder object - IMediaControl *pControl; // Media control object - IBaseFilter *pVideoInputFilter; // Video Capture filter - IBaseFilter *pGrabberF; - IBaseFilter * pDestFilter; - IAMStreamConfig *streamConf; - ISampleGrabber * pGrabber; // Grabs frame - AM_MEDIA_TYPE * pAmMediaType; - - IMediaEventEx * pMediaEvent; - - GUID videoType; - long formatType; - - SampleGrabberCallback * sgCallback; - - bool tryDiffSize; - bool useCrossbar; - bool readyToCapture; - bool sizeSet; - bool setupStarted; - bool specificFormat; - bool autoReconnect; - int nFramesForReconnect; - unsigned long nFramesRunning; - int connection; - int storeConn; - int myID; - long requestedFrameTime; //ie fps - - char nDeviceName[255]; - WCHAR wDeviceName[255]; - - unsigned char * pixels; - char * pBuffer; - -}; - - - - -////////////////////////////////////// VIDEO INPUT ///////////////////////////////////// - - - -class videoInput{ - - public: - videoInput(); - ~videoInput(); - - //turns off console messages - default is to print messages - static void setVerbose(bool _verbose); - - //Functions in rough order they should be used. - static int listDevices(bool silent = false); - - //needs to be called after listDevices - otherwise returns NULL - static char * getDeviceName(int deviceID); - - //choose to use callback based capture - or single threaded - void setUseCallback(bool useCallback); - - //call before setupDevice - //directshow will try and get the closest possible framerate to what is requested - void setIdealFramerate(int deviceID, int idealFramerate); - - //some devices will stop delivering frames after a while - this method gives you the option to try and reconnect - //to a device if videoInput detects that a device has stopped delivering frames. - //you MUST CALL isFrameNew every app loop for this to have any effect - void setAutoReconnectOnFreeze(int deviceNumber, bool doReconnect, int numMissedFramesBeforeReconnect); - - //Choose one of these four to setup your device - bool setupDevice(int deviceID); - bool setupDevice(int deviceID, int w, int h); - - //These two are only for capture cards - //USB and Firewire cameras souldn't specify connection - bool setupDevice(int deviceID, int connection); - bool setupDevice(int deviceID, int w, int h, int connection); - - //If you need to you can set your NTSC/PAL/SECAM - //preference here. if it is available it will be used. - //see #defines above for available formats - eg VI_NTSC_M or VI_PAL_B - //should be called after setupDevice - //can be called multiple times - bool setFormat(int deviceNumber, int format); - - //Tells you when a new frame has arrived - you should call this if you have specified setAutoReconnectOnFreeze to true - bool isFrameNew(int deviceID); - - bool isDeviceSetup(int deviceID); - - //Returns the pixels - flipRedAndBlue toggles RGB/BGR flipping - and you can flip the image too - unsigned char * getPixels(int deviceID, bool flipRedAndBlue = true, bool flipImage = false); - - //Or pass in a buffer for getPixels to fill returns true if successful. - bool getPixels(int id, unsigned char * pixels, bool flipRedAndBlue = true, bool flipImage = false); - - //Launches a pop up settings window - //For some reason in GLUT you have to call it twice each time. - void showSettingsWindow(int deviceID); - - //Manual control over settings thanks..... - //These are experimental for now. - bool setVideoSettingFilter(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); - bool setVideoSettingFilterPct(int deviceID, long Property, float pctValue, long Flags = NULL); - bool getVideoSettingFilter(int deviceID, long Property, long &min, long &max, long &SteppingDelta, long ¤tValue, long &flags, long &defaultValue); - - bool setVideoSettingCamera(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); - bool setVideoSettingCameraPct(int deviceID, long Property, float pctValue, long Flags = NULL); - bool getVideoSettingCamera(int deviceID, long Property, long &min, long &max, long &SteppingDelta, long ¤tValue, long &flags, long &defaultValue); - - //bool setVideoSettingCam(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); - - //get width, height and number of pixels - int getWidth(int deviceID); - int getHeight(int deviceID); - int getSize(int deviceID); - - //completely stops and frees a device - void stopDevice(int deviceID); - - //as above but then sets it up with same settings - bool restartDevice(int deviceID); - - //number of devices available - int devicesFound; - - long propBrightness; - long propContrast; - long propHue; - long propSaturation; - long propSharpness; - long propGamma; - long propColorEnable; - long propWhiteBalance; - long propBacklightCompensation; - long propGain; - - long propPan; - long propTilt; - long propRoll; - long propZoom; - long propExposure; - long propIris; - long propFocus; - - - private: - void setPhyCon(int deviceID, int conn); - void setAttemptCaptureSize(int deviceID, int w, int h); - bool setup(int deviceID); - void processPixels(unsigned char * src, unsigned char * dst, int width, int height, bool bRGB, bool bFlip); - int start(int deviceID, videoDevice * VD); - int getDeviceCount(); - void getMediaSubtypeAsString(GUID type, char * typeAsString); - - HRESULT getDevice(IBaseFilter **pSrcFilter, int deviceID, WCHAR * wDeviceName, char * nDeviceName); - static HRESULT ShowFilterPropertyPages(IBaseFilter *pFilter); - HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath); - HRESULT routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter **pVidInFilter, int conType, GUID captureMode); - - //don't touch - static bool comInit(); - static bool comUnInit(); - - int connection; - int callbackSetCount; - bool bCallback; - - GUID CAPTURE_MODE; - - //Extra video subtypes - GUID MEDIASUBTYPE_Y800; - GUID MEDIASUBTYPE_Y8; - GUID MEDIASUBTYPE_GREY; - - videoDevice * VDList[VI_MAX_CAMERAS]; - GUID mediaSubtypes[VI_NUM_TYPES]; - long formatTypes[VI_NUM_FORMATS]; - - static void __cdecl basicThread(void * objPtr); - - static char deviceNames[VI_MAX_CAMERAS][255]; - -}; - - #endif diff --git a/FTNoIR_Tracker_PT/videoInput/videoInput_vc8.lib b/FTNoIR_Tracker_PT/videoInput/videoInput_vc8.lib deleted file mode 100644 index 15ca9cf3..00000000 Binary files a/FTNoIR_Tracker_PT/videoInput/videoInput_vc8.lib and /dev/null differ diff --git a/FTNoIR_Tracker_PT/videoInput/videoInput_vc9.lib b/FTNoIR_Tracker_PT/videoInput/videoInput_vc9.lib deleted file mode 100644 index 32637cc9..00000000 Binary files a/FTNoIR_Tracker_PT/videoInput/videoInput_vc9.lib and /dev/null differ diff --git a/FTNoIR_Tracker_PT/video_widget.cpp b/FTNoIR_Tracker_PT/video_widget.cpp deleted file mode 100644 index c2b41da1..00000000 --- a/FTNoIR_Tracker_PT/video_widget.cpp +++ /dev/null @@ -1,98 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - * - * 20130312, WVR: Add 7 lines to resizeGL after resize_frame. This should lower CPU-load. - */ - -#include "video_widget.h" - -#include - -using namespace cv; -using namespace std; -using namespace boost; - -// ---------------------------------------------------------------------------- -void VideoWidget::initializeGL() -{ - glClearColor(0.0, 0.0, 0.0, 0.0); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); -} - -void VideoWidget::resizeGL(int w, int h) -{ - // setup 1 to 1 projection - glViewport(0, 0, w, h); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - glOrtho(0, w, 0, h, -1, 1); - resize_frame(); - glDisable(GL_DEPTH_TEST); - glBegin(GL_QUADS); - glVertex2f(0,0); - glVertex2f(1,0); - glVertex2f(1,1); - glVertex2f(0,1); - glEnd(); -} - -void VideoWidget::paintGL() -{ - glClear(GL_COLOR_BUFFER_BIT); - if (!resized_qframe.isNull()) - { - glDrawPixels(resized_qframe.width(), resized_qframe.height(), GL_RGBA, GL_UNSIGNED_BYTE, resized_qframe.bits()); - - const int crosshair_radius = 10; - const int crosshair_thickness = 1; - - glColor3f(1.0, 0.0, 0.0); - glLineWidth(crosshair_thickness); - int x,y; - for (vector::iterator iter = points->begin(); - iter != points->end(); - ++iter) - { - x = (*iter)[0] * resized_qframe.width() + resized_qframe.width()/2.0 + 0.5; - y = (*iter)[1] * resized_qframe.width() + resized_qframe.height()/2.0 + 0.5; - - glBegin(GL_LINES); - glVertex2i(x-crosshair_radius, y); - glVertex2i(x+crosshair_radius, y); - glEnd(); - glBegin(GL_LINES); - glVertex2i(x, y-crosshair_radius); - glVertex2i(x, y+crosshair_radius); - glEnd(); - } - } - glFlush(); -} - - -void VideoWidget::resize_frame() -{ - if (!qframe.isNull()) - resized_qframe = qframe.scaled(this->size(), Qt::KeepAspectRatio); -} - - -void VideoWidget::update(Mat frame, shared_ptr< vector > points) -{ - this->frame = frame; - this->points = points; - - // convert to QImage - if (frame.channels() == 3) - qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888).rgbSwapped(); - else if (frame.channels() == 1) - qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_Indexed8); - qframe = QGLWidget::convertToGLFormat(qframe); - - resize_frame(); - updateGL(); -} diff --git a/FTNoIR_Tracker_PT/video_widget.h b/FTNoIR_Tracker_PT/video_widget.h deleted file mode 100644 index f49fef18..00000000 --- a/FTNoIR_Tracker_PT/video_widget.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef VIDEOWIDGET_H -#define VIDEOWIDGET_H - -#include -#include -#include -#include - -// ---------------------------------------------------------------------------- -class VideoWidget : public QGLWidget -{ - Q_OBJECT - -public: - VideoWidget(QWidget *parent) : QGLWidget(parent) {} - - void initializeGL(); - void resizeGL(int w, int h); - void paintGL(); - - void update(cv::Mat frame, boost::shared_ptr< std::vector > points); - -private: - void resize_frame(); - - cv::Mat frame; - QImage qframe; - QImage resized_qframe; - - boost::shared_ptr< std::vector > points; -}; - -#endif // VIDEOWIDGET_H diff --git a/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui b/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui deleted file mode 100644 index 93befd19..00000000 --- a/FTNoIR_Tracker_SM/FTNoIR_SM_Controls.ui +++ /dev/null @@ -1,405 +0,0 @@ - - - UICSMClientControls - - - - 0 - 0 - 388 - 313 - - - - faceAPI tracker settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 100 - 0 - - - - wait... - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Camera - - - - - - - Start - - - - - - - Stop - - - - - - - Engine state: - - - - - - - Internal filtering: - - - - - - - - - - - - - 0 - 140 - - - - Enable Axis - - - - - 10 - 20 - 55 - 110 - - - - - - - Roll: - - - - - - - Pitch: - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - X: - - - - - - - Y: - - - - - - - Z: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 100 - 16777215 - - - - Save - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - btnOK - btnCancel - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h deleted file mode 100644 index b7aed1d0..00000000 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.h +++ /dev/null @@ -1,157 +0,0 @@ -/******************************************************************************** -* 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" - -#include -#include -#include -#include "Windows.h" -#include "math.h" - -using namespace std; - -class FTNoIR_Tracker : public ITracker -{ -public: - FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - - void Initialize( QFrame *videoframe ); - void StartTracker( HWND parent_window ); - void StopTracker( bool exit ); - bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good - - void loadSettings(); - bool SMCreateMapping(); - -private: - // - // global variables - // - HANDLE hSMMemMap; - SMMemMap *pMemData; - HANDLE hSMMutex; - QProcess *faceAPI; - -// int numTracker; - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; -}; - -// Widget that has controls for SMoIR protocol client-settings. -class TrackerControls: public QWidget, Ui::UICSMClientControls, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) { - theTracker = (FTNoIR_Tracker *) tracker; // Accept the pointer to the Tracker - }; - void unRegisterTracker() { - theTracker = NULL; // Reset the pointer - }; - -private: - Ui::UICSMClientControls ui; - void loadSettings(); - bool SMCreateMapping(); - void doCommand( int command ); - void doCommand( int command, int value ); - - /** helper **/ - bool settingsDirty; - int prev_state; // Previous engine state - - // - // global variables - // - HANDLE hSMMemMap; - SMMemMap *pMemData; - HANDLE hSMMutex; - smEngineHandle *engine_handle; - QTimer *timUpdateSettings; // Timer to display current settings - - FTNoIR_Tracker *theTracker; - -private slots: - void doOK(); - void doCancel(); - void save(); - void settingChanged() { settingsDirty = true; }; - void doTimUpdate(); - void showSettings( int newState ); - void doStartEngine(){ - doCommand(FT_SM_START); - } - void doStopEngine(){ - doCommand(FT_SM_STOP); - } - void doShowCam(){ - doCommand(FT_SM_SHOW_CAM); - } - void doSetFilter(int value){ - doCommand(FT_SM_SET_PAR_FILTER, value); - } - void settingChanged(int dummy) { - settingsDirty = true; - }; - -signals: - void stateChanged(int newState); - -}; - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class FTNoIR_TrackerDll : public ITrackerDll -{ -public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - - void Initialize(); - - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; -}; diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user deleted file mode 100644 index 12f78238..00000000 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc8.vcproj b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc8.vcproj deleted file mode 100644 index 2efa6022..00000000 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc8.vcproj +++ /dev/null @@ -1,413 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc9.vcproj b/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc9.vcproj deleted file mode 100644 index 8fbfae89..00000000 --- a/FTNoIR_Tracker_SM/FTNoIR_Tracker_SM_vc9.vcproj +++ /dev/null @@ -1,405 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_SM/Tracker.qrc b/FTNoIR_Tracker_SM/Tracker.qrc deleted file mode 100644 index b76ff1b2..00000000 --- a/FTNoIR_Tracker_SM/Tracker.qrc +++ /dev/null @@ -1,5 +0,0 @@ - - - images/SeeingMachines.ico - - diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp deleted file mode 100644 index 624e35a0..00000000 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi.cpp +++ /dev/null @@ -1,254 +0,0 @@ -/******************************************************************************** -* 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 - -FTNoIR_Tracker::FTNoIR_Tracker() -{ -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - qDebug() << "~FTNoIR_Tracker says: cleaning up"; - - if ( pMemData != NULL ) { - UnmapViewOfFile ( pMemData ); - } - - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; - - CloseHandle( hSMMutex ); - CloseHandle( hSMMemMap ); - hSMMemMap = 0; -} - -void FTNoIR_Tracker::Initialize( QFrame *videoframe ) -{ - qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; - - if (SMCreateMapping()) { - qDebug() << "FTNoIR_Tracker::Initialize Mapping created."; - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); - } - - loadSettings(); - - if ( pMemData != NULL ) { - pMemData->command = 0; // Reset any and all commands - if (videoframe != NULL) { - pMemData->handle = videoframe->winId(); // Handle of Videoframe widget - } - else { - pMemData->handle = NULL; // reset Handle of Videoframe widget - } - } - - // - // Start FTNoIR_FaceAPI_EXE.exe. The exe contains all faceAPI-stuff and is non-Qt... - // - QString program = "FTNoIR_FaceAPI_EXE.exe"; - faceAPI = new QProcess(0); - faceAPI->start(program); - - // Show the video widget - qDebug() << "FTNoIR_Tracker::Initialize says: videoframe = " << videoframe; - - if (videoframe != NULL) { - videoframe->show(); - } - return; -} - -void FTNoIR_Tracker::StartTracker( HWND parent_window ) -{ - if ( pMemData != NULL ) { - pMemData->command = FT_SM_START; // Start command - } - return; -} - -void FTNoIR_Tracker::StopTracker( bool exit ) -{ - - qDebug() << "FTNoIR_Tracker::StopTracker says: Starting "; - // stops the faceapi engine - if ( pMemData != NULL ) { -// if (exit == true) { - pMemData->command = (exit) ? FT_SM_EXIT : FT_SM_STOP; // Issue 'stop' command - //} - //else { - // pMemData->command = FT_SM_STOP; // Issue 'stop' command - //} - } - return; -} - -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::GiveHeadPoseData says: Retrieving data."; - - // - // Copy the measurements to FaceTrackNoIR. - // - if (bEnableX) { - data->x = pMemData->data.new_pose.head_pos.x * 100.0f; // From meters to centimeters - } - if (bEnableY) { - data->y = pMemData->data.new_pose.head_pos.y * 100.0f; - } - if (bEnableZ) { - data->z = pMemData->data.new_pose.head_pos.z * 100.0f; - } - if (bEnableYaw) { - data->yaw = pMemData->data.new_pose.head_rot.y_rads * 57.295781f; // From rads to degrees - } - if (bEnablePitch) { - data->pitch = pMemData->data.new_pose.head_rot.x_rads * 57.295781f; - } - if (bEnableRoll) { - data->roll = pMemData->data.new_pose.head_rot.z_rads * 57.295781f; - } - - // - // Reset the handshake, to let faceAPI know we're still here! - // - pMemData->handshake = 0; - - ReleaseMutex(hSMMutex); - return ( pMemData->data.new_pose.confidence > 0 ); - } - return false; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Tracker::loadSettings() { - - 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::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "SMTracker" ); - if (pMemData) { - pMemData->initial_filter_level = iniFile.value ( "FilterLevel", 1 ).toInt(); - } - - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); - - iniFile.endGroup (); -} - -// -// Create a memory-mapping to the faceAPI data. -// It contains the tracking data, a command-code from FaceTrackNoIR -// -// -bool FTNoIR_Tracker::SMCreateMapping() -{ - qDebug() << "FTNoIR_Tracker::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() << "FTNoIR_Tracker::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() << "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::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::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; -} - - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTracker - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTracker@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() -{ - return new FTNoIR_Tracker; -} diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp deleted file mode 100644 index 5c422402..00000000 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dialog.cpp +++ /dev/null @@ -1,346 +0,0 @@ -/******************************************************************************** -* 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 - -//******************************************************************************************************* -// faceAPI Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -TrackerControls::TrackerControls() : -QWidget() -{ - ui.setupUi( this ); - - theTracker = NULL; - prev_state = -1; - - // 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())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); - - 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() << "TrackerControls::Initialize Mapping created."; - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); - } - - //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 ))); - - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(200, 200); - if (parent) { - this->move(parent->pos() + offsetpos); - } - - // Load the settings from the current .INI-file - loadSettings(); - - show(); -} - -// -// OK clicked on server-dialog -// -void TrackerControls::doOK() { - save(); - this->close(); -} - -// override show event -void TrackerControls::showEvent ( QShowEvent * event ) { - prev_state = -1; - loadSettings(); -} - -// -// 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 ); - - 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 TrackerControls::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()); - - ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); - ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); - ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); - - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::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.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); - iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); - iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); - - iniFile.endGroup (); - - // - // If the Tracker is active, let it load the new Settings. - // - if (theTracker) { - theTracker->loadSettings(); - } - - settingsDirty = false; -} - -// -// Create a memory-mapping to the faceAPI data. -// It contains the tracking data, a command-code from FaceTrackNoIR -// -// -bool TrackerControls::SMCreateMapping() -{ - qDebug() << "TrackerControls::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() << "TrackerControls::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() << "TrackerControls::FTCreateMapping says: FileMapping Created again..." << hSMMemMap; - pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFaceData)); - if (pMemData != NULL) { - qDebug() << "TrackerControls::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() << "TrackerControls::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 TrackerControls::doTimUpdate() -{ - int state = pMemData->state; - if ( state != prev_state) { - emit stateChanged(state); - prev_state = state; - } -} - -// -// Show the current engine-settings etc. -// -void TrackerControls::showSettings( int newState ) -{ - qDebug() << "TrackerControls::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 TrackerControls::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 TrackerControls::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 ITrackerDialogPtr __stdcall GetTrackerDialog( ) -{ - return new TrackerControls; -} diff --git a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dll.cpp b/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dll.cpp deleted file mode 100644 index 5f01568f..00000000 --- a/FTNoIR_Tracker_SM/ftnoir_tracker_faceapi_dll.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The TrackerDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_tracker_sm.h" -#include - -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "faceAPI V3.2.6"; - trackerShortName = "faceAPI"; - trackerDescription = "SeeingMachines faceAPI V3.2.6"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - -void FTNoIR_TrackerDll::Initialize() -{ - return; -} - -void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = trackerFullName; -}; - -void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = trackerShortName; -}; - -void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = trackerDescription; -}; - -void FTNoIR_TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/SeeingMachines.ico"); -}; - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() -{ - return new FTNoIR_TrackerDll; -} diff --git a/FTNoIR_Tracker_SM/images/SeeingMachines.ico b/FTNoIR_Tracker_SM/images/SeeingMachines.ico deleted file mode 100644 index 19b24c84..00000000 Binary files a/FTNoIR_Tracker_SM/images/SeeingMachines.ico and /dev/null differ diff --git a/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui b/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui deleted file mode 100644 index 7ac6c0f4..00000000 --- a/FTNoIR_Tracker_UDP/FTNoIR_FTNClientControls.ui +++ /dev/null @@ -1,381 +0,0 @@ - - - UICFTNClientControls - - - - 0 - 0 - 411 - 210 - - - - FTNoIR tracker settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - Port-number - - - - - - - 5550 - - - 10000 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 0 - 85 - - - - Enable Axis - - - - - 10 - 20 - 143 - 60 - - - - - - - Roll: - - - - - - - Pitch: - - - - - - - Yaw: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - X: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Y: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Z: - - - - - - - - 20 - 16777215 - - - - Qt::LeftToRight - - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Minimum - - - - 40 - 20 - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Enter the port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinPortNumber - btnOK - btnCancel - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h deleted file mode 100644 index 94645c84..00000000 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP.h +++ /dev/null @@ -1,99 +0,0 @@ -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include "ui_FTNoIR_FTNClientcontrols.h" -#include -#include -#include -#include -#include "Windows.h" -#include "math.h" - -class FTNoIR_Tracker : public ITracker, QThread -{ -public: - FTNoIR_Tracker(); - ~FTNoIR_Tracker(); - - void Initialize( QFrame *videoframe ); - void StartTracker( HWND parent_window ); - void StopTracker( bool exit ); - bool GiveHeadPoseData(THeadPoseData *data); - void loadSettings(); - -protected: - void run(); // qthread override run method - -private: - // Handles to neatly terminate thread... - HANDLE m_StopThread; - HANDLE m_WaitThread; - - // UDP socket-variables - QUdpSocket *inSocket; // Receive from ... - QUdpSocket *outSocket; // Send to ... - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - QHostAddress srcIP; // Source IP-address - int srcPort; // Source port-number - - THeadPoseData newHeadPose; // Structure with new headpose - - float portAddress; // Port-number - bool bEnableRoll; - bool bEnablePitch; - bool bEnableYaw; - bool bEnableX; - bool bEnableY; - bool bEnableZ; -}; - -// Widget that has controls for FTNoIR protocol client-settings. -class TrackerControls: public QWidget, Ui::UICFTNClientControls, public ITrackerDialog -{ - Q_OBJECT -public: - - explicit TrackerControls(); - virtual ~TrackerControls(); - void showEvent ( QShowEvent * event ); - - void Initialize(QWidget *parent); - void registerTracker(ITracker *tracker) {}; - void unRegisterTracker() {}; - -private: - Ui::UICFTNClientControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; - void settingChanged(int) { settingsDirty = true; }; -}; - -//******************************************************************************************************* -// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker -//******************************************************************************************************* -class FTNoIR_TrackerDll : public ITrackerDll -{ -public: - FTNoIR_TrackerDll(); - ~FTNoIR_TrackerDll(); - - void Initialize(); - - void getFullName(QString *strToBeFilled); - void getShortName(QString *strToBeFilled); - void getDescription(QString *strToBeFilled); - void getIcon(QIcon *icon); - -private: - QString trackerFullName; // Trackers' name and description - QString trackerShortName; - QString trackerDescription; -}; - diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc8.vcproj b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc8.vcproj deleted file mode 100644 index d855e3c2..00000000 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc8.vcproj +++ /dev/null @@ -1,338 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc9.vcproj b/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc9.vcproj deleted file mode 100644 index fa465ec9..00000000 --- a/FTNoIR_Tracker_UDP/FTNoIR_Tracker_UDP_vc9.vcproj +++ /dev/null @@ -1,335 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp deleted file mode 100644 index 102c85bd..00000000 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp.cpp +++ /dev/null @@ -1,217 +0,0 @@ -/******************************************************************************** -* 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_udp.h" - -FTNoIR_Tracker::FTNoIR_Tracker() -{ - inSocket = 0; - outSocket = 0; - - // Create events - m_StopThread = CreateEvent(0, TRUE, FALSE, 0); - m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); - - bEnableRoll = true; - bEnablePitch = true; - bEnableYaw = true; - bEnableX = true; - bEnableY = true; - bEnableZ = true; - portAddress = 5551; - - newHeadPose.x = 0.0f; - newHeadPose.y = 0.0f; - newHeadPose.z = 0.0f; - newHeadPose.yaw = 0.0f; - newHeadPose.pitch = 0.0f; - newHeadPose.roll = 0.0f; -} - -FTNoIR_Tracker::~FTNoIR_Tracker() -{ - // Trigger thread to stop - ::SetEvent(m_StopThread); - - // Wait until thread finished - if (isRunning()) { - ::WaitForSingleObject(m_WaitThread, INFINITE); - } - - // Close handles - ::CloseHandle(m_StopThread); - ::CloseHandle(m_WaitThread); - - if (inSocket) { - inSocket->close(); - delete inSocket; - } - - if (outSocket) { - outSocket->close(); - delete outSocket; - } -} - -/** QThread run @override **/ -void FTNoIR_Tracker::run() { - -int no_bytes; -QHostAddress sender; -quint16 senderPort; - - // - // Read the data that was received. - // - forever { - - // Check event for stop thread - if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) - { - // Set event - ::SetEvent(m_WaitThread); - qDebug() << "FTNoIR_Tracker::run() terminated run()"; - return; - } - - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - - inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort); - } - } - else { - qDebug() << "FTNoIR_Tracker::run() insocket not ready: exit run()"; - return; - } - - //for lower cpu load - usleep(10000); -// yieldCurrentThread(); - } -} - -void FTNoIR_Tracker::Initialize( QFrame *videoframe ) -{ - 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::run()) - // - if (inSocket == 0) { - qDebug() << "FTNoIR_Tracker::Initialize() creating insocket"; - inSocket = new QUdpSocket(); - // Connect the inSocket to the port, to receive messages - - if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); - delete inSocket; - inSocket = 0; - } - } - - return; -} - -void FTNoIR_Tracker::StartTracker( HWND parent_window ) -{ - start( QThread::TimeCriticalPriority ); - return; -} - -void FTNoIR_Tracker::StopTracker( bool exit ) -{ - // - // OK, the thread is not stopped, doing this. That might be dangerous anyway... - // - if (exit || !exit) return; - return; -} - -bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) -{ - if (bEnableX) { - data->x = newHeadPose.x; - } - if (bEnableX) { - data->y = newHeadPose.y; - } - if (bEnableX) { - data->z = newHeadPose.z; - } - if (bEnableX) { - data->yaw = newHeadPose.yaw; - } - if (bEnableX) { - data->pitch = newHeadPose.pitch; - } - if (bEnableX) { - data->roll = newHeadPose.roll; - } - return true; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNoIR_Tracker::loadSettings() { - - 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::loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "FTNClient" ); - bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); - bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); - bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); - bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); - bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); - bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); - portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); - iniFile.endGroup (); -} - - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTracker - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTracker@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTracker=_GetTracker@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() -{ - return new FTNoIR_Tracker; -} diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp deleted file mode 100644 index b489822a..00000000 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dialog.cpp +++ /dev/null @@ -1,181 +0,0 @@ -/******************************************************************************** -* 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_udp.h" - -//******************************************************************************************************* -// FaceTrackNoIR Client Settings-dialog. -//******************************************************************************************************* - -// -// Constructor for server-settings-dialog -// -TrackerControls::TrackerControls() : -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.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); - - connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -TrackerControls::~TrackerControls() { - qDebug() << "~TrackerControls() says: started"; -} - -// -// Initialize tracker-client-dialog -// -void TrackerControls::Initialize(QWidget *parent) { - - QPoint offsetpos(100, 100); - if (parent) { - this->move(parent->pos() + offsetpos); - } - show(); -} - -// -// OK clicked on server-dialog -// -void TrackerControls::doOK() { - save(); - this->close(); -} - -// override show event -void TrackerControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// 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 ); - - 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 TrackerControls::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.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); - ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); - ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); - ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); - ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); - ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); - - ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void TrackerControls::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 ( "EnableRoll", ui.chkEnableRoll->isChecked() ); - iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); - iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); - iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); - iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); - iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); - 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 ITrackerDialogPtr __stdcall GetTrackerDialog( ) -{ - return new TrackerControls; -} diff --git a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dll.cpp b/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dll.cpp deleted file mode 100644 index a086a888..00000000 --- a/FTNoIR_Tracker_UDP/ftnoir_tracker_udp_dll.cpp +++ /dev/null @@ -1,85 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: The Dialog class was used to get general info on the DLL. This - had a big disadvantage: the complete dialog was loaded, just to get - some data and then it was deleted again (without ever showing the dialog). - The TrackerDll class solves this. - The functions to get the name(s) and icon were removed from the two other classes. -*/ -#include "ftnoir_tracker_udp.h" -#include - -FTNoIR_TrackerDll::FTNoIR_TrackerDll() { - //populate the description strings - trackerFullName = "FaceTrackNoIR UDP"; - trackerShortName = "UDP"; - trackerDescription = "FaceTrackNoIR UDP"; -} - -FTNoIR_TrackerDll::~FTNoIR_TrackerDll() -{ - -} - -void FTNoIR_TrackerDll::Initialize() -{ - return; -} - -void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) -{ - *strToBeFilled = trackerFullName; -}; - -void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) -{ - *strToBeFilled = trackerShortName; -}; - -void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) -{ - *strToBeFilled = trackerDescription; -}; - -void FTNoIR_TrackerDll::getIcon(QIcon *icon) -{ - *icon = QIcon(":/images/FaceTrackNoIR.ico"); -}; - -//////////////////////////////////////////////////////////////////////////////// -// Factory function that creates instances if the Tracker object. - -// Export both decorated and undecorated names. -// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress -// Win32 API function. -// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. -#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") - -FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() -{ - return new FTNoIR_TrackerDll; -} diff --git a/FaceTrackNoIR/ClientFiles/CFS3/Readme.txt b/FaceTrackNoIR/ClientFiles/CFS3/Readme.txt deleted file mode 100644 index 141daa27..00000000 --- a/FaceTrackNoIR/ClientFiles/CFS3/Readme.txt +++ /dev/null @@ -1,27 +0,0 @@ -FaceTrackNoIR for - - * Combat Flight Simulator 3 (also works for Over Flanders Fields) - * Wings of War - * NASCAR Racing Season 2003 - * Colin McRae Rally 4 - * Race Driver 2 - * F1 Challenge - * Richard Burns Rally - -FaceTrackNoIR was made compatible with these programs with the help of the functions TrackIR provides in the dll TIRViews.dll. -This dll can be downloaded from the TrackIR website: http://www.naturalpoint.com/trackir/06-support/support-download-software-and-manuals.html - -To make the functions work, copy the dll in the FaceTrackNoIR installation folder. Then tick the 'use TIRViews.dll' checkbox for the 'fake TrackIR' game protocol. - -Please let us know if you like the program, if you have ideas for improvements or any questions you might have. - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - - - -Disclaimer: For usage of 3rd party software like FlightGear, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/FaceTrackNoIR/ClientFiles/CFS3/TIRViews.dll b/FaceTrackNoIR/ClientFiles/CFS3/TIRViews.dll deleted file mode 100644 index a1fb306f..00000000 Binary files a/FaceTrackNoIR/ClientFiles/CFS3/TIRViews.dll and /dev/null differ diff --git a/FaceTrackNoIR/ClientFiles/FS2002 and FS2004/FSUIPC.dll b/FaceTrackNoIR/ClientFiles/FS2002 and FS2004/FSUIPC.dll deleted file mode 100644 index 264d14c5..00000000 Binary files a/FaceTrackNoIR/ClientFiles/FS2002 and FS2004/FSUIPC.dll and /dev/null differ diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml b/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml deleted file mode 100644 index d8bd1d0a..00000000 --- a/FaceTrackNoIR/ClientFiles/FlightGear/Nasal/headtracker.xml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - 0 - 0 - 0 - 0 - 0 - 0 - 0 - 0 - - - diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml b/FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml deleted file mode 100644 index cd1d0dad..00000000 --- a/FaceTrackNoIR/ClientFiles/FlightGear/Protocol/headtracker.xml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - true - none - host - 52 - - - x - double - /sim/headtracker/x-m - - - - y - double - /sim/headtracker/y-m - - - - z - double - /sim/headtracker/z-m - - - - heading - double - /sim/headtracker/heading-deg - - - - pitch - double - /sim/headtracker/pitch-deg - - - - roll - double - /sim/headtracker/roll-deg - - - - status - int - /sim/headtracker/status - - - - - true - none - host - 4 - - - control - int - /sim/headtracker/control - - - - diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt b/FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt deleted file mode 100644 index c86ffffe..00000000 --- a/FaceTrackNoIR/ClientFiles/FlightGear/Readme.txt +++ /dev/null @@ -1,19 +0,0 @@ -FaceTrackNoIR for FlightGear. - -FaceTrackNoIR was made compatible with FlightGear with the help of Melchior Franz, who initially made a Linux headtracker. FaceTrackNoIR sends UDP-packets to FlightGear which contain 6DOF-data. The script and protocol provided by Melchior take care of receiving the data and moving 'the head' in-game. - -To make the FlightGear script work, copy the files in the subfolders to the corresponding folders in the FlightGear installation folder. Start FlightGear with the batch-file 'start_fg.bat'. - - -Please let us know if you like the program, if you have ideas for improvements or any questions you might have. - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - - - -Disclaimer: For usage of 3rd party software like FlightGear, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat b/FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat deleted file mode 100644 index cd9829b5..00000000 --- a/FaceTrackNoIR/ClientFiles/FlightGear/Win32/start_fg.bat +++ /dev/null @@ -1 +0,0 @@ -fgfs --generic=socket,in,25,localhost,5550,udp,headtracker --generic=socket,out,10,localhost,5551,udp,headtracker --prop:browser=/sim/headtracker "c:\Program Files\FlightGear\data\Nasal\headtracker.xml" \ No newline at end of file diff --git a/FaceTrackNoIR/ClientFiles/FreeTrackTest/FreeTrackTest.exe b/FaceTrackNoIR/ClientFiles/FreeTrackTest/FreeTrackTest.exe deleted file mode 100644 index 2965a07f..00000000 Binary files a/FaceTrackNoIR/ClientFiles/FreeTrackTest/FreeTrackTest.exe and /dev/null differ diff --git a/FaceTrackNoIR/ClientFiles/FreeTrackTest/Readme.txt b/FaceTrackNoIR/ClientFiles/FreeTrackTest/Readme.txt deleted file mode 100644 index 54f3ccd1..00000000 --- a/FaceTrackNoIR/ClientFiles/FreeTrackTest/Readme.txt +++ /dev/null @@ -1,20 +0,0 @@ -FaceTrackNoIR for Free-track 'enabled' games. - -FaceTrackNoIR was made compatible with the Free-track protocol, for which the Free-track source (a well, part of it) was -translated from Delphi Pascal to C++ (Visual Studio C++, with Qt). - -To start the Free-track protocol-server in FaceTrackNoIR, select Free-track in the 'game-protocol' listbox. The program -'FreeTrackTest.exe' is provided to check, if the protocol-server is running. - -FreeTrackTest.exe was created by the Free-track team. - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - - - -Disclaimer: For usage of 3rd party software like FreeTrackTest, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/FaceTrackNoIR/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE b/FaceTrackNoIR/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE deleted file mode 100644 index 745da7c6..00000000 --- a/FaceTrackNoIR/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE +++ /dev/null @@ -1,16 +0,0 @@ -// -// 6 Degrees of Freedom Headtracking with FaceTrackNoIR -// 2010 by Wim Vriend -// -pie.FrameRate = 120Hz -var.multiply = 1.5 -var.R2D = 57.295781 -FakeTrackIR.pitch=(Joystick.pitch - 0.10) * var.R2D * var.multiply -FakeTrackIR.yaw=(Joystick.yaw - 0.10) * var.R2D * var.multiply -FakeTrackIR.roll=(Joystick.roll - 0.10) * var.R2D * var.multiply -FakeTrackIR.x=(Joystick.x - 0.10) * var.R2D * var.multiply -FakeTrackIR.y=(Joystick.y - 0.10) * var.R2D * var.multiply -FakeTrackIR.z=(Joystick.z - 0.10) * var.R2D * var.multiply -debug = 'pitch='+FakeTrackIR.pitch+' roll='+FakeTrackIR.roll+' yaw='+FakeTrackIR.yaw+' xyz=('+FakeTrackIR.x+','+FakeTrackIR.y+','+FakeTrackIR.z+')' -//debug = FakeTrackIR.active - diff --git a/FaceTrackNoIR/ClientFiles/GlovePIE/Readme.txt b/FaceTrackNoIR/ClientFiles/GlovePIE/Readme.txt deleted file mode 100644 index db88fdc8..00000000 --- a/FaceTrackNoIR/ClientFiles/GlovePIE/Readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -FaceTrackNoIR for PPJoy 'enabled' games/programs. - -FaceTrackNoIR was made compatible with the PPJoy virtual joystick(s), that can be used by various other programs as input. GlovePIE is one of the most powerfull we know (we have also tried tir4fun, but that is quite limited). - -To start the PPJoy protocol-server in FaceTrackNoIR, select Virtual Joystick in the 'game-protocol' listbox. The -settings, necessary to configure PPJoy for FaceTrackNoIR as included in the PPJoy folder. - -GlovePIE was made by Carl Kenner and may NOT be used for military purposes. You can download it from the website -http://glovepie.org/glovepie.php - -The script FaceTrackNoIR2TrackIR.PIE, which was included in this folder, surves as an example for GlovePIE. If anyone -want to use, change or improve it: feel free to do so. In fact, if you do, we would like to receive a copy :-) - -Regards, - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - - - -Disclaimer: For usage of 3rd party software like GlovePIE, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/FaceTrackNoIR/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg b/FaceTrackNoIR/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg deleted file mode 100644 index 052c6899..00000000 Binary files a/FaceTrackNoIR/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg and /dev/null differ diff --git a/FaceTrackNoIR/ClientFiles/PPJoy/Readme.txt b/FaceTrackNoIR/ClientFiles/PPJoy/Readme.txt deleted file mode 100644 index 3000ece6..00000000 --- a/FaceTrackNoIR/ClientFiles/PPJoy/Readme.txt +++ /dev/null @@ -1,24 +0,0 @@ -FaceTrackNoIR for PPJoy 'enabled' games/programs. - -FaceTrackNoIR was made compatible with the PPJoy virtual joystick(s), that can be used by various other programs as input. - -To start the PPJoy protocol-server in FaceTrackNoIR, select Virtual Joystick in the 'game-protocol' listbox. The -settings, necessary to configure PPJoy for FaceTrackNoIR as included in the PPJoy folder, in the file -PPJoy mapping for FaceTrackNoIR.jpg. - -PPJoy was made by Deon van der Westhuysen and is unfortunately not updated anymore. You can download it from the website -http://shareware.pcmag.com/free/Miscellaneous-Utilities/PPJoy/75176.html, but possibly from others as well... - - -Regards, - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - - - - -Disclaimer: For usage of 3rd party software like PPJoy, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/FaceTrackNoIR/ClientFiles/Tir4Fun/NPClient.dll b/FaceTrackNoIR/ClientFiles/Tir4Fun/NPClient.dll deleted file mode 100644 index e392442e..00000000 Binary files a/FaceTrackNoIR/ClientFiles/Tir4Fun/NPClient.dll and /dev/null differ diff --git a/FaceTrackNoIR/ClientFiles/Tir4Fun/readme.txt b/FaceTrackNoIR/ClientFiles/Tir4Fun/readme.txt deleted file mode 100644 index 010510db..00000000 --- a/FaceTrackNoIR/ClientFiles/Tir4Fun/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -What is TIR4FUN? - -TIR4FUN is a free utility for dedicated gamers. It enables 6DOF POV control with mouse and joystick axes. - -Software is provided as it is. Configuration is straightforward. GUI says it all! - -Installation: - -Copy all files to a directory. Launch tir4fun.exe to bring up the GUI. diff --git a/FaceTrackNoIR/ClientFiles/Tir4Fun/tir4fun.exe b/FaceTrackNoIR/ClientFiles/Tir4Fun/tir4fun.exe deleted file mode 100644 index a51eced0..00000000 Binary files a/FaceTrackNoIR/ClientFiles/Tir4Fun/tir4fun.exe and /dev/null differ diff --git a/FaceTrackNoIR/FSUIPCServer.cpp b/FaceTrackNoIR/FSUIPCServer.cpp deleted file mode 100644 index 3006b430..00000000 --- a/FaceTrackNoIR/FSUIPCServer.cpp +++ /dev/null @@ -1,308 +0,0 @@ -/******************************************************************************** -* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * -* to games, using the FSUIPC.dll. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* 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 . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include "FSUIPCServer.h" -#include - -/** constructor **/ -FSUIPCServer::FSUIPCServer() { - - loadSettings(); - ProgramName = "Microsoft FS2004"; - - prevPosX = 0.0f; - prevPosY = 0.0f; - prevPosZ = 0.0f; - prevRotX = 0.0f; - prevRotY = 0.0f; - prevRotZ = 0.0f; - -} - -/** destructor **/ -FSUIPCServer::~FSUIPCServer() { - - // - // Free the DLL - // - FSUIPCLib.unload(); -} - -// -// Update Headpose in Game. -// -void FSUIPCServer::sendHeadposeToGame() { -DWORD result; -TFSState pitch; -TFSState yaw; -TFSState roll; -WORD FSZoom; - - qDebug() << "FSUIPCServer::run() says: started!"; - - // - // Init. the FSUIPC offsets (derived from Free-track...) - // - pitch.Control = 66503; - yaw.Control = 66504; - roll.Control = 66505; - - // - // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. - // - if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || - (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { - // - // Open the connection - // - FSUIPC_Open(SIM_ANY, &result); - - // - // Check the FS-version - // - if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && - ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { -// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; - // - // Write the 4! DOF-data to FS. Only rotations and zoom are possible. - // - pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); - FSUIPC_Write(0x3110, 8, &pitch, &result); - - yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); - FSUIPC_Write(0x3110, 8, &yaw, &result); - - roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); - FSUIPC_Write(0x3110, 8, &roll, &result); - - FSZoom = (WORD) (64/50) * virtPosZ + 64; - FSUIPC_Write(0x832E, 2, &FSZoom, &result); - - // - // Write the data, in one go! - // - FSUIPC_Process(&result); - if (result == FSUIPC_ERR_SENDMSG) { - FSUIPC_Close(); //timeout (1 second) so assume FS closed - } - } - } - - prevPosX = virtPosX; - prevPosY = virtPosY; - prevPosZ = virtPosZ; - prevRotX = virtRotX; - prevRotY = virtRotY; - prevRotZ = virtRotZ; - -} - -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// -bool FSUIPCServer::checkServerInstallationOK() -{ - qDebug() << "FSUIPCCheckClientDLL says: Starting Function"; - - // - // Load the DLL. - // - FSUIPCLib.setFileName( LocationOfDLL ); - if (FSUIPCLib.load() != true) { - qDebug() << "FSUIPCCheckClientDLL says: Error loading FSUIPC DLL"; - return false; - } - - return true; -} - -// -// Scale the measured value to the Joystick values -// -int FSUIPCServer::scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; - - local_x = x; - if (local_x > max_x) { - local_x = max_x; - } - if (local_x < min_x) { - local_x = min_x; - } - y = ( 16383 * local_x ) / max_x; - - return (int) y; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FSUIPCServer::loadSettings() { - - 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 ( "FSUIPC" ); - LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); - iniFile.endGroup (); -} - -// -// Constructor for server-settings-dialog -// -FSUIPCControls::FSUIPCControls( QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - this->move(parent->pos() + offsetpos); - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -FSUIPCControls::~FSUIPCControls() { - qDebug() << "~FSUIPCControls() says: started"; -} - -// -// OK clicked on server-dialog -// -void FSUIPCControls::doOK() { - save(); - this->close(); -} - -// override show event -void FSUIPCControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FSUIPCControls::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 FSUIPCControls::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 ( "FSUIPC" ); - ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); - iniFile.endGroup (); - - settingsDirty = false; - -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FSUIPCControls::save() { - - qDebug() << "save() says: started"; - - 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 ( "FSUIPC" ); - iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Show the Dialog to set the DLL's location -// -void FSUIPCControls::getLocationOfDLL() -{ - // - // Get the new filename of the INI-file. - // - QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), - ui.txtLocationOfDLL->text(), - tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); - if (!fileName.isEmpty()) { - ui.txtLocationOfDLL->setText( fileName ); - settingsDirty = true; - } -} - - -//END diff --git a/FaceTrackNoIR/FSUIPCServer.h b/FaceTrackNoIR/FSUIPCServer.h deleted file mode 100644 index caba2f33..00000000 --- a/FaceTrackNoIR/FSUIPCServer.h +++ /dev/null @@ -1,121 +0,0 @@ -/******************************************************************************** -* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * -* to games, using the FSUIPC.dll. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* 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 . * -* * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FSUIPCSERVER_H -#define INCLUDED_FSUIPCSERVER_H - -#include "Windows.h" -#include -#include "FTNoIR_cxx_protocolserver.h" -#include "FSUIPC_User.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "ui_FTNoIR_FSUIPCcontrols.h" - -using namespace std; -using namespace v4friend::ftnoir; - -static const char* FSUIPC_FILENAME = "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll"; - -// -// Define the structures necessary for the FSUIPC_Write calls -// -#pragma pack(push,1) // All fields in structure must be byte aligned. -typedef struct -{ - int Control; // Control identifier - int Value; // Value of DOF -} TFSState; -#pragma pack(pop) - -class FSUIPCServer : public ProtocolServerBase { - Q_OBJECT - -public: - - // public member methods - FSUIPCServer(); - ~FSUIPCServer(); - - // protected member methods -protected: - bool checkServerInstallationOK(); - void sendHeadposeToGame(); - -private: - // Private properties - QString ProgramName; - QLibrary FSUIPCLib; - QString LocationOfDLL; - void loadSettings(); - float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; - -public: - - // Settings for calculating the Virtual Pose - void setVirtRotX(float rot) { virtRotX = -1.0f * rot; } // degrees - void setVirtRotY(float rot) { virtRotY = rot; } - void setVirtRotZ(float rot) { virtRotZ = rot; } - - void setVirtPosX(float pos) { virtPosX = 0.0f; } // cm, X and Y are not working for FS2002/2004! - void setVirtPosY(float pos) { virtPosY = 0.0f; } - void setVirtPosZ(float pos) { virtPosZ = -1.0f * pos; } - - static int scale2AnalogLimits( float x, float min_x, float max_x ); -}; - -// Widget that has controls for FSUIPC server-settings. -class FSUIPCControls: public QWidget, public Ui::UICFSUIPCControls -{ - Q_OBJECT -public: - - explicit FSUIPCControls( QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~FSUIPCControls(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICFSUIPCControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void getLocationOfDLL(); - -}; - - -#endif//INCLUDED_FSUIPCSERVER_H -//END diff --git a/FaceTrackNoIR/FTNServer.cpp b/FaceTrackNoIR/FTNServer.cpp deleted file mode 100644 index 101d06a5..00000000 --- a/FaceTrackNoIR/FTNServer.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNServer FTNServer is the Class, that communicates headpose-data * -* to another FaceTrackNoIR program, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -/* - Modifications (last one on top): - 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame - is called from run() of Tracker.cpp -*/ -#include -#include -#include "FTNServer.h" -#include "Tracker.h" -#include - -/** constructor **/ -FTNServer::FTNServer( Tracker *parent ) { - - // Save the parent - headTracker = parent; - loadSettings(); -} - -/** destructor **/ -FTNServer::~FTNServer() { - if (inSocket != 0) { - inSocket->close(); - delete inSocket; - } - - if (outSocket != 0) { - outSocket->close(); - delete outSocket; - } -} - -// -// Update Headpose in Game. -// -void FTNServer::sendHeadposeToGame() { -int no_bytes; -QHostAddress sender; -quint16 senderPort; - - // - // Create UDP-sockets if they don't exist already. - // They must be created here, because they must be in the Tracker thread (Tracker::run()) - // - if (inSocket == 0) { - qDebug() << "FTNServer::sendHeadposeToGame creating sockets"; - inSocket = new QUdpSocket(); - // Connect the inSocket to the port, to receive messages - if (!inSocket->bind(QHostAddress::Any, destPort+1)) { - qDebug() << "FTNServer::writePendingDatagrams says: unable to bind inSocket!"; - delete inSocket; - inSocket = 0; - } - } - - if (outSocket == 0) { - outSocket = new QUdpSocket(); - } - - // - // Copy the Raw measurements directly to the client. - // - TestData.x = virtPosX; - TestData.y = virtPosY; - TestData.z = virtPosZ; - TestData.pitch = virtRotX; - TestData.yaw = virtRotY; - TestData.roll = virtRotZ; - - // - // Try to send an UDP-message to the receiver - // - - //! [1] - no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort); - if ( no_bytes > 0) { -// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); - } - else { - qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; - } - - // - // Receiver may send data, so we must read that here. - // - if (inSocket != 0) { - while (inSocket->hasPendingDatagrams()) { - - QByteArray datagram; - datagram.resize(inSocket->pendingDatagramSize()); - - inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); - - fg_cmd = cmd; // Let's just accept that command for now... - if ( cmd > 0 ) { - qDebug() << "FTNServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; - headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle - } - } - } -} - -// -// Check if the Client DLL exists and load it (to test it), if so. -// Returns 'true' if all seems OK. -// -bool FTNServer::checkServerInstallationOK( HANDLE handle ) -{ - // Init. the data - TestData.x = 0.0f; - TestData.y = 0.0f; - TestData.z = 0.0f; - TestData.yaw = 0.0f; - TestData.pitch = 0.0f; - TestData.roll = 0.0f; -// TestData.status = 0; - fg_cmd = 1; - - inSocket = 0; - outSocket = 0; - - return true; -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FTNServer::loadSettings() { - - 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 ( "FTN" ); - - QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); - destIP = QHostAddress( destAddr ); - destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); - - iniFile.endGroup (); -} - -// -// Constructor for server-settings-dialog -// -FTNServerControls::FTNServerControls( QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - this->move(parent->pos() + offsetpos); - - // 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 -// -FTNServerControls::~FTNServerControls() { - qDebug() << "~FTNServerControls() says: started"; -} - -// -// OK clicked on server-dialog -// -void FTNServerControls::doOK() { - save(); - this->close(); -} - -// override show event -void FTNServerControls::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void FTNServerControls::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 FTNServerControls::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 ( "FTN" ); - 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 FTNServerControls::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 ( "FTN" ); - 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; -} - -//END diff --git a/FaceTrackNoIR/FTNServer.h b/FaceTrackNoIR/FTNServer.h deleted file mode 100644 index f392e708..00000000 --- a/FaceTrackNoIR/FTNServer.h +++ /dev/null @@ -1,107 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -* FTNServer FTNServer is the Class, that communicates headpose-data * -* to FlightGear, using UDP. * -* It is based on the (Linux) example made by Melchior FRANZ. * -********************************************************************************/ -#pragma once -#ifndef INCLUDED_FTNSERVER_H -#define INCLUDED_FTNSERVER_H - -#include "FTNoIR_cxx_protocolserver.h" -#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace std; -using namespace v4friend::ftnoir; - -#include "ui_FTNoIR_FTNServercontrols.h" - -class Tracker; // pre-define parent-class to avoid circular includes - -class FTNServer : public ProtocolServerBase { - Q_OBJECT - -public: - - // public member methods - FTNServer( Tracker *parent ); - ~FTNServer(); - - // protected member methods -protected: - bool checkServerInstallationOK( HANDLE handle ); - void sendHeadposeToGame(); - void setVirtPosX(float pos) { virtPosX = pos; } - void setVirtPosY(float pos) { virtPosY = pos; } - void setVirtPosZ(float pos) { virtPosZ = pos; } - -private: - Tracker *headTracker; // For upstream messages... - THeadPoseData TestData; - QUdpSocket *inSocket; // Receive from FligthGear - QUdpSocket *outSocket; // Send to FligthGear - qint32 cmd; - qint32 fg_cmd; // Command from FlightGear - QHostAddress destIP; // Destination IP-address - int destPort; // Destination port-number - void loadSettings(); -}; - -// Widget that has controls for FTNoIR protocol server-settings. -class FTNServerControls: public QWidget, public Ui::UICFTNServerControls -{ - Q_OBJECT -public: - - explicit FTNServerControls( QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~FTNServerControls(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICFTNServerControls ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - -private slots: - void doOK(); - void doCancel(); - void settingChanged() { settingsDirty = true; }; -}; - - - -#endif//INCLUDED_FTNSERVER_H -//END diff --git a/FaceTrackNoIR/FTNoIR_Curves.ui b/FaceTrackNoIR/FTNoIR_Curves.ui deleted file mode 100644 index 19c68cf0..00000000 --- a/FaceTrackNoIR/FTNoIR_Curves.ui +++ /dev/null @@ -1,608 +0,0 @@ - - - UICCurveConfigurationDialog - - - - 0 - 0 - 901 - 661 - - - - FaceTrackNoIR tracking curves - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - /* Customize any plain widget that is a child of a QMainWindow. */ -QMainWindow > .QWidget { -background-color: rgb(100, 100, 100); -} - -/* Set the selection colors for all widgets. */ -QWidget { -selection-color: black; -selection-background-color: Silver; -color: black; -} - -/* Specials for individual widget(s) */ -QWidget#UICCurveConfigurationDialog { -background-color: #484848; -} - -QWidget#tabWidget { -background-color: #595959; -} - -/* -QWidget#widgetTop { -background-color: #595959; -border-bottom: 1px solid #000; -} -*/ - -/* Make text in message boxes selectable. */ -QMessageBox { -/* LinksAccessibleByMouse | TextSelectableByMouse */ -messagebox-text-interaction-flags: 5; -} -/* Make the entire row selected in item views. */ -QAbstractItemView { -show-decoration-selected: 1; -} - -/* Nice WindowsXP-style password character for password line edits. */ -QLineEdit[echoMode="2"] { -lineedit-password-character: 9679; -} - -/* Customize tooltips. */ -QToolTip { -background-color: rgb(170, 255, 127); -opacity: 200; -} - -/* Customize push buttons and comboboxes. Our read-only combobox -is very similar to a push button, so they share the same border image. */ - -QPushButton { -min-width: 4em; -} - -QPushButton:disabled { -color: rgb(128, 128, 128); -} - -QGroupBox { -color: rgb(255, 255, 255); -} - - - - - - - - - - - 0 - - - - - :/images/rotation_DOFs.png:/images/rotation_DOFs.png - - - Rotations - - - - - 10 - 10 - 794 - 548 - - - - - - - - 0 - 0 - - - - - 260 - 240 - - - - - 260 - 500 - - - - 180 - - - 1 - - - - 0 - 255 - 255 - - - - - 192 - 192 - 192 - - - - Input Pitch Up (degr.) - - - Output Pitch Up (degr.) - - - - - - - - 0 - 0 - - - - - 260 - 240 - - - - - 260 - 500 - - - - 1 - - - - 0 - 255 - 0 - - - - - 192 - 192 - 192 - - - - Input Roll (degr.) - - - Output Roll (degr.) - - - - - - - - 0 - 0 - - - - - 260 - 240 - - - - - 400 - 500 - - - - 1 - - - - 255 - 170 - 0 - - - - - 192 - 192 - 192 - - - - Input Yaw (degr.) - - - Output Yaw (degr.) - - - - - - - - 0 - 0 - - - - - 260 - 240 - - - - - 260 - 500 - - - - 90 - - - 2 - - - - 0 - 255 - 255 - - - - - 192 - 192 - 192 - - - - Input Pitch Down (degr.) - - - Output Pitch Down (degr.) - - - - - - - - 16777215 - 25 - - - - Left-click the graph to place a new point, right-click a point to remove. Left-click and drag to move a point. - - - true - - - - - - - - 170 - 140 - - - - image: url(:/images/rotation_DOFs.png); - - - - - - - - - - :/images/translation_DOFs.png:/images/translation_DOFs.png - - - Translations - - - - - 30 - 10 - 794 - 390 - - - - - - - - 260 - 240 - - - - - 260 - 240 - - - - - 255 - 255 - 0 - - - - - 192 - 192 - 192 - - - - Left/Right Input X (cm.) - - - Output X (cm.) - - - - - - - - 260 - 240 - - - - - 260 - 240 - - - - - 85 - 0 - 255 - - - - - 192 - 192 - 192 - - - - Up/Down Input Y (cm.) - - - Output Y (cm.) - - - - - - - - 260 - 240 - - - - - 260 - 240 - - - - - 255 - 0 - 0 - - - - - 192 - 192 - 192 - - - - Forward/Backward Input Z (cm.) - - - Output Z (cm.) - - - - - - - - 16777215 - 25 - - - - Left-click the graph to place a new point, right-click a point to remove. Left-click and drag to move a point. - - - true - - - - - - - - 170 - 140 - - - - image: url(:/images/translation_DOFs.png); - - - - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 52 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 52 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - QFunctionConfigurator - QWidget -
qfunctionconfigurator.h
-
-
- - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - -
diff --git a/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui b/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui deleted file mode 100644 index b6120378..00000000 --- a/FaceTrackNoIR/FTNoIR_FSUIPCcontrols.ui +++ /dev/null @@ -1,228 +0,0 @@ - - - UICFSUIPCControls - - - - 0 - 0 - 541 - 127 - - - - FSUIPC settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 0 - 0 - - - - Location of FSUIPC.dll: - - - Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter - - - false - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 230 - 0 - - - - Location of FSUIPC.dll - - - QFrame::Box - - - QFrame::Sunken - - - 1 - - - Location of FSUIPC.dll - - - - - - - - 35 - 16777215 - - - - ... - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - The DLL should be placed in the Modules folder of MS Flight Simulator - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FaceTrackNoIR/FTNoIR_FTNServerControls.ui b/FaceTrackNoIR/FTNoIR_FTNServerControls.ui deleted file mode 100644 index 44c7e99f..00000000 --- a/FaceTrackNoIR/FTNoIR_FTNServerControls.ui +++ /dev/null @@ -1,261 +0,0 @@ - - - UICFTNServerControls - - - - 0 - 0 - 411 - 156 - - - - FTNoIR protocol settings FaceTrackNoIR - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - - 60 - 16777215 - - - - 255 - - - 1 - - - - - - - IP-address remote PC - - - - - - - Port-number - - - - - - - 5550 - - - 10000 - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Enter IP-address and port-number for the remote PC. - - - true - - - - - - - Remember: you may have to change firewall-settings too! - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - spinIPFirstNibble - spinIPSecondNibble - spinIPThirdNibble - spinIPFourthNibble - spinPortNumber - btnOK - btnCancel - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui b/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui deleted file mode 100644 index 2a5ad691..00000000 --- a/FaceTrackNoIR/FTNoIR_KeyboardShortcuts.ui +++ /dev/null @@ -1,1018 +0,0 @@ - - - UICKeyboardShortcutDialog - - - - 0 - 0 - 687 - 438 - - - - FaceTrackNoIR Keyboard and Mouse shortcuts - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - - Disables: - - - - - - - When OFF: - - - - - - - - 0 - 0 - - - - Center - - - false - - - - - - - Axis Inhibitor - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 90 - 0 - - - - - - - - - 90 - 0 - - - - - - - - - 0 - 80 - - - - color: rgb(0, 0, 0); - - - Rotations - - - - - 10 - 20 - 50 - 17 - - - - - 50 - 16777215 - - - - Yaw - - - - - - 10 - 40 - 46 - 17 - - - - - 50 - 16777215 - - - - Pitch - - - - - - 10 - 60 - 50 - 17 - - - - - 50 - 16777215 - - - - Roll - - - - - - - - - 60 - 60 - - - - color: rgb(0, 0, 0); - - - View - - - - - 10 - 20 - 46 - 17 - - - - Zero - - - - - - 10 - 40 - 45 - 17 - - - - Stay - - - - - - - - Start/stop - - - Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter - - - - - - - color: rgb(0, 0, 0); - - - Translations - - - - - 10 - 20 - 30 - 17 - - - - - 30 - 16777215 - - - - X - - - - - - 10 - 40 - 30 - 17 - - - - - 30 - 16777215 - - - - Y - - - - - - 10 - 60 - 30 - 17 - - - - - 30 - 16777215 - - - - Z - - - - - - - - - 100 - 0 - - - - color: rgb(0, 0, 0); - - - Engine tracker - - - - - 10 - 20 - 81 - 17 - - - - Stop Engine - - - - - - 10 - 40 - 91 - 17 - - - - Keep tracking - - - - - - - - - 0 - 0 - - - - Game Zero - - - false - - - - - - - - 50 - 16777215 - - - - Shift - - - - - - - - 50 - 16777215 - - - - Ctrl - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 50 - 16777215 - - - - Alt - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 0 - 0 - - - - Keyboard - - - Qt::AlignCenter - - - false - - - - - - - - 0 - 0 - - - - Mouse - - - Qt::AlignCenter - - - false - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 90 - 0 - - - - Select Number - - - QComboBox::InsertAlphabetically - - - - - - - - 90 - 0 - - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - Qt::Vertical - - - - - - - - 85 - 16777215 - - - - Disable Beep - - - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - The axis inhibitor shortkey toggles the selected axis Off/On - - - - - - - - - Qt::Horizontal - - - - - - - - - - - Yaw angle for Reverse Axis - - - - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - 90 - - - 45 - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - degrees - - - - - - - Z-position for Reverse Axis - - - - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - -50 - - - 150 - - - 50 - - - - - - - cm - - - - - - - When Reverse: - - - - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - -50 - - - 150 - - - -20 - - - - - - - cm - - - - - - - Enable Revers Axis - - - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - These settings are saved 'per game' (INI-file) - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FaceTrackNoIR/FTNoIR_Preferences.ui b/FaceTrackNoIR/FTNoIR_Preferences.ui deleted file mode 100644 index bb440fc6..00000000 --- a/FaceTrackNoIR/FTNoIR_Preferences.ui +++ /dev/null @@ -1,240 +0,0 @@ - - - UICPreferencesDialog - - - - 0 - 0 - 485 - 151 - - - - FaceTrackNoIR Preferences - - - - images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico - - - Qt::LeftToRight - - - false - - - - - - - - - 0 - 0 - - - - Auto Minimize FaceTrackNoIR (0 = disable): - - - false - - - - - - - - - - 1000 - - - 5 - - - - - - - sec. (after 'Start') - - - - - - - Automatically Start tracking on Startup - - - - - - - Taskbar - - - - - - - Tray - - - - - - - - - - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - 0 - 0 - - - - These settings are saved globally (Registry) - - - false - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - QLayout::SetDefaultConstraint - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - OK - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - Cancel - - - - - - - - - Qt::Horizontal - - - QSizePolicy::Fixed - - - - 10 - 20 - - - - - - - - - - - - startEngineClicked() - stopEngineClicked() - cameraSettingsClicked() - - diff --git a/FaceTrackNoIR/FaceApp.cpp b/FaceTrackNoIR/FaceApp.cpp deleted file mode 100644 index 2811974c..00000000 --- a/FaceTrackNoIR/FaceApp.cpp +++ /dev/null @@ -1,60 +0,0 @@ -#include "FaceApp.h" -#include "windows.h" -#include "..\FTNoIR_Protocol_FT\FTTypes.h" -#include "..\FTNoIR_Protocol_FTIR\FTIRTypes.h" -#include - -// -// Override the Application MessageFilter, to receive messages from the game(s) -// -bool FaceApp::winEventFilter( MSG * msg, long * result ) -{ - int msgType = msg->message; // test line - - if (msgType == msgID_FTClient) { - qDebug() << "FaceApp::winEventFilter says: game tickles me =" << msgType << "hwnd =" << msg->hwnd; - if (mainWindow != NULL) { - mainWindow->getGameProgramName(); - } - } - - ////if (msgType == WM_HOTKEY) { - //// switch ( msg->wParam ) { - //// case 777: - //// qDebug() << "FaceApp::winEventFilter says: HOME pressed"; - //// break; - //// case 778: - //// qDebug() << "FaceApp::winEventFilter says: END pressed"; - //// break; - //// default: - //// qDebug() << "FaceApp::winEventFilter says: unknown HotKey pressed"; - //// break; - //// } - ////} - return( false ); -} - -// -// Setup the EventFilter -// -void FaceApp::SetupEventFilter( FaceTrackNoIR *window ) { - - mainWindow = window; - msgID_FTClient = RegisterWindowMessageA ( FT_PROGRAMID ); - qDebug() << "FaceApp::SetupEventFilter says: Message ID =" << msgID_FTClient; - msgID_FTIR_Register = RegisterWindowMessageA ( FTIR_REGISTER_PROGRAMHANDLE ); - msgID_FTIR_UnRegister = RegisterWindowMessageA ( FTIR_UNREGISTER_PROGRAMHANDLE ); - - ////if ( RegisterHotKey( window->winId(), 777, MOD_WIN, VK_HOME ) ) { - //// qDebug() << "FaceApp::SetupEventFilter says: RegisterHotKey HOME =" << VK_HOME; - ////} - ////if ( RegisterHotKey( window->winId(), 778, MOD_WIN, VK_END ) ) { - //// qDebug() << "FaceApp::SetupEventFilter says: RegisterHotKey END =" << VK_END; - ////} - //// - ////QAbstractEventDispatcher *evtdis = QAbstractEventDispatcher::instance(); - ////if (evtdis != NULL) { - //// qDebug() << "FaceApp::SetupEventFilter says: EventDispatcher found!"; - ////} - -} \ No newline at end of file diff --git a/FaceTrackNoIR/FaceApp.h b/FaceTrackNoIR/FaceApp.h deleted file mode 100644 index 39fd4b2f..00000000 --- a/FaceTrackNoIR/FaceApp.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef FACEAPP_H -#define FACEAPP_H - -#include -#include "FaceTrackNoIR.h" - -class FaceApp : public QApplication -{ - Q_OBJECT -public: - FaceApp( int &argc, char **argv ) : QApplication( argc, argv ) {} - ~FaceApp() {} - - void SetupEventFilter( FaceTrackNoIR *window ); - -protected: - bool winEventFilter( MSG * msg, long * result ); - -private: - FaceTrackNoIR *mainWindow; - int msgID_FTClient; - int msgID_FTIR_Register; - int msgID_FTIR_UnRegister; - int msgID_FilterSettingChanged; -}; - -#endif // FACEAPP_H diff --git a/FaceTrackNoIR/FaceTrackNoIR.cpp b/FaceTrackNoIR/FaceTrackNoIR.cpp deleted file mode 100644 index cd4e0a4d..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR.cpp +++ /dev/null @@ -1,2220 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2011 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -/* - Modifications (last one on top): - 20130201 - WVR: Load FreeTrack 2.0 protocol instead of fake TrackIR (which is now obsolete). - 20130101 - WVR: Added "None" to filter-listbox to remove "use advanced filtering". - 20121209 - WVR: Pre-v170 DLLs will not be added to the Listbox. Initial selection was changed (made case-insensitive). - 20121014 - WVR: Added second Tracker Source for Arduino solution. The two will be mutually exclusive. - 20120929 - WVR: Disable button Filter-settings when StartTracker. - 20120918 - WVR: When AutoStart is TRUE, the program is not directly minimized any more. - This now depends on the AutoMinimize time. Fixed the 'not showing' of the MIB. - Also disable combo and buttons after 'Start'. - 20120917 - WVR: Added Mouse-buttons to ShortKeys. - 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. - 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled ´statically´. Now, a Dir() of the - EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs - 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. 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. - 20110328 - WVR: Added the display for output-pose. - 20110207 - WVR: RadioButtons for 'Stop engine' added. It is now possible to choose Stop or Keep tracking. - 20110109 - WVR: Added minimizeTaskBar option added. It is now possible to choose minimized or tray. -*/ -#include "FaceTrackNoIR.h" -#include "tracker.h" - -//#define USE_VISAGE - -// -// Setup the Main Dialog -// -FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : -QMainWindow(parent, flags), -pTrackerDialog(NULL), -pSecondTrackerDialog(NULL), -pProtocolDialog(NULL), -pFilterDialog(NULL) -{ - cameraDetected = false; - - // - // Initialize Widget handles, to prevent memory-access errors. - // - _keyboard_shortcuts = 0; - _preferences = 0; - _keyboard_shortcuts = 0; - _curve_config = 0; - - tracker = 0; -// _display = 0; - l = 0; - trayIcon = 0; - - setupFaceTrackNoIR(); - - // - // Read the AutoStartTracking value from the registry. If it is '1', start the Tracker and Minimize... - // - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - if (settings.value ( "AutoStartTracking", 0 ).toBool()) { - startTracker(); - } - - Q_INIT_RESOURCE(PoseWidget); - _pose_display = new GLWidget(ui.widget4logo, 0); - _pose_display->rotateBy(0, 0, 0); - - ui.lblX->setVisible(false); - ui.lblY->setVisible(false); - ui.lblZ->setVisible(false); - ui.lblRotX->setVisible(false); - ui.lblRotY->setVisible(false); - ui.lblRotZ->setVisible(false); - - ui.lcdNumOutputPosX->setVisible(false); - ui.lcdNumOutputPosY->setVisible(false); - ui.lcdNumOutputPosZ->setVisible(false); - ui.lcdNumOutputRotX->setVisible(false); - ui.lcdNumOutputRotY->setVisible(false); - ui.lcdNumOutputRotZ->setVisible(false); -} - -/** sets up all objects and connections to buttons */ -void FaceTrackNoIR::setupFaceTrackNoIR() { - - ui.setupUi(this); - - ui.headPoseWidget->show(); - ui.video_frame->hide(); - - // menu objects will be connected with the functions in FaceTrackNoIR class - connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(open())); - connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); - connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(save())); - connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); - connect(ui.actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs())); - connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); - connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(exit())); - - connect(ui.actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); - connect(ui.actionKeyboard_Shortcuts, SIGNAL(triggered()), this, SLOT(showKeyboardShortcuts())); - connect(ui.actionCurve_Configuration, SIGNAL(triggered()), this, SLOT(showCurveConfiguration())); - connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); - connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); - - connect(ui.actionSupport, SIGNAL(triggered()), this, SLOT(openurl_support())); - connect(ui.actionYour_Support, SIGNAL(triggered()), this, SLOT(openurl_donation())); - connect(ui.btnDonate, SIGNAL(clicked()), this, SLOT(openurl_donation())); - connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); - - connect(ui.actionVideoWidget, SIGNAL(triggered()), this, SLOT(showVideoWidget())); - connect(ui.actionHeadPoseWidget, SIGNAL(triggered()), this, SLOT(showHeadPoseWidget())); - connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); - connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); - connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); - connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); - - // Connect checkboxes - connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); - connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); - connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); - connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); - connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); - connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); - - // button methods connect with methods in this class - connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); - connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); - - // Connect slider for smoothing - connect(ui.slideSmoothing, SIGNAL(valueChanged(int)), this, SLOT(setSmoothing(int))); - - //read the camera-name, using DirectShow - GetCameraNameDX(); - - //Create the system-tray and connect the events for that. - createIconGroupBox(); - createActions(); - createTrayIcon(); - - connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); - - //Load the tracker-settings, from the INI-file - loadSettings(); - trayIcon->show(); - - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - - //Setup the timer for automatically minimizing after StartTracker. - timMinimizeFTN = new QTimer(this); - connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized())); - - //Setup the timer for showing the headpose. - timUpdateHeadPose = new QTimer(this); - connect(timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); - ui.txtTracking->setVisible(false); - ui.txtAxisReverse->setVisible(false); - ui.gameName->setText(""); -} - -/** destructor stops the engine and quits the faceapi **/ -FaceTrackNoIR::~FaceTrackNoIR() { - - // - // Stop the tracker, by simulating a button-push - // - stopTracker(); - - // - // 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::Discard ); - - switch (ret) { - case QMessageBox::Save: - saveAs(); - break; - case QMessageBox::Discard: - // Don't Save was clicked - break; - case QMessageBox::Cancel: - // Cancel was clicked - break; - default: - // should never be reached - break; - } - } -} - -// -// Get the ProgramName from a connected game and display it. -// -void FaceTrackNoIR::getGameProgramName() { - if ( tracker != NULL ) { - ui.gameName->setText( tracker->getGameProgramName() ); - } -} - -// -// Update the Settings, after a value has changed. This way, the Tracker does not have to re-start. -// -void FaceTrackNoIR::updateSettings() { - if ( tracker != NULL ) { - tracker->loadSettings(); - } -} - -// -// Get a pointer to the video-widget, to use in the DLL -// -QFrame *FaceTrackNoIR::getVideoWidget() { - return ui.video_frame; -} - -// -// Return the name of the Protocol-DLL -// -QString FaceTrackNoIR::getCurrentProtocolName() -{ - if (ui.iconcomboProtocol->currentIndex() < 0) { - return QString(""); - } - else { - return protocolFileList.at(ui.iconcomboProtocol->currentIndex()); - } -} - -// -// Return the name of the Filter-DLL -// -QString FaceTrackNoIR::getCurrentFilterName() -{ - qDebug() << "getCurrentFilterName says: " << ui.iconcomboFilter->currentIndex(); - if (ui.iconcomboFilter->currentIndex() <= 0) { - return QString("None"); - } - else { - return filterFileList.at(ui.iconcomboFilter->currentIndex() - 1 ); - } -} - -// -// Return the name of the Tracker-DLL -// -QString FaceTrackNoIR::getCurrentTrackerName() -{ - if (ui.iconcomboTrackerSource->currentIndex() < 0) { - return QString(""); - } - else { - qDebug() << "FaceTrackNoIR::getCurrentTrackerName libName = " << trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); - return trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); - } -} - -// -// Return the name of the second Tracker-DLL -// -QString FaceTrackNoIR::getSecondTrackerName() -{ - if (ui.cbxSecondTrackerSource->currentIndex() <= 0) { - return QString("None"); - } - else { - return trackerFileList.at(ui.cbxSecondTrackerSource->currentIndex() - 1 ); - } -} - -/** read the name of the first video-capturing device at start up **/ -/** FaceAPI can only use this first one... **/ -void FaceTrackNoIR::GetCameraNameDX() { - -//// ui.widget->setCameraName("No video-capturing device was found in your system: check if it's connected!"); - - ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); - - // Create the System Device Enumerator. - HRESULT hr; - ICreateDevEnum *pSysDevEnum = NULL; - hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); - if (FAILED(hr)) - { - qDebug() << "GetWDM says: CoCreateInstance Failed!"; - return; - } - - qDebug() << "GetWDM says: CoCreateInstance succeeded!"; - - // Obtain a class enumerator for the video compressor category. - IEnumMoniker *pEnumCat = NULL; - hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); - - if (hr == S_OK) { - qDebug() << "GetWDM says: CreateClassEnumerator succeeded!"; - - // Enumerate the monikers. - IMoniker *pMoniker = NULL; - ULONG cFetched; - if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { - IPropertyBag *pPropBag; - hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); - if (SUCCEEDED(hr)) { - // To retrieve the filter's friendly name, do the following: - VARIANT varName; - VariantInit(&varName); - hr = pPropBag->Read(L"FriendlyName", &varName, 0); - if (SUCCEEDED(hr)) - { - // Display the name in your UI somehow. - QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); - qDebug() << "GetWDM says: Moniker found:" << str; - ui.cameraName->setText(str); - } - VariantClear(&varName); - - ////// To create an instance of the filter, do the following: - ////IBaseFilter *pFilter; - ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, - //// (void**)&pFilter); - // Now add the filter to the graph. - //Remember to release pFilter later. - pPropBag->Release(); - } - pMoniker->Release(); - } - pEnumCat->Release(); - } - pSysDevEnum->Release(); - -} - -// -// Open an INI-file with the QFileDialog -// If succesfull, the settings in it will be read -// -void FaceTrackNoIR::open() { - QFileDialog::Options options; - QFileDialog::FileMode mode; - - options |= QFileDialog::DontUseNativeDialog; - mode = QFileDialog::ExistingFile; - QString selectedFilter; - QStringList fileNames = QFileDialog::getOpenFileNames( - this, - tr("Select one FTNoir settings file"), - QCoreApplication::applicationDirPath() + "/Settings", - tr("Settings file (*.ini);;All Files (*)")); - - // - // If a file was selected, save it's name and read it's contents. - // - if (! fileNames.isEmpty() ) { - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - settings.setValue ("SettingsFile", fileNames.at(0)); - loadSettings(); - } -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void FaceTrackNoIR::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 ( "Tracking" ); - iniFile.setValue ( "Smooth", ui.slideSmoothing->value() ); - iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); - iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); - iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); - iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); - iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); - iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "GameProtocol" ); - iniFile.setValue ( "Selection", ui.iconcomboProtocol->currentIndex() ); - iniFile.setValue ( "DLL", getCurrentProtocolName() ); - iniFile.endGroup (); - - iniFile.beginGroup ( "TrackerSource" ); - iniFile.setValue ( "Selection", ui.iconcomboTrackerSource->currentIndex() ); - iniFile.setValue ( "DLL", getCurrentTrackerName() ); - iniFile.setValue ( "2ndDLL", getSecondTrackerName() ); - iniFile.endGroup (); - - // - // Save the name of the filter in the INI-file. - // - iniFile.beginGroup ( "Filter" ); - iniFile.setValue ( "DLL", getCurrentFilterName() ); - iniFile.endGroup (); - - settingsDirty = false; -} - -// -// Get the new name of the INI-file and save the settings to it. -// -// The user may choose to overwrite an existing file. This will be deleted, before copying the current file to it. -// -void FaceTrackNoIR::saveAs() -{ - // - // Get the current filename of the INI-file. - // - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - - // - // Get the new filename of the INI-file. - // - QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), - oldFile, -// QCoreApplication::applicationDirPath() + "/Settings", - tr("Settings file (*.ini);;All Files (*)")); - if (!fileName.isEmpty()) { - - // - // Remove the file, if it already exists. - // - QFileInfo newFileInfo ( fileName ); - if ((newFileInfo.exists()) && (oldFile != fileName)) { - QFile newFileFile ( fileName ); - newFileFile.remove(); - } - - // - // Copy the current INI-file to the new name. - // - QFileInfo oldFileInfo ( oldFile ); - if (oldFileInfo.exists()) { - QFile oldFileFile ( oldFile ); - oldFileFile.copy( fileName ); - } - - // - // Write the new name to the Registry and save the other INI-values. - // - settings.setValue ("SettingsFile", fileName); - save(); - - // - // Reload the settings, to get the GUI right again... - // - loadSettings(); - } -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void FaceTrackNoIR::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) - - // - // Put the filename in the window-title. - // - QFileInfo pathInfo ( currentFile ); - setWindowTitle ( "FaceTrackNoIR (1.7) - " + pathInfo.fileName() ); - - // - // Get a List of all the INI-files in the (currently active) Settings-folder. - // - QDir settingsDir( pathInfo.dir() ); - QStringList filters; - filters << "*.ini"; - iniFileList.clear(); - iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - // - // Add strings to the Listbox. - // - disconnect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - ui.iconcomboProfile->clear(); - for ( int i = 0; i < iniFileList.size(); i++) { - ui.iconcomboProfile->addItem(QIcon(":/images/Settings16.png"), iniFileList.at(i)); - if (iniFileList.at(i) == pathInfo.fileName()) { - ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/SettingsOpen16.png")); - ui.iconcomboProfile->setCurrentIndex( i ); - } - } - connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); - - qDebug() << "loadSettings says: iniFile = " << currentFile; - - iniFile.beginGroup ( "Tracking" ); - ui.slideSmoothing->setValue (iniFile.value ( "Smooth", 10 ).toInt()); - ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); - ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); - ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); - ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); - ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); - ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); - iniFile.endGroup (); - - // - // Read the currently selected Protocol from the INI-file. - // If the setting "DLL" isn't found (pre-1.7 version of INI), then the setting 'Selection' is evaluated. - // - iniFile.beginGroup ( "GameProtocol" ); - - QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "loadSettings says: selectedProtocolName = " << selectedProtocolName; - - if (selectedProtocolName.length() == 0) { - int index = iniFile.value ( "Selection", 0 ).toInt(); - switch ( index ) { - case TRACKIR: - case FREE_TRACK: - selectedProtocolName = QString("FTNoIR_Protocol_FT.dll"); - break; - - case SIMCONNECT: - selectedProtocolName = QString("FTNoIR_Protocol_SC.dll"); - break; - - case PPJOY: - selectedProtocolName = QString("FTNoIR_Protocol_PPJOY.dll"); - break; - - case FSUIPC: - selectedProtocolName = QString("FTNoIR_Protocol_FSUIPC.dll"); - break; - - case FLIGHTGEAR: - selectedProtocolName = QString("FTNoIR_Protocol_FG.dll"); - break; - - case FTNOIR: - selectedProtocolName = QString("FTNoIR_Protocol_FTN.dll"); - break; - - case MOUSE: - selectedProtocolName = QString("FTNoIR_Protocol_MOUSE.dll"); - break; - - default: - selectedProtocolName = QString("FTNoIR_Protocol_MOUSE.dll"); - break; - } - } - iniFile.endGroup (); - - // - // Find the Index of the DLL and set the selection. - // - for ( int i = 0; i < protocolFileList.size(); i++) { - if (protocolFileList.at(i).compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboProtocol->setCurrentIndex( i ); - break; - } - } - - // - // 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" ); - QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); - qDebug() << "loadSettings 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; - } - } - QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); - qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; - - iniFile.endGroup (); - - disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - for ( int i = 0; i < trackerFileList.size(); i++) { - if (trackerFileList.at(i).compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboTrackerSource->setCurrentIndex( i ); - } - if (trackerFileList.at(i).compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { - ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 - } - } - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - - // - // Read the currently selected Filter from the INI-file. - // - iniFile.beginGroup ( "Filter" ); - QString selectedFilterName = iniFile.value ( "DLL", "FTNoIR_Filter_EWMA2.dll" ).toString(); - qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; - iniFile.endGroup (); - - // - // Find the Index of the DLL and set the selection. - // - for ( int i = 0; i < filterFileList.size(); i++) { - if (filterFileList.at(i).compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { - ui.iconcomboFilter->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 - break; - } - } - - settingsDirty = false; -} - -/** show support page in web-browser **/ -void FaceTrackNoIR::openurl_support() { - QDesktopServices::openUrl(QUrl("http://facetracknoir.sourceforge.net/manual/manual.htm", QUrl::TolerantMode)); -} - -/** show donations page in web-browser **/ -void FaceTrackNoIR::openurl_donation() { - QDesktopServices::openUrl(QUrl("http://facetracknoir.sourceforge.net/information_links/donate.htm", QUrl::TolerantMode)); -} - - -/** show about dialog **/ -void FaceTrackNoIR::about() { - - QPoint offsetpos(100, 100); - aboutDialog.move(this->pos() + offsetpos); - aboutDialog.show(); - - /** ABOUT DIALOG **/ - aboutDialog.setBaseSize(270, 440); - - aboutDialog.setMaximumWidth(270); - aboutDialog.setMaximumHeight(440); - - aboutDialog.setMinimumWidth(270); - aboutDialog.setMinimumHeight(440); - aboutDialog.setStyleSheet("background:#fff url(:/UIElements/aboutFaceTrackNoIR.png) no-repeat;"); -} - -/** start tracking the face **/ -void FaceTrackNoIR::startTracker( ) { - - // - // Disable buttons - // - ui.iconcomboProfile->setEnabled ( false ); - ui.btnLoad->setEnabled ( false ); - ui.btnSave->setEnabled ( false ); - ui.btnSaveAs->setEnabled ( false ); - ui.btnShowFilterControls->setEnabled ( false ); - - // - // Create the Tracker and setup - // - tracker = new Tracker ( this ); - - // - // Setup the Tracker and send the settings. - // This is necessary, because the events are only triggered 'on change' - // - tracker->setup(); - tracker->setSmoothing ( ui.slideSmoothing->value() ); - tracker->setInvertYaw (ui.chkInvertYaw->isChecked() ); - tracker->setInvertPitch (ui.chkInvertPitch->isChecked() ); - tracker->setInvertRoll (ui.chkInvertRoll->isChecked() ); - tracker->setInvertX (ui.chkInvertX->isChecked() ); - tracker->setInvertY (ui.chkInvertY->isChecked() ); - tracker->setInvertZ (ui.chkInvertZ->isChecked() ); - - tracker->start( QThread::TimeCriticalPriority ); - - // - // Register the Tracker instance with the Tracker Dialog (if open) - // - if (pTrackerDialog) { - pTrackerDialog->registerTracker( tracker->getTrackerPtr() ); - } - - ui.headPoseWidget->show(); - - // - ui.btnStartTracker->setEnabled ( false ); - ui.btnStopTracker->setEnabled ( true ); - - // Enable/disable Protocol-server Settings - ui.iconcomboTrackerSource->setEnabled ( false ); - ui.cbxSecondTrackerSource->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( false ); -// ui.btnShowServerControls->setEnabled ( false ); - ui.iconcomboFilter->setEnabled ( false ); - - // - // Update the camera-name, FaceAPI can only use the 1st one found! - // - GetCameraNameDX(); - - - // - // Get the TimeOut value for minimizing FaceTrackNoIR - // Only start the Timer if value > 0 - // - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - int timevalue = settings.value ( "AutoMinimizeTime", 0 ).toInt() * 1000; - if (timevalue > 0) { - - bool minimizeTaskBar = settings.value ( "MinimizeTaskBar", 1 ).toBool(); - if (minimizeTaskBar) { - connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized())); - } - else { - connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(hide())); - } - - timMinimizeFTN->setSingleShot( true ); - timMinimizeFTN->start(timevalue); - } - - // - // Start the timer to update the head-pose (digits and 'man in black') - // - timUpdateHeadPose->start(50); - - ui.lblX->setVisible(true); - ui.lblY->setVisible(true); - ui.lblZ->setVisible(true); - ui.lblRotX->setVisible(true); - ui.lblRotY->setVisible(true); - ui.lblRotZ->setVisible(true); - - ui.lcdNumOutputPosX->setVisible(true); - ui.lcdNumOutputPosY->setVisible(true); - ui.lcdNumOutputPosZ->setVisible(true); - ui.lcdNumOutputRotX->setVisible(true); - ui.lcdNumOutputRotY->setVisible(true); - ui.lcdNumOutputRotZ->setVisible(true); -} - -/** stop tracking the face **/ -void FaceTrackNoIR::stopTracker( ) { - - // - // Stop displaying the head-pose. - // - timUpdateHeadPose->stop(); - _pose_display->rotateBy(0, 0, 0); - - - ui.lblX->setVisible(false); - ui.lblY->setVisible(false); - ui.lblZ->setVisible(false); - ui.lblRotX->setVisible(false); - ui.lblRotY->setVisible(false); - ui.lblRotZ->setVisible(false); - - ui.lcdNumOutputPosX->setVisible(false); - ui.lcdNumOutputPosY->setVisible(false); - ui.lcdNumOutputPosZ->setVisible(false); - ui.lcdNumOutputRotX->setVisible(false); - ui.lcdNumOutputRotY->setVisible(false); - ui.lcdNumOutputRotZ->setVisible(false); - ui.txtTracking->setVisible(false); - ui.txtAxisReverse->setVisible(false); - - // - // UnRegister the Tracker instance with the Tracker Dialog (if open) - // - if (pTrackerDialog) { - pTrackerDialog->unRegisterTracker(); - } - if (pProtocolDialog) { - pProtocolDialog->unRegisterProtocol(); - } - - // - // Delete the tracker (after stopping things and all). - // - if ( tracker ) { - qDebug() << "stopTracker says: Deleting tracker!"; - delete tracker; - qDebug() << "stopTracker says: Tracker deleted!"; - tracker = 0; - } - ui.btnStartTracker->setEnabled ( true ); - ui.btnStopTracker->setEnabled ( false ); -// ui.btnShowEngineControls->setEnabled ( false ); - ui.iconcomboProtocol->setEnabled ( true ); - ui.iconcomboTrackerSource->setEnabled ( true ); - ui.cbxSecondTrackerSource->setEnabled ( true ); - ui.iconcomboFilter->setEnabled ( true ); - - // Enable/disable Protocol-server Settings - ui.btnShowServerControls->setEnabled ( true ); - ui.video_frame->hide(); - - // - ui.iconcomboProfile->setEnabled ( true ); - ui.btnLoad->setEnabled ( true ); - ui.btnSave->setEnabled ( true ); - ui.btnSaveAs->setEnabled ( true ); - ui.btnShowFilterControls->setEnabled ( true ); - - // - // Stop the timer, so it won't go off again... - // - timMinimizeFTN->stop(); - -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertYaw( int invert ) { - Tracker::setInvertYaw ( (invert != 0)?true:false ); - settingsDirty = true; -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertPitch( int invert ) { - Tracker::setInvertPitch ( (invert != 0)?true:false ); - settingsDirty = true; -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertRoll( int invert ) { - Tracker::setInvertRoll ( (invert != 0)?true:false ); - settingsDirty = true; -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertX( int invert ) { - Tracker::setInvertX ( (invert != 0)?true:false ); - settingsDirty = true; -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertY( int invert ) { - Tracker::setInvertY ( (invert != 0)?true:false ); - settingsDirty = true; -} - -/** set the invert from the checkbox **/ -void FaceTrackNoIR::setInvertZ( int invert ) { - Tracker::setInvertZ ( (invert != 0)?true:false ); - settingsDirty = true; -} - -/** Show the headpose in the widget (triggered by timer) **/ -void FaceTrackNoIR::showHeadPose() { -THeadPoseData newdata; - - ui.lblX->setVisible(true); - ui.lblY->setVisible(true); - ui.lblZ->setVisible(true); - ui.lblRotX->setVisible(true); - ui.lblRotY->setVisible(true); - ui.lblRotZ->setVisible(true); - - ui.lcdNumOutputPosX->setVisible(true); - ui.lcdNumOutputPosY->setVisible(true); - ui.lcdNumOutputPosZ->setVisible(true); - ui.lcdNumOutputRotX->setVisible(true); - ui.lcdNumOutputRotY->setVisible(true); - ui.lcdNumOutputRotZ->setVisible(true); - - if (!isMinimized()) { - - // - // Get the pose and also display it. - // Updating the pose from within the Tracker-class caused crashes... - // - Tracker::getHeadPose(&newdata); - ui.lcdNumX->display(QString("%1").arg(newdata.x, 0, 'f', 1)); - ui.lcdNumY->display(QString("%1").arg(newdata.y, 0, 'f', 1)); - ui.lcdNumZ->display(QString("%1").arg(newdata.z, 0, 'f', 1)); - - ui.lcdNumRotX->display(QString("%1").arg(newdata.yaw, 0, 'f', 1)); - ui.lcdNumRotY->display(QString("%1").arg(newdata.pitch, 0, 'f', 1)); - ui.lcdNumRotZ->display(QString("%1").arg(newdata.roll, 0, 'f', 1)); - - ui.txtTracking->setVisible(Tracker::getTrackingActive()); - ui.txtAxisReverse->setVisible(Tracker::getAxisReverse()); - - // - // Get the output-pose and also display it. - // - if (_pose_display) { - Tracker::getOutputHeadPose(&newdata); - _pose_display->rotateBy(newdata.pitch, newdata.yaw, newdata.roll); - - ui.lcdNumOutputPosX->display(QString("%1").arg(newdata.x, 0, 'f', 1)); - ui.lcdNumOutputPosY->display(QString("%1").arg(newdata.y, 0, 'f', 1)); - ui.lcdNumOutputPosZ->display(QString("%1").arg(newdata.z, 0, 'f', 1)); - - ui.lcdNumOutputRotX->display(QString("%1").arg(newdata.yaw, 0, 'f', 1)); - 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 - // - if (tracker) { - ITracker * theTracker = tracker->getTrackerPtr(); - if (theTracker) { - theTracker->refreshVideo(); - } - } - // Tracker::doRefreshVideo(); - - if (_curve_config) { - _curve_config->update(); - } - } - //else { - // qDebug() << "FaceTrackNoIR::showHeadPose status: window = minimized."; - //} -} - -/** set the smoothing from the slider **/ -void FaceTrackNoIR::setSmoothing( int smooth ) { - - // - // Pass the smoothing setting, if the Tracker exists. - // - if ( tracker ) { - tracker->setSmoothing ( smooth ); - settingsDirty = true; - } -} - - -/** toggles Video Widget **/ -void FaceTrackNoIR::showVideoWidget() { - if(ui.video_frame->isHidden()) - ui.video_frame->show(); - else - ui.video_frame->hide(); -} - -/** toggles Video Widget **/ -void FaceTrackNoIR::showHeadPoseWidget() { - if(ui.headPoseWidget->isHidden()) - ui.headPoseWidget->show(); - else - ui.headPoseWidget->hide(); -} - -/** toggles Engine Controls Dialog **/ -void FaceTrackNoIR::showTrackerSettings() { -importGetTrackerDialog getIT; -QLibrary *trackerLib; -QString libName; - - qDebug() << "FaceTrackNoIR::showTrackerSettings started."; - - // - // Delete the existing QDialog - // - if (pTrackerDialog) { - delete pTrackerDialog; - pTrackerDialog = NULL; - } - - // Show the appropriate Tracker Settings - libName.clear(); - libName = getCurrentTrackerName(); - - // - // Load the Server-settings dialog (if any) and show it. - // - if (!libName.isEmpty()) { - trackerLib = new QLibrary(libName); - -// qDebug() << "FaceTrackNoIR::showTrackerSettings Loaded trackerLib." << trackerLib; - - getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); - -// qDebug() << "FaceTrackNoIR::showTrackerSettings resolved." << getIT; - - if (getIT) { - ITrackerDialog *ptrXyz(getIT()); - if (ptrXyz) - { - pTrackerDialog = ptrXyz; - pTrackerDialog->Initialize( this ); -// qDebug() << "FaceTrackNoIR::showTrackerSettings GetTrackerDialog Function Resolved!"; - if (tracker) { - pTrackerDialog->registerTracker( tracker->getTrackerPtr() ); -// qDebug() << "FaceTrackNoIR::showTrackerSettings RegisterTracker Function Executed"; - } - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } - } - -} - -// Show the Settings dialog for the secondary Tracker -void FaceTrackNoIR::showSecondTrackerSettings() { -importGetTrackerDialog getIT; -QLibrary *trackerLib; -QString libName; - - qDebug() << "FaceTrackNoIR::showSecondTrackerSettings started."; - - // - // Delete the existing QDialog - // - if (pSecondTrackerDialog) { - delete pSecondTrackerDialog; - pSecondTrackerDialog = NULL; - } - - // Show the appropriate Tracker Settings - libName.clear(); - libName = getSecondTrackerName(); - - // - // Load the Server-settings dialog (if any) and show it. - // - if ((!libName.isEmpty()) && (libName != "None")) { - trackerLib = new QLibrary(libName); - -// qDebug() << "FaceTrackNoIR::showTrackerSettings Loaded trackerLib." << trackerLib; - - getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); - -// qDebug() << "FaceTrackNoIR::showTrackerSettings resolved." << getIT; - - if (getIT) { - ITrackerDialog *ptrXyz(getIT()); - if (ptrXyz) - { - pSecondTrackerDialog = ptrXyz; - pSecondTrackerDialog->Initialize( this ); -// qDebug() << "FaceTrackNoIR::showTrackerSettings GetTrackerDialog Function Resolved!"; - if (tracker) { - pSecondTrackerDialog->registerTracker( tracker->getSecondTrackerPtr() ); -// qDebug() << "FaceTrackNoIR::showTrackerSettings RegisterTracker Function Executed"; - } - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } - } - -} - -/** toggles Server Controls Dialog **/ -void FaceTrackNoIR::showServerControls() { -importGetProtocolDialog getIT; -QLibrary *protocolLib; -QString libName; - - // - // Delete the existing QDialog - // - if (pProtocolDialog) { - delete pProtocolDialog; - } - - // Show the appropriate Protocol-server Settings - libName.clear(); - libName = getCurrentProtocolName(); - - // - // Load the Server-settings dialog (if any) and show it. - // - if (!libName.isEmpty()) { - protocolLib = new QLibrary(libName); - - getIT = (importGetProtocolDialog) protocolLib->resolve("GetProtocolDialog"); - if (getIT) { - IProtocolDialogPtr ptrXyz(getIT()); - if (ptrXyz) - { - pProtocolDialog = ptrXyz; - pProtocolDialog->Initialize( this ); - if (tracker) { - pProtocolDialog->registerProtocol( tracker->getProtocolPtr() ); - qDebug() << "FaceTrackNoIR::showServerControls RegisterProtocol Function Executed"; - } - qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!"; - } - else { - qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } - } -} - -/** toggles Filter Controls Dialog **/ -void FaceTrackNoIR::showFilterControls() { -importGetFilterDialog getIT; -QLibrary *filterLib; -QString libName; - - // - // Delete the existing QDialog - // - if (pFilterDialog) { - delete pFilterDialog; - pFilterDialog = NULL; - } - - // Get the currently selected Filter - libName.clear(); - libName = getCurrentFilterName(); - - // - // Load the Filter-settings dialog (if any) and show it. - // - if (!libName.isEmpty()) { - filterLib = new QLibrary(libName); - - getIT = (importGetFilterDialog) filterLib->resolve("GetFilterDialog"); - if (getIT) { - IFilterDialogPtr ptrXyz(getIT()); - if (ptrXyz) - { - pFilterDialog = ptrXyz; - pFilterDialog->Initialize( this, Tracker::getFilterPtr() ); - qDebug() << "FaceTrackNoIR::showFilterControls GetFilterDialog Function Resolved!"; - } - else { - qDebug() << "FaceTrackNoIR::showFilterControls Function NOT Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } - } -} - -/** toggles FaceTrackNoIR Preferences Dialog **/ -void FaceTrackNoIR::showPreferences() { - - // Create if new - if (!_preferences) - { - _preferences = new PreferencesDialog( this, this, Qt::Dialog ); - } - - // Show if already created - if (_preferences) { - _preferences->show(); - _preferences->raise(); - } -} - -/** toggles Keyboard Shortcut Dialog **/ -void FaceTrackNoIR::showKeyboardShortcuts() { - - // Create if new - if (!_keyboard_shortcuts) - { - _keyboard_shortcuts = new KeyboardShortcutDialog( this, this, Qt::Dialog ); - } - - // Show if already created - if (_keyboard_shortcuts) { - _keyboard_shortcuts->show(); - _keyboard_shortcuts->raise(); - } -} - -/** toggles Curve Configuration Dialog **/ -void FaceTrackNoIR::showCurveConfiguration() { - - // Create if new - if (!_curve_config) - { - _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); - } - - // Show if already created - if (_curve_config) { - _curve_config->show(); - _curve_config->raise(); - } -} - -/** exit application **/ -void FaceTrackNoIR::exit() { - QCoreApplication::exit(0); -} - -// -// Setup the icons for the comboBoxes -// -void FaceTrackNoIR::createIconGroupBox() -{ -importGetProtocolDll getProtocol; -IProtocolDllPtr pProtocolDll; // Pointer to Protocol info instance (in DLL) -importGetFilterDll getFilter; -IFilterDllPtr pFilterDll; // Pointer to Filter info instance (in DLL) -importGetTrackerDll getTracker; -ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) -QStringList listDLLs; // List of specific DLLs - - 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) - - // - // Get a List of all the Protocol-DLL-files in the Program-folder. - // - QDir settingsDir( QCoreApplication::applicationDirPath() ); - QStringList filters; - filters.clear(); - filters << "FTNoIR_Protocol_*.dll"; - protocolFileList.clear(); - listDLLs.clear(); - listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - // - // Add strings to the Listbox. - // - disconnect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - ui.iconcomboProtocol->clear(); - for ( int i = 0; i < listDLLs.size(); i++) { - - // Try to load the DLL and get the Icon and Name - QLibrary *protocolLib = new QLibrary(listDLLs.at(i)); - QString *protocolName = new QString(""); - QIcon *protocolIcon = new QIcon(); - - getProtocol = (importGetProtocolDll) protocolLib->resolve("GetProtocolDll"); - if (getProtocol) { - IProtocolDllPtr ptrXyz(getProtocol()); - if (ptrXyz) - { - pProtocolDll = ptrXyz; - pProtocolDll->getFullName( protocolName ); - pProtocolDll->getIcon( protocolIcon ); - - // - // Add the Icon and the Name to the Listbox and update the fileList - // - ui.iconcomboProtocol->addItem(*protocolIcon, *protocolName ); - protocolFileList.append(listDLLs.at(i)); - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); - } - - } - connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); - - // - // Get a List of all the Filter-DLL-files in the Program-folder. - // - filters.clear(); - filters << "FTNoIR_Filter_*.dll"; - filterFileList.clear(); - listDLLs.clear(); - listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - // - // Add strings to the Listbox. - // - disconnect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - ui.iconcomboFilter->clear(); - ui.iconcomboFilter->addItem("None"); - - for ( int i = 0; i < listDLLs.size(); i++) { - - // Try to load the DLL and get the Icon and Name - QLibrary *filterLib = new QLibrary(listDLLs.at(i)); - QString *filterName = new QString(""); - QIcon *filterIcon = new QIcon(); - - getFilter = (importGetFilterDll) filterLib->resolve("GetFilterDll"); - if (getFilter) { - IFilterDllPtr ptrXyz(getFilter()); - if (ptrXyz) - { - pFilterDll = ptrXyz; - pFilterDll->getFullName( filterName ); - pFilterDll->getIcon( filterIcon ); - - // - // Add the Icon and the Name to the Listbox and update the fileList - // - ui.iconcomboFilter->addItem(*filterIcon, *filterName ); - filterFileList.append(listDLLs.at(i)); - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); - } - - } - connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); - - // - // Get a List of all the Tracker-DLL-files in the Program-folder. - // - filters.clear(); - filters << "FTNoIR_Tracker_*.dll"; - trackerFileList.clear(); - listDLLs.clear(); - listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); - - // - // Add strings to the Listbox(es). - // - disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - ui.iconcomboTrackerSource->clear(); - - disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - ui.cbxSecondTrackerSource->clear(); - ui.cbxSecondTrackerSource->addItem("None"); - - for ( int i = 0; i < listDLLs.size(); i++) { - - // Try to load the DLL and get the Icon and Name - QLibrary *trackerLib = new QLibrary(listDLLs.at(i)); - QString *trackerName = new QString(""); - QIcon *trackerIcon = new QIcon(); - - getTracker = (importGetTrackerDll) trackerLib->resolve("GetTrackerDll"); - if (getTracker) { - ITrackerDll *ptrXyz(getTracker()); - if (ptrXyz) - { - pTrackerDll = ptrXyz; - pTrackerDll->getFullName( trackerName ); - pTrackerDll->getIcon( trackerIcon ); - - // - // Add the Icon and the Name to the Listbox and update the fileList - // - ui.iconcomboTrackerSource->addItem(*trackerIcon, *trackerName ); - ui.cbxSecondTrackerSource->addItem(*trackerIcon, *trackerName ); - trackerFileList.append(listDLLs.at(i)); - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Tracker-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); - } - - } - connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); - connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); -} - -// -// Create the Actions in the System tray and connect them to Application events -// -void FaceTrackNoIR::createActions() -{ - minimizeAction = new QAction(tr("Mi&nimize FaceTrackNoIR"), this); - connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); - - //maximizeAction = new QAction(tr("Ma&ximize"), this); - //connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); - - restoreAction = new QAction(tr("&Restore FaceTrackNoIR"), this); - connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); - - quitAction = new QAction(tr("&Quit FaceTrackNoIR"), this); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); -} - -// -// Create the SystemTray and set the default Icon -// -void FaceTrackNoIR::createTrayIcon() -{ - if (QSystemTrayIcon::isSystemTrayAvailable()) { - trayIconMenu = new QMenu(this); - trayIconMenu->addAction(minimizeAction); - trayIconMenu->addAction(restoreAction); - trayIconMenu->addSeparator(); - trayIconMenu->addAction(quitAction); - - trayIcon = new QSystemTrayIcon(this); - trayIcon->setContextMenu(trayIconMenu); - - trayIcon->setIcon(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico")); - } -} - -// -// Handle SystemTray events -// -void FaceTrackNoIR::iconActivated(QSystemTrayIcon::ActivationReason reason) -{ - switch (reason) { - case QSystemTrayIcon::Trigger: - case QSystemTrayIcon::DoubleClick: - //ui.iconcomboProtocol->setCurrentIndex((ui.iconcomboProtocol->currentIndex() + 1) - // % ui.iconcomboProtocol->count()); - break; - ////case QSystemTrayIcon::MiddleClick: - //// showMessage(); - //// break; - default: - ; - } - } - -// -// Handle changes of the Protocol selection -// -void FaceTrackNoIR::protocolSelected(int index) -{ - settingsDirty = true; - ui.btnShowServerControls->setEnabled ( true ); - - // - // Set the Icon for the tray and update the Icon for the Settings button. - // - QIcon icon = ui.iconcomboProtocol->itemIcon(index); - if (trayIcon != 0) { - trayIcon->setIcon(icon); - trayIcon->setToolTip(ui.iconcomboProtocol->itemText(index)); - trayIcon->show(); - trayIcon->showMessage( "FaceTrackNoIR", ui.iconcomboProtocol->itemText(index)); - } - setWindowIcon(QIcon(":/images/FaceTrackNoIR.ico")); - ui.btnShowServerControls->setIcon(icon); -} - -// -// Handle changes of the Tracking Source selection -// -void FaceTrackNoIR::trackingSourceSelected(int index) -{ - settingsDirty = true; - ui.btnShowEngineControls->setEnabled ( true ); -} - -// -// Handle changes of the Profile selection -// -void FaceTrackNoIR::profileSelected(int index) -{ - // - // Read the current INI-file setting, to get the folder in which it's located... - // - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - QFileInfo pathInfo ( currentFile ); - - // - // Save the name of the INI-file in the Registry. - // - settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.at(ui.iconcomboProfile->currentIndex())); - loadSettings(); -} - -// -// Handle changes of the Filter selection -// -void FaceTrackNoIR::filterSelected(int index) -{ - settingsDirty = true; - - //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) - - ui.btnShowFilterControls->setEnabled ( true ); -} - -// -// Constructor for FaceTrackNoIR=Preferences-dialog -// -PreferencesDialog::PreferencesDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - connect(ui.spinAutoMinimizeTime, SIGNAL(valueChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkAutoStartTracking, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.radioMinimize, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -PreferencesDialog::~PreferencesDialog() { - qDebug() << "~PreferencesDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void PreferencesDialog::doOK() { - save(); - this->close(); -} - -// override show event -void PreferencesDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void PreferencesDialog::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 PreferencesDialog::loadSettings() { - - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - ui.spinAutoMinimizeTime->setValue( settings.value ( "AutoMinimizeTime", 0 ).toInt() ); - ui.chkAutoStartTracking->setChecked( settings.value ( "AutoStartTracking", 0 ).toBool() ); - ui.radioMinimize->setChecked( settings.value ( "MinimizeTaskBar", 1 ).toBool() ); - - settingsDirty = false; - -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void PreferencesDialog::save() { - - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - settings.setValue( "AutoMinimizeTime", ui.spinAutoMinimizeTime->value() ); - settings.setValue( "AutoStartTracking", ui.chkAutoStartTracking->isChecked() ); - settings.setValue( "MinimizeTaskBar", ui.radioMinimize->isChecked() ); - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); - - settingsDirty = false; -} - -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Keyboard-shortcuts-dialog -// -KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(100, 100); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - connect(ui.cbxCenterKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.cbxCenterMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.chkCenterShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkCenterCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkCenterAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - - connect(ui.cbxGameZeroKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.cbxGameZeroMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.chkGameZeroShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkGameZeroCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkGameZeroAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - - connect(ui.cbxStartStopKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.cbxStartStopMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.chkStartStopShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkStartStopCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkStartStopAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.radioSetZero, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool))); - connect(ui.radioSetEngineStop, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool))); - - connect(ui.cbxInhibitKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.cbxInhibitMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); - connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - - // Also add events for the Axis-checkboxes - connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitYaw, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitRoll, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitX, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitY, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - connect(ui.chkInhibitZ, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); - - // - // Clear the Lists with key-descriptions and keycodes and build the Lists - // The strings will all be added to the ListBoxes for each Shortkey - // - stringList.clear(); - stringList.append("NONE"); - stringList.append("F1"); - stringList.append("F2"); - stringList.append("F3"); - stringList.append("F4"); - stringList.append("F5"); - stringList.append("F6"); - stringList.append("F7"); - stringList.append("F8"); - stringList.append("F9"); - stringList.append("F10"); - stringList.append("F11"); - stringList.append("F12"); - stringList.append("MINUS"); - stringList.append("EQUALS"); - stringList.append("BACK"); - stringList.append("A"); - stringList.append("B"); - stringList.append("C"); - stringList.append("D"); - stringList.append("E"); - stringList.append("F"); - stringList.append("G"); - stringList.append("H"); - stringList.append("I"); - stringList.append("J"); - stringList.append("K"); - stringList.append("L"); - stringList.append("M"); - stringList.append("N"); - stringList.append("O"); - stringList.append("P"); - stringList.append("Q"); - stringList.append("R"); - stringList.append("S"); - stringList.append("T"); - stringList.append("U"); - stringList.append("V"); - stringList.append("W"); - stringList.append("X"); - stringList.append("Y"); - stringList.append("Z"); - stringList.append("NUMPAD0"); - stringList.append("NUMPAD1"); - stringList.append("NUMPAD2"); - stringList.append("NUMPAD3"); - stringList.append("NUMPAD4"); - stringList.append("NUMPAD5"); - stringList.append("NUMPAD6"); - stringList.append("NUMPAD7"); - stringList.append("NUMPAD8"); - stringList.append("NUMPAD9"); - stringList.append("HOME"); - stringList.append("UP"); - stringList.append("PGUP"); /* PgUp on arrow keypad */ - stringList.append("LEFT"); - stringList.append("RIGHT"); - stringList.append("END"); - stringList.append("DOWN"); - stringList.append("PGDWN"); /* PgDn on arrow keypad */ - stringList.append("INSERT"); - stringList.append("DELETE"); - - keyList.clear(); - keyList.append(0); // NONE = 0 - keyList.append(DIK_F1); - keyList.append(DIK_F2); - keyList.append(DIK_F3); - keyList.append(DIK_F4); - keyList.append(DIK_F5); - keyList.append(DIK_F6); - keyList.append(DIK_F7); - keyList.append(DIK_F8); - keyList.append(DIK_F9); - keyList.append(DIK_F10); - keyList.append(DIK_F11); - keyList.append(DIK_F12); - keyList.append(DIK_MINUS); - keyList.append(DIK_EQUALS); - keyList.append(DIK_BACK); - keyList.append(DIK_A); - keyList.append(DIK_B); - keyList.append(DIK_C); - keyList.append(DIK_D); - keyList.append(DIK_E); - keyList.append(DIK_F); - keyList.append(DIK_G); - keyList.append(DIK_H); - keyList.append(DIK_I); - keyList.append(DIK_J); - keyList.append(DIK_K); - keyList.append(DIK_L); - keyList.append(DIK_M); - keyList.append(DIK_N); - keyList.append(DIK_O); - keyList.append(DIK_P); - keyList.append(DIK_Q); - keyList.append(DIK_R); - keyList.append(DIK_S); - keyList.append(DIK_T); - keyList.append(DIK_U); - keyList.append(DIK_V); - keyList.append(DIK_W); - keyList.append(DIK_X); - keyList.append(DIK_Y); - keyList.append(DIK_Z); - keyList.append(DIK_NUMPAD0); - keyList.append(DIK_NUMPAD1); - keyList.append(DIK_NUMPAD2); - keyList.append(DIK_NUMPAD3); - keyList.append(DIK_NUMPAD4); - keyList.append(DIK_NUMPAD5); - keyList.append(DIK_NUMPAD6); - keyList.append(DIK_NUMPAD7); - keyList.append(DIK_NUMPAD8); - keyList.append(DIK_NUMPAD9); - keyList.append(DIK_HOME); - keyList.append(DIK_UP); - keyList.append(DIK_PRIOR); /* PgUp on arrow keypad */ - keyList.append(DIK_LEFT); - keyList.append(DIK_RIGHT); - keyList.append(DIK_END); - keyList.append(DIK_DOWN); - keyList.append(DIK_NEXT); /* PgDn on arrow keypad */ - keyList.append(DIK_INSERT); - keyList.append(DIK_DELETE); - - // - // Add strings to the Listboxes. - // - for ( int i = 0; i < stringList.size(); i++) { - ui.cbxCenterKey->addItem(stringList.at(i)); - ui.cbxGameZeroKey->addItem(stringList.at(i)); - ui.cbxStartStopKey->addItem(stringList.at(i)); - ui.cbxInhibitKey->addItem(stringList.at(i)); - } - - // - // Clear the Lists with key-descriptions and keycodes and build the Lists - // The strings will all be added to the ListBoxes for each Shortkey - // - stringListMouse.clear(); - stringListMouse.append("NONE"); - stringListMouse.append("LEFT"); - stringListMouse.append("RIGHT"); - stringListMouse.append("MIDDLE"); - stringListMouse.append("BACK"); - stringListMouse.append("FORWARD"); - - // - // Add strings to the Listboxes. - // - for ( int i = 0; i < stringListMouse.size(); i++) { - ui.cbxCenterMouseKey->addItem(stringListMouse.at(i)); - ui.cbxGameZeroMouseKey->addItem(stringListMouse.at(i)); - ui.cbxStartStopMouseKey->addItem(stringListMouse.at(i)); - ui.cbxInhibitMouseKey->addItem(stringListMouse.at(i)); - } - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -KeyboardShortcutDialog::~KeyboardShortcutDialog() { - qDebug() << "~KeyboardShortcutDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void KeyboardShortcutDialog::doOK() { - save(); - this->close(); -} - -// override show event -void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void KeyboardShortcutDialog::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 KeyboardShortcutDialog::loadSettings() { -int keyindex; - - 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 ( "KB_Shortcuts" ); - - // Center key - ui.cbxCenterMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_Center", 0 ).toInt() ); - keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Center", DIK_HOME ).toInt() ); - if ( keyindex > 0 ) { - ui.cbxCenterKey->setCurrentIndex( keyindex ); - } - else { - ui.cbxCenterKey->setCurrentIndex( 0 ); - } - ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); - ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); - ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); - ui.chkDisableBeep->setChecked (iniFile.value ( "Disable_Beep", 0 ).toBool()); - - // GameZero key - ui.cbxGameZeroMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_GameZero", 0 ).toInt() ); - keyindex = keyList.indexOf ( iniFile.value ( "Keycode_GameZero", 1 ).toInt() ); - if ( keyindex > 0 ) { - ui.cbxGameZeroKey->setCurrentIndex( keyindex ); - } - else { - ui.cbxGameZeroKey->setCurrentIndex( 0 ); - } - ui.chkGameZeroShift->setChecked (iniFile.value ( "Shift_GameZero", 0 ).toBool()); - ui.chkGameZeroCtrl->setChecked (iniFile.value ( "Ctrl_GameZero", 0 ).toBool()); - ui.chkGameZeroAlt->setChecked (iniFile.value ( "Alt_GameZero", 0 ).toBool()); - - // Start/stop key - ui.cbxStartStopMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_StartStop", 0 ).toInt() ); - keyindex = keyList.indexOf ( iniFile.value ( "Keycode_StartStop", DIK_END ).toInt() ); - if ( keyindex > 0 ) { - ui.cbxStartStopKey->setCurrentIndex( keyindex ); - } - else { - ui.cbxStartStopKey->setCurrentIndex( 0 ); - } - ui.chkStartStopShift->setChecked (iniFile.value ( "Shift_StartStop", 0 ).toBool()); - ui.chkStartStopCtrl->setChecked (iniFile.value ( "Ctrl_StartStop", 0 ).toBool()); - ui.chkStartStopAlt->setChecked (iniFile.value ( "Alt_StartStop", 0 ).toBool()); - ui.radioSetZero->setChecked (iniFile.value ( "SetZero", 1 ).toBool()); - ui.radioSetFreeze->setChecked(!ui.radioSetZero->isChecked()); - ui.radioSetEngineStop->setChecked (iniFile.value ( "SetEngineStop", 1 ).toBool()); - ui.radioSetKeepTracking->setChecked(!ui.radioSetEngineStop->isChecked()); - - // Axis-inhibitor key - ui.cbxInhibitMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_Inhibit", 0 ).toInt() ); - keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Inhibit", 1 ).toInt() ); - if ( keyindex > 0 ) { - ui.cbxInhibitKey->setCurrentIndex( keyindex ); - } - else { - ui.cbxInhibitKey->setCurrentIndex( 0 ); - } - ui.chkInhibitShift->setChecked (iniFile.value ( "Shift_Inhibit", 0 ).toBool()); - ui.chkInhibitCtrl->setChecked (iniFile.value ( "Ctrl_Inhibit", 0 ).toBool()); - ui.chkInhibitAlt->setChecked (iniFile.value ( "Alt_Inhibit", 0 ).toBool()); - - ui.chkInhibitPitch->setChecked (iniFile.value ( "Inhibit_Pitch", 0 ).toBool()); - ui.chkInhibitYaw->setChecked (iniFile.value ( "Inhibit_Yaw", 0 ).toBool()); - ui.chkInhibitRoll->setChecked (iniFile.value ( "Inhibit_Roll", 0 ).toBool()); - ui.chkInhibitX->setChecked (iniFile.value ( "Inhibit_X", 0 ).toBool()); - ui.chkInhibitY->setChecked (iniFile.value ( "Inhibit_Y", 0 ).toBool()); - ui.chkInhibitZ->setChecked (iniFile.value ( "Inhibit_Z", 0 ).toBool()); - - - // Reverse Axis - ui.chkEnableReverseAxis->setChecked (iniFile.value ( "Enable_ReverseAxis", 0 ).toBool()); - ui.spinYawAngle4ReverseAxis->setValue( iniFile.value ( "RA_Yaw", 40 ).toInt() ); - ui.spinZ_Pos4ReverseAxis->setValue( iniFile.value ( "RA_ZPos", -20 ).toInt() ); - ui.spinZ_PosWhenReverseAxis->setValue( iniFile.value ( "RA_ToZPos", 50 ).toInt() ); - - iniFile.endGroup (); - - settingsDirty = false; - -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void KeyboardShortcutDialog::save() { - - qDebug() << "save() says: started"; - - 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 ( "KB_Shortcuts" ); - iniFile.setValue ( "MouseKey_Center", ui.cbxCenterMouseKey->currentIndex()); - iniFile.setValue ( "Keycode_Center", keyList.at( ui.cbxCenterKey->currentIndex() ) ); - iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); - iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); - iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); - iniFile.setValue ( "Disable_Beep", ui.chkDisableBeep->isChecked() ); - - iniFile.setValue ( "MouseKey_GameZero", ui.cbxGameZeroMouseKey->currentIndex()); - iniFile.setValue ( "Keycode_GameZero", keyList.at( ui.cbxGameZeroKey->currentIndex() ) ); - iniFile.setValue ( "Shift_GameZero", ui.chkGameZeroShift->isChecked() ); - iniFile.setValue ( "Ctrl_GameZero", ui.chkGameZeroCtrl->isChecked() ); - iniFile.setValue ( "Alt_GameZero", ui.chkGameZeroAlt->isChecked() ); - - iniFile.setValue ( "MouseKey_StartStop", ui.cbxStartStopMouseKey->currentIndex()); - iniFile.setValue ( "Keycode_StartStop", keyList.at( ui.cbxStartStopKey->currentIndex() ) ); - iniFile.setValue ( "Shift_StartStop", ui.chkStartStopShift->isChecked() ); - iniFile.setValue ( "Ctrl_StartStop", ui.chkStartStopCtrl->isChecked() ); - iniFile.setValue ( "Alt_StartStop", ui.chkStartStopAlt->isChecked() ); - iniFile.setValue ( "SetZero", ui.radioSetZero->isChecked() ); - iniFile.setValue ( "SetEngineStop", ui.radioSetEngineStop->isChecked() ); - - iniFile.setValue ( "MouseKey_Inhibit", ui.cbxInhibitMouseKey->currentIndex()); - iniFile.setValue ( "Keycode_Inhibit", keyList.at( ui.cbxInhibitKey->currentIndex() ) ); - iniFile.setValue ( "Shift_Inhibit", ui.chkInhibitShift->isChecked() ); - iniFile.setValue ( "Ctrl_Inhibit", ui.chkInhibitCtrl->isChecked() ); - iniFile.setValue ( "Alt_Inhibit", ui.chkInhibitAlt->isChecked() ); - - iniFile.setValue ( "Inhibit_Pitch", ui.chkInhibitPitch->isChecked() ); - iniFile.setValue ( "Inhibit_Yaw", ui.chkInhibitYaw->isChecked() ); - iniFile.setValue ( "Inhibit_Roll", ui.chkInhibitRoll->isChecked() ); - iniFile.setValue ( "Inhibit_X", ui.chkInhibitX->isChecked() ); - iniFile.setValue ( "Inhibit_Y", ui.chkInhibitY->isChecked() ); - iniFile.setValue ( "Inhibit_Z", ui.chkInhibitZ->isChecked() ); - - // Reverse Axis - iniFile.setValue ( "Enable_ReverseAxis", ui.chkEnableReverseAxis->isChecked() ); - iniFile.setValue( "RA_Yaw", ui.spinYawAngle4ReverseAxis->value() ); - iniFile.setValue( "RA_ZPos", ui.spinZ_Pos4ReverseAxis->value() ); - iniFile.setValue( "RA_ToZPos", ui.spinZ_PosWhenReverseAxis->value() ); - - iniFile.endGroup (); - - settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); -} - -//**************************************************************************************************// -//**************************************************************************************************// -// -// Constructor for Curve-configuration-dialog -// -CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : -QWidget( parent , f) -{ - ui.setupUi( this ); - - QPoint offsetpos(120, 30); - this->move(parent->pos() + offsetpos); - - mainApp = ftnoir; // Preserve a pointer to FTNoIR - - // Connect Qt signals to member-functions - connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); - connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); - - QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) - QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); - - ui.qFunctionX->setConfig(Tracker::X.curvePtr, currentFile); - connect(ui.qFunctionX, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionY->setConfig(Tracker::Y.curvePtr, currentFile); - connect(ui.qFunctionY, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionZ->setConfig(Tracker::Z.curvePtr, currentFile); - connect(ui.qFunctionZ, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - - ui.qFunctionYaw->setConfig(Tracker::Yaw.curvePtr, currentFile); - connect(ui.qFunctionYaw, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - // - // There are 2 curves for Pitch: Up and Down. Users have indicated that, to be able to use visual Flight controls, it is necessary to have a 'slow' curve for Down... - // - ui.qFunctionPitch->setConfig(Tracker::Pitch.curvePtr, currentFile); - connect(ui.qFunctionPitch, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - ui.qFunctionPitchDown->setConfig(Tracker::Pitch.curvePtrAlt, currentFile); - connect(ui.qFunctionPitchDown, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - - ui.qFunctionRoll->setConfig(Tracker::Roll.curvePtr, currentFile); - connect(ui.qFunctionRoll, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); - - // Load the settings from the current .INI-file - loadSettings(); -} - -// -// Destructor for server-dialog -// -CurveConfigurationDialog::~CurveConfigurationDialog() { - qDebug() << "~CurveConfigurationDialog() says: started"; -} - -// -// OK clicked on server-dialog -// -void CurveConfigurationDialog::doOK() { - save(); - this->close(); -} - -// override show event -void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { - loadSettings(); -} - -// -// Cancel clicked on server-dialog -// -void CurveConfigurationDialog::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 CurveConfigurationDialog::loadSettings() { -int NeutralZone; -int sensYaw, sensPitch, sensRoll; -int sensX, sensY, sensZ; - - 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 ( "Tracking" ); - NeutralZone = iniFile.value ( "NeutralZone", 5 ).toInt(); - sensYaw = iniFile.value ( "sensYaw", 100 ).toInt(); - sensPitch = iniFile.value ( "sensPitch", 100 ).toInt(); - sensRoll = iniFile.value ( "sensRoll", 100 ).toInt(); - sensX = iniFile.value ( "sensX", 100 ).toInt(); - sensY = iniFile.value ( "sensY", 100 ).toInt(); - sensZ = iniFile.value ( "sensZ", 100 ).toInt(); - - iniFile.endGroup (); - - ui.qFunctionYaw->loadSettings(currentFile); - ui.qFunctionPitch->loadSettings(currentFile); - ui.qFunctionPitchDown->loadSettings(currentFile); - ui.qFunctionRoll->loadSettings(currentFile); - - settingsDirty = false; - -} - -// -// Save the current Settings to the currently 'active' INI-file. -// -void CurveConfigurationDialog::save() { - - qDebug() << "save() says: started"; - - 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) - - ui.qFunctionYaw->saveSettings(currentFile); - ui.qFunctionPitch->saveSettings(currentFile); - ui.qFunctionPitchDown->saveSettings(currentFile); - ui.qFunctionRoll->saveSettings(currentFile); - - ui.qFunctionX->saveSettings(currentFile); - ui.qFunctionY->saveSettings(currentFile); - ui.qFunctionZ->saveSettings(currentFile); - - settingsDirty = false; - - // - // Send a message to the main program, to update the Settings (for the tracker) - // - mainApp->updateSettings(); -} diff --git a/FaceTrackNoIR/FaceTrackNoIR.h b/FaceTrackNoIR/FaceTrackNoIR.h deleted file mode 100644 index 756b5867..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR.h +++ /dev/null @@ -1,249 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ - -#ifndef FaceTrackNoIR_H -#define FaceTrackNoIR_H - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include "../FTNoIR_PoseWidget/glwidget.h" - -#include "ui_FaceTrackNoIR.h" -#include "ui_FTNoIR_KeyboardShortcuts.h" -#include "ui_FTNoIR_Preferences.h" -#include "ui_FTNoIR_Curves.h" - -#include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h" -#include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h" -#include "..\ftnoir_filter_base\FTNoIR_Filter_base.h" - -typedef ITrackerDialogPtr (WINAPI *importGetTrackerDialog)(void); -typedef ITrackerDllPtr (WINAPI *importGetTrackerDll)(void); -typedef IProtocolDialogPtr (WINAPI *importGetProtocolDialog)(void); -typedef IProtocolDllPtr (WINAPI *importGetProtocolDll)(void); -typedef IFilterDialogPtr (WINAPI *importGetFilterDialog)(void); -typedef IFilterDllPtr (WINAPI *importGetFilterDll)(void); - -#include - -class Tracker; // pre-define class to avoid circular includes - -class FaceTrackNoIR : public QMainWindow -{ - Q_OBJECT - -public: - FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); - ~FaceTrackNoIR(); - - void getGameProgramName(); // Get the ProgramName from the game and display it. - 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 getCurrentProtocolName(); // Get the name of the selected protocol - QString getCurrentFilterName(); // Get the name of the selected filter - QString getCurrentTrackerName(); // Get the name of the selected face-tracker - QString getSecondTrackerName(); // Get the name of the second face-tracker ("None" if no selection) - -private: - Ui::FaceTrackNoIRClass ui; - Tracker *tracker; - QTimer *timMinimizeFTN; // Timer to Auto-minimize - QTimer *timUpdateHeadPose; // Timer to display headpose - QStringList iniFileList; // List of INI-files, that are present in the Settings folder - QStringList protocolFileList; // List of Protocol-DLL-files, that are present in the program-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) - ITrackerDialogPtr pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) - IProtocolDialogPtr pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) - IFilterDialogPtr pFilterDialog; // Pointer to Filter dialog instance (in DLL) - - /** Widget variables **/ - QVBoxLayout *l; - QWidget *_preferences; - QWidget *_keyboard_shortcuts; - QWidget *_curve_config; - GLWidget *_pose_display; - - /** QT objects **/ - QDialog aboutDialog; - QDesktopWidget desktop; - - QAction *minimizeAction; - QAction *restoreAction; - QAction *quitAction; - - QSystemTrayIcon *trayIcon; - QMenu *trayIconMenu; - - void createIconGroupBox(); -// void createMessageGroupBox(); - void createActions(); - void createTrayIcon(); - - /** helper **/ - bool cameraDetected; - bool settingsDirty; - - void GetCameraNameDX(); - void loadSettings(); - void setupFaceTrackNoIR(); - - private slots: - //file menu - void open(); - void save(); - void saveAs(); - void exit(); - - //about menu - void openurl_support(); - void openurl_donation(); - void about(); - -// void setIcon(int index); - void iconActivated(QSystemTrayIcon::ActivationReason reason); - void profileSelected(int index); - void protocolSelected(int index); - void filterSelected(int index); - void trackingSourceSelected(int index); - - void showVideoWidget(); - void showHeadPoseWidget(); - void showTrackerSettings(); - void showSecondTrackerSettings(); - - void showServerControls(); - void showFilterControls(); - void showPreferences(); - void showKeyboardShortcuts(); - void showCurveConfiguration(); - - void setInvertYaw( int invert ); - void setInvertPitch( int invert ); - void setInvertRoll( int invert ); - void setInvertX( int invert ); - void setInvertY( int invert ); - void setInvertZ( int invert ); - - void showHeadPose(); - - //smoothing slider - void setSmoothing( int smooth ); - - void startTracker(); - void stopTracker(); -}; - -// Widget that has controls for FaceTrackNoIR Preferences. -class PreferencesDialog: public QWidget, public Ui::UICPreferencesDialog -{ - Q_OBJECT -public: - - explicit PreferencesDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~PreferencesDialog(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICPreferencesDialog ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - -private slots: - void doOK(); - void doCancel(); - void keyChanged( int index ) { settingsDirty = true; }; -}; - -// Widget that has controls for Keyboard shortcuts. -class KeyboardShortcutDialog: public QWidget, public Ui::UICKeyboardShortcutDialog -{ - Q_OBJECT -public: - - explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~KeyboardShortcutDialog(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICKeyboardShortcutDialog ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - QList stringList; // List of strings, that describe the keyboard-keys - QList keyList; // List of keys, with the values of the keyboard-keys - QList stringListMouse; // List of strings, that describe the mouse-keys - -private slots: - void doOK(); - void doCancel(); - void keyChanged( int index ) { settingsDirty = true; }; - void keyChanged( bool index ) { settingsDirty = true; }; -}; - -// Widget that has controls for Keyboard shortcuts. -class CurveConfigurationDialog: public QWidget, public Ui::UICCurveConfigurationDialog -{ - Q_OBJECT -public: - - explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); - virtual ~CurveConfigurationDialog(); - void showEvent ( QShowEvent * event ); - -private: - Ui::UICCurveConfigurationDialog ui; - void loadSettings(); - void save(); - - /** helper **/ - bool settingsDirty; - FaceTrackNoIR *mainApp; - -private slots: - void doOK(); - void doCancel(); - void curveChanged( bool change ) { settingsDirty = true; }; -}; - - -#endif // FaceTrackNoIR_H diff --git a/FaceTrackNoIR/FaceTrackNoIR.ico b/FaceTrackNoIR/FaceTrackNoIR.ico deleted file mode 100644 index 5115066c..00000000 Binary files a/FaceTrackNoIR/FaceTrackNoIR.ico and /dev/null differ diff --git a/FaceTrackNoIR/FaceTrackNoIR.qrc b/FaceTrackNoIR/FaceTrackNoIR.qrc deleted file mode 100644 index 60e4da7b..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR.qrc +++ /dev/null @@ -1,14 +0,0 @@ - - - UIElements/Tools.png - images/Settings16.png - images/SettingsOpen16.png - UIElements/Donate.png - UIElements/Curves.png - images/rotation_DOFs.png - images/translation_DOFs.png - images/330px-6DOF_en.png - images/FaceTrackNoIR.ico - UIElements/aboutFaceTrackNoIR.png - - diff --git a/FaceTrackNoIR/FaceTrackNoIR.rc b/FaceTrackNoIR/FaceTrackNoIR.rc deleted file mode 100644 index ed8a68c1..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR.rc +++ /dev/null @@ -1,84 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Dutch (Neutral) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) -#ifdef _WIN32 -LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL -#pragma code_page(1252) -#endif //_WIN32 - -///////////////////////////////////////////////////////////////////////////// -// -// Icon -// - -// Icon with lowest ID value placed first to ensure application icon -// remains consistent on all systems. -IDI_ICON1 ICON "FaceTrackNoIR.ico" -#endif // Dutch (Neutral) resources -///////////////////////////////////////////////////////////////////////////// - - -///////////////////////////////////////////////////////////////////////////// -// German (Germany) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) -#ifdef _WIN32 -LANGUAGE LANG_GERMAN, SUBLANG_GERMAN -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - -#endif // German (Germany) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/FaceTrackNoIR/FaceTrackNoIR.ui b/FaceTrackNoIR/FaceTrackNoIR.ui deleted file mode 100644 index 8c3db4a4..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR.ui +++ /dev/null @@ -1,2375 +0,0 @@ - - - WVR - FaceTrackNoIRClass - - - Qt::NonModal - - - - 0 - 0 - 925 - 415 - - - - - 0 - 0 - - - - - 0 - 415 - - - - - 16777215 - 415 - - - - Qt::DefaultContextMenu - - - FaceTrackNoIR - - - - UIElements/FaceTrackNoIR.icoUIElements/FaceTrackNoIR.ico - - - - - - /* Customize any plain widget that is a child of a QMainWindow. */ -QMainWindow > .QWidget { - background-color: rgb(100, 100, 100); -} - -/* Set the selection colors for all widgets. */ -QWidget { - selection-color: black; - selection-background-color: Silver; - color: black; -} - -/* Specials for individual widget(s) */ -QWidget#widget { -/* background-color: #484848;*/ - background-color: #595959; - border-left: 1px solid #000; -} - -/* Specials for individual widget(s) */ -QWidget#widget4logo { - background-color: #000000; -} - -/* Specials for individual widget(s) */ -QWidget#headPoseWidget { - background-color: #595959; -} - -QWidget#widget4video { -/* background-color: #595959;*/ -} - -QWidget#Leftwidget { - background-color: ; -} - -QWidget#widgetTop { - background-color: #595959; - border-bottom: 1px solid #000; -} - -/* Make text in message boxes selectable. */ -QMessageBox { - /* LinksAccessibleByMouse | TextSelectableByMouse */ - messagebox-text-interaction-flags: 5; -} - -/* Make the entire row selected in item views. */ -QAbstractItemView { - show-decoration-selected: 1; -} - -/* Nice WindowsXP-style password character for password line edits. */ -QLineEdit[echoMode="2"] { - lineedit-password-character: 9679; -} - -/* Customize tooltips. */ -QToolTip { - background-color: rgb(170, 255, 127); - opacity: 200; -} - -/* Customize push buttons and comboboxes. Our read-only combobox - is very similar to a push button, so they share the same border image. */ - -QPushButton { - min-width: 4em; -} - -QCheckBox { - background:none; -} - -QPushButton:disabled { - color: rgb(128, 128, 128); -} - -QGroupBox { - color: rgb(255, 255, 255); -} - - - - - - Qt::ToolButtonIconOnly - - - true - - - - - 925 - 350 - - - - - - - - 0 - - - 0 - - - - - 0 - - - - - 0 - - - 0 - - - 6 - - - - - - 250 - 170 - - - - - - 0 - 0 - 250 - 170 - - - - - 250 - 150 - - - - - 500 - 500 - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - 0 - 90 - - - - - 16777215 - 90 - - - - - - 100 - 1 - 145 - 34 - - - - PointingHandCursor - - - Please help us: make gaming fun... - - - Click here to -Support FaceTrackNoIR! - - - - :/UIElements/Donate.png:/UIElements/Donate.png - - - - 18 - 18 - - - - - - - 196 - 34 - 50 - 21 - - - - false - - - color: rgb(0, 255, 0); - - - QFrame::NoFrame - - - QFrame::Raised - - - 5 - - - QLCDNumber::Flat - - - - - - 196 - 52 - 50 - 21 - - - - false - - - color: rgb(0, 255, 0); - - - QFrame::NoFrame - - - QFrame::Raised - - - 5 - - - QLCDNumber::Flat - - - - - - 196 - 70 - 50 - 21 - - - - false - - - color: rgb(0, 255, 0); - - - QFrame::NoFrame - - - QFrame::Raised - - - 5 - - - QLCDNumber::Flat - - - - - - 112 - 34 - 50 - 21 - - - - false - - - color: rgb(0, 255, 0); - - - QFrame::NoFrame - - - QFrame::Raised - - - 5 - - - QLCDNumber::Flat - - - - - - 112 - 52 - 50 - 21 - - - - false - - - color: rgb(0, 255, 0); - - - QFrame::NoFrame - - - QFrame::Raised - - - 5 - - - QLCDNumber::Flat - - - - - - 112 - 70 - 50 - 21 - - - - false - - - color: rgb(0, 255, 0); - - - QFrame::NoFrame - - - QFrame::Raised - - - 5 - - - QLCDNumber::Flat - - - - - - 104 - 35 - 16 - 16 - - - - color: rgb(0, 255, 0); - - - X - - - - - - 105 - 55 - 16 - 16 - - - - color: rgb(0, 255, 0); - - - Y - - - - - - 105 - 74 - 16 - 16 - - - - color: rgb(0, 255, 0); - - - Z - - - - - - 164 - 74 - 20 - 16 - - - - color: rgb(0, 255, 0); - - - roll - - - - - - 166 - 35 - 20 - 16 - - - - color: rgb(0, 255, 0); - - - yaw - - - - - - 164 - 55 - 25 - 16 - - - - color: rgb(0, 255, 0); - - - pitch - - - - - - - - - - - 0 - 160 - - - - - 16777215 - 160 - - - - - - - - - 10 - 60 - 231 - 80 - - - - Raw Input - - - true - - - - - 150 - 60 - 71 - 21 - - - - QFrame::NoFrame - - - 6 - - - - - - 150 - 20 - 71 - 21 - - - - QFrame::NoFrame - - - 6 - - - - - - 10 - 20 - 21 - 16 - - - - border:none; -color:white - - - X - - - - - - 10 - 40 - 21 - 16 - - - - border:none; -color:white; - - - Y - - - - - - 30 - 60 - 61 - 21 - - - - QFrame::NoFrame - - - - - - 10 - 60 - 21 - 16 - - - - color:white; -border:none; - - - Z - - - - - - 30 - 40 - 61 - 21 - - - - QFrame::NoFrame - - - - - - 108 - 58 - 31 - 20 - - - - border:none; -color:white; - - - roll - - - - - - 109 - 38 - 31 - 20 - - - - color:white; -border:none; - - - pitch - - - - - - 108 - 18 - 31 - 20 - - - - border:none; -color:white; - - - yaw - - - - - - 150 - 40 - 71 - 21 - - - - QFrame::NoFrame - - - 6 - - - - - - 30 - 20 - 61 - 21 - - - - QFrame::NoFrame - - - 5 - - - - - - - 10 - 10 - 231 - 50 - - - - Status - - - true - - - - - 110 - 10 - 101 - 16 - - - - border:none; -color: rgb(0, 255, 0); - - - Tracking - - - - - - 110 - 30 - 101 - 16 - - - - border:none; -color: rgb(0, 255, 0); - - - Axis Reverse - - - - - - - - - - - true - - - - 0 - 0 - - - - - 400 - 300 - - - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 89 - 89 - 89 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 72 - 72 - 72 - - - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 89 - 89 - 89 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 72 - 72 - 72 - - - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 89 - 89 - 89 - - - - - - - 89 - 89 - 89 - - - - - - - 192 - 192 - 192 - - - - - - - 0 - 0 - 0 - - - - - - - 72 - 72 - 72 - - - - - - - - false - - - - - - - - - - - - - - 10 - - - 10 - - - - - - 206 - 120 - - - - - 210 - 120 - - - - Profile - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 10 - - - - - true - - - - 10 - 80 - 180 - 23 - - - - Save the INI-file under another name - - - - - - Save As ... - - - - - - 10 - 50 - 81 - 23 - - - - Load an INI-file from a folder - - - - - - Load - - - - - true - - - - 110 - 50 - 81 - 23 - - - - Save the current INI-file - - - - - - Save - - - - - - - - - 420 - 120 - - - - - 16777215 - 120 - - - - Global Settings - - - - - 9 - 20 - 171 - 80 - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - color:#ccc; -background:none; - - - Smoothing: - - - - - - - color:#ccc; -background:none; - - - (samples) - - - - - - - - 50 - 15 - - - - 1 - - - 50 - - - 5 - - - 10 - - - Qt::Horizontal - - - QSlider::NoTicks - - - - - - - - 35 - 22 - - - - background:none; - - - 1 - - - 50 - - - 10 - - - - - - - - - 190 - 20 - 211 - 81 - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - color:#ccc; -background:none; - - - Roll - - - - - - - background:none; - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - color:#ccc; -background:none; - - - Z - - - - - - - background:none; - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - color:#ccc; -background:none; - - - Pitch - - - - - - - background:none; - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - color:#ccc; -background:none; - - - Y - - - - - - - background:none; - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - color:#ccc; -background:none; - - - Yaw - - - - - - - background:none; - - - - - - - - - - - 25 - 0 - - - - - 150 - 16777215 - - - - Qt::RightToLeft - - - color:#ccc; -background:none; - - - X - - - - - - - background:none; - - - - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - color:#ccc; -background:none; - - - Invert - - - - - - - - 0 - 0 - - - - - 30 - 16777215 - - - - color:#ccc; -background:none; - - - Invert - - - - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - - - 500 - 67 - - - - - 700 - 67 - - - - true - - - background: url("UIElements/bubble_1_small.png") no-repeat; -opacity:100; - - - - 0 - - - 15 - - - 10 - - - 10 - - - 10 - - - - - - - - - - 400 - 25 - - - - - 600 - 30 - - - - color:#ccc; -background:none; - - - Camera Name - - - - - - - - 400 - 20 - - - - - 600 - 30 - - - - color:#ccc; -background:none; - - - Game Name - - - - - - - - - - - - - - - - 10 - - - 6 - - - - - - 200 - 80 - - - - - 200 - 80 - - - - - - - Tracker Source(1st = Master) - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 5 - - - - - true - - - - 10 - 50 - 180 - 23 - - - - Change tracker settings - - - - - - Settings - - - - - - - - - 200 - 70 - - - - - 200 - 80 - - - - - - - Filter - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 7 - - - - - true - - - - 10 - 50 - 180 - 23 - - - - Change game protocol settings - - - - - - Settings - - - - - - - - - 200 - 80 - - - - - 200 - 80 - - - - - - - Game protocol - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 7 - - - - - true - - - - 10 - 50 - 180 - 23 - - - - Change game protocol settings - - - - - - Settings - - - - - - - - - 200 - 80 - - - - - 16777215 - 80 - - - - GO! - - - - - 10 - 20 - 81 - 23 - - - - Start the Tracker - - - - - - Start - - - - - false - - - - 100 - 20 - 81 - 23 - - - - Stop the Tracker - - - - - - Stop - - - - - - - - - 200 - 80 - - - - - 200 - 80 - - - - Tracker Source (2nd) - - - - true - - - - 10 - 50 - 180 - 23 - - - - Change tracker settings - - - - - - Settings - - - - - - 10 - 20 - 180 - 22 - - - - - - - -1 - - - 5 - - - - - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - - - - 52 - 38 - - - - - 200 - 16777215 - - - - PointingHandCursor - - - Edit the Keyboard and mouse shortcuts - - - Shortkeys - - - - :/UIElements/Tools.png:/UIElements/Tools.png - - - - 24 - 24 - - - - - - - - - 52 - 38 - - - - - 200 - 16777215 - - - - PointingHandCursor - - - Edit the Curve settings - - - Qt::LeftToRight - - - background:none; - - - Curves - - - - :/UIElements/Curves.png:/UIElements/Curves.png - - - - 120 - 24 - - - - - - - - - - - - - - - - - - - - - 0 - 0 - 925 - 21 - - - - b - - - - File - - - - - - - - - - View - - - - - - Options - - - - - - - - - Help - - - - - - - - - - - - - - &Open - - - Ctrl+O - - - false - - - - - &Exit - - - Ctrl+Q - - - QAction::QuitRole - - - false - - - - - true - - - Play / Pause - - - false - - - - - Next - - - Ctrl+. - - - false - - - - - Previews - - - Ctrl+, - - - false - - - - - Volume Up - - - Ctrl++ - - - false - - - - - Volume Down - - - Ctrl+- - - - false - - - - - true - - - true - - - Video Widget - - - Ctrl+V - - - - - true - - - HeadPose Widget - - - Ctrl+W - - - - - About FaceTrackNoIR - - - Ctrl+A - - - - - true - - - Mute - - - Ctrl+M - - - - - Save - - - - - Save As - - - - - Keyboard and Mouse Shortcuts - - - - - Preferences - - - - - Curve Configuration - - - - - Support - - - - - Your Support - - - - - - iconcomboTrackerSource - btnStartTracker - btnStopTracker - btnShowEngineControls - iconcomboProtocol - - - - - - - slideSmoothing - valueChanged(int) - spinSmoothing - setValue(int) - - - 442 - 387 - - - 494 - 389 - - - - - spinSmoothing - valueChanged(int) - slideSmoothing - setValue(int) - - - 494 - 389 - - - 442 - 387 - - - - - diff --git a/FaceTrackNoIR/FaceTrackNoIR_vc8.vcproj b/FaceTrackNoIR/FaceTrackNoIR_vc8.vcproj deleted file mode 100644 index 524e7826..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR_vc8.vcproj +++ /dev/null @@ -1,892 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj b/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj deleted file mode 100644 index 56b5e1d5..00000000 --- a/FaceTrackNoIR/FaceTrackNoIR_vc9.vcproj +++ /dev/null @@ -1,886 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FaceTrackNoIR/Readme.txt b/FaceTrackNoIR/Readme.txt deleted file mode 100644 index 8bd28966..00000000 --- a/FaceTrackNoIR/Readme.txt +++ /dev/null @@ -1,31 +0,0 @@ -FaceTrackNoIR (v. 1.6.0). - -FaceTrackNoIR is a head-tracker, which uses the FaceAPI provided by SeeingMachines. It was made using Visual Studio 2005 and Qt. -The major advantage over other headtrackers is, that it uses a simple webcam to track the face of 'the gamer'. There is no need -for expensive equipment or even Borg-like devices with LED's and such. - - -Installation: -To install the program, simply start Setup.exe and follow the directions. Use the desktop-icon to start FaceTrackNoIR. - -Compatibility: -FaceTrackNoIR is made for Windows and tested on XP, Vista and Windows7. The FaceAPI creators recommend a dual-core processor or better. -Because the 'non-commercial' version of the FaceAPI is used, the webcam can not be 'chosen': it always uses the first webcam it finds! When FaceTrackNoIR is started, the name of this webcam is displayed. - - -Games: -FaceTrackNoIR supports several protocols, so it can be used with several games, flight-sims and other. Check out the website for a -list: http://facetracknoir.sourceforge.net/compatibility/games.htm - -Visit the website for the latest info! - - -Please let us know if you like the program, if you have ideas for improvements or any questions you might have. -The source is also available! - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks -and others... diff --git a/FaceTrackNoIR/Readme_Update_20100615.txt b/FaceTrackNoIR/Readme_Update_20100615.txt deleted file mode 100644 index e43d954c..00000000 --- a/FaceTrackNoIR/Readme_Update_20100615.txt +++ /dev/null @@ -1,51 +0,0 @@ -FaceTrackNoIR (v. 20100615). - -From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep -improving FaceTrackNoIR... - -Installation: -Unzip the .exe to the installation folder of FaceTrackNoIR (best rename the old .exe first). The folders in the ZIP-file -contain support info and examples of a .INI-file (IL-2) and a script for GlovePIE. - - -The following upgrades have been applied: - -- ‘=’ is center view - -- ‘BACKSPACE’ = start (+center)/stop tracking. A messagebeep is generated when tracking is resumed and the - headpose-data is valid again (faceAPI has 'locked on'... ). - -- Checkbox ‘use EWMA filter’: Ticking this checkbox will make FaceTrackNoIR filter the headpose data with - a so-called 'Exponentially Weighed Moving Average'. This technique was adopted from FlightGear, where - Melchior Franz had 'invented' it. - If the filter is active, the factor for each of the 6 DOF's are used. These factors determine the weight that is - given to previous measurements and goes from 0 - 1 (in the GUI this setting is 0 - 100). A lower value will give a quicker response (but less stable). - - Remark: for FlightGear, the EWMA checkbox does nothing: the filter is embedded in the FlightGear script. - -- Some timing-issues with the faceAPI were resolved, so now the scanning-frequency can be higher that 20Hz. - We do not know yet, how this influences performance of both FaceTrackNoIR and your CPU. Experience learns, that - the headtracking is influenced by many factors, like CPU, video-card, framerate of the game etc. - -- The protocol-server that is selected in the combobox is now the only one that is started, when the tracker is started. - Before loading an .INI-file, please stop the tracker. - -- PPJoy support is added, so now FaceTrackNoIR can be used for other games too. We tested this feature with IL-2, - using GlovePIE to generate TrackIR data. Check out the files in the ZIP-file for instructions. PPjoy was created by - Deon van der Westhuysen and GlovePIE by Carl Kenner. We thank them both for their effort! - - - -Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge -(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. - -If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive -examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - diff --git a/FaceTrackNoIR/Readme_Update_20100716.txt b/FaceTrackNoIR/Readme_Update_20100716.txt deleted file mode 100644 index e99111a1..00000000 --- a/FaceTrackNoIR/Readme_Update_20100716.txt +++ /dev/null @@ -1,35 +0,0 @@ -FaceTrackNoIR (v. 20100716). - -From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep -improving FaceTrackNoIR... - -Installation: -Unzip the .exe and .dll to the installation folder of FaceTrackNoIR (best rename the old .exe first). The folders in the ZIP-file contain icons for the protocols and an .INI-file (FreeFalcon). Extract these to the folder 'Settings' and 'Images'. - - -The following upgrades have been applied: - -- TrackIR support is added. Start FaceTrackNoIR and the TrackIR-protocol before starting the game (at least once).. - A registry-entry is added/changed, that the game or flightsim needs. - -Hints from the previous update: -- ‘=’ is center view - -- ‘BACKSPACE’ = start (+center)/stop tracking. A messagebeep is generated when tracking is resumed and the - headpose-data is valid again (faceAPI has 'locked on'... ). - - - -Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge -(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. - -If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive -examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - diff --git a/FaceTrackNoIR/Readme_Update_20100822.txt b/FaceTrackNoIR/Readme_Update_20100822.txt deleted file mode 100644 index e121fe9f..00000000 --- a/FaceTrackNoIR/Readme_Update_20100822.txt +++ /dev/null @@ -1,32 +0,0 @@ -FaceTrackNoIR (v. 20100822). - -From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep -improving FaceTrackNoIR... - -Installation: -Unzip all files to the installation folder of FaceTrackNoIR (typicaly c:\program files\abbequerque inc\facetracknoir\): overwrite files when asked. - - -The following upgrades have been applied: - -- The program-menu now contains a Tools menu. Via this menu the program preferences and keyboard shortcuts can be modified. - -- The preferences dialog contains the 'Auto-minimize' setting: FaceTrackNoIR will minimize x sec. after starting the face-tracker. - Entering 0 will disable auto-minimize. This setting is global, for all INI-files. - -- The keyboard shortcuts for 'center' and 'start/stop' can be assigned here. These settings are stored in the INI-file. - - -Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge -(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. - -If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive -examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! - - - -The FaceTrackNoIR team: - -Wim Vriend -Ron Hendriks - diff --git a/FaceTrackNoIR/UIElements/ButtonIcoBlack.bmp b/FaceTrackNoIR/UIElements/ButtonIcoBlack.bmp deleted file mode 100644 index 9bc402aa..00000000 Binary files a/FaceTrackNoIR/UIElements/ButtonIcoBlack.bmp and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Curves.png b/FaceTrackNoIR/UIElements/Curves.png deleted file mode 100644 index fe21fa15..00000000 Binary files a/FaceTrackNoIR/UIElements/Curves.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Donate.png b/FaceTrackNoIR/UIElements/Donate.png deleted file mode 100644 index cf4223fb..00000000 Binary files a/FaceTrackNoIR/UIElements/Donate.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/FaceTrackNoIR.ico b/FaceTrackNoIR/UIElements/FaceTrackNoIR.ico deleted file mode 100644 index af36ec30..00000000 Binary files a/FaceTrackNoIR/UIElements/FaceTrackNoIR.ico and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.jpg b/FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.jpg deleted file mode 100644 index 73ead853..00000000 Binary files a/FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.jpg and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.png b/FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.png deleted file mode 100644 index c4e63c76..00000000 Binary files a/FaceTrackNoIR/UIElements/Logo_FaceTrackNoIR_32px.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Logo_NoIR.png b/FaceTrackNoIR/UIElements/Logo_NoIR.png deleted file mode 100644 index bb654a07..00000000 Binary files a/FaceTrackNoIR/UIElements/Logo_NoIR.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Logo_NoIR_small.png b/FaceTrackNoIR/UIElements/Logo_NoIR_small.png deleted file mode 100644 index 5d49e0b1..00000000 Binary files a/FaceTrackNoIR/UIElements/Logo_NoIR_small.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Logo_NoIR_small_target.png b/FaceTrackNoIR/UIElements/Logo_NoIR_small_target.png deleted file mode 100644 index 4bbaf41f..00000000 Binary files a/FaceTrackNoIR/UIElements/Logo_NoIR_small_target.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Logo_NoIR_small_target90px.png b/FaceTrackNoIR/UIElements/Logo_NoIR_small_target90px.png deleted file mode 100644 index ecaa4e12..00000000 Binary files a/FaceTrackNoIR/UIElements/Logo_NoIR_small_target90px.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/Tools.png b/FaceTrackNoIR/UIElements/Tools.png deleted file mode 100644 index 2da8f9f5..00000000 Binary files a/FaceTrackNoIR/UIElements/Tools.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/aboutFaceTrackNoIR.png b/FaceTrackNoIR/UIElements/aboutFaceTrackNoIR.png deleted file mode 100644 index 90f8f792..00000000 Binary files a/FaceTrackNoIR/UIElements/aboutFaceTrackNoIR.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/bubble_1_small.png b/FaceTrackNoIR/UIElements/bubble_1_small.png deleted file mode 100644 index ebd4e66f..00000000 Binary files a/FaceTrackNoIR/UIElements/bubble_1_small.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/bubble_2_big.png b/FaceTrackNoIR/UIElements/bubble_2_big.png deleted file mode 100644 index 5dc40254..00000000 Binary files a/FaceTrackNoIR/UIElements/bubble_2_big.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/logoFaceTrackNoIR.png b/FaceTrackNoIR/UIElements/logoFaceTrackNoIR.png deleted file mode 100644 index a1a3407b..00000000 Binary files a/FaceTrackNoIR/UIElements/logoFaceTrackNoIR.png and /dev/null differ diff --git a/FaceTrackNoIR/UIElements/logoFaceTrackNoIR60px.png b/FaceTrackNoIR/UIElements/logoFaceTrackNoIR60px.png deleted file mode 100644 index f01f6024..00000000 Binary files a/FaceTrackNoIR/UIElements/logoFaceTrackNoIR60px.png and /dev/null differ diff --git a/FaceTrackNoIR/images/330px-6DOF_en.png b/FaceTrackNoIR/images/330px-6DOF_en.png deleted file mode 100644 index 9d1d72ff..00000000 Binary files a/FaceTrackNoIR/images/330px-6DOF_en.png and /dev/null differ diff --git a/FaceTrackNoIR/images/FaceTrackNoIR.ico b/FaceTrackNoIR/images/FaceTrackNoIR.ico deleted file mode 100644 index 5115066c..00000000 Binary files a/FaceTrackNoIR/images/FaceTrackNoIR.ico and /dev/null differ diff --git a/FaceTrackNoIR/images/Settings16.png b/FaceTrackNoIR/images/Settings16.png deleted file mode 100644 index 3b31623b..00000000 Binary files a/FaceTrackNoIR/images/Settings16.png and /dev/null differ diff --git a/FaceTrackNoIR/images/SettingsOpen16.png b/FaceTrackNoIR/images/SettingsOpen16.png deleted file mode 100644 index 5bf65f0d..00000000 Binary files a/FaceTrackNoIR/images/SettingsOpen16.png and /dev/null differ diff --git a/FaceTrackNoIR/images/rotation_DOFs.png b/FaceTrackNoIR/images/rotation_DOFs.png deleted file mode 100644 index 68682d88..00000000 Binary files a/FaceTrackNoIR/images/rotation_DOFs.png and /dev/null differ diff --git a/FaceTrackNoIR/images/translation_DOFs.png b/FaceTrackNoIR/images/translation_DOFs.png deleted file mode 100644 index 886c586e..00000000 Binary files a/FaceTrackNoIR/images/translation_DOFs.png and /dev/null differ diff --git a/FaceTrackNoIR/main.cpp b/FaceTrackNoIR/main.cpp deleted file mode 100644 index 6e0549d7..00000000 --- a/FaceTrackNoIR/main.cpp +++ /dev/null @@ -1,59 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -/* - Modifications (last one on top): - 20100520 - WVR: Added class FaceApp, to override winEventFilter. It receives - messages from the Game. -*/ - -#include "FaceApp.h" -#include "FaceTrackNoIR.h" -#include -#include -#include -#include - -int main(int argc, char *argv[]) -{ -//// QApplication a(argc, argv); - FaceApp a(argc, argv); - QFont font; - font.setFamily(font.defaultFamily()); - font.setPointSize(9); - a.setFont(font); - - // - // Create the Main Window and DeskTop and Exec! - // - FaceTrackNoIR w; - a.SetupEventFilter(&w); - - QDesktopWidget desktop; - w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); - w.show(); - qApp->exec(); - - return 0; -} - diff --git a/FaceTrackNoIR/paintwidget.h b/FaceTrackNoIR/paintwidget.h deleted file mode 100644 index e69de29b..00000000 diff --git a/FaceTrackNoIR/postbuild.bat b/FaceTrackNoIR/postbuild.bat deleted file mode 100644 index 6653067e..00000000 --- a/FaceTrackNoIR/postbuild.bat +++ /dev/null @@ -1,27 +0,0 @@ -@echo off -rem Copies required DLL files into output folder. - -setlocal -set COPY=xcopy /D /S /C /I /H /R /Y -set FILTER=find /v "File(s) copied" - -echo parameters %1 en %2 en %3 - -set API_BIN=%1 -set OUTDIR=%2 -set CONFIG=%3 - -if %CONFIG%==Debug (goto Debug) -if %CONFIG%==Release (goto Release) - -echo Unknown build configuration %CONFIG% -exit /b -1 - -:Debug -%COPY% %API_BIN% %OUTDIR%\ | %FILTER% -exit /b 0 - -:Release -%COPY% %API_BIN% %OUTDIR%\ | %FILTER% -exit /b 0 - diff --git a/FaceTrackNoIR/resource.h b/FaceTrackNoIR/resource.h deleted file mode 100644 index 75059fe3..00000000 --- a/FaceTrackNoIR/resource.h +++ /dev/null @@ -1,16 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by Sweetspotter.rc -// -#define IDI_ICON1 102 - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 103 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/FaceTrackNoIR/rotation.cpp b/FaceTrackNoIR/rotation.cpp deleted file mode 100644 index 1c89d775..00000000 --- a/FaceTrackNoIR/rotation.cpp +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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 "rotation.h" - -#include - -// ---------------------------------------------------------------------------- -Rotation Rotation::inv() -{ - return Rotation(a,-b,-c,-d); -} - -// conversions -// see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles -void Rotation::fromEuler(double yaw, double pitch, double roll) -{ - double sin_phi = sin(roll/2.0); - double cos_phi = cos(roll/2.0); - double sin_the = sin(pitch/2.0); - double cos_the = cos(pitch/2.0); - double sin_psi = sin(yaw/2.0); - double cos_psi = cos(yaw/2.0); - - a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; - b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; - c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; - d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; -} - -void Rotation::toEuler(double& yaw, double& pitch, double& roll) -{ - roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); - pitch = asin(2.0*(a*c - b*d)); - yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); -} - -Rotation operator*(const Rotation& A, const Rotation& B) -{ - return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication - A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, - A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, - A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); -} \ No newline at end of file diff --git a/FaceTrackNoIR/rotation.h b/FaceTrackNoIR/rotation.h deleted file mode 100644 index 967d6661..00000000 --- a/FaceTrackNoIR/rotation.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2012 Patrick Ruoff - * - * 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. - */ - -#ifndef ROTATION_H -#define ROTATION_H - -// ---------------------------------------------------------------------------- -class Rotation { - friend Rotation operator*(const Rotation& A, const Rotation& B); -public: - Rotation() : a(1.0),b(0.0),c(0.0),d(0.0) {} - Rotation(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } - Rotation(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} - - Rotation inv(); // inverse - - // conversions - void fromEuler(double yaw, double pitch, double roll); - void toEuler(double& yaw, double& pitch, double& roll); - -protected: - double a,b,c,d; // quaternion coefficients -}; - -Rotation operator*(const Rotation& A, const Rotation& B); // composition of rotations - -#endif //ROTATION_H diff --git a/FaceTrackNoIR/spot.h b/FaceTrackNoIR/spot.h deleted file mode 100644 index 38518c74..00000000 --- a/FaceTrackNoIR/spot.h +++ /dev/null @@ -1,27 +0,0 @@ -#ifndef __SPOT_H__ -#define __SPOT_H__ - -class Spot { - -private: - QPoint distance; - QPoint position; - QImage image; - QRect target; - QRect source; - -public: - Spot(); - - void setDistance(QPoint distance); - QPoint getDistance(); - - void setPosition(QPoint position); - QPoint getPosition(); - - QRect getTarget(); - QRect getSource(); - QImage getImage(); -}; - -#endif \ No newline at end of file diff --git a/FaceTrackNoIR/tracker.cpp b/FaceTrackNoIR/tracker.cpp deleted file mode 100644 index 5396c95b..00000000 --- a/FaceTrackNoIR/tracker.cpp +++ /dev/null @@ -1,1081 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 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 . * -*********************************************************************************/ -/* - Modifications (last one on top): - 20130201 - WVR: Remove the Protocol, when stopping the Thread. - 20121215 - WVR: Fixed crash after message: protocol not installed correctly... by terminating the thread. - 20120921 - WVR: Fixed centering when no filter is selected. - 20120917 - WVR: Added Mouse-buttons to ShortKeys. - 20120827 - WVR: Signal tracking = false to Curve-widget(s) when quitting run(). Also when Alternative Pitch curve is used. - 20120805 - WVR: The FunctionConfig-widget is used to configure the Curves. It was tweaked some more, because the Accela filter now also - uses the Curve(s). ToDo: make the ranges configurable by the user. Development on the Toradex IMU makes us realize, that - a fixed input-range may not be so handy after all.. - 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled ´statically´. Now, a Dir() of the - EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs - 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. 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. - 20110328 - WVR: Changed the camera-structs into class-instances. This makes initialisation - easier and hopefully solves the remaining 'start-up problem'. - 20110313 - WVR: Removed 'set_initial'. Less is more. - 20110109 - WVR: Added setZero option to define behaviour after STOP tracking via shortkey. - 20110104 - WVR: Removed a few nasty bugs (it was impossible to stop tracker without crash). - 20101224 - WVR: Removed the QThread inheritance of the Base Class for the protocol-servers. - Again, this drastically simplifies the code in the protocols. - 20101217 - WVR: Created Base Class for the protocol-servers. This drastically simplifies - the code needed here. - 20101024 - WVR: Added shortkey to disable/enable one or more axis during tracking. - 20101021 - WVR: Added FSUIPC server for FS2004. - 20101011 - WVR: Added SimConnect server. - 20101007 - WVR: Created 6DOF-curves and drastically changed the tracker for that. - Also eliminated a 'glitch' in the process. - 20100607 - WVR: Re-installed Rotation Neutral Zone and improved reaction - after 'start/stop'. MessageBeep when confidence is back... - 20100604 - WVR: Created structure for DOF-data and changed timing of - ReceiveHeadPose end run(). - 20100602 - WVR: Implemented EWMA-filtering, according to the example of - Melchior Franz. Works like a charm... - 20100601 - WVR: Added DirectInput keyboard-handling. '=' used for center, - 'BACK' for start (+center)/stop. - 20100517 - WVR: Added upstream command(s) from FlightGear - 20100523 - WVR: Checkboxes to invert 6DOF's was implemented. Multiply by - 1 or (-1). -*/ -#include "tracker.h" -#include "FaceTrackNoIR.h" - -// Flags -bool Tracker::confid = false; -bool Tracker::do_tracking = true; -bool Tracker::do_center = false; -bool Tracker::do_inhibit = false; -bool Tracker::do_game_zero = false; -bool Tracker::do_axis_reverse = false; - -bool Tracker::setZero = true; -bool Tracker::setEngineStop = true; -HANDLE Tracker::hTrackMutex = 0; - -bool Tracker::useAxisReverse = false; // Use Axis Reverse -float Tracker::YawAngle4ReverseAxis = 40.0f; // Axis Reverse settings -float Tracker::Z_Pos4ReverseAxis = -20.0f; -float Tracker::Z_PosWhenReverseAxis = 50.0f; - - -T6DOF Tracker::current_camera(0,0,0,0,0,0); // Used for filtering -T6DOF Tracker::target_camera(0,0,0,0,0,0); -T6DOF Tracker::new_camera(0,0,0,0,0,0); -T6DOF Tracker::output_camera(0,0,0,0,0,0); // Position sent to game protocol - -THeadPoseDOF Tracker::Pitch("PitchUp", "PitchDown", 50, 180, 50, 90); // One structure for each of 6DOF's -THeadPoseDOF Tracker::Yaw("Yaw", "", 50, 180); -THeadPoseDOF Tracker::Roll("Roll", "", 50, 180); -THeadPoseDOF Tracker::X("X","", 50, 180); -THeadPoseDOF Tracker::Y("Y","", 50, 180); -THeadPoseDOF Tracker::Z("Z","", 50, 180); - -TShortKey Tracker::CenterKey; // ShortKey to Center headposition -TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking -TShortKey Tracker::InhibitKey; // ShortKey to inhibit axis while tracking -TShortKey Tracker::GameZeroKey; // ShortKey to Set Game Zero -bool Tracker::DisableBeep = false; // Disable beep when center -//TShortKey Tracker::AxisReverseKey; // ShortKey to start/stop axis reverse while tracking - -int Tracker::CenterMouseKey; // ShortKey to Center headposition -int Tracker::StartStopMouseKey; // ShortKey to Start/stop tracking -int Tracker::InhibitMouseKey; // ShortKey to inhibit axis while tracking -int Tracker::GameZeroMouseKey; // ShortKey to Set Game Zero - -//ITrackerPtr Tracker::pTracker; // Pointer to Tracker instance (in DLL) -IProtocolPtr Tracker::pProtocol; // Pointer to Protocol instance (in DLL) -IFilterPtr Tracker::pFilter; // Pointer to Filter instance (in DLL) - - -/** constructor **/ -Tracker::Tracker( FaceTrackNoIR *parent ) { -QString libName; -importGetTracker getIT; -QLibrary *trackerLib; -importGetFilter getFilter; -QLibrary *filterLib; -importGetProtocol getProtocol; -QLibrary *protocolLib; -QFrame *video_frame; - - // Retieve the pointer to the parent - mainApp = parent; - - // Create events - m_StopThread = CreateEvent(0, TRUE, FALSE, 0); - m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); - - Tracker::hTrackMutex = CreateMutexA(NULL, false, "HeadPose_mutex"); - - // - // Initialize the headpose-data - // - Tracker::Yaw.initHeadPoseData(); - Tracker::Pitch.initHeadPoseData(); - Tracker::Roll.initHeadPoseData(); - Tracker::X.initHeadPoseData(); - Tracker::Y.initHeadPoseData(); - Tracker::Z.initHeadPoseData(); - - // - // Locate the video-frame, for the DLL - // - video_frame = 0; - video_frame = mainApp->getVideoWidget(); - qDebug() << "Tracker::Tracker VideoFrame = " << video_frame; - - // - // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... - // - pTracker = NULL; - libName = mainApp->getCurrentTrackerName(); - if (!libName.isEmpty()) { - trackerLib = new QLibrary(libName); - getIT = (importGetTracker) trackerLib->resolve("GetTracker"); - qDebug() << "Tracker::Tracker libName = " << libName; - - if (getIT) { - ITracker *ptrXyz(getIT()); // Get the Class - if (ptrXyz) - { - pTracker = ptrXyz; - pTracker->Initialize( video_frame ); - qDebug() << "Tracker::setup Function Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", libName + " DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } - } - // - // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... - // - pSecondTracker = NULL; - libName = mainApp->getSecondTrackerName(); - if ((!libName.isEmpty()) && (libName != "None")) { - trackerLib = new QLibrary(libName); - getIT = (importGetTracker) trackerLib->resolve("GetTracker"); - - if (getIT) { - ITracker *ptrXyz(getIT()); // Get the Class - if (ptrXyz) - { - pSecondTracker = ptrXyz; - pSecondTracker->Initialize( NULL ); - qDebug() << "Tracker::setup Function Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", libName + " DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - } - } - - // - // Load the DLL with the protocol-logic and retrieve a pointer to the Protocol-class. - // - libName = mainApp->getCurrentProtocolName(); - if (!libName.isEmpty()) { - protocolLib = new QLibrary(libName); - getProtocol = (importGetProtocol) protocolLib->resolve("GetProtocol"); - if (getProtocol) { - IProtocolPtr ptrXyz(getProtocol()); - if (ptrXyz) - { - pProtocol = ptrXyz; - pProtocol->Initialize(); - qDebug() << "Protocol::setup Function Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - return; - } - } - - // - // Load the DLL with the filter-logic and retrieve a pointer to the Filter-class. - // - pFilter = NULL; - libName = mainApp->getCurrentFilterName(); - - if ((!libName.isEmpty()) && (libName != "None")) { - filterLib = new QLibrary(libName); - - getFilter = (importGetFilter) filterLib->resolve("GetFilter"); - if (getFilter) { - IFilterPtr ptrXyz(getFilter()); - if (ptrXyz) - { - pFilter = ptrXyz; - qDebug() << "Filter::setup Function Resolved!"; - } - } - else { - QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); - return; - } - } - - // Load the settings from the INI-file - loadSettings(); -} - -/** destructor empty **/ -Tracker::~Tracker() { - - // Stop the Tracker(s) - if (pTracker) { - pTracker->StopTracker( true ); - } - if (pSecondTracker) { - pSecondTracker->StopTracker( true ); - } - - // Trigger thread to stop - ::SetEvent(m_StopThread); - - // Wait until thread finished - if (isRunning()) { - ::WaitForSingleObject(m_WaitThread, INFINITE); - } - - // - // Remove the Tracker - // 20120615, WVR: As suggested by Stanislaw - if (pTracker) { - delete pTracker; - pTracker = NULL; - } - if (pSecondTracker) { - delete pSecondTracker; - pSecondTracker = NULL; - } - - // - // Remove the Protocol - // - if (pProtocol) { - delete pProtocol; - pProtocol = NULL; - } - - // Close handles - ::CloseHandle(m_StopThread); - ::CloseHandle(m_WaitThread); - - if (Tracker::hTrackMutex != 0) { - ::CloseHandle( Tracker::hTrackMutex ); - } - -# ifdef USE_DEBUG_CLIENT - debug_Client->deleteLater(); // Delete Excel protocol-server -# endif - - qDebug() << "Tracker::~Tracker Finished..."; - -} - -/** setting up the tracker engine **/ -void Tracker::setup() { - bool DLL_Ok; - - // retrieve pointers to the User Interface and the main Application - if (pTracker) { - pTracker->StartTracker( mainApp->winId() ); - } - if (pSecondTracker) { - pSecondTracker->StartTracker( mainApp->winId() ); - } - - // - // Check if the Protocol-server files were installed OK. - // Some servers also create a memory-mapping, for Inter Process Communication. - // The handle of the MainWindow is sent to 'The Game', so it can send a message back. - // - if (pProtocol) { - - DLL_Ok = pProtocol->checkServerInstallationOK( mainApp->winId() ); - if (!DLL_Ok) { - // Trigger thread to stop - ::SetEvent(m_StopThread); - QMessageBox::information(mainApp, "FaceTrackNoIR error", "Protocol is not (correctly) installed!"); - } - } - -# ifdef USE_DEBUG_CLIENT - DLL_Ok = debug_Client->checkServerInstallationOK( mainApp->winId() ); // Check installation - if (!DLL_Ok) { - QMessageBox::information(mainApp, "FaceTrackNoIR error", "Excel Protocol is not (correctly) installed!"); - } -# endif - -} - -/** QThread run method @override **/ -void Tracker::run() { -/** Direct Input variables **/ -// -// The DirectX stuff was found here: http://www.directxtutorial.com/tutorial9/e-directinput/dx9e2.aspx -// -LPDIRECTINPUT8 din; // the pointer to our DirectInput interface -LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device -LPDIRECTINPUTDEVICE8 dinmouse; // the pointer to the mouse device -BYTE keystate[256]; // the storage for the key-information -DIMOUSESTATE mousestate; // the storage for the mouse-information -HRESULT retAcquire; -bool lastCenterKey = false; // Remember state, to detect rising edge -bool lastStartStopKey = false; -bool lastInhibitKey = false; -bool lastGameZeroKey = false; - -bool lastCenterMouseKey = false; // Remember state, to detect rising edge -bool lastStartStopMouseKey = false; -bool lastInhibitMouseKey = false; -bool lastGameZeroMouseKey = false; - -bool waitAxisReverse = false; -bool waitThroughZero = false; -double actualYaw = 0.0f; -double actualZ = 0.0f; -T6DOF offset_camera(0,0,0,0,0,0); -T6DOF gamezero_camera(0,0,0,0,0,0); -T6DOF gameoutput_camera(0,0,0,0,0,0); - -bool bInitialCenter1 = true; -bool bInitialCenter2 = true; -bool bTracker1Confid = false; -bool bTracker2Confid = false; - - Tracker::do_tracking = true; // Start initially - Tracker::do_center = false; // Center initially - - // - // Test some Filter-stuff - // - if (pFilter) { - QString filterName; - //pFilter->getFullName(&filterName); - //qDebug() << "Tracker::run() FilterName = " << filterName; - } - - // - // Setup the DirectInput for keyboard strokes - // - // create the DirectInput interface - if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, - (void**)&din, NULL) != DI_OK) { // COM stuff, so we'll set it to NULL - qDebug() << "Tracker::setup DirectInput8 Creation failed!" << GetLastError(); - } - - // create the keyboard device - if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { - qDebug() << "Tracker::setup CreateDevice function failed!" << GetLastError(); - } - // create the mouse device - din->CreateDevice(GUID_SysMouse, &dinmouse, NULL); - - // set the data format to keyboard format - if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { - qDebug() << "Tracker::setup SetDataFormat function failed!" << GetLastError(); - } - // set the data format to mouse format - dinmouse->SetDataFormat(&c_dfDIMouse); - - // set the control you will have over the keyboard - if (dinkeyboard->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { - qDebug() << "Tracker::setup SetCooperativeLevel function failed!" << GetLastError(); - } - // set the control you will have over the mouse - dinmouse->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND); - - forever - { - - // Check event for stop thread - if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) - { - dinkeyboard->Unacquire(); // Unacquire keyboard - dinkeyboard->Release(); - dinmouse->Unacquire(); // Unacquire mouse - dinmouse->Release(); - din->Release(); // Release DirectInput - - // Set event - ::SetEvent(m_WaitThread); - qDebug() << "Tracker::run terminated run()"; - X.curvePtr->setTrackingActive( false ); - Y.curvePtr->setTrackingActive( false ); - Z.curvePtr->setTrackingActive( false ); - Yaw.curvePtr->setTrackingActive( false ); - Pitch.curvePtr->setTrackingActive( false ); - Pitch.curvePtrAlt->setTrackingActive( false ); - Roll.curvePtr->setTrackingActive( false ); - - return; - } - - // - // Check the mouse - // - // get access if we don't have it already - retAcquire = dinmouse->Acquire(); - if ( (retAcquire != DI_OK) && (retAcquire != S_FALSE) ) { - qDebug() << "Tracker::run Acquire function failed!" << GetLastError(); - } - else { - if (dinmouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate) != DI_OK) { - qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); - } - else { - // - // Check the state of the StartStop MouseKey - // - if ( isMouseKeyPressed( &StartStopMouseKey, &mousestate ) && (!lastStartStopMouseKey) ) { - Tracker::do_tracking = !Tracker::do_tracking; - - // - // To start tracking again and to be at '0', execute Center command too - // - if (Tracker::do_tracking) { - Tracker::confid = false; - if (pTracker) { - pTracker->StartTracker( mainApp->winId() ); - } - if (pSecondTracker) { - pSecondTracker->StartTracker( mainApp->winId() ); - } - } - else { - if (setEngineStop) { // Only stop engine when option is checked - if (pTracker) { - pTracker->StopTracker( false ); - } - if (pSecondTracker) { - pSecondTracker->StopTracker( false ); - } - } - } - qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; - } - lastStartStopMouseKey = isMouseKeyPressed( &StartStopMouseKey, &mousestate ); // Remember - - // - // Check the state of the Center MouseKey - // - if ( isMouseKeyPressed( &CenterMouseKey, &mousestate ) && (!lastCenterMouseKey) ) { - Tracker::do_center = true; - qDebug() << "Tracker::run() says Center MouseKey pressed"; - } - lastCenterMouseKey = isMouseKeyPressed( &CenterMouseKey, &mousestate ); // Remember - - // - // Check the state of the GameZero MouseKey - // - if ( isMouseKeyPressed( &GameZeroMouseKey, &mousestate ) && (!lastGameZeroMouseKey) ) { - Tracker::do_game_zero = true; - qDebug() << "Tracker::run() says GameZero MouseKey pressed"; - } - lastGameZeroMouseKey = isMouseKeyPressed( &GameZeroMouseKey, &mousestate ); // Remember - - // - // Check the state of the Inhibit MouseKey - // - if ( isMouseKeyPressed( &InhibitMouseKey, &mousestate ) && (!lastInhibitMouseKey) ) { - Tracker::do_inhibit = !Tracker::do_inhibit; - qDebug() << "Tracker::run() says Inhibit MouseKey pressed"; - // - // Execute Center command too, when inhibition ends. - // - if (!Tracker::do_inhibit) { - Tracker::do_center = true; - } - } - lastInhibitMouseKey = isMouseKeyPressed( &InhibitMouseKey, &mousestate ); // Remember - } - } - - // - // Check the keyboard - // - // get access if we don't have it already - retAcquire = dinkeyboard->Acquire(); - if ( (retAcquire != DI_OK) && (retAcquire != S_FALSE) ) { - qDebug() << "Tracker::run Acquire function failed!" << GetLastError(); - } - else { - // get the input data - if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) { - qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); - } - else { - // - // Check the state of the Start/Stop key - // - if ( isShortKeyPressed( &StartStopKey, &keystate[0] ) && (!lastStartStopKey) ) { - Tracker::do_tracking = !Tracker::do_tracking; - - // - // To start tracking again and to be at '0', execute Center command too - // - if (Tracker::do_tracking) { - Tracker::confid = false; - if (pTracker) { - pTracker->StartTracker( mainApp->winId() ); - } - if (pSecondTracker) { - pSecondTracker->StartTracker( mainApp->winId() ); - } - } - else { - if (setEngineStop) { // Only stop engine when option is checked - if (pTracker) { - pTracker->StopTracker( false ); - } - if (pSecondTracker) { - pSecondTracker->StopTracker( false ); - } - } - } - qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; - } - lastStartStopKey = isShortKeyPressed( &StartStopKey, &keystate[0] ); // Remember - - // - // Check the state of the Center key - // - if ( isShortKeyPressed( &CenterKey, &keystate[0] ) && (!lastCenterKey) ) { - Tracker::do_center = true; - qDebug() << "Tracker::run() says Center pressed"; - } - lastCenterKey = isShortKeyPressed( &CenterKey, &keystate[0] ); // Remember - - // - // Check the state of the GameZero key - // - if ( isShortKeyPressed( &GameZeroKey, &keystate[0] ) && (!lastGameZeroKey) ) { - Tracker::do_game_zero = true; - qDebug() << "Tracker::run() says GameZero pressed"; - } - lastGameZeroKey = isShortKeyPressed( &GameZeroKey, &keystate[0] ); // Remember - - // - // Check the state of the Inhibit key - // - if ( isShortKeyPressed( &InhibitKey, &keystate[0] ) && (!lastInhibitKey) ) { - Tracker::do_inhibit = !Tracker::do_inhibit; - qDebug() << "Tracker::run() says Inhibit pressed"; - // - // Execute Center command too, when inhibition ends. - // - if (!Tracker::do_inhibit) { - Tracker::do_center = true; - } - } - lastInhibitKey = isShortKeyPressed( &InhibitKey, &keystate[0] ); // Remember - } - } - - // - // Reset the 'wait' flag. Moving above 90 with the key pressed, will (de-)activate Axis Reverse. - // -// qDebug() << "Tracker::run() says actualZ = " << actualZ << ", terwijl Z_Pos4 = " << Z_Pos4ReverseAxis; - if (useAxisReverse) { - Tracker::do_axis_reverse = ((fabs(actualYaw) > YawAngle4ReverseAxis) && (actualZ < Z_Pos4ReverseAxis)); - } - else { - Tracker::do_axis_reverse = false; - } - - - if (WaitForSingleObject(Tracker::hTrackMutex, 100) == WAIT_OBJECT_0) { - - THeadPoseData newpose; - newpose.pitch = 0.0f; - newpose.roll = 0.0f; - newpose.yaw = 0.0f; - newpose.x = 0.0f; - newpose.y = 0.0f; - newpose.z = 0.0f; - - // - // The second tracker serves as 'secondary'. So if an axis is written by the second tracker it CAN be overwritten by the Primary tracker. - // This is enforced by the sequence below. - // - if (pSecondTracker) { - bTracker2Confid = pSecondTracker->GiveHeadPoseData(&newpose); - } - else { - bTracker2Confid = false; - bInitialCenter2 = false; - } - if (pTracker) { - bTracker1Confid = pTracker->GiveHeadPoseData(&newpose); -// qDebug() << "Tracker::run() says Roll = " << newpose.roll; - } - else { - bTracker1Confid = false; - bInitialCenter1 = false; - } - - Tracker::confid = (bTracker1Confid || bTracker2Confid); - if ( Tracker::confid ) { - addHeadPose(newpose); - } - - // - // If Center is pressed, copy the current values to the offsets. - // - if ((Tracker::do_center) || ((bInitialCenter1 && bTracker1Confid ) || (bInitialCenter2 && bTracker2Confid))) { - - if (!DisableBeep) { - MessageBeep (MB_ICONASTERISK); // Acknowledge the key-press with a beep. - } - if (pTracker && bTracker1Confid) { - pTracker->notifyCenter(); // Send 'center' to the tracker - bInitialCenter1 = false; - } - if (pSecondTracker && bTracker2Confid) { - pSecondTracker->notifyCenter(); // Send 'center' to the second tracker - bInitialCenter2 = false; - } - - // - // Only copy valid values - // - if (Tracker::confid) { - - offset_camera.x = getSmoothFromList( &X.rawList ); - offset_camera.y = getSmoothFromList( &Y.rawList ); - offset_camera.z = getSmoothFromList( &Z.rawList ); - offset_camera.pitch = getSmoothFromList( &Pitch.rawList ); - offset_camera.yaw = getSmoothFromList( &Yaw.rawList ); - offset_camera.roll = getSmoothFromList( &Roll.rawList ); - } - - Tracker::do_center = false; - } - - // - // If Set Game Zero is pressed, copy the current values to the offsets. - // Change requested by Stanislaw - // - if (Tracker::confid && Tracker::do_game_zero) { - if (pTracker) { - if (!pTracker->notifyZeroed()) - gamezero_camera = gameoutput_camera; - } -// gamezero_camera = gameoutput_camera; - - Tracker::do_game_zero = false; - } - - if (Tracker::do_tracking && Tracker::confid) { - - // get values - target_camera.x = getSmoothFromList( &X.rawList ); - target_camera.y = getSmoothFromList( &Y.rawList ); - target_camera.z = getSmoothFromList( &Z.rawList ); - target_camera.pitch = getSmoothFromList( &Pitch.rawList ); - target_camera.yaw = getSmoothFromList( &Yaw.rawList ); - target_camera.roll = getSmoothFromList( &Roll.rawList ); -// qDebug() << "Tracker::run() says Roll from Smoothing = " << target_camera.roll; - - // do the centering - target_camera = target_camera - offset_camera; - - // - // Use advanced filtering, when a filter was selected. - // - if (pFilter) { - pFilter->FilterHeadPoseData(¤t_camera, &target_camera, &new_camera, Tracker::Pitch.newSample); -// qDebug() << "Tracker::run() says Roll in Filter = " << current_camera.roll << ", Roll to output = " << new_camera.roll; - } - else { - new_camera = target_camera; -// qDebug() << "Tracker::run() says Roll to output = " << new_camera.roll; - } - output_camera.x = X.invert * X.curvePtr->getValue(new_camera.x); - output_camera.y = Y.invert * Y.curvePtr->getValue(new_camera.y); - output_camera.z = Z.invert * Z.curvePtr->getValue(new_camera.z); - - // - // Determine, which curve (Up or Down) must be used for Pitch - // - bool altp = (new_camera.pitch < 0); - if (altp) { - output_camera.pitch = Pitch.invert * Pitch.curvePtrAlt->getValue(new_camera.pitch); - Pitch.curvePtr->setTrackingActive( false ); - Pitch.curvePtrAlt->setTrackingActive( true ); - } - else { - output_camera.pitch = Pitch.invert * Pitch.curvePtr->getValue(new_camera.pitch); - Pitch.curvePtr->setTrackingActive( true ); - Pitch.curvePtrAlt->setTrackingActive( false ); - } - output_camera.yaw = Yaw.invert * Yaw.curvePtr->getValue(new_camera.yaw); - output_camera.roll = Roll.invert * Roll.curvePtr->getValue(new_camera.roll); - - X.curvePtr->setTrackingActive( true ); - Y.curvePtr->setTrackingActive( true ); - Z.curvePtr->setTrackingActive( true ); - Yaw.curvePtr->setTrackingActive( true ); - Roll.curvePtr->setTrackingActive( true ); - - // - // Reverse Axis. - // - actualYaw = output_camera.yaw; // Save the actual Yaw, otherwise we can't check for +90 - actualZ = output_camera.z; // Also the Z - if (Tracker::do_axis_reverse) { - output_camera.z = Z_PosWhenReverseAxis; // Set the desired Z-position - } - - // - // Reset value for the selected axis, if inhibition is active - // - if (Tracker::do_inhibit) { - if (InhibitKey.doPitch) output_camera.pitch = 0.0f; - if (InhibitKey.doYaw) output_camera.yaw = 0.0f; - if (InhibitKey.doRoll) output_camera.roll = 0.0f; - if (InhibitKey.doX) output_camera.x = 0.0f; - if (InhibitKey.doY) output_camera.y = 0.0f; - if (InhibitKey.doZ) output_camera.z = 0.0f; - } - - // - // Send the headpose to the game - // - if (pProtocol) { - gameoutput_camera = output_camera + gamezero_camera; - pProtocol->sendHeadposeToGame( &gameoutput_camera, &newpose ); // degrees & centimeters - } - } - else { - // - // Go to initial position - // - if (pProtocol && setZero) { - output_camera.pitch = 0.0f; - output_camera.yaw = 0.0f; - output_camera.roll = 0.0f; - output_camera.x = 0.0f; - output_camera.y = 0.0f; - output_camera.z = 0.0f; - gameoutput_camera = output_camera + gamezero_camera; - pProtocol->sendHeadposeToGame( &gameoutput_camera, &newpose ); // degrees & centimeters - } - X.curvePtr->setTrackingActive( false ); - Y.curvePtr->setTrackingActive( false ); - Z.curvePtr->setTrackingActive( false ); - Yaw.curvePtr->setTrackingActive( false ); - Pitch.curvePtr->setTrackingActive( false ); - Pitch.curvePtrAlt->setTrackingActive( false ); - Roll.curvePtr->setTrackingActive( false ); - } - } - - Tracker::Pitch.newSample = false; - ReleaseMutex(Tracker::hTrackMutex); - - //for lower cpu load - usleep(10000); - yieldCurrentThread(); - } -} - -/** Add the headpose-data to the Lists **/ -void Tracker::addHeadPose( THeadPoseData head_pose ) -{ - // Pitch - Tracker::Pitch.headPos = head_pose.pitch; // degrees - addRaw2List ( &Pitch.rawList, Pitch.maxItems, Tracker::Pitch.headPos ); -// Tracker::Pitch.confidence = head_pose.confidence; // Just this one ... - Tracker::Pitch.newSample = true; - - // Yaw - Tracker::Yaw.headPos = head_pose.yaw; // degrees - addRaw2List ( &Yaw.rawList, Yaw.maxItems, Tracker::Yaw.headPos ); - - // Roll - Tracker::Roll.headPos = head_pose.roll; // degrees - addRaw2List ( &Roll.rawList, Roll.maxItems, Tracker::Roll.headPos ); - - // X-position - Tracker::X.headPos = head_pose.x; // centimeters - addRaw2List ( &X.rawList, X.maxItems, Tracker::X.headPos ); - - // Y-position - Tracker::Y.headPos = head_pose.y; // centimeters - addRaw2List ( &Y.rawList, Y.maxItems, Tracker::Y.headPos ); - - // Z-position (distance to camera, absolute!) - Tracker::Z.headPos = head_pose.z; // centimeters - addRaw2List ( &Z.rawList, Z.maxItems, Tracker::Z.headPos ); -} - -// -// Get the ProgramName from the Game and return it. -// -QString Tracker::getGameProgramName() { -QString str; -char dest[100]; - - str = QString("No protocol active?"); - if (pProtocol) { - pProtocol->getNameFromGame( dest ); - str = QString( dest ); - } - return str; -} - -// -// Handle the command, send upstream by the game. -// Valid values are: -// 1 = reset Headpose -// -bool Tracker::handleGameCommand ( int command ) { - - qDebug() << "handleGameCommand says: Command =" << command; - - switch ( command ) { - case 1: // reset headtracker - Tracker::do_center = true; - break; - default: - break; - } - return false; -} - -// -// Add the new Raw value to the QList. -// Remove the last item(s), depending on the set maximum list-items. -// -void Tracker::addRaw2List ( QList *rawList, float maxIndex, float raw ) { - // - // Remove old values from the end of the QList. - // If the setting for MaxItems was lowered, the QList is shortened here... - // - while (rawList->size() >= maxIndex) { - rawList->removeLast(); - } - - // - // Insert the newest at the beginning. - // - rawList->prepend ( raw ); -} - -// -// Get the raw headpose, so it can be displayed. -// -void Tracker::getHeadPose( THeadPoseData *data ) { - data->x = Tracker::X.headPos; // centimeters - data->y = Tracker::Y.headPos; - data->z = Tracker::Z.headPos; - - data->pitch = Tracker::Pitch.headPos; // degrees - data->yaw = Tracker::Yaw.headPos; - data->roll = Tracker::Roll.headPos; -} - -// -// Get the output-headpose, so it can be displayed. -// -void Tracker::getOutputHeadPose( THeadPoseData *data ) { - data->x = output_camera.x; // centimeters - data->y = output_camera.y; - data->z = output_camera.z; - - data->pitch = output_camera.pitch; // degrees - data->yaw = output_camera.yaw; - data->roll = output_camera.roll; -} - -// -// Get the Smoothed value from the QList. -// -float Tracker::getSmoothFromList ( QList *rawList ) { -float sum = 0; - - if (rawList->isEmpty()) return 0.0f; - - // - // Add the Raw values and divide. - // - for ( int i = 0; i < rawList->size(); i++) { - sum += rawList->at(i); - } - return sum / rawList->size(); -} - -// -// Load the current Settings from the currently 'active' INI-file. -// -void Tracker::loadSettings() { -//int NeutralZone; -//int sensYaw, sensPitch, sensRoll; -//int sensX, sensY, sensZ; - - qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; - - // - // Read the Tracking settings, to fill the curves. - // - //iniFile.beginGroup ( "Tracking" ); - //NeutralZone = iniFile.value ( "NeutralZone", 5 ).toInt(); - //sensYaw = iniFile.value ( "sensYaw", 100 ).toInt(); - //sensPitch = iniFile.value ( "sensPitch", 100 ).toInt(); - //sensRoll = iniFile.value ( "sensRoll", 100 ).toInt(); - //sensX = iniFile.value ( "sensX", 100 ).toInt(); - //sensY = iniFile.value ( "sensY", 100 ).toInt(); - //sensZ = iniFile.value ( "sensZ", 100 ).toInt(); - //iniFile.endGroup (); - - // - // Read the keyboard shortcuts. - // - iniFile.beginGroup ( "KB_Shortcuts" ); - - // Center key - CenterMouseKey = iniFile.value ( "MouseKey_Center", 0 ).toInt(); - CenterKey.keycode = iniFile.value ( "Keycode_Center", DIK_HOME ).toInt(); - CenterKey.shift = iniFile.value ( "Shift_Center", 0 ).toBool(); - CenterKey.ctrl = iniFile.value ( "Ctrl_Center", 0 ).toBool(); - CenterKey.alt = iniFile.value ( "Alt_Center", 0 ).toBool(); - DisableBeep = iniFile.value ( "Disable_Beep", 0 ).toBool(); - - // StartStop key - StartStopMouseKey = iniFile.value ( "MouseKey_StartStop", 0 ).toInt(); - StartStopKey.keycode = iniFile.value ( "Keycode_StartStop", DIK_END ).toInt(); - StartStopKey.shift = iniFile.value ( "Shift_StartStop", 0 ).toBool(); - StartStopKey.ctrl = iniFile.value ( "Ctrl_StartStop", 0 ).toBool(); - StartStopKey.alt = iniFile.value ( "Alt_StartStop", 0 ).toBool(); - setZero = iniFile.value ( "SetZero", 1 ).toBool(); - setEngineStop = iniFile.value ( "SetEngineStop", 1 ).toBool(); - - // Inhibit key - InhibitMouseKey = iniFile.value ( "MouseKey_Inhibit", 0 ).toInt(); - InhibitKey.keycode = iniFile.value ( "Keycode_Inhibit", 0 ).toInt(); - InhibitKey.shift = iniFile.value ( "Shift_Inhibit", 0 ).toBool(); - InhibitKey.ctrl = iniFile.value ( "Ctrl_Inhibit", 0 ).toBool(); - InhibitKey.alt = iniFile.value ( "Alt_Inhibit", 0 ).toBool(); - InhibitKey.doPitch = iniFile.value ( "Inhibit_Pitch", 0 ).toBool(); - InhibitKey.doYaw = iniFile.value ( "Inhibit_Yaw", 0 ).toBool(); - InhibitKey.doRoll = iniFile.value ( "Inhibit_Roll", 0 ).toBool(); - InhibitKey.doX = iniFile.value ( "Inhibit_X", 0 ).toBool(); - InhibitKey.doY = iniFile.value ( "Inhibit_Y", 0 ).toBool(); - InhibitKey.doZ = iniFile.value ( "Inhibit_Z", 0 ).toBool(); - - // Game Zero key - GameZeroMouseKey = iniFile.value ( "MouseKey_GameZero", 0 ).toInt(); - GameZeroKey.keycode = iniFile.value ( "Keycode_GameZero", 0 ).toInt(); - GameZeroKey.shift = iniFile.value ( "Shift_GameZero", 0 ).toBool(); - GameZeroKey.ctrl = iniFile.value ( "Ctrl_GameZero", 0 ).toBool(); - GameZeroKey.alt = iniFile.value ( "Alt_GameZero", 0 ).toBool(); - - // Axis Reverse key - //AxisReverseKey.keycode = DIK_R; - //AxisReverseKey.shift = false; - //AxisReverseKey.ctrl = false; - //AxisReverseKey.alt = false; - - // Reverse Axis - useAxisReverse = iniFile.value ( "Enable_ReverseAxis", 0 ).toBool(); - YawAngle4ReverseAxis = iniFile.value ( "RA_Yaw", 40 ).toInt(); - Z_Pos4ReverseAxis = iniFile.value ( "RA_ZPos", 50 ).toInt(); - Z_PosWhenReverseAxis = iniFile.value ( "RA_ToZPos", 80 ).toInt(); - - iniFile.endGroup (); -} - -// -// Determine if the ShortKey (incl. CTRL, SHIFT and/or ALT) is pressed. -// -bool Tracker::isShortKeyPressed( TShortKey *key, BYTE *keystate ){ -bool shift; -bool ctrl; -bool alt; - - // - // First, check if the right key is pressed. If so, check the modifiers - // - if (keystate[key->keycode] & 0x80) { - shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); - ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); - alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); - - // - // If one of the modifiers is needed and not pressed, return false. - // - if (key->shift && !shift) return false; - if (key->ctrl && !ctrl) return false; - if (key->alt && !alt) return false; - - // - // All is well! - // - return true; - } - else { - return false; - } -} - -// -// Determine if the MouseKey is pressed. -// -bool Tracker::isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate ){ - - // - // If key == NONE, or invalid: ready! - // - if ((*key <= 0) || (*key > 5)) { - return false; - } - - // - // Now, check if the right key is pressed. - // - if (mousestate->rgbButtons[*key-1] & 0x80) { - return true; - } - else { - return false; - } -} diff --git a/FaceTrackNoIR/tracker.h b/FaceTrackNoIR/tracker.h deleted file mode 100644 index 4b161293..00000000 --- a/FaceTrackNoIR/tracker.h +++ /dev/null @@ -1,282 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -/* - Modifications (last one on top): - 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. -*/ -#ifndef __TRACKER_H__ -#define __TRACKER_H__ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#define DIRECTINPUT_VERSION 0x0800 -#include - -#include "FunctionConfig.h" - -#include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h" -#include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h" -#include "..\ftnoir_filter_base\FTNoIR_Filter_base.h" -#include "tracker_types.h" - -typedef ITrackerPtr (WINAPI *importGetTracker)(void); -typedef IProtocolPtr (WINAPI *importGetProtocol)(void); -typedef IFilterPtr (WINAPI *importGetFilter)(void); - -// include the DirectX Library files -#pragma comment (lib, "dinput8.lib") -#pragma comment (lib, "dxguid.lib") - -enum AngleName { - PITCH = 0, - YAW = 1, - ROLL = 2, - X = 3, - Y = 4, - Z = 5 -}; - -enum FTNoIR_Client { - FREE_TRACK = 0, - FLIGHTGEAR = 1, - FTNOIR = 2, - PPJOY = 3, - TRACKIR = 4, - SIMCONNECT = 5, - FSUIPC = 6, - MOUSE = 7 -}; - -//enum FTNoIR_Face_Tracker { -// FT_SM_FACEAPI = 0, -// FT_FTNOIR = 1, -// FT_VISAGE = 2 -//}; - -enum FTNoIR_Tracker_Status { - TRACKER_OFF = 0, - TRACKER_ON = 1 -}; - -class FaceTrackNoIR; // pre-define parent-class to avoid circular includes - -// -// Structure to hold all variables concerning one of 6 DOF's -// -class THeadPoseDOF { -public: - - THeadPoseDOF(QString primary, QString secondary = "", int maxInput1 = 50, int maxOutput1 = 180, int maxInput2 = 50, int maxOutput2 = 90) { - 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) - - curvePtr = new FunctionConfig(primary, maxInput1, maxOutput1); // Create the Function-config for input-output translation - curvePtr->loadSettings(iniFile); // Load the settings from the INI-file - if (secondary != "") { - curvePtrAlt = new FunctionConfig(secondary, maxInput2, maxOutput2); - curvePtrAlt->loadSettings(iniFile); - } - - } - - void initHeadPoseData(){ - headPos = 0.0f; - invert = 0.0f; - red = 0.0f; - rawList.clear(); - maxItems = 10.0f; - prevPos = 0.0f; - prevRawPos = 0.0f; - NeutralZone = 0; - MaxInput = 0; - confidence = 0.0f; - newSample = FALSE; - - qDebug() << "initHeadPoseData: " << curvePtr->getTitle(); - - } - float headPos; // Current position (from faceTracker, radials or meters) - float invert; // Invert measured value (= 1.0f or -1.0f) - float red; // Reduction factor (used for EWMA-filtering, between 0.0f and 1.0f) - QList rawList; // List of 'n' headPos values (used for moving average) - int maxItems; // Maximum number of elements in rawList - float prevPos; // Previous Position - float prevRawPos; // Previous Raw Position - - FunctionConfig* curvePtr; // Function to translate input -> output - FunctionConfig* curvePtrAlt; - - int NeutralZone; // Neutral zone - int MaxInput; // Maximum raw input - float confidence; // Current confidence - bool newSample; // Indicate new sample from tracker -}; - -// -// Structure to hold keycode and CTRL, SHIFT, ALT for shortkeys -// -struct TShortKey { - BYTE keycode; // Required Key - bool shift; // Modifiers to examine - bool ctrl; - bool alt; - bool doPitch; // Modifiers to act on axis - bool doYaw; - bool doRoll; - bool doX; - bool doY; - bool doZ; -}; - -class Tracker : public QThread { - Q_OBJECT - -private: - // Handles to neatly terminate thread... - HANDLE m_StopThread; - HANDLE m_WaitThread; - - static T6DOF current_camera; // Used for filtering - static T6DOF target_camera; - static T6DOF new_camera; - static T6DOF output_camera; - - ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL) - ITrackerPtr pSecondTracker; // Pointer to second Tracker instance (in DLL) - static IProtocolPtr pProtocol; // Pointer to Protocol instance (in DLL) - static IFilterPtr pFilter; // Pointer to Filter instance (in DLL) - - static void addHeadPose( THeadPoseData head_pose ); - static void addRaw2List ( QList *rawList, float maxIndex, float raw ); - - static TShortKey CenterKey; // ShortKey to Center headposition - static TShortKey StartStopKey; // ShortKey to Start/stop tracking - static TShortKey InhibitKey; // ShortKey to disable one or more axis during tracking - static TShortKey GameZeroKey; // ShortKey to Set Game Zero -// static TShortKey AxisReverseKey; // ShortKey to reverse axis during tracking - - static int CenterMouseKey; // ShortKey to Center headposition - static int StartStopMouseKey; // ShortKey to Start/stop tracking - static int InhibitMouseKey; // ShortKey to disable one or more axis during tracking - static int GameZeroMouseKey; // ShortKey to Set Game Zero - static bool DisableBeep; // Disable Beep when center is pressed - - // Flags to start/stop/reset tracking - static bool confid; // Tracker data is OK - static bool do_tracking; // Start/stop tracking, using the shortkey - static bool do_center; // Center head-position, using the shortkey - static bool do_inhibit; // Inhibit DOF-axis, using the shortkey - static bool do_game_zero; // Set in-game zero, using the shortkey - static bool do_axis_reverse; // Axis reverse, using the shortkey - - static HANDLE hTrackMutex; // Prevent reading/writing the headpose simultaneously - - static bool setZero; // Set to zero's, when OFF (one-shot) - static bool setEngineStop; // Stop tracker->engine, when OFF - - static bool useAxisReverse; // Use Axis Reverse - static float YawAngle4ReverseAxis; // Axis Reverse settings - static float Z_Pos4ReverseAxis; - static float Z_PosWhenReverseAxis; - - FaceTrackNoIR *mainApp; - -protected: - // qthread override run method - void run(); - -public: - Tracker( FaceTrackNoIR *parent ); - ~Tracker(); - - /** static member variables for saving the head pose **/ - static THeadPoseDOF Pitch; // Head-rotation X-direction (Up/Down) - static THeadPoseDOF Yaw; // Head-rotation Y-direction () - static THeadPoseDOF Roll; // Head-rotation Z-direction () - static THeadPoseDOF X; // Head-movement X-direction (Left/Right) - static THeadPoseDOF Y; // Head-movement Y-direction (Up/Down) - static THeadPoseDOF Z; // Head-movement Z-direction (To/From camera) - - void setup(); - -// void registerHeadPoseCallback(); - bool handleGameCommand ( int command ); - QString getGameProgramName(); // Get the ProgramName from the game and display it. - void loadSettings(); // Load settings from the INI-file - bool isShortKeyPressed( TShortKey *key, BYTE *keystate ); - bool isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate ); - - static bool getTrackingActive() { return do_tracking && confid; } - static bool getAxisReverse() { return do_axis_reverse; } - - static bool getConfid() { return confid; } - - static void setInvertPitch(bool invert) { Pitch.invert = invert?-1.0f:+1.0f; } - static void setInvertYaw(bool invert) { Yaw.invert = invert?-1.0f:+1.0f; } - static void setInvertRoll(bool invert) { Roll.invert = invert?-1.0f:+1.0f; } - static void setInvertX(bool invert) { X.invert = invert?-1.0f:+1.0f; } - static void setInvertY(bool invert) { Y.invert = invert?-1.0f:+1.0f; } - static void setInvertZ(bool invert) { Z.invert = invert?-1.0f:+1.0f; } - - 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; } // Return the pointer for the active Filter - ITracker *getTrackerPtr() { return pTracker; } // Return the pointer for the active Tracker - ITracker *getSecondTrackerPtr() { return pSecondTracker; } // Return the pointer for the secondary Tracker - IProtocol *getProtocolPtr() { return pProtocol; } // Return the pointer for the active Protocol - - void doRefreshVideo() { // Call the face-tracker-function RefreshVideo - if (pTracker) { - pTracker->refreshVideo(); - } - if (pSecondTracker) { - pSecondTracker->refreshVideo(); - } - }; - - static float getSmoothFromList ( QList *rawList ); - static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } - static float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } - - // For now, use one slider for all - void setSmoothing(int x) { - Pitch.maxItems = x; - Yaw.maxItems = x; - Roll.maxItems = x; - X.maxItems = x; - Y.maxItems = x; - Z.maxItems = x; - } - -}; - -#endif \ No newline at end of file diff --git a/FaceTrackNoIR/tracker_types.cpp b/FaceTrackNoIR/tracker_types.cpp deleted file mode 100644 index cdd8d239..00000000 --- a/FaceTrackNoIR/tracker_types.cpp +++ /dev/null @@ -1,44 +0,0 @@ -#include "tracker_types.h" -#include "rotation.h" - -const double PI = 3.14159265358979323846264; -const double D2R = PI/180.0; -const double R2D = 180.0/PI; - -T6DOF operator-(const T6DOF& A, const T6DOF& B) -{ - Rotation R_A(A.yaw*D2R, A.pitch*D2R, A.roll*D2R); - Rotation R_B(B.yaw*D2R, B.pitch*D2R, B.roll*D2R); - Rotation R_C = R_A * R_B.inv(); - - T6DOF C; - R_C.toEuler(C.yaw, C.pitch, C.roll); - C.yaw *= R2D; - C.pitch *= R2D; - C.roll *= R2D; - - C.x = A.x - B.x; - C.y = A.y - B.y; - C.z = A.z - B.z; - //C.frame_number? - return C; -} - -T6DOF operator+(const T6DOF& A, const T6DOF& B) -{ - Rotation R_A(A.yaw*D2R, A.pitch*D2R, A.roll*D2R); - Rotation R_B(B.yaw*D2R, B.pitch*D2R, B.roll*D2R); - Rotation R_C = R_A * R_B; - - T6DOF C; - R_C.toEuler(C.yaw, C.pitch, C.roll); - C.yaw *= R2D; - C.pitch *= R2D; - C.roll *= R2D; - - C.x = A.x + B.x; - C.y = A.y + B.y; - C.z = A.z + B.z; - //C.frame_number? - return C; -} diff --git a/FaceTrackNoIR/tracker_types.h b/FaceTrackNoIR/tracker_types.h deleted file mode 100644 index 5a13af85..00000000 --- a/FaceTrackNoIR/tracker_types.h +++ /dev/null @@ -1,45 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -/* - Modifications (last one on top): - 20120924 - C14: Moved tracker types only used by Tracker to this file (should not be part of public interface) - Modified operators to represent correct frame transitions -*/ -#ifndef __TRACKER_TYPES_H__ -#define __TRACKER_TYPES_H__ - -#include "..\ftnoir_tracker_base\ftnoir_tracker_types.h" - -class T6DOF : public THeadPoseData -{ -public: - T6DOF() : THeadPoseData() {} - - T6DOF(double x, double y, double z, double yaw, double pitch, double roll) - : THeadPoseData(x,y,z, yaw,pitch,roll) {} -}; - -T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B -T6DOF operator+(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B^-1 - -#endif //__TRACKER_TYPES_H__ \ No newline at end of file diff --git a/FaceTrackNoIR_vc8.sln b/FaceTrackNoIR_vc8.sln deleted file mode 100644 index 65577c99..00000000 --- a/FaceTrackNoIR_vc8.sln +++ /dev/null @@ -1,82 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_EWMA2", "FTNoIR_Filter_EWMA2\FTNoIR_Filter_EWMA2_vc8.vcproj", "{7DD9F1AA-B7C0-4056-AC4A-1501840E6438}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_SM", "FTNoIR_Tracker_SM\FTNoIR_Tracker_SM_vc8.vcproj", "{26346BCF-92A5-47A7-B4CF-73C402F7C3AD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_FaceAPI_EXE", "faceAPI\FaceAPI2FSX_vc8.vcproj", "{EF743D32-0980-44D9-BA9E-B9D2456251AC}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FTIR", "FTNoIR_Protocol_FTIR\FTNoIR_Protocol_FTIR_vc8.vcproj", "{BC5B8583-036A-4A9B-84AE-01158EE6F5A4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FT", "FTNoIR_Protocol_FT\FTNoIR_Protocol_FT_vc8.vcproj", "{FE2FF09B-207D-468C-9763-23861956F388}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FaceTrackNoIR", "FaceTrackNoIR\FaceTrackNoIR_vc8.vcproj", "{9DCDB5B9-941E-42F7-AF76-DF794AA3C013}" - ProjectSection(ProjectDependencies) = postProject - {2527B683-7EFC-4D51-B25A-843668649C54} = {2527B683-7EFC-4D51-B25A-843668649C54} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QFunctionConfigurator", "QFunctionConfigurator\QFunctionConfigurator\QFunctionConfigurator.vcproj", "{2527B683-7EFC-4D51-B25A-843668649C54}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_Accela", "FTNoIR_Filter_Accela\FTNoIR_Filter_accela_vc8.vcproj", "{2212857A-7634-4E30-BA83-539EC70176E6}" - ProjectSection(ProjectDependencies) = postProject - {2527B683-7EFC-4D51-B25A-843668649C54} = {2527B683-7EFC-4D51-B25A-843668649C54} - EndProjectSection -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_UDP", "FTNoIR_Tracker_UDP\FTNoIR_Tracker_UDP_vc8.vcproj", "{507B92A6-8725-4921-9432-2864EF2B64D9}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_HT", "FTNoIR_Tracker_HT\FTNoIR_Tracker_HT_vc8.vcproj", "{61F2B142-F7DD-4070-8A68-53AD63A5D528}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.ActiveCfg = Debug|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.Build.0 = Debug|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.ActiveCfg = Release|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.Build.0 = Release|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.ActiveCfg = Debug|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.Build.0 = Debug|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.ActiveCfg = Release|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.Build.0 = Release|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.ActiveCfg = Debug|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.Build.0 = Debug|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.ActiveCfg = Release|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.Build.0 = Release|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.Build.0 = Debug|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.ActiveCfg = Release|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.Build.0 = Release|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.Build.0 = Debug|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.ActiveCfg = Release|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.Build.0 = Release|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.ActiveCfg = Debug|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.Build.0 = Debug|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.ActiveCfg = Release|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.Build.0 = Release|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.ActiveCfg = Debug|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.Build.0 = Debug|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.ActiveCfg = Release|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.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 - {2212857A-7634-4E30-BA83-539EC70176E6}.Release|Win32.Build.0 = Release|Win32 - {507B92A6-8725-4921-9432-2864EF2B64D9}.Debug|Win32.ActiveCfg = Debug|Win32 - {507B92A6-8725-4921-9432-2864EF2B64D9}.Debug|Win32.Build.0 = Debug|Win32 - {507B92A6-8725-4921-9432-2864EF2B64D9}.Release|Win32.ActiveCfg = Release|Win32 - {507B92A6-8725-4921-9432-2864EF2B64D9}.Release|Win32.Build.0 = Release|Win32 - {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Debug|Win32.ActiveCfg = Debug|Win32 - {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Debug|Win32.Build.0 = Debug|Win32 - {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Release|Win32.ActiveCfg = Release|Win32 - {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - QtVersion = qt-everywhere-opensource-src-4.6.2 - EndGlobalSection -EndGlobal diff --git a/FaceTrackNoIR_vc9.sln b/FaceTrackNoIR_vc9.sln deleted file mode 100644 index 1ba0c10e..00000000 --- a/FaceTrackNoIR_vc9.sln +++ /dev/null @@ -1,119 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_UDP", "FTNoIR_Tracker_UDP\FTNoIR_Tracker_UDP_vc9.vcproj", "{A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_EWMA2", "FTNoIR_Filter_EWMA2\FTNoIR_Filter_EWMA2_vc9.vcproj", "{7DD9F1AA-B7C0-4056-AC4A-1501840E6438}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_SM", "FTNoIR_Tracker_SM\FTNoIR_Tracker_SM_vc9.vcproj", "{26346BCF-92A5-47A7-B4CF-73C402F7C3AD}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_FaceAPI_EXE", "faceAPI\FaceAPI2FSX_vc9.vcproj", "{EF743D32-0980-44D9-BA9E-B9D2456251AC}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FG", "FTNoIR_Protocol_FG\FTNoIR_Protocol_FG_vc9.vcproj", "{7C77C833-5687-4A35-B219-4CF4D3D8E626}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FTIR", "FTNoIR_Protocol_FTIR\FTNoIR_Protocol_FTIR_vc9.vcproj", "{BC5B8583-036A-4A9B-84AE-01158EE6F5A4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FT", "FTNoIR_Protocol_FT\FTNoIR_Protocol_FT_vc9.vcproj", "{FE2FF09B-207D-468C-9763-23861956F388}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_PPJOY", "FTNoIR_Protocol_PPJOY\FTNoIR_Protocol_PPJOY_vc9.vcproj", "{8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_SC", "FTNoIR_Protocol_SC\FTNoIR_Protocol_SC_vc9.vcproj", "{B8F3B67B-6C25-4E06-8076-0513D2368A1F}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FSUIPC", "FTNoIR_Protocol_FSUIPC\FTNoIR_Protocol_FSUIPC_vc9.vcproj", "{46E66901-0212-410A-99B6-793F7ACD2ED0}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FTN", "FTNoIR_Protocol_FTN\FTNoIR_Protocol_FTN_vc9.vcproj", "{166A9AF8-90E0-4889-ADAA-5E6E3DD20194}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_MOUSE", "FTNoIR_Protocol_MOUSE\FTNoIR_Protocol_MOUSE_vc9.vcproj", "{BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FaceTrackNoIR", "FaceTrackNoIR\FaceTrackNoIR_vc9.vcproj", "{9DCDB5B9-941E-42F7-AF76-DF794AA3C013}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_FD", "FTNoIR_Tracker_FD\FTNoIR_Tracker_FD_vc9.vcproj", "{0FE16301-240D-42B9-9141-12294BA08AC4}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_Accela", "FTNoIR_Filter_Accela\FTNoIR_Filter_accela_vc9.vcproj", "{2212857A-7634-4E30-BA83-539EC70176E6}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_PT", "FTNoIR_Tracker_PT\FTNoIR_Tracker_PT_vc9.vcproj", "{7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}" -EndProject -Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "SetupFaceTrackNoIR", "SetupFaceTrackNoIR\SetupFaceTrackNoIR_vc9.vdproj", "{043D4535-6CF9-439A-A144-80208CA0313B}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Debug|Win32.ActiveCfg = Debug|Win32 - {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Debug|Win32.Build.0 = Debug|Win32 - {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Release|Win32.ActiveCfg = Release|Win32 - {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Release|Win32.Build.0 = Release|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.ActiveCfg = Debug|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.Build.0 = Debug|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.ActiveCfg = Release|Win32 - {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.Build.0 = Release|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.ActiveCfg = Debug|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.Build.0 = Debug|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.ActiveCfg = Release|Win32 - {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.Build.0 = Release|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.ActiveCfg = Debug|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.Build.0 = Debug|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.ActiveCfg = Release|Win32 - {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.Build.0 = Release|Win32 - {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Debug|Win32.ActiveCfg = Debug|Win32 - {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Debug|Win32.Build.0 = Debug|Win32 - {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Release|Win32.ActiveCfg = Release|Win32 - {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Release|Win32.Build.0 = Release|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.ActiveCfg = Debug|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.Build.0 = Debug|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.ActiveCfg = Release|Win32 - {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.Build.0 = Release|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.ActiveCfg = Debug|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.Build.0 = Debug|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.ActiveCfg = Release|Win32 - {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.Build.0 = Release|Win32 - {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Debug|Win32.ActiveCfg = Debug|Win32 - {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Debug|Win32.Build.0 = Debug|Win32 - {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Release|Win32.ActiveCfg = Release|Win32 - {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Release|Win32.Build.0 = Release|Win32 - {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Debug|Win32.ActiveCfg = Debug|Win32 - {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Debug|Win32.Build.0 = Debug|Win32 - {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Release|Win32.ActiveCfg = Release|Win32 - {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Release|Win32.Build.0 = Release|Win32 - {46E66901-0212-410A-99B6-793F7ACD2ED0}.Debug|Win32.ActiveCfg = Debug|Win32 - {46E66901-0212-410A-99B6-793F7ACD2ED0}.Debug|Win32.Build.0 = Debug|Win32 - {46E66901-0212-410A-99B6-793F7ACD2ED0}.Release|Win32.ActiveCfg = Release|Win32 - {46E66901-0212-410A-99B6-793F7ACD2ED0}.Release|Win32.Build.0 = Release|Win32 - {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Debug|Win32.ActiveCfg = Debug|Win32 - {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Debug|Win32.Build.0 = Debug|Win32 - {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Release|Win32.ActiveCfg = Release|Win32 - {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Release|Win32.Build.0 = Release|Win32 - {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Debug|Win32.ActiveCfg = Debug|Win32 - {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Debug|Win32.Build.0 = Debug|Win32 - {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Release|Win32.ActiveCfg = Release|Win32 - {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Release|Win32.Build.0 = Release|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.ActiveCfg = Debug|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.Build.0 = Debug|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.ActiveCfg = Release|Win32 - {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.Build.0 = Release|Win32 - {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 - {2212857A-7634-4E30-BA83-539EC70176E6}.Release|Win32.Build.0 = Release|Win32 - {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Debug|Win32.ActiveCfg = Debug|Win32 - {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Debug|Win32.Build.0 = Debug|Win32 - {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Release|Win32.ActiveCfg = Release|Win32 - {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Release|Win32.Build.0 = Release|Win32 - {043D4535-6CF9-439A-A144-80208CA0313B}.Debug|Win32.ActiveCfg = Debug - {043D4535-6CF9-439A-A144-80208CA0313B}.Debug|Win32.Build.0 = Debug - {043D4535-6CF9-439A-A144-80208CA0313B}.Release|Win32.ActiveCfg = Release - {043D4535-6CF9-439A-A144-80208CA0313B}.Release|Win32.Build.0 = Release - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - QtVersion = QT114 - EndGlobalSection -EndGlobal diff --git a/FreeTrackClient/FTClient.cpp b/FreeTrackClient/FTClient.cpp deleted file mode 100644 index d48a2c28..00000000 --- a/FreeTrackClient/FTClient.cpp +++ /dev/null @@ -1,119 +0,0 @@ -/** @file - @brief -*/ -#include "FTClient.h" - - - - - static double/*?*/ const FT_PROGRAMID = "FT_ProgramID"; - - - HANDLE hFTMemMap; - PFreetrackData FTData; - unsigned long lastDataID; - PHandle FTHandle; - PAnsiChar FTProgramName; - HANDLE FTMutex; - - -bool FTGetData(PFreetrackData data) -{ bool result; - result = false; - if( !! FTData ) { - if( FTData->DataID != lastDataID ) { - Move( FTData/*?*/^ , data/*?*/^ , SizeOf( TFreetrackData ) ); - lastDataID = FTData->DataID; - result = true; - } - } else - OpenMapping; -return result; -} - - -void FTReportName(PAnsiChar name) -{ - unsigned long MsgResult; - - if( OpenMapping && ( WaitForSingleObject( FTMutex , 100 ) == WAIT_OBJECT_0 ) ) { - Move( name/*?*/^ , FTProgramName/*?*/^ , 100 ); - SendMessageTimeout( FTHandle/*?*/^ , RegisterWindowMessage( FT_PROGRAMID ) , 0 , 0 , 0 , 2000 , MsgResult ); - ReleaseMutex( FTMutex ); - } -} - - -char* FTGetDllVersion() -{ char* result; - unsigned long VerInfoSize; - Pointer VerInfo; - unsigned long VerValueSize; - PVSFixedFileInfo VerValue; - unsigned long Dummy; - std::string verString; - char* dllName[100]; - - result = ""; - GetModuleFilename( HInstance , &dllName , 100 ); - VerInfoSize = GetFileVersionInfoSize( &dllName , Dummy ); - if( !( VerInfoSize == 0 ) ) { - GetMem( VerInfo , VerInfoSize ); - GetFileVersionInfo( &dllName , 0 , VerInfoSize , VerInfo ); - VerQueryValue( VerInfo , "\\" , Pointer( VerValue ) , VerValueSize ); - /*?*//* WITH VerValue/*?*/^ */ - { - verString = IntToStr( dwFileVersionMS >> 16 ); - verString = verString + "." + IntToStr( dwFileVersionMS && 0xFFFF ); - verString = verString + "." + IntToStr( dwFileVersionLS >> 16 ); - verString = verString + "." + IntToStr( dwFileVersionLS && 0xFFFF ); - result = char*( verString ); - } - FreeMem( VerInfo , VerInfoSize ); - } -return result; -} - - -char* FTProvider() -{ char* result; - result = FREETRACK;return result; -} - - - - - -bool OpenMapping() -{ bool result; - if( hFTMemMap != 0 ) - result = true;else { - hFTMemMap = OpenFileMapping( FILE_MAP_ALL_ACCESS , false , FT_MM_DATA ); - if( ( hFTMemMap != 0 ) ) { - FTData = MapViewOfFile( hFTMemMap , FILE_MAP_ALL_ACCESS , 0 , 0 , SizeOf( TFreetrackData ) + SizeOf( HANDLE ) + 100 ); - FTHandle = Pointer( unsigned long( FTData ) + SizeOf( TFreetrackData ) ); - FTProgramName = Pointer( unsigned long( FTHandle ) + SizeOf( HANDLE ) ); - FTMutex = OpenMutex( MUTEX_ALL_ACCESS , false , FREETRACK_MUTEX ); - } - result = !! FTData; - } -return result; -} - - -void DestroyMapping() -{ - if( FTData != 00 ) { - UnMapViewofFile( FTData ); - FTData = 00; - } - - CloseHandle( FTMutex ); - CloseHandle( hFTMemMap ); - hFTMemMap = 0; -} - - - - -//END diff --git a/FreeTrackClient/FTClient.h b/FreeTrackClient/FTClient.h deleted file mode 100644 index 406e1237..00000000 --- a/FreeTrackClient/FTClient.h +++ /dev/null @@ -1,30 +0,0 @@ -/** @file - @brief -*/ -#pragma once -#ifndef INCLUDED_FTCLIENT_H -#define INCLUDED_FTCLIENT_H - - - - - - -#include "Windows.h" -#include "SysUtils.h" -#include "FTTypes.h" - -/*__stdcall*/ bool FTGetData(PFreetrackData data); -/*__stdcall*/ void FTReportName(PAnsiChar name); -/*__stdcall*/ char* FTGetDllVersion(); -/*__stdcall*/ char* FTProvider(); - - -bool OpenMapping(); -void DestroyMapping(); - - - - -#endif//INCLUDED_FTCLIENT_H -//END diff --git a/FreeTrackClient/FreeTrackClient.sln b/FreeTrackClient/FreeTrackClient.sln deleted file mode 100644 index 5bbc5a5b..00000000 --- a/FreeTrackClient/FreeTrackClient.sln +++ /dev/null @@ -1,26 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeTrackClient", "FreeTrackClient\FreeTrackClient.vcproj", "{74CE36A5-0E38-4252-AAD1-7B2066247F0E}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Release|Win32 = Release|Win32 - Release|x64 = Release|x64 - Release64|Win32 = Release64|Win32 - Release64|x64 = Release64|x64 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|Win32.ActiveCfg = Release|Win32 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|Win32.Build.0 = Release|Win32 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|x64.ActiveCfg = Release|x64 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|x64.Build.0 = Release|x64 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|Win32.ActiveCfg = Release64|Win32 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|Win32.Build.0 = Release64|Win32 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|x64.ActiveCfg = Release64|x64 - {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|x64.Build.0 = Release64|x64 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/FreeTrackClient/FreeTrackClient/FreeTrackClient.cpp b/FreeTrackClient/FreeTrackClient/FreeTrackClient.cpp deleted file mode 100644 index e02f2fe8..00000000 --- a/FreeTrackClient/FreeTrackClient/FreeTrackClient.cpp +++ /dev/null @@ -1,294 +0,0 @@ -/******************************************************************************** -* FreeTrackClientDll Implements the FreeTrack 2.0 interface for FT-enabled * -* games. * -* It uses the FreeTrack protocol (memory mapping) to * -* receive data from FaceTrackNoIR (or FreeTrack, or ...). * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Testing and Research) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -* * -********************************************************************************/ -/* - Modifications (last one on top): - - 20130208 - WVR: The old DLL from FreeTrack seems to crash ArmA2. And we need 64-bit support. - -*/ - -#ifdef WIN64 -#pragma comment(linker, "/export:FTGetData") -#pragma comment(linker, "/export:FTReportName") -#pragma comment(linker, "/export:FTGetDllVersion") -#pragma comment(linker, "/export:FTProvider") -#endif - -#ifdef WIN64 -# define FT_DECLSPEC __declspec(dllexport) -#else -# define FT_DECLSPEC -#endif - -#define FT_EXPORT(t) extern "C" t FT_DECLSPEC __stdcall -#define NP_AXIS_MAX 16383 - -#include -#include -#include -#include -#include -#include - -#include "..\..\FTNOIR_PROTOCOL_FT\FTTypes.h" - -// -// Functions to create/open the file-mapping -// and to destroy it again. -// -bool FTCreateMapping(); -void FTDestroyMapping(); -float scale2AnalogLimits( float x, float min_x, float max_x ); -float getDegreesFromRads ( float rads ); - -#if 1 -static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); -#define dbg_report(...) if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } -#else -#define dbg_report(...) -#endif - -// -// Handles to 'handle' the memory mapping -// -static HANDLE hFTMemMap = 0; -static FTMemMap *pMemData = 0; -static HANDLE hFTMutex = 0; -static char* dllVersion = "1.0.0.0"; -static char* dllProvider = "FreeTrack"; - -static unsigned short gameid = 0; - -// -// DllMain gets called, when the DLL is (un)loaded or a process attaches. -// -BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) -{ - switch (fdwReason) { - case DLL_PROCESS_ATTACH: -#ifdef WIN64 - dbg_report("\n= WIN64 =========================================================================================\n"); -#else - dbg_report("\n= WIN32 =========================================================================================\n"); -#endif - dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); - dbg_report("DllMain: Attach request\n"); - DisableThreadLibraryCalls(hinstDLL); - break; - - case DLL_PROCESS_DETACH: - dbg_report("DllMain: Detach\n"); - dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); - dbg_report("==========================================================================================\n"); - break; - } - return TRUE; -} - -/****************************************************************** - * FTGetData (FreeTrackClient.1) - */ -#pragma comment(linker, "/export:FTGetData@4=FTGetData") -FT_EXPORT(bool) FTGetData(PFreetrackData data) -{ - static int frame = 0; - static int prevDataID = 0; - static int dlyTrackingOff = 0; - static int tracking = 0; - -// dbg_report("NP_GetData called."); - if (FTCreateMapping() == false) return false; - - if (hFTMutex && WaitForSingleObject(hFTMutex, 5) == WAIT_OBJECT_0) { - if (pMemData) { - - // - // When FaceTrackNoIR does not update frames (any more), don't update the data. - // - if (prevDataID != pMemData->data.DataID) { - memcpy(data, &pMemData->data, sizeof(TFreeTrackData)); - dlyTrackingOff = 0; - } - else { - dlyTrackingOff++; - if (dlyTrackingOff > 20) { - dlyTrackingOff = 100; - tracking = false; - } - } - prevDataID = pMemData->data.DataID; - - // - // Limit the range of DataID - // - if (pMemData->data.DataID > 1000) { - pMemData->data.DataID = 0; - } - data->DataID = pMemData->data.DataID; - - // - // Send the ID to FaceTrackNoIR, so it can display the game-name. - // This could be a FreeTrack-specific ID - // - sprintf_s(pMemData->GameID, 19, "%d", gameid ); - - } - ReleaseMutex(hFTMutex); - } - return true; -} - -/****************************************************************** - * FTReportName (FreeTrackClient.2) - */ -#pragma comment(linker, "/export:FTReportName@4=FTReportName") -// -// For some mysterious reason, the previously existing function FTReportID has been changed to FTReportName, but with an integer as argument. -// The Delphi-code from the FreeTrack repo suggest a char * as argument, so it cost me an afternoon to figure it out (and keep ArmA2 from crashing). -// Thanks guys! -// -FT_EXPORT(void) FTReportName( int name ) -{ - dbg_report("FTReportName request (ID = %d).\n", name); - gameid = name; // They might have really passed the name here... but they didn't! - return; -} - -/****************************************************************** - * FTGetDllVersion (FreeTrackClient.3) - */ -#pragma comment(linker, "/export:FTGetDllVersion@0=FTGetDllVersion") -extern "C" __declspec( dllexport ) char* FTGetDllVersion(void) -{ - dbg_report("FTGetDllVersion request.\n"); - - return dllVersion; -} - -/****************************************************************** - * FTProvider (FreeTrackClient.4) - */ -#pragma comment(linker, "/export:FTProvider@0=FTProvider") -extern "C" __declspec( dllexport ) char* FTProvider(void) -{ - dbg_report("FTProvider request.\n"); - - return dllProvider; -} - -// -// Create a memory-mapping to the Freetrack data. -// It contains the tracking data, a handle to the main-window and the program-name of the Game! -// -// -bool FTCreateMapping() -{ - bool bMappingExists = false; - PDWORD_PTR MsgResult = 0; - - // - // Memory-mapping already exists! - // - if ( pMemData != NULL ) { - return true; - } - - dbg_report("FTCreateMapping request (pMemData == NULL).\n"); - - // - // A FileMapping is used to create 'shared memory' between the FTClient and the FTServer. - // - // Try to create a FileMapping to the Shared Memory. This is done to check if it's already there (what - // may mean the face-tracker program is already running). - // - // If one already exists: close it and open the file-mapping to the existing one. - // - hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , - sizeof( FTMemMap ), - (LPCSTR) FT_MM_DATA ); - - if ( ( hFTMemMap != 0 ) && ( GetLastError() == ERROR_ALREADY_EXISTS ) ) { - dbg_report("FTCreateMapping: Mapping already exists.\n"); - bMappingExists = true; // So the server was (probably) already started! - CloseHandle( hFTMemMap ); - hFTMemMap = 0; - } - - // - // Create a new FileMapping, Read/Write access - // - hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA ); - if ( ( hFTMemMap != 0 ) ) { - dbg_report("FTCreateMapping: Mapping opened.\n"); - pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof( FTMemMap ) ); - hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); - } - else { - return false; - } - return true; -} - -// -// Destory the FileMapping to the shared memory -// -void FTDestroyMapping() -{ - if ( pMemData != NULL ) { - UnmapViewOfFile ( pMemData ); - } - - CloseHandle( hFTMutex ); - CloseHandle( hFTMemMap ); - pMemData = 0; - hFTMemMap = 0; -} - -// -// 4 convenience -// -float getDegreesFromRads ( float rads ) { - return (rads * 57.295781f); -} - -// -// Scale the measured value to the TIR values -// -float scale2AnalogLimits( float x, float min_x, float max_x ) { -double y; -double local_x; - - local_x = x; - if (local_x > max_x) { - local_x = max_x; - } - if (local_x < min_x) { - local_x = min_x; - } - y = ( NP_AXIS_MAX * local_x ) / max_x; - - return (float) y; -} diff --git a/FreeTrackClient/FreeTrackClient/FreeTrackClient.rc b/FreeTrackClient/FreeTrackClient/FreeTrackClient.rc deleted file mode 100644 index 299beb82..00000000 --- a/FreeTrackClient/FreeTrackClient/FreeTrackClient.rc +++ /dev/null @@ -1,103 +0,0 @@ -// Microsoft Visual C++ generated resource script. -// -#include "resource.h" - -#define APSTUDIO_READONLY_SYMBOLS -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 2 resource. -// -#include "afxres.h" - -///////////////////////////////////////////////////////////////////////////// -#undef APSTUDIO_READONLY_SYMBOLS - -///////////////////////////////////////////////////////////////////////////// -// Dutch (Netherlands) resources - -#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) -#ifdef _WIN32 -LANGUAGE LANG_DUTCH, SUBLANG_DUTCH -#pragma code_page(1252) -#endif //_WIN32 - -#ifdef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// TEXTINCLUDE -// - -1 TEXTINCLUDE -BEGIN - "resource.h\0" -END - -2 TEXTINCLUDE -BEGIN - "#include ""afxres.h""\r\n" - "\0" -END - -3 TEXTINCLUDE -BEGIN - "\r\n" - "\0" -END - -#endif // APSTUDIO_INVOKED - - -///////////////////////////////////////////////////////////////////////////// -// -// Version -// - -VS_VERSION_INFO VERSIONINFO - FILEVERSION 1,0,0,1 - PRODUCTVERSION 1,0,0,1 - FILEFLAGSMASK 0x17L -#ifdef _DEBUG - FILEFLAGS 0x1L -#else - FILEFLAGS 0x0L -#endif - FILEOS 0x4L - FILETYPE 0x2L - FILESUBTYPE 0x0L -BEGIN - BLOCK "StringFileInfo" - BEGIN - BLOCK "041304b0" - BEGIN - VALUE "Comments", "FreeTrack interface for FaceTrackNoIR." - VALUE "CompanyName", "FaceTrackNoIR Team" - VALUE "FileDescription", "64-bit interface for FreeTrack-enables games." - VALUE "FileVersion", "1, 0, 0, 1" - VALUE "InternalName", "FreeTrackClient" - VALUE "LegalCopyright", "Copyright (C) 2013, FaceTrackNoIR Team" - VALUE "OriginalFilename", "FreeTrackClient64.dll" - VALUE "ProductName", "Interface DLL for FreeTrack 2.0" - VALUE "ProductVersion", "1, 0, 0, 1" - END - END - BLOCK "VarFileInfo" - BEGIN - VALUE "Translation", 0x413, 1200 - END -END - -#endif // Dutch (Netherlands) resources -///////////////////////////////////////////////////////////////////////////// - - - -#ifndef APSTUDIO_INVOKED -///////////////////////////////////////////////////////////////////////////// -// -// Generated from the TEXTINCLUDE 3 resource. -// - - -///////////////////////////////////////////////////////////////////////////// -#endif // not APSTUDIO_INVOKED - diff --git a/FreeTrackClient/FreeTrackClient/FreeTrackClient.vcproj b/FreeTrackClient/FreeTrackClient/FreeTrackClient.vcproj deleted file mode 100644 index 7d69802e..00000000 --- a/FreeTrackClient/FreeTrackClient/FreeTrackClient.vcproj +++ /dev/null @@ -1,556 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/FreeTrackClient/FreeTrackClient/postbuild.bat b/FreeTrackClient/FreeTrackClient/postbuild.bat deleted file mode 100644 index 87c192d1..00000000 --- a/FreeTrackClient/FreeTrackClient/postbuild.bat +++ /dev/null @@ -1,15 +0,0 @@ -@echo off -rem Copies required DLL files into output folder. - -setlocal -set COPY=xcopy /D /S /C /I /H /R /Y -set FILTER=find /v "File(s) copied" - -echo parameters %1 en %2 - -set API_BIN=%1 -set FTN_BIN=%2 - -%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% -exit /b 0 - diff --git a/FreeTrackClient/FreeTrackClient/resource.h b/FreeTrackClient/FreeTrackClient/resource.h deleted file mode 100644 index e517577e..00000000 --- a/FreeTrackClient/FreeTrackClient/resource.h +++ /dev/null @@ -1,15 +0,0 @@ -//{{NO_DEPENDENCIES}} -// Microsoft Visual C++ generated include file. -// Used by FreeTrackClient.rc -// - -// Next default values for new objects -// -#ifdef APSTUDIO_INVOKED -#ifndef APSTUDIO_READONLY_SYMBOLS -#define _APS_NEXT_RESOURCE_VALUE 101 -#define _APS_NEXT_COMMAND_VALUE 40001 -#define _APS_NEXT_CONTROL_VALUE 1001 -#define _APS_NEXT_SYMED_VALUE 101 -#endif -#endif diff --git a/List of compatible games.xls b/List of compatible games.xls deleted file mode 100644 index bdc55e62..00000000 Binary files a/List of compatible games.xls and /dev/null differ diff --git a/List of compatible webcams.xls b/List of compatible webcams.xls deleted file mode 100644 index a057ef43..00000000 Binary files a/List of compatible webcams.xls and /dev/null differ diff --git a/QFunctionConfigurator/Prerequisites for using widget in Qt Designer.png b/QFunctionConfigurator/Prerequisites for using widget in Qt Designer.png deleted file mode 100644 index 6e4d8903..00000000 Binary files a/QFunctionConfigurator/Prerequisites for using widget in Qt Designer.png and /dev/null differ diff --git a/QFunctionConfigurator/QFunctionConfigurator.sln b/QFunctionConfigurator/QFunctionConfigurator.sln deleted file mode 100644 index 91b827df..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 9.00 -# Visual Studio 2005 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QFunctionConfigurator", "QFunctionConfigurator\QFunctionConfigurator.vcproj", "{2527B683-7EFC-4D51-B25A-843668649C54}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.ActiveCfg = Debug|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.Build.0 = Debug|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.ActiveCfg = Release|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.cpp b/QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.cpp deleted file mode 100644 index 243564d1..00000000 Binary files a/QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.cpp and /dev/null differ diff --git a/QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.h b/QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.h deleted file mode 100644 index 8dc9cf98..00000000 Binary files a/QFunctionConfigurator/QFunctionConfigurator/FunctionConfig.h and /dev/null differ diff --git a/QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj b/QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj deleted file mode 100644 index 29a06271..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj +++ /dev/null @@ -1,355 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj b/QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj deleted file mode 100644 index 940a6198..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj +++ /dev/null @@ -1,354 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/QFunctionConfigurator/QFunctionConfigurator/postbuild.bat b/QFunctionConfigurator/QFunctionConfigurator/postbuild.bat deleted file mode 100644 index 3fe2e3ca..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/postbuild.bat +++ /dev/null @@ -1,30 +0,0 @@ -@echo off -rem Copies required DLL files into output folder. - -setlocal -set COPY=xcopy /D /S /C /I /H /R /Y -set FILTER=find /v "File(s) copied" - -echo parameters %1 en %2 en %3 en %4 - -set API_BIN=%1 -set OUTDIR=%2 -set CONFIG=%3 -set FTN_BIN=%4 - -if %CONFIG%==Debug (goto Debug) -if %CONFIG%==Release (goto Release) - -echo Unknown build configuration %CONFIG% -exit /b -1 - -:Debug -%COPY% %API_BIN%\*.* %OUTDIR%\ | %FILTER% -%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% -exit /b 0 - -:Release -%COPY% %API_BIN%\*.* %OUTDIR%\ | %FILTER% -%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% -exit /b 0 - diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp deleted file mode 100644 index fe2ad49d..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp +++ /dev/null @@ -1,721 +0,0 @@ -/******************************************************************************** -* 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 . * -* * -* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * -* FaceTrackNoIR. * -* * -* All credits for this nice piece of code should go to Stanislaw. * -* * -* Copyright (c) 2011-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. * -********************************************************************************/ -/* - Modifications (last one on top): - 20120830 - WVR: Changed functionality a bit. Now only draw the handles, when the function is drawn. - Only check mouseMoves, when they occur 'in range'. Redraw the curve, when a resize occurs. - Somehow, the curve was not drawn correctly, when this was not done (all points were too high). - After a 'Reset' this would disappear... - 20120828 - WVR: Removed bSkipText, which was used to not show a number below each vertical gridline. -*/ -#include "qfunctionconfigurator.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include - -QFunctionConfigurator::~QFunctionConfigurator() -{ - WaitForSingleObject(_mutex, INFINITE); - CloseHandle(_mutex); - delete btnReset; -} - -static const int pointSize = 5; - -QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) - : QWidget(parent) -{ - - // - // Defaults, for when the widget has no values different from the domXML() - // - MaxInput = 50; // Maximum input limit - MaxOutput = 180; // Maximum output limit - pPerEGU_Output = 1; // Number of pixels, per EGU - pPerEGU_Input = 4; // Number of pixels, per EGU - gDistEGU_Input = 5; // Distance of gridlines - gDistEGU_Output = 10; // Distance of gridlines - - - // Change compared to BezierConfigurator: X = horizontal (input), Y = vertical (output) - // This will require the Curve-Dialog to be higher (which was the reason it was reversed in the first place..) - range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); - - setMouseTracking(true); - moving = NULL; // Pointer to the curve-point, that's being moved - movingPoint = 1; // Index of that same point - - // - // Add a Reset-button - // - btnReset = new QPushButton(QString("Reset"), this); - connect(btnReset, SIGNAL(clicked()), this, SLOT(resetCurve())); - - // - // Variables for FunctionConfig - // - _config = 0; - _points = QList(); - _draw_points = QList(); - _mutex = CreateMutex(NULL, false, NULL); - _draw_background = true; - _draw_function = true; - -// qDebug() << "QFunctionConfigurator::QFunctionConfigurator object created."; - -} - -// -// Attach an existing FunctionConfig to the Widget. -// -void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFile) { -QPointF currentPoint; -QPointF drawPoint; -qreal x; - - WaitForSingleObject(_mutex, INFINITE); - _config = config; - _points = config->getPoints(); - strSettingsFile = settingsFile; // Remember for Reset() - - qDebug() << "QFunctionConfigurator::setConfig" << config->getTitle(); - setCaption(config->getTitle()); - - // - // Get the Function Points, one for each pixel in the horizontal range. - // If the curve does not change, there is no need to run this code every time (it slows down drawing). - // - _draw_points.clear(); - for (int j = 0; j < MaxInput * pPerEGU_Input; j++) { - // - // Weird: not casting to float causes C++ to round the number... - // - x = (float) j / (float) pPerEGU_Input; - currentPoint.setX ( x ); - currentPoint.setY (_config->getValue( x )); - drawPoint = graphicalizePoint(currentPoint, "setConfig"); - if (withinRect(drawPoint, range)) { - _draw_points.append(drawPoint); -// qDebug() << "QFunctionConfigurator::setConfig _draw_Point to add = " << drawPoint; - } - } - - ReleaseMutex(_mutex); - _draw_function = true; - this->update(); -} - -// -// Load the FunctionConfig (points) from the INI-file. -// -void QFunctionConfigurator::loadSettings(QString settingsFile) { - - QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::loadSettings = " << settingsFile; - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - _config->loadSettings(iniFile); - setConfig(_config, settingsFile); - } - ReleaseMutex(_mutex); -} - -// -// Save the FunctionConfig (points) to the INI-file. -// -void QFunctionConfigurator::saveSettings(QString settingsFile) { - QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) - strSettingsFile = settingsFile; // Remember for Reset() - qDebug() << "QFunctionConfigurator::saveSettings = " << settingsFile; - - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - _config->saveSettings(iniFile); - } - ReleaseMutex(_mutex); -} - -// -// Draw the Background for the graph, the gridlines and the gridpoints. -// The static objects are drawn on a Pixmap, so it does not have to be repeated every paintEvent. Hope this speeds things up... -// -void QFunctionConfigurator::drawBackground(const QRectF &fullRect) -{ -int i; -QRect scale; - - qDebug() << "QFunctionConfigurator::drawBackground."; - - _background = QPixmap(fullRect.width(), fullRect.height()); - QPainter painter(&_background); - - painter.save(); - painter.setRenderHint(QPainter::Antialiasing); - painter.fillRect(fullRect, colBackground); - QColor bg_color(112, 154, 209); - painter.fillRect(range, bg_color); - - QFont font("ComicSans", 4); - font.setPointSize(8); - painter.setFont(font); - - QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine); - - // - // Draw the Caption - // - if (_config) { - strCaption = _config->getTitle(); - } - - scale.setCoords(range.left(), 0, range.right(), 20); - painter.drawText(scale, Qt::AlignCenter, strCaption); - - // - // Draw the horizontal grid - // - for (i = range.bottom() - gDistEGU_Output * pPerEGU_Output; i >= range.top(); i -= gDistEGU_Output * pPerEGU_Output) { - drawLine(&painter, QPointF(40, i), QPointF(range.right(), i), pen); - scale.setCoords(0, i - 5, range.left() - 5, i + 5); - painter.drawText(scale, Qt::AlignRight, tr("%1").arg(((range.bottom() - i))/pPerEGU_Output)); - } - - // - // Draw the vertical guidelines - // - for (i = range.left(); i <= range.right(); i += gDistEGU_Input * pPerEGU_Input) { - drawLine(&painter, QPointF(i, range.top()), QPointF(i, range.bottom()), pen); - scale.setCoords(i - 10, range.bottom() + 2, i + 10, range.bottom() + 15); - painter.drawText(scale, Qt::AlignCenter, tr("%1").arg(abs(((range.left() - i))/pPerEGU_Input))); - } - - scale.setCoords(range.left(), range.bottom() + 20, range.right(), range.bottom() + 35); - painter.drawText(scale, Qt::AlignRight, strInputEGU); - - // - // Draw the EGU of the vertical axis (vertically!) - // - font.setPointSize(10); - painter.translate(range.topLeft().x() - 35, range.topLeft().y()); - painter.rotate(90); - painter.drawText(0,0,strOutputEGU ); - - // - // Draw the two axis - // - pen.setWidth(2); - pen.setColor( Qt::black ); - drawLine(&painter, range.topLeft() - QPointF(2,0), range.bottomLeft() - QPointF(2,0), pen); - drawLine(&painter, range.bottomLeft(), range.bottomRight(), pen); - - painter.restore(); -} - - -// -// Draw the Function for the graph, on a Pixmap. -// -void QFunctionConfigurator::drawFunction(const QRectF &fullRect) -{ - if (!_config) - return; -int i; -QPointF prevPoint; -QPointF currentPoint; - - // - // Use the background picture to draw on. - // ToDo: find out how to add Pixmaps, without getting it all green... - // - _function = QPixmap(_background); - QPainter painter(&_function); - - painter.save(); - painter.setRenderHint(QPainter::Antialiasing, false); - - // - // Draw the handles for the Points - // - for (i = 0; i < _points.size(); i++) { - currentPoint = graphicalizePoint( _points[i], "drawFunction handles" ); // Get the next point and convert it to Widget measures - drawPoint(&painter, currentPoint, QColor(200, 200, 210, 120)); - lastPoint = currentPoint; // Remember which point is the rightmost in the graph -//qDebug() << "QFunctionConfigurator::paintEvent, drawing handle for " << currentPoint; - } - - - QPen pen(colBezier, 2, Qt::SolidLine); - - prevPoint = graphicalizePoint( QPointF(0,0), "drawFunction lines" ); // Start at the Axis - double max = maxInputEGU(); - QPointF prev = graphicalizePoint(QPointF(0, 0)); - double step = 1 / (double) pixPerEGU_Input(); - for (double i = 0; i < max; i += step) { - double val = _config->getValue(i); - QPointF cur = graphicalizePoint(QPointF(i, val)); - drawLine(&painter, prev, cur, pen); - prev = cur; - } - painter.restore(); -} - -// -// The Widget paints the surface every x msecs. -// -void QFunctionConfigurator::paintEvent(QPaintEvent *e) -{ -QPointF prevPoint; -QPointF currentPoint; -QPointF actualPos; -int i; - -// qDebug() << "QFunctionConfigurator::paintEvent."; - - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - p.setClipRect(e->rect()); - - if (_draw_background) { - drawBackground(e->rect()); // Draw the static parts on a Pixmap - p.drawPixmap(0, 0, _background); // Paint the background - _draw_background = false; - - btnReset->move(e->rect().left(), e->rect().bottom() - btnReset->height() - 2); - } - - if (_draw_function) { - drawFunction(e->rect()); // Draw the Function on a Pixmap - _draw_function = false; - } - p.drawPixmap(0, 0, _function); // Always draw the background and the function - - QPen pen(Qt::white, 1, Qt::SolidLine); - - // - // Draw the Points, that make up the Curve - // - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - - // - // When moving, also draw a sketched version of the Function. - // - if (moving) { - prevPoint = graphicalizePoint( QPointF(0,0), "paintEvent moving" ); // Start at the Axis - for (i = 0; i < _points.size(); i++) { - currentPoint = graphicalizePoint( _points[i], "paintEvent moving" ); // Get the next point and convert it to Widget measures - drawLine(&p, prevPoint, currentPoint, pen); - prevPoint = currentPoint; -// qDebug() << "QFunctionConfigurator::paintEvent, drawing while moving " << currentPoint; - } - - // - // When moving, also draw a few help-lines, so positioning the point gets easier. - // - pen.setWidth(1); - pen.setColor( Qt::white ); - pen.setStyle( Qt::DashLine ); - actualPos = graphicalizePoint(*moving, "paintEvent moving help line(s)"); - drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); - } - - // - // If the Tracker is active, the 'Last Point' it requested is recorded. - // Show that point on the graph, with some lines to assist. - // This new feature is very handy for tweaking the curves! - // - if (_config->getLastPoint( currentPoint )) { - -// qDebug() << "QFunctionConfigurator::paintEvent, drawing tracked Point " << currentPoint; - - actualPos = graphicalizePoint( currentPoint, "paintEvent tracking" ); - drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); - - pen.setWidth(1); - pen.setColor( Qt::black ); - pen.setStyle( Qt::SolidLine ); - drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); - drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); - } - - } - ReleaseMutex(_mutex); - - // - // Draw the delimiters - // - pen.setWidth(1); - pen.setColor( Qt::white ); - pen.setStyle( Qt::SolidLine ); - drawLine(&p, QPoint(lastPoint.x(), range.top()), QPoint(lastPoint.x(), range.bottom()), pen); - drawLine(&p, QPoint(range.left(), lastPoint.y()), QPoint(range.right(), lastPoint.y()), pen); - - QTimer::singleShot(250, this, SLOT(update())); -} - -// -// Draw the handle, to move the Bezier-curve. -// -void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG ) -{ - painter->save(); - painter->setPen(QColor(50, 100, 120, 200)); - painter->setBrush( colBG ); - painter->drawEllipse(QRectF(pos.x() - pointSize, - pos.y() - pointSize, - pointSize*2, pointSize*2)); - painter->restore(); -} - -void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen) -{ - painter->save(); - painter->setPen(pen); - painter->setBrush(Qt::NoBrush); - painter->drawLine(start, end); - painter->restore(); -} - -// -// If the mousebutton is pressed, check if it is inside one of the Points. -// If so: start moving that Point, until mouse release. -// -void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) -{ - // - // First: check the left mouse-button - // - if (e->button() == Qt::LeftButton) { - - // - // Check to see if the cursor is touching one of the points. - // - bool bTouchingPoint = false; - movingPoint = -1; - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - - for (int i = 0; i < _points.size(); i++) { - if ( markContains( graphicalizePoint( _points[i], "mousePressEvent markContains" ), e->pos() ) ) { - bTouchingPoint = true; - moving = &_points[i]; - movingPoint = i; - } - } - - // - // If the Left Mouse-button was clicked without touching a Point, add a new Point - // - if (!bTouchingPoint) { - if (withinRect(e->pos(), range)) { - _config->addPoint(normalizePoint(e->pos())); - setConfig(_config, strSettingsFile); - moving = NULL; - emit CurveChanged( true ); - } - } - } - ReleaseMutex(_mutex); - } - - // - // Then: check the right mouse-button - // - if (e->button() == Qt::RightButton) { - - // - // Check to see if the cursor is touching one of the points. - // - moving = NULL; - movingPoint = -1; - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - - for (int i = 0; i < _points.size(); i++) { - if ( markContains( graphicalizePoint( _points[i], "mousePressEvent RightButton" ), e->pos() ) ) { - movingPoint = i; - } - } - - // - // If the Right Mouse-button was clicked while touching a Point, remove the Point - // - if (movingPoint >= 0) { - _config->removePoint(movingPoint); - setConfig(_config, strSettingsFile); - movingPoint = -1; - emit CurveChanged( true ); - } - } - ReleaseMutex(_mutex); - } - -} - -// -// If the mouse if moving, make sure the Bezier moves along. -// Of course, only when a Point is selected... -// -void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) -{ - - if (moving) { - - setCursor(Qt::ClosedHandCursor); - - // - // Change the currently moving Point. - // - *moving = normalizePoint(e->pos()); - update(); - } - else { - - // - // Check to see if the cursor is touching one of the points. - // - bool bTouchingPoint = false; - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - - for (int i = 0; i < _points.size(); i++) { - if ( markContains( graphicalizePoint( _points[i], "mouseMoveEvent" ), e->pos() ) ) { - bTouchingPoint = true; - } - } - } - ReleaseMutex(_mutex); - - if ( bTouchingPoint ) { - setCursor(Qt::OpenHandCursor); - } - else { - setCursor(Qt::ArrowCursor); - } - - } -} - -void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) -{ - //qDebug()<<"releasing"; - if (moving > 0) { - emit CurveChanged( true ); - - // - // Update the Point in the _config - // - WaitForSingleObject(_mutex, INFINITE); - if (_config) { - _config->movePoint(movingPoint, normalizePoint(e->pos())); - setConfig(_config, strSettingsFile); - } - ReleaseMutex(_mutex); - - } - setCursor(Qt::ArrowCursor); - moving = NULL; - movingPoint = 0; -} - -// -// Determine if the mousebutton was pressed within the range of the Point. -// -bool QFunctionConfigurator::markContains(const QPointF &pos, const QPointF &coord) const -{ - QRectF rect(pos.x() - pointSize, - pos.y() - pointSize, - pointSize*2, pointSize*2); - QPainterPath path; - path.addEllipse(rect); - return path.contains(coord); -} - -bool QFunctionConfigurator::withinRect( const QPointF &coord, const QRectF &rect ) const -{ - QPainterPath path; - path.addRect(rect); - return path.contains(coord); -} - -// -// Convert the Point in the graph, to the real-life Point. -// -QPointF QFunctionConfigurator::normalizePoint(QPointF point) const -{ - QPointF norm; - - norm.setX( (point.x() - range.left()) / pPerEGU_Input ); - norm.setY( (range.bottom() - point.y()) / pPerEGU_Output ); - - if (norm.x() > maxInputEGU()) - norm.setX(maxInputEGU()); - else if (norm.x() < 0) - norm.setX(0); - if (norm.y() > maxOutputEGU()) - norm.setY(maxOutputEGU()); - else if (norm.y() < 0) - norm.setY(0); - - return norm; -} - -// -// Convert the real-life Point into the graphical Point. -// -QPointF QFunctionConfigurator::graphicalizePoint(QPointF point, QString source) const -{ -QPointF graph; - - graph.setX( range.left() + (fabs(point.x()) * pPerEGU_Input) ); - graph.setY( range.bottom() - (fabs(point.y()) * pPerEGU_Output) ); - -// qDebug() << "QFunctionConfigurator::graphicalizePoint source = " << source << ", point = " << point << ", graph = " << graph; - - return graph; -} - -void QFunctionConfigurator::setmaxInputEGU(int value) -{ - MaxInput = value; - setMinimumWidth(MaxInput * pPerEGU_Input + 55); -// resetCurve(); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} -void QFunctionConfigurator::setmaxOutputEGU(int value) -{ - MaxOutput = value; - setMinimumHeight(MaxOutput * pPerEGU_Output + 60); -// resetCurve(); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} - -// -// To make configuration more visibly attractive, the number of pixels 'per EGU' can be defined. -// -void QFunctionConfigurator::setpixPerEGU_Input(int value) -{ - pPerEGU_Input = value; - setMinimumWidth(MaxInput * pPerEGU_Input + 55); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} - -// -// To make configuration more visibly attractive, the number of pixels 'per EGU' can be defined. -// -void QFunctionConfigurator::setpixPerEGU_Output(int value) -{ - pPerEGU_Output = value; - setMinimumHeight(MaxOutput * pPerEGU_Output + 60); - resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); -} - -// -// Define the distance of the grid 'in EGU' points. -// -void QFunctionConfigurator::setgridDistEGU_Input(int value) -{ - gDistEGU_Input = value; - _draw_background = true; - _draw_function = true; - repaint(); -} - -// -// Define the distance of the grid 'in EGU' points. -// -void QFunctionConfigurator::setgridDistEGU_Output(int value) -{ - gDistEGU_Output = value; - _draw_background = true; - _draw_function = true; - repaint(); -} - -void QFunctionConfigurator::setColorBezier(QColor color) -{ - colBezier = color; - update(); -} -void QFunctionConfigurator::setColorBackground(QColor color) -{ - colBackground = color; - update(); -} - -void QFunctionConfigurator::setInputEGU(QString egu) -{ - strInputEGU = egu; - update(); -} -void QFunctionConfigurator::setOutputEGU(QString egu) -{ - strOutputEGU = egu; - update(); -} -void QFunctionConfigurator::setCaption(QString cap) -{ - strCaption = cap; - update(); -} - -void QFunctionConfigurator::resizeEvent(QResizeEvent *e) -{ - QSize s = e->size(); - range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); - - qDebug() << "QFunctionConfigurator::resizeEvent, name = " << strCaption << ",range = " << range; - - if (_config) { - setConfig(_config, strSettingsFile); - } - _draw_background = true; - _draw_function = true; - repaint(); -} diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h deleted file mode 100644 index c467bc92..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfigurator.h +++ /dev/null @@ -1,206 +0,0 @@ -/******************************************************************************** -* 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 . * -* * -* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * -* FaceTrackNoIR. * -* * -* All credits for this nice piece of code should go to Stanislaw. * -* * -* Copyright (c) 2011-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. * -********************************************************************************/ -#ifndef QFUNCTIONCONFIGURATOR_H -#define QFUNCTIONCONFIGURATOR_H - -#include -#include -#include -#include "FunctionConfig.h" - -// -// The FunctionConfigurator Widget is used to display and configure a function (curve). -// The Function is used by FaceTrackNoIR to 'translate' the actual head-pose to the virtual headpose. Every axis is configured by a separate Function. -// -// The Function is coded in a separate Class and can exists, without the Widget. When the widget is displayed (therefore 'created'), the Function can be attached to the -// Widget and the Widget used to change the Function. -// -class QDESIGNER_WIDGET_EXPORT QFunctionConfigurator : public QWidget -{ - Q_OBJECT - Q_PROPERTY(int maxInputEGU READ maxInputEGU WRITE setmaxInputEGU); - Q_PROPERTY(int maxOutputEGU READ maxOutputEGU WRITE setmaxOutputEGU); - Q_PROPERTY(int pixPerEGU_Input READ pixPerEGU_Input WRITE setpixPerEGU_Input); - Q_PROPERTY(int pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output); - Q_PROPERTY(int gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input); - Q_PROPERTY(int gridDistEGU_Output READ gridDistEGU_Output WRITE setgridDistEGU_Output); - - Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier); - Q_PROPERTY(QColor colorBackground READ colorBackground WRITE setColorBackground); - Q_PROPERTY(QString stringInputEGU READ stringInputEGU WRITE setInputEGU); - Q_PROPERTY(QString stringOutputEGU READ stringOutputEGU WRITE setOutputEGU); - Q_PROPERTY(QString stringCaption READ stringCaption WRITE setCaption); - - // Return the current value to Designer - int maxInputEGU() const - { - return MaxInput; - } - int maxOutputEGU() const - { - return MaxOutput; - } - int pixPerEGU_Input() const - { - return pPerEGU_Input; - } - int pixPerEGU_Output() const - { - return pPerEGU_Output; - } - int gridDistEGU_Input() const - { - return gDistEGU_Input; - } - int gridDistEGU_Output() const - { - return gDistEGU_Output; - } - - // Return the current color to Designer - QColor colorBezier() const - { - return colBezier; - } - // Return the current color to Designer - QColor colorBackground() const - { - return colBackground; - } - // Return the current string to Designer - QString stringInputEGU() const - { - return strInputEGU; - } - // Return the current string to Designer - QString stringOutputEGU() const - { - return strOutputEGU; - } - // Return the current string to Designer - QString stringCaption() const - { - return strCaption; - } - -public: - QFunctionConfigurator(QWidget *parent = 0); - ~QFunctionConfigurator(); - FunctionConfig* config(); - - void setConfig(FunctionConfig* config, QString settingsFile); // Connect the FunctionConfig to the Widget. - void loadSettings(QString settingsFile); // Load the FunctionConfig (points) from the INI-file - void saveSettings(QString settingsFile); // Save the FunctionConfig (points) to the INI-file - -signals: - void CurveChanged(bool); - -public slots: - void setmaxInputEGU(int); - void setmaxOutputEGU(int); - void setpixPerEGU_Input(int); - void setpixPerEGU_Output(int); - void setgridDistEGU_Input(int); - void setgridDistEGU_Output(int); - - void setColorBezier(QColor); - void setColorBackground(QColor); - void setInputEGU(QString); - void setOutputEGU(QString); - void setCaption(QString); - - void resetCurve() { - qDebug() << "QFunctionConfigurator::resetCurve = " << strSettingsFile; - loadSettings( strSettingsFile ); - } - -protected slots: - void paintEvent(QPaintEvent *e); - void mousePressEvent(QMouseEvent *e); - void mouseMoveEvent(QMouseEvent *e); - void mouseReleaseEvent(QMouseEvent *e); - -protected: - void drawBackground(const QRectF &rect); - void drawFunction(const QRectF &rect); - void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); - void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); - bool markContains(const QPointF &pt, const QPointF &coord) const; -// bool withinRange( const QPointF &coord ) const; - bool withinRect( const QPointF &coord, const QRectF &rect ) const; - -protected: - virtual void resizeEvent(QResizeEvent *); - -private: - QRectF range; // The actual rectangle for the Bezier-curve - QPointF lastPoint; // The right-most point of the Function - QPointF normalizePoint (QPointF point) const; // Convert the graphical Point to a real-life Point - QPointF graphicalizePoint (QPointF point, QString source = "") const; // Convert the Point to a graphical Point - - QPointF *moving; - int movingPoint; - - int MaxInput; // Maximum input limit - int MaxOutput; // Maximum output limit - int pPerEGU_Input; // Number of pixels, per EGU of Input - int pPerEGU_Output; // Number of pixels, per EGU of Output - int gDistEGU_Input; // Distance of the grid, in EGU of Input - int gDistEGU_Output; // Distance of the grid, in EGU of Output - - QColor colBezier; // Color of Bezier curve - QColor colBackground; // Color of widget background - QString strInputEGU; // Engineering Units input (vertical axis) - QString strOutputEGU; // Engineering Units output (horizontal axis) - QString strCaption; // Caption of the graph - QString strSettingsFile; // Name of last read INI-file - QPushButton *btnReset; // Reset Curve - - bool _draw_background; // Flag to determine if the background should be (re-)drawn on the QPixmap - QPixmap _background; // Image of the static parts (axis, lines, etc.) - bool _draw_function; // Flag to determine if the function should be (re-)drawn on the QPixmap - QPixmap _function; // Image of the function (static unless edited by the user) - - // - // Properties of the CurveConfigurator Widget - // - QString _title; // Title do display in Widget and to load Settings - FunctionConfig* _config; - QList _points; // Function-points - QList _draw_points; // Curve-points needed for drawing - HANDLE _mutex; -}; - -#endif // QFUNCTIONCONFIGURATOR_H diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp deleted file mode 100644 index 44e9f831..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp +++ /dev/null @@ -1,146 +0,0 @@ -/******************************************************************************** -* 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 . * -* * -* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * -* FaceTrackNoIR. * -* * -* All credits for this nice piece of code should go to Stanislaw. * -* * -* Copyright (c) 2011-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 "qfunctionconfigurator.h" - -#include -#include "qfunctionconfiguratorplugin.h" - - -QFunctionConfiguratorPlugin::QFunctionConfiguratorPlugin(QObject *parent) - : QObject(parent) -{ - initialized = false; -} - -void QFunctionConfiguratorPlugin::initialize(QDesignerFormEditorInterface */*core*/) -{ - if (initialized) - return; - - initialized = true; -} - -bool QFunctionConfiguratorPlugin::isInitialized() const -{ - return initialized; -} - -QWidget *QFunctionConfiguratorPlugin::createWidget(QWidget *parent) -{ - return new QFunctionConfigurator(parent); -} - -QString QFunctionConfiguratorPlugin::name() const -{ - return "QFunctionConfigurator"; -} - -QString QFunctionConfiguratorPlugin::group() const -{ - return "My Plugins"; -} - -QIcon QFunctionConfiguratorPlugin::icon() const -{ - return QIcon(); -} - -QString QFunctionConfiguratorPlugin::toolTip() const -{ - return QString(); -} - -QString QFunctionConfiguratorPlugin::whatsThis() const -{ - return QString(); -} - -bool QFunctionConfiguratorPlugin::isContainer() const -{ - return false; -} - -QString QFunctionConfiguratorPlugin::domXml() const -{ - return "\n" - " \n" - " \n" - " 0\n" - " 0\n" - " 161\n" - " 220\n" - " \n" - " \n" - " \n" - " \n" - " 255\n" - " 170\n" - " 0\n" - " \n" - " \n" - " \n" - " \n" - " 192\n" - " 192\n" - " 192\n" - " \n" - " \n" - " \n" - " Input Yaw (degr.)\n" - " \n" - " \n" - " Output Yaw (degr.)\n" - " \n" - " \n" - " 50\n" - " \n" - " \n" - " 180\n" - " \n" - " \n" - " 2\n" - " \n" - " \n" - " 1\n" - " \n" - "\n"; -} - -QString QFunctionConfiguratorPlugin::includeFile() const -{ - return "qfunctionconfigurator.h"; -} - -Q_EXPORT_PLUGIN2(qfunctionconfigurator, QFunctionConfiguratorPlugin) diff --git a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h b/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h deleted file mode 100644 index 31bf0b2e..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef QFUNCTIONCONFIGURATORPLUGIN_H -#define QFUNCTIONCONFIGURATORPLUGIN_H - -#include - -class QFunctionConfiguratorPlugin : public QObject, public QDesignerCustomWidgetInterface -{ - Q_OBJECT - Q_INTERFACES(QDesignerCustomWidgetInterface) - -public: - QFunctionConfiguratorPlugin(QObject *parent = 0); - - bool isContainer() const; - bool isInitialized() const; - QIcon icon() const; - QString domXml() const; - QString group() const; - QString includeFile() const; - QString name() const; - QString toolTip() const; - QString whatsThis() const; - QWidget *createWidget(QWidget *parent); - void initialize(QDesignerFormEditorInterface *core); - -private: - bool initialized; -}; - -#endif // QFUNCTIONCONFIGURATORPLUGIN_H diff --git a/QFunctionConfigurator/QFunctionConfigurator_vc9.sln b/QFunctionConfigurator/QFunctionConfigurator_vc9.sln deleted file mode 100644 index 3e82962f..00000000 --- a/QFunctionConfigurator/QFunctionConfigurator_vc9.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 10.00 -# Visual Studio 2008 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QFunctionConfigurator", "QFunctionConfigurator\QFunctionConfigurator_vc9.vcproj", "{2527B683-7EFC-4D51-B25A-843668649C54}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.ActiveCfg = Debug|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.Build.0 = Debug|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.ActiveCfg = Release|Win32 - {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.Build.0 = Release|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/ReadMe.txt b/ReadMe.txt deleted file mode 100644 index 18d3babb..00000000 --- a/ReadMe.txt +++ /dev/null @@ -1,48 +0,0 @@ -This project was derived from the 'Sweetspotter' project. - - -If you want to work with the source code you should use the Microsoft Visual Studio 2005 and the Qt 4.6.x or better source code. (http://qt.nokia.com/downloads) Also it's useful to install the Qt Visual Studio Add-In. - -The integration of Qt (LGPL) in Visual Studio must be done manually. See the PDF's in the documentation folder for specific instructions. - -Here are some remarks, which were not mentioned in the PDF's, but have to be followed: -Remark 1: instead of just running "configure" you should run -"configure -debug-and-release -no-qt3support -no-webkit -platform win32-msvc2005". - -Remark 2: in the Qt folders (\src\script\tmp\moc\debug_shared\, src\script\tmp\moc\release_shared\ -and src\3rdparty\webkit\WebCore\tmp\moc can be a file called: mocinclude.tmp. Remove these, because "nmake" will fail if you don't. - - -You need also: -- FaceApi www.faceapi.com - -You need to setup the folders to the binaries and include files in the Visual Studio IDE. - - Tools > Options > Projects and Solutions > VC++ Directories - -Example in the standard way: - - Executable Files: - - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\API\bin - - Include Files: - - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\API\include - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\C++\include - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\Qt\include - C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Win32\api\inc - C:\Qt\4.6.2\include - - Library Files: - - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\Qt\lib - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\C++\lib - C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\API\bin - C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Win32\api\lib - C:\Qt\4.6.2\lib - - -Best regards, - -Wim Vriend. diff --git a/faceAPI/FaceAPI2FSX_vc8.vcproj b/faceAPI/FaceAPI2FSX_vc8.vcproj deleted file mode 100644 index 8e2fc936..00000000 --- a/faceAPI/FaceAPI2FSX_vc8.vcproj +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/faceAPI/FaceAPI2FSX_vc9.vcproj b/faceAPI/FaceAPI2FSX_vc9.vcproj deleted file mode 100644 index 227d872d..00000000 --- a/faceAPI/FaceAPI2FSX_vc9.vcproj +++ /dev/null @@ -1,232 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/faceAPI/build_options.h b/faceAPI/build_options.h deleted file mode 100644 index 6bc6a44c..00000000 --- a/faceAPI/build_options.h +++ /dev/null @@ -1,8 +0,0 @@ -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -// Build Options -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -//controls whether or not FaceAPI should use the callback or poll -#define USE_HEADPOSE_CALLBACK 1 diff --git a/faceAPI/lock.h b/faceAPI/lock.h deleted file mode 100644 index efe38605..00000000 --- a/faceAPI/lock.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef SM_API_TESTAPPCONSOLE_LOCK_H -#define SM_API_TESTAPPCONSOLE_LOCK_H - -#include "mutex.h" - -namespace sm -{ - namespace faceapi - { - namespace samplecode - { - // A very simple scoped-lock class for sample code purposes. - // It is recommended that you use the boost threads library. - class Lock - { - public: - Lock(const Mutex &mutex): _mutex(mutex) - { - _mutex.lock(); - } - ~Lock() - { - _mutex.unlock(); - } - private: - // Noncopyable - Lock(const Lock &); - Lock &operator=(const Lock &); - private: - const Mutex &_mutex; - }; - } - } -} -#endif diff --git a/faceAPI/lockfree.h b/faceAPI/lockfree.h deleted file mode 100644 index ce7d2a64..00000000 --- a/faceAPI/lockfree.h +++ /dev/null @@ -1,65 +0,0 @@ -//lock free queue template class by Herb Sutter -//Dr Dobbs Journal article http://www.drdobbs.com/cpp/210604448;jsessionid=OQGQPSMNL4X4XQE1GHPSKH4ATMY32JVN?pgno=1 - -template class LockFreeQueue -{ -private: - struct Node - { - Node( T val ) : value(val), next(nullptr) { } - T value; - Node* next; - }; - - Node* first; // for producer only - Node* divider, last; // shared - - //not working in VC2008 - //atomic divider, last; // shared - -public: - LockFreeQueue() - { - // add dummy separator - first = divider = last = new Node( T() ); - } - - ~LockFreeQueue() - { - while( first != nullptr ) - { - // release the list - Node* tmp = first; - first = tmp->next; - delete tmp; - } - } - - void Produce( const T& t ) - { - last->next = new Node(t); // add the new item - last = last->next; // publish it - - while( first != divider ) - { - // trim unused nodes - Node* tmp = first; - first = first->next; - delete tmp; - } - } - - bool Consume( T& result ) - { - if( divider != last ) - { - // if queue is nonempty - result = divider->next->value; // copy it back - divider = divider->next; // publish that we took it - return true; // and report success - } - - return false; // else report empty - } -}; - diff --git a/faceAPI/main.cpp b/faceAPI/main.cpp deleted file mode 100644 index 46732cb3..00000000 --- a/faceAPI/main.cpp +++ /dev/null @@ -1,543 +0,0 @@ -/******************************************************************************** -* FaceTrackNoIR This program is a private project of the some enthusiastic * -* gamers from Holland, who don't like to pay much for * -* head-tracking. * -* * -* Copyright (C) 2013 Wim Vriend (Developing) * -* Ron Hendriks (Researching and Testing) * -* * -* Homepage * -* * -* This program is free software; you can redistribute it and/or modify it * -* under the terms of the GNU General Public License as published by the * -* Free Software Foundation; either version 3 of the License, or (at your * -* option) any later version. * -* * -* This program is distributed in the hope that it will be useful, but * -* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * -* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * -* more details. * -* * -* You should have received a copy of the GNU General Public License along * -* with this program; if not, see . * -*********************************************************************************/ -/* - Modifications (last one on top): - 20130105 - WVR: Set engine state to TERMINATED, when EXIT. - 20110501 - WVR: Added some command to be handled from FaceTrackNoIR (settings dialog). - 20110322 - WVR: Somehow the video-widget of faceAPI version 3.2.6. does not - work with FaceTrackNoIR (Qt issue?!). To be able to use - release 3.2.6 of faceAPI anyway, this console-app is used. - It exchanges data with FaceTrackNoIR via shared-memory... -*/ - -//Precompiled header -#include "stdafx.h" - -//FaceAPI headers -#include -#include "ftnoir_tracker_sm_types.h" -#include "utils.h" - -//local headers -#include "build_options.h" - -//namespaces -using namespace std; -using namespace sm::faceapi::samplecode; - -// -// global variables -// -HANDLE hSMMemMap = NULL; -SMMemMap *pMemData; -HANDLE hSMMutex; -smEngineHeadPoseData new_head_pose; -bool stopCommand = false; -bool ftnoirConnected = false; - -//enums -enum GROUP_ID -{ - GROUP0=0, -}; - -enum EVENT_ID -{ - EVENT_PING=0, - EVENT_INIT, -}; - -enum INPUT_ID -{ - INPUT0=0, -}; - -//function definitions -void updateHeadPose(smEngineHeadPoseData* temp_head_pose); -bool SMCreateMapping(); - -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -// -//FaceAPI function implementations -// -////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - -void STDCALL receiveLogMessage(void *, const char *buf, int /*buf_len*/) -{ - Lock lock(g_mutex); // serialize logging calls from different threads to avoid garbled output. - //cout << string(buf); -} - -// Callback function for face-data -void STDCALL receiveFaceData(void *, smEngineFaceData face_data, smCameraVideoFrame video_frame) -{ - Lock lock(g_mutex); - - // Get info including data pointer to original image from camera - smImageInfo video_frame_image_info; - THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok - - // video_frame_image_info.plane_addr[*] now point to the image memory planes. - // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). - // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. - // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. - - // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. - // Since the smEngineFaceData contains multiple pod types copying it is not atomic and - // a mutex is required to avoid the race-condition with any thread simultaneously - // reading from your data-structure. - // Such a race condition will not crash your code but will create weird noise in the tracking data. - - if (g_do_face_data_printing) - { - //cout << video_frame << " " << face_data; - - // Save any face texture to a PNG file - if (face_data.texture) - { - // Create a unique filename - std::stringstream filename; - filename << "face_" << video_frame.frame_num << ".png"; - // Try saving to a file - if (saveToPNGFile(filename.str(), face_data.texture->image_info) == SM_API_OK) - { - cout << "Saved face-texture to " << filename.str() << std::endl; - } - else - { - cout << "Error saving face-texture to " << filename.str() << std::endl; - } - } - } -} - -// Callback function for head-pose -void STDCALL receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVideoFrame video_frame) -{ - Lock lock(g_mutex); - - // Get info including data pointer to original image from camera - smImageInfo video_frame_image_info; - THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok - - // video_frame_image_info.plane_addr[*] now point to the image memory planes. - // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). - // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. - // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. - - // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. - // Since the smEngineFaceData contains multiple pod types copying it is not atomic and - // a mutex is required to avoid the race-condition with any thread simultaneously - // reading from your data-structure. - // Such a race condition will not crash your code but will create weird noise in the tracking data. - - if (g_do_head_pose_printing) - { - //cout << video_frame << " " << head_pose << std::endl; - } - - //make a copy of the new head pose data and send it to simconnect - //when we get a simmconnect frame event the new offset will be applied to the camera - updateHeadPose(&head_pose); -} - -// Create the first available camera detected on the system, and return its handle -smCameraHandle createFirstCamera() -{ - // Detect cameras - smCameraInfoList info_list; - THROW_ON_ERROR(smCameraCreateInfoList(&info_list)); - - if (info_list.num_cameras == 0) - { - throw runtime_error("No cameras were detected"); - } - else - { - cout << "The followings cameras were detected: " << endl; - for (int i=0; ihandle,TRUE)); - THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->initial_filter_level)); - pMemData->handshake = 0; - } - else { - THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,0,TRUE)); - } - - // Setup the VideoDisplay - THROW_ON_ERROR(smVideoDisplaySetFlags(video_display_handle,g_overlay_flags)); - - // Get the handle to the window and change the title to "Hello World" - smWindowHandle win_handle = 0; - THROW_ON_ERROR(smVideoDisplayGetWindowHandle(video_display_handle,&win_handle)); - SetWindowText(win_handle, _T("faceAPI Video-widget")); - MoveWindow(win_handle, 0, 0, 250, 180, true); - - // Loop on the keyboard - while (processKeyPress(engine_handle, video_display_handle) && !stopCommand) - { - // Read and print the current head-pose (if not using the callback mechanism) - #if (USE_HEADPOSE_CALLBACK==0) - #pragma message("Polling Headpose Manually") - if (engine_licensed) - { - smEngineHeadPoseData head_pose; - Lock lock(g_mutex); - - THROW_ON_ERROR(smHTCurrentHeadPose(engine_handle,&head_pose)); - if (g_do_head_pose_printing) - { - std::cout << head_pose << std::endl; - } - - } - #endif - - // NOTE: If you have a windows event loop in your program you - // will not need to call smAPIProcessEvents(). This manually redraws the video window. - THROW_ON_ERROR(smAPIProcessEvents()); - - // Prevent CPU overload in our simple loop. - const int frame_period_ms = 10; - Sleep(frame_period_ms); - - // - // Process the command sent by FaceTrackNoIR. - // - if (ftnoirConnected && (pMemData != 0)) { - - sprintf_s(msg, "Command: %d, \n", pMemData->command, pMemData->par_val_int); - OutputDebugStringA(msg); - std::cout << msg; - - // - // - // Determine the trackers' state and send it to FaceTrackNoIR. - // - THROW_ON_ERROR(smEngineGetState(engine_handle, &state)); - pMemData->state = state; - pMemData->handshake += 1; - - // - // Check if FaceTrackNoIR is still 'in contact'. - // FaceTrackNoIR will reset the handshake, every time in writes data. - // If the value rises too high, this exe will stop itself... - // - if ( pMemData->handshake > 200) { - stopCommand = TRUE; - } - - // - // Check if a command was issued and do something with it! - // - switch (pMemData->command) { - case FT_SM_START: - - // - // Only execute Start, if the engine is not yet tracking. - // - if (state != SM_API_ENGINE_STATE_HT_TRACKING) { - THROW_ON_ERROR(smEngineStart(engine_handle)); // Start tracking - } - pMemData->command = 0; // Reset - break; - - case FT_SM_STOP: - THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking - pMemData->command = 0; // Reset - break; - - case FT_SM_EXIT: - THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking - stopCommand = TRUE; - pMemData->command = 0; // Reset - pMemData->state = SM_API_ENGINE_STATE_TERMINATED; // One last update, before quitting... - break; - - case FT_SM_SET_PAR_FILTER: - THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->par_val_int)); - pMemData->command = 0; // Reset - break; - - case FT_SM_SHOW_CAM: - THROW_ON_ERROR(smEngineShowCameraControlPanel(engine_handle)); - pMemData->command = 0; // Reset - break; - - default: - pMemData->command = 0; // Reset - // should never be reached - break; - } - } - } // While(1) - - // Destroy engine - THROW_ON_ERROR(smEngineDestroy(&engine_handle)); - // Destroy video display - THROW_ON_ERROR(smVideoDisplayDestroy(&video_display_handle)); - - if (ftnoirConnected) { - if ( pMemData != NULL ) { - UnmapViewOfFile ( pMemData ); - } - - if (hSMMutex != 0) { - CloseHandle( hSMMutex ); - } - hSMMutex = 0; - - if (hSMMemMap != 0) { - CloseHandle( hSMMemMap ); - } - hSMMemMap = 0; - } - -} // run() - -// Application entry point -int _tmain(int /*argc*/, _TCHAR** /*argv*/) -{ - OutputDebugString(_T("_tmain() says: Starting Function\n")); - - try - { - if (SMCreateMapping()) { - run(); - } - } - catch (exception &e) - { - cerr << e.what() << endl; - } - - return smAPIQuit(); -} - -// -// This is called exactly once for each FaceAPI callback and must be within an exclusive lock -// -void updateHeadPose(smEngineHeadPoseData* temp_head_pose) -{ - // - // Check if the pointer is OK and wait for the Mutex. - // - if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { - - // - // Copy the Raw measurements directly to the client. - // - if (temp_head_pose->confidence > 0.0f) - { - memcpy(&pMemData->data.new_pose,temp_head_pose,sizeof(smEngineHeadPoseData)); - } - ReleaseMutex(hSMMutex); - } -}; - -// -// Create a memory-mapping to the faceAPI data. -// It contains the tracking data, a command-code from FaceTrackNoIR -// -// -bool SMCreateMapping() -{ - OutputDebugString(_T("FTCreateMapping says: Starting Function\n")); - - // - // A FileMapping is used to create 'shared memory' between the faceAPI and FaceTrackNoIR. - // FaceTrackNoIR creates the mapping, this program only opens it. - // If it's not there: the program was apparently started by the user instead of FaceTrackNoIR... - // - // Open an existing FileMapping, Read/Write access - // - hSMMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) SM_MM_DATA ); - if ( ( hSMMemMap != 0 ) ) { - ftnoirConnected = true; - OutputDebugString(_T("FTCreateMapping says: FileMapping opened successfully...\n")); - pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFaceData)); - if (pMemData != NULL) { - OutputDebugString(_T("FTCreateMapping says: MapViewOfFile OK.\n")); - pMemData->state = 0; - } - hSMMutex = CreateMutexA(NULL, false, SM_MUTEX); - } - else { - OutputDebugString(_T("FTCreateMapping says: FileMapping not opened...FaceTrackNoIR not connected!\n")); - ftnoirConnected = false; - pMemData = 0; - } - - return true; -} diff --git a/faceAPI/mutex.h b/faceAPI/mutex.h deleted file mode 100644 index 11aabafc..00000000 --- a/faceAPI/mutex.h +++ /dev/null @@ -1,44 +0,0 @@ -#ifndef SM_API_TESTAPPCONSOLE_MUTEX_H -#define SM_API_TESTAPPCONSOLE_MUTEX_H - -namespace sm -{ - namespace faceapi - { - namespace samplecode - { - // A very simple mutex class for sample code purposes. - // It is recommended that you use the boost threads library. - class Mutex - { - public: - Mutex() - { - if (!InitializeCriticalSectionAndSpinCount(&_cs,0x80000400)) - { - throw std::runtime_error("Failed to initialize Mutex"); - } - } - ~Mutex() - { - DeleteCriticalSection(&_cs); - } - void lock() const - { - EnterCriticalSection(&_cs); - } - void unlock() const - { - LeaveCriticalSection(&_cs); - } - private: - // Noncopyable - Mutex(const Mutex &); - Mutex &operator=(const Mutex &); - private: - mutable CRITICAL_SECTION _cs; - }; - } - } -} -#endif diff --git a/faceAPI/stdafx.cpp b/faceAPI/stdafx.cpp deleted file mode 100644 index b4263f59..00000000 --- a/faceAPI/stdafx.cpp +++ /dev/null @@ -1,8 +0,0 @@ -// stdafx.cpp : source file that includes just the standard includes -// TestAppConsole.pch will be the pre-compiled header -// stdafx.obj will contain the pre-compiled type information - -#include "stdafx.h" - -// TODO: reference any additional headers you need in STDAFX.H -// and not in this file diff --git a/faceAPI/stdafx.h b/faceAPI/stdafx.h deleted file mode 100644 index d97c9353..00000000 --- a/faceAPI/stdafx.h +++ /dev/null @@ -1,21 +0,0 @@ -// stdafx.h : include file for standard system include files, -// or project specific include files that are used frequently, but -// are changed infrequently -// - -#pragma once - -#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. -#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. -#endif - -#include -#include - -// TODO: reference additional headers your program requires here -#include -#include -#include -#include -#include -#include diff --git a/faceAPI/utils.h b/faceAPI/utils.h deleted file mode 100644 index 1fdb35b5..00000000 --- a/faceAPI/utils.h +++ /dev/null @@ -1,346 +0,0 @@ -#ifndef SM_API_TESTAPPCONSOLE_UTILS_H -#define SM_API_TESTAPPCONSOLE_UTILS_H - -#include "lock.h" - -#define THROW_ON_ERROR(x) \ -{ \ - smReturnCode result = (x); \ - if (result < 0) \ - { \ - std::stringstream s; \ - s << "API error code: " << result; \ - throw std::runtime_error(s.str()); \ - } \ -} - -namespace sm -{ - namespace faceapi - { - namespace samplecode - { - // Global variables - Mutex g_mutex; - bool g_ctrl_c_detected(false); - bool g_do_head_pose_printing(false); - bool g_do_face_data_printing(false); - unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH | SM_API_VIDEO_DISPLAY_PERFORMANCE); - - // CTRL-C handler function - void __cdecl CtrlCHandler(int) - { - Lock lock(g_mutex); - std::cout << "Ctrl-C detected, stopping..." << std::endl; - g_ctrl_c_detected = true; - } - - // Radians to degrees conversion - float rad2deg(float rad) - { - return rad*57.2957795f; - } - - void toggleFlag(unsigned short &val, unsigned short flag) - { - if (val & flag) - { - val = val & ~flag; - } - else - { - val = val | flag; - } - } - - // Save an image to PNG file - smReturnCode saveToPNGFile(const std::string& filepath, smImageInfo image_info) - { - smBool ok; - smReturnCode error; - - // Create an API string - smStringHandle filepath_handle = 0; - ok = (error = smStringCreate(&filepath_handle)) == SM_API_OK; - ok = ok && (error = smStringReadBuffer(filepath_handle,filepath.c_str(),filepath.size())) == SM_API_OK; - - // Create an API image - smImageHandle image_handle = 0; - smImageMemoryCopyMode copy_mode = SM_API_IMAGE_MEMORYCOPYMODE_AUTO; - ok = ok && (error = smImageCreateFromInfo(&image_info,©_mode,&image_handle)) == SM_API_OK; - - // Save the image as PNG - ok = ok && (error = smImageSaveToPNG(image_handle,filepath_handle)) == SM_API_OK; - - // Destroy the image and string - smStringDestroy(&filepath_handle); - smImageDestroy(&image_handle); - return error; - } - - // Stream operators for printing - - std::ostream &operator<<(std::ostream & os, const smSize2i &s) - { - return os << "[" << s.h << "," << s.h << "]"; - } - - std::ostream &operator<<(std::ostream & os, const smCoord3f &pos) - { - return os << "(" << pos.x << "," << pos.y << "," << pos.z << ")"; - } - - std::ostream &operator<<(std::ostream & os, const smRotEuler &rot) - { - return os << "(" << rad2deg(rot.x_rads) << "," << rad2deg(rot.y_rads) << "," << rad2deg(rot.z_rads) << ")"; - } - - std::ostream &operator<<(std::ostream & os, const smPixel &p) - { - return os << "[" << static_cast(p.x) << "," << static_cast(p.y) << "]"; - } - - std::ostream &operator<<(std::ostream & os, const smFaceTexCoord &ftc) - { - return os << "{" << ftc.u << "," << ftc.v << "}"; - } - - std::ostream &operator<<(std::ostream & os, const smFaceLandmark &lm) - { - return os << "id "<< lm.id << " fc" << lm.fc << " ftc" << lm.ftc << " pc" << lm.pc << " wc" << lm.wc; - } - - std::ostream &operator<<(std::ostream & os, const smImageInfo &im) - { - os << "format "; - switch (im.format) - { - case SM_API_IMAGECODE_GRAY_8U: - os << "GRAY_8U"; - break; - case SM_API_IMAGECODE_GRAY_16U: - os << "GRAY_16U"; - break; - case SM_API_IMAGECODE_YUY2: - os << "YUY2"; - break; - case SM_API_IMAGECODE_I420: - os << "I420"; - break; - case SM_API_IMAGECODE_BGRA_32U: - os << "BGRA_32U"; - break; - case SM_API_IMAGECODE_ARGB_32U: - os << "ARGB_32U"; - break; - case SM_API_IMAGECODE_BGR_24U: - os << "BGR_24U"; - break; - case SM_API_IMAGECODE_RGB_24U: - os << "RGB_24U"; - break; - default: - os << "unknown"; - break; - } - os << " res" << im.res; - os << " plane_addr(" << static_cast(im.plane_addr[0]) << "," - << static_cast(im.plane_addr[1]) << "," - << static_cast(im.plane_addr[2]) << "," - << static_cast(im.plane_addr[3]) << ")"; - os << " step_bytes(" << im.step_bytes[0] << "," << im.step_bytes[1] << "," << im.step_bytes[2] << "," << im.step_bytes[3] << ")"; - os << " user_data " << im.user_data; - return os; - } - - std::ostream &operator<<(std::ostream & os, const smFaceTexture &t) - { - os << "type "; - switch (t.type) - { - case SM_ORTHOGRAPHIC_PROJECTION: - os << "orthographic"; - break; - default: - os << "unknown"; - break; - } - os << " origin" << t.origin << " scale" << t.scale << std::endl; - os << " image_info " << t.image_info << std::endl; - os << " num_mask_landmarks " << t.num_mask_landmarks << std::endl; - for (int i=0; i + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/faceapi/FaceAPI2FSX_vc9.vcproj b/faceapi/FaceAPI2FSX_vc9.vcproj new file mode 100644 index 00000000..227d872d --- /dev/null +++ b/faceapi/FaceAPI2FSX_vc9.vcproj @@ -0,0 +1,232 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/faceapi/build_options.h b/faceapi/build_options.h new file mode 100644 index 00000000..6bc6a44c --- /dev/null +++ b/faceapi/build_options.h @@ -0,0 +1,8 @@ +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// Build Options +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +//controls whether or not FaceAPI should use the callback or poll +#define USE_HEADPOSE_CALLBACK 1 diff --git a/faceapi/lock.h b/faceapi/lock.h new file mode 100644 index 00000000..efe38605 --- /dev/null +++ b/faceapi/lock.h @@ -0,0 +1,35 @@ +#ifndef SM_API_TESTAPPCONSOLE_LOCK_H +#define SM_API_TESTAPPCONSOLE_LOCK_H + +#include "mutex.h" + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // A very simple scoped-lock class for sample code purposes. + // It is recommended that you use the boost threads library. + class Lock + { + public: + Lock(const Mutex &mutex): _mutex(mutex) + { + _mutex.lock(); + } + ~Lock() + { + _mutex.unlock(); + } + private: + // Noncopyable + Lock(const Lock &); + Lock &operator=(const Lock &); + private: + const Mutex &_mutex; + }; + } + } +} +#endif diff --git a/faceapi/lockfree.h b/faceapi/lockfree.h new file mode 100644 index 00000000..ce7d2a64 --- /dev/null +++ b/faceapi/lockfree.h @@ -0,0 +1,65 @@ +//lock free queue template class by Herb Sutter +//Dr Dobbs Journal article http://www.drdobbs.com/cpp/210604448;jsessionid=OQGQPSMNL4X4XQE1GHPSKH4ATMY32JVN?pgno=1 + +template class LockFreeQueue +{ +private: + struct Node + { + Node( T val ) : value(val), next(nullptr) { } + T value; + Node* next; + }; + + Node* first; // for producer only + Node* divider, last; // shared + + //not working in VC2008 + //atomic divider, last; // shared + +public: + LockFreeQueue() + { + // add dummy separator + first = divider = last = new Node( T() ); + } + + ~LockFreeQueue() + { + while( first != nullptr ) + { + // release the list + Node* tmp = first; + first = tmp->next; + delete tmp; + } + } + + void Produce( const T& t ) + { + last->next = new Node(t); // add the new item + last = last->next; // publish it + + while( first != divider ) + { + // trim unused nodes + Node* tmp = first; + first = first->next; + delete tmp; + } + } + + bool Consume( T& result ) + { + if( divider != last ) + { + // if queue is nonempty + result = divider->next->value; // copy it back + divider = divider->next; // publish that we took it + return true; // and report success + } + + return false; // else report empty + } +}; + diff --git a/faceapi/main.cpp b/faceapi/main.cpp new file mode 100644 index 00000000..46732cb3 --- /dev/null +++ b/faceapi/main.cpp @@ -0,0 +1,543 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +/* + Modifications (last one on top): + 20130105 - WVR: Set engine state to TERMINATED, when EXIT. + 20110501 - WVR: Added some command to be handled from FaceTrackNoIR (settings dialog). + 20110322 - WVR: Somehow the video-widget of faceAPI version 3.2.6. does not + work with FaceTrackNoIR (Qt issue?!). To be able to use + release 3.2.6 of faceAPI anyway, this console-app is used. + It exchanges data with FaceTrackNoIR via shared-memory... +*/ + +//Precompiled header +#include "stdafx.h" + +//FaceAPI headers +#include +#include "ftnoir_tracker_sm_types.h" +#include "utils.h" + +//local headers +#include "build_options.h" + +//namespaces +using namespace std; +using namespace sm::faceapi::samplecode; + +// +// global variables +// +HANDLE hSMMemMap = NULL; +SMMemMap *pMemData; +HANDLE hSMMutex; +smEngineHeadPoseData new_head_pose; +bool stopCommand = false; +bool ftnoirConnected = false; + +//enums +enum GROUP_ID +{ + GROUP0=0, +}; + +enum EVENT_ID +{ + EVENT_PING=0, + EVENT_INIT, +}; + +enum INPUT_ID +{ + INPUT0=0, +}; + +//function definitions +void updateHeadPose(smEngineHeadPoseData* temp_head_pose); +bool SMCreateMapping(); + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +//FaceAPI function implementations +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +void STDCALL receiveLogMessage(void *, const char *buf, int /*buf_len*/) +{ + Lock lock(g_mutex); // serialize logging calls from different threads to avoid garbled output. + //cout << string(buf); +} + +// Callback function for face-data +void STDCALL receiveFaceData(void *, smEngineFaceData face_data, smCameraVideoFrame video_frame) +{ + Lock lock(g_mutex); + + // Get info including data pointer to original image from camera + smImageInfo video_frame_image_info; + THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok + + // video_frame_image_info.plane_addr[*] now point to the image memory planes. + // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). + // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. + // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. + + // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. + // Since the smEngineFaceData contains multiple pod types copying it is not atomic and + // a mutex is required to avoid the race-condition with any thread simultaneously + // reading from your data-structure. + // Such a race condition will not crash your code but will create weird noise in the tracking data. + + if (g_do_face_data_printing) + { + //cout << video_frame << " " << face_data; + + // Save any face texture to a PNG file + if (face_data.texture) + { + // Create a unique filename + std::stringstream filename; + filename << "face_" << video_frame.frame_num << ".png"; + // Try saving to a file + if (saveToPNGFile(filename.str(), face_data.texture->image_info) == SM_API_OK) + { + cout << "Saved face-texture to " << filename.str() << std::endl; + } + else + { + cout << "Error saving face-texture to " << filename.str() << std::endl; + } + } + } +} + +// Callback function for head-pose +void STDCALL receiveHeadPose(void *,smEngineHeadPoseData head_pose, smCameraVideoFrame video_frame) +{ + Lock lock(g_mutex); + + // Get info including data pointer to original image from camera + smImageInfo video_frame_image_info; + THROW_ON_ERROR(smImageGetInfo(video_frame.image_handle, &video_frame_image_info)); // reentrant, so ok + + // video_frame_image_info.plane_addr[*] now point to the image memory planes. + // The memory is only valid until the end of this routine unless you call smImageAddRef(video_frame.image_handle). + // So you can deep copy the image data here, or use smImageAddRef() and just copy the pointer. + // If you use smImageAddRef() you are responsible for calling smImageDestroy() to avoid a memory leak later. + + // In this callback you will typically want to copy the smEngineFaceData data into your own data-structure. + // Since the smEngineFaceData contains multiple pod types copying it is not atomic and + // a mutex is required to avoid the race-condition with any thread simultaneously + // reading from your data-structure. + // Such a race condition will not crash your code but will create weird noise in the tracking data. + + if (g_do_head_pose_printing) + { + //cout << video_frame << " " << head_pose << std::endl; + } + + //make a copy of the new head pose data and send it to simconnect + //when we get a simmconnect frame event the new offset will be applied to the camera + updateHeadPose(&head_pose); +} + +// Create the first available camera detected on the system, and return its handle +smCameraHandle createFirstCamera() +{ + // Detect cameras + smCameraInfoList info_list; + THROW_ON_ERROR(smCameraCreateInfoList(&info_list)); + + if (info_list.num_cameras == 0) + { + throw runtime_error("No cameras were detected"); + } + else + { + cout << "The followings cameras were detected: " << endl; + for (int i=0; ihandle,TRUE)); + THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->initial_filter_level)); + pMemData->handshake = 0; + } + else { + THROW_ON_ERROR(smVideoDisplayCreate(engine_handle,&video_display_handle,0,TRUE)); + } + + // Setup the VideoDisplay + THROW_ON_ERROR(smVideoDisplaySetFlags(video_display_handle,g_overlay_flags)); + + // Get the handle to the window and change the title to "Hello World" + smWindowHandle win_handle = 0; + THROW_ON_ERROR(smVideoDisplayGetWindowHandle(video_display_handle,&win_handle)); + SetWindowText(win_handle, _T("faceAPI Video-widget")); + MoveWindow(win_handle, 0, 0, 250, 180, true); + + // Loop on the keyboard + while (processKeyPress(engine_handle, video_display_handle) && !stopCommand) + { + // Read and print the current head-pose (if not using the callback mechanism) + #if (USE_HEADPOSE_CALLBACK==0) + #pragma message("Polling Headpose Manually") + if (engine_licensed) + { + smEngineHeadPoseData head_pose; + Lock lock(g_mutex); + + THROW_ON_ERROR(smHTCurrentHeadPose(engine_handle,&head_pose)); + if (g_do_head_pose_printing) + { + std::cout << head_pose << std::endl; + } + + } + #endif + + // NOTE: If you have a windows event loop in your program you + // will not need to call smAPIProcessEvents(). This manually redraws the video window. + THROW_ON_ERROR(smAPIProcessEvents()); + + // Prevent CPU overload in our simple loop. + const int frame_period_ms = 10; + Sleep(frame_period_ms); + + // + // Process the command sent by FaceTrackNoIR. + // + if (ftnoirConnected && (pMemData != 0)) { + + sprintf_s(msg, "Command: %d, \n", pMemData->command, pMemData->par_val_int); + OutputDebugStringA(msg); + std::cout << msg; + + // + // + // Determine the trackers' state and send it to FaceTrackNoIR. + // + THROW_ON_ERROR(smEngineGetState(engine_handle, &state)); + pMemData->state = state; + pMemData->handshake += 1; + + // + // Check if FaceTrackNoIR is still 'in contact'. + // FaceTrackNoIR will reset the handshake, every time in writes data. + // If the value rises too high, this exe will stop itself... + // + if ( pMemData->handshake > 200) { + stopCommand = TRUE; + } + + // + // Check if a command was issued and do something with it! + // + switch (pMemData->command) { + case FT_SM_START: + + // + // Only execute Start, if the engine is not yet tracking. + // + if (state != SM_API_ENGINE_STATE_HT_TRACKING) { + THROW_ON_ERROR(smEngineStart(engine_handle)); // Start tracking + } + pMemData->command = 0; // Reset + break; + + case FT_SM_STOP: + THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking + pMemData->command = 0; // Reset + break; + + case FT_SM_EXIT: + THROW_ON_ERROR(smEngineStop(engine_handle)); // Stop tracking + stopCommand = TRUE; + pMemData->command = 0; // Reset + pMemData->state = SM_API_ENGINE_STATE_TERMINATED; // One last update, before quitting... + break; + + case FT_SM_SET_PAR_FILTER: + THROW_ON_ERROR(smHTV2SetHeadPoseFilterLevel(engine_handle, pMemData->par_val_int)); + pMemData->command = 0; // Reset + break; + + case FT_SM_SHOW_CAM: + THROW_ON_ERROR(smEngineShowCameraControlPanel(engine_handle)); + pMemData->command = 0; // Reset + break; + + default: + pMemData->command = 0; // Reset + // should never be reached + break; + } + } + } // While(1) + + // Destroy engine + THROW_ON_ERROR(smEngineDestroy(&engine_handle)); + // Destroy video display + THROW_ON_ERROR(smVideoDisplayDestroy(&video_display_handle)); + + if (ftnoirConnected) { + if ( pMemData != NULL ) { + UnmapViewOfFile ( pMemData ); + } + + if (hSMMutex != 0) { + CloseHandle( hSMMutex ); + } + hSMMutex = 0; + + if (hSMMemMap != 0) { + CloseHandle( hSMMemMap ); + } + hSMMemMap = 0; + } + +} // run() + +// Application entry point +int _tmain(int /*argc*/, _TCHAR** /*argv*/) +{ + OutputDebugString(_T("_tmain() says: Starting Function\n")); + + try + { + if (SMCreateMapping()) { + run(); + } + } + catch (exception &e) + { + cerr << e.what() << endl; + } + + return smAPIQuit(); +} + +// +// This is called exactly once for each FaceAPI callback and must be within an exclusive lock +// +void updateHeadPose(smEngineHeadPoseData* temp_head_pose) +{ + // + // Check if the pointer is OK and wait for the Mutex. + // + if ( (pMemData != NULL) && (WaitForSingleObject(hSMMutex, 100) == WAIT_OBJECT_0) ) { + + // + // Copy the Raw measurements directly to the client. + // + if (temp_head_pose->confidence > 0.0f) + { + memcpy(&pMemData->data.new_pose,temp_head_pose,sizeof(smEngineHeadPoseData)); + } + ReleaseMutex(hSMMutex); + } +}; + +// +// Create a memory-mapping to the faceAPI data. +// It contains the tracking data, a command-code from FaceTrackNoIR +// +// +bool SMCreateMapping() +{ + OutputDebugString(_T("FTCreateMapping says: Starting Function\n")); + + // + // A FileMapping is used to create 'shared memory' between the faceAPI and FaceTrackNoIR. + // FaceTrackNoIR creates the mapping, this program only opens it. + // If it's not there: the program was apparently started by the user instead of FaceTrackNoIR... + // + // Open an existing FileMapping, Read/Write access + // + hSMMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) SM_MM_DATA ); + if ( ( hSMMemMap != 0 ) ) { + ftnoirConnected = true; + OutputDebugString(_T("FTCreateMapping says: FileMapping opened successfully...\n")); + pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFaceData)); + if (pMemData != NULL) { + OutputDebugString(_T("FTCreateMapping says: MapViewOfFile OK.\n")); + pMemData->state = 0; + } + hSMMutex = CreateMutexA(NULL, false, SM_MUTEX); + } + else { + OutputDebugString(_T("FTCreateMapping says: FileMapping not opened...FaceTrackNoIR not connected!\n")); + ftnoirConnected = false; + pMemData = 0; + } + + return true; +} diff --git a/faceapi/mutex.h b/faceapi/mutex.h new file mode 100644 index 00000000..11aabafc --- /dev/null +++ b/faceapi/mutex.h @@ -0,0 +1,44 @@ +#ifndef SM_API_TESTAPPCONSOLE_MUTEX_H +#define SM_API_TESTAPPCONSOLE_MUTEX_H + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // A very simple mutex class for sample code purposes. + // It is recommended that you use the boost threads library. + class Mutex + { + public: + Mutex() + { + if (!InitializeCriticalSectionAndSpinCount(&_cs,0x80000400)) + { + throw std::runtime_error("Failed to initialize Mutex"); + } + } + ~Mutex() + { + DeleteCriticalSection(&_cs); + } + void lock() const + { + EnterCriticalSection(&_cs); + } + void unlock() const + { + LeaveCriticalSection(&_cs); + } + private: + // Noncopyable + Mutex(const Mutex &); + Mutex &operator=(const Mutex &); + private: + mutable CRITICAL_SECTION _cs; + }; + } + } +} +#endif diff --git a/faceapi/stdafx.cpp b/faceapi/stdafx.cpp new file mode 100644 index 00000000..b4263f59 --- /dev/null +++ b/faceapi/stdafx.cpp @@ -0,0 +1,8 @@ +// stdafx.cpp : source file that includes just the standard includes +// TestAppConsole.pch will be the pre-compiled header +// stdafx.obj will contain the pre-compiled type information + +#include "stdafx.h" + +// TODO: reference any additional headers you need in STDAFX.H +// and not in this file diff --git a/faceapi/stdafx.h b/faceapi/stdafx.h new file mode 100644 index 00000000..d97c9353 --- /dev/null +++ b/faceapi/stdafx.h @@ -0,0 +1,21 @@ +// stdafx.h : include file for standard system include files, +// or project specific include files that are used frequently, but +// are changed infrequently +// + +#pragma once + +#ifndef _WIN32_WINNT // Allow use of features specific to Windows XP or later. +#define _WIN32_WINNT 0x0501 // Change this to the appropriate value to target other versions of Windows. +#endif + +#include +#include + +// TODO: reference additional headers your program requires here +#include +#include +#include +#include +#include +#include diff --git a/faceapi/utils.h b/faceapi/utils.h new file mode 100644 index 00000000..1fdb35b5 --- /dev/null +++ b/faceapi/utils.h @@ -0,0 +1,346 @@ +#ifndef SM_API_TESTAPPCONSOLE_UTILS_H +#define SM_API_TESTAPPCONSOLE_UTILS_H + +#include "lock.h" + +#define THROW_ON_ERROR(x) \ +{ \ + smReturnCode result = (x); \ + if (result < 0) \ + { \ + std::stringstream s; \ + s << "API error code: " << result; \ + throw std::runtime_error(s.str()); \ + } \ +} + +namespace sm +{ + namespace faceapi + { + namespace samplecode + { + // Global variables + Mutex g_mutex; + bool g_ctrl_c_detected(false); + bool g_do_head_pose_printing(false); + bool g_do_face_data_printing(false); + unsigned short g_overlay_flags(SM_API_VIDEO_DISPLAY_HEAD_MESH | SM_API_VIDEO_DISPLAY_PERFORMANCE); + + // CTRL-C handler function + void __cdecl CtrlCHandler(int) + { + Lock lock(g_mutex); + std::cout << "Ctrl-C detected, stopping..." << std::endl; + g_ctrl_c_detected = true; + } + + // Radians to degrees conversion + float rad2deg(float rad) + { + return rad*57.2957795f; + } + + void toggleFlag(unsigned short &val, unsigned short flag) + { + if (val & flag) + { + val = val & ~flag; + } + else + { + val = val | flag; + } + } + + // Save an image to PNG file + smReturnCode saveToPNGFile(const std::string& filepath, smImageInfo image_info) + { + smBool ok; + smReturnCode error; + + // Create an API string + smStringHandle filepath_handle = 0; + ok = (error = smStringCreate(&filepath_handle)) == SM_API_OK; + ok = ok && (error = smStringReadBuffer(filepath_handle,filepath.c_str(),filepath.size())) == SM_API_OK; + + // Create an API image + smImageHandle image_handle = 0; + smImageMemoryCopyMode copy_mode = SM_API_IMAGE_MEMORYCOPYMODE_AUTO; + ok = ok && (error = smImageCreateFromInfo(&image_info,©_mode,&image_handle)) == SM_API_OK; + + // Save the image as PNG + ok = ok && (error = smImageSaveToPNG(image_handle,filepath_handle)) == SM_API_OK; + + // Destroy the image and string + smStringDestroy(&filepath_handle); + smImageDestroy(&image_handle); + return error; + } + + // Stream operators for printing + + std::ostream &operator<<(std::ostream & os, const smSize2i &s) + { + return os << "[" << s.h << "," << s.h << "]"; + } + + std::ostream &operator<<(std::ostream & os, const smCoord3f &pos) + { + return os << "(" << pos.x << "," << pos.y << "," << pos.z << ")"; + } + + std::ostream &operator<<(std::ostream & os, const smRotEuler &rot) + { + return os << "(" << rad2deg(rot.x_rads) << "," << rad2deg(rot.y_rads) << "," << rad2deg(rot.z_rads) << ")"; + } + + std::ostream &operator<<(std::ostream & os, const smPixel &p) + { + return os << "[" << static_cast(p.x) << "," << static_cast(p.y) << "]"; + } + + std::ostream &operator<<(std::ostream & os, const smFaceTexCoord &ftc) + { + return os << "{" << ftc.u << "," << ftc.v << "}"; + } + + std::ostream &operator<<(std::ostream & os, const smFaceLandmark &lm) + { + return os << "id "<< lm.id << " fc" << lm.fc << " ftc" << lm.ftc << " pc" << lm.pc << " wc" << lm.wc; + } + + std::ostream &operator<<(std::ostream & os, const smImageInfo &im) + { + os << "format "; + switch (im.format) + { + case SM_API_IMAGECODE_GRAY_8U: + os << "GRAY_8U"; + break; + case SM_API_IMAGECODE_GRAY_16U: + os << "GRAY_16U"; + break; + case SM_API_IMAGECODE_YUY2: + os << "YUY2"; + break; + case SM_API_IMAGECODE_I420: + os << "I420"; + break; + case SM_API_IMAGECODE_BGRA_32U: + os << "BGRA_32U"; + break; + case SM_API_IMAGECODE_ARGB_32U: + os << "ARGB_32U"; + break; + case SM_API_IMAGECODE_BGR_24U: + os << "BGR_24U"; + break; + case SM_API_IMAGECODE_RGB_24U: + os << "RGB_24U"; + break; + default: + os << "unknown"; + break; + } + os << " res" << im.res; + os << " plane_addr(" << static_cast(im.plane_addr[0]) << "," + << static_cast(im.plane_addr[1]) << "," + << static_cast(im.plane_addr[2]) << "," + << static_cast(im.plane_addr[3]) << ")"; + os << " step_bytes(" << im.step_bytes[0] << "," << im.step_bytes[1] << "," << im.step_bytes[2] << "," << im.step_bytes[3] << ")"; + os << " user_data " << im.user_data; + return os; + } + + std::ostream &operator<<(std::ostream & os, const smFaceTexture &t) + { + os << "type "; + switch (t.type) + { + case SM_ORTHOGRAPHIC_PROJECTION: + os << "orthographic"; + break; + default: + os << "unknown"; + break; + } + os << " origin" << t.origin << " scale" << t.scale << std::endl; + os << " image_info " << t.image_info << std::endl; + os << " num_mask_landmarks " << t.num_mask_landmarks << std::endl; + for (int i=0; i + + + + + + + + + + + 0 + 0 + 0 + 0 + 0 + 0 + 0 + 0 + + + diff --git a/facetracknoir/ClientFiles/FlightGear/Protocol/headtracker.xml b/facetracknoir/ClientFiles/FlightGear/Protocol/headtracker.xml new file mode 100644 index 00000000..cd1d0dad --- /dev/null +++ b/facetracknoir/ClientFiles/FlightGear/Protocol/headtracker.xml @@ -0,0 +1,67 @@ + + + + + + true + none + host + 52 + + + x + double + /sim/headtracker/x-m + + + + y + double + /sim/headtracker/y-m + + + + z + double + /sim/headtracker/z-m + + + + heading + double + /sim/headtracker/heading-deg + + + + pitch + double + /sim/headtracker/pitch-deg + + + + roll + double + /sim/headtracker/roll-deg + + + + status + int + /sim/headtracker/status + + + + + true + none + host + 4 + + + control + int + /sim/headtracker/control + + + + diff --git a/facetracknoir/ClientFiles/FlightGear/Readme.txt b/facetracknoir/ClientFiles/FlightGear/Readme.txt new file mode 100644 index 00000000..c86ffffe --- /dev/null +++ b/facetracknoir/ClientFiles/FlightGear/Readme.txt @@ -0,0 +1,19 @@ +FaceTrackNoIR for FlightGear. + +FaceTrackNoIR was made compatible with FlightGear with the help of Melchior Franz, who initially made a Linux headtracker. FaceTrackNoIR sends UDP-packets to FlightGear which contain 6DOF-data. The script and protocol provided by Melchior take care of receiving the data and moving 'the head' in-game. + +To make the FlightGear script work, copy the files in the subfolders to the corresponding folders in the FlightGear installation folder. Start FlightGear with the batch-file 'start_fg.bat'. + + +Please let us know if you like the program, if you have ideas for improvements or any questions you might have. + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + + + +Disclaimer: For usage of 3rd party software like FlightGear, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/facetracknoir/ClientFiles/FlightGear/Win32/start_fg.bat b/facetracknoir/ClientFiles/FlightGear/Win32/start_fg.bat new file mode 100644 index 00000000..cd9829b5 --- /dev/null +++ b/facetracknoir/ClientFiles/FlightGear/Win32/start_fg.bat @@ -0,0 +1 @@ +fgfs --generic=socket,in,25,localhost,5550,udp,headtracker --generic=socket,out,10,localhost,5551,udp,headtracker --prop:browser=/sim/headtracker "c:\Program Files\FlightGear\data\Nasal\headtracker.xml" \ No newline at end of file diff --git a/facetracknoir/ClientFiles/FreeTrackTest/FreeTrackTest.exe b/facetracknoir/ClientFiles/FreeTrackTest/FreeTrackTest.exe new file mode 100644 index 00000000..2965a07f Binary files /dev/null and b/facetracknoir/ClientFiles/FreeTrackTest/FreeTrackTest.exe differ diff --git a/facetracknoir/ClientFiles/FreeTrackTest/Readme.txt b/facetracknoir/ClientFiles/FreeTrackTest/Readme.txt new file mode 100644 index 00000000..54f3ccd1 --- /dev/null +++ b/facetracknoir/ClientFiles/FreeTrackTest/Readme.txt @@ -0,0 +1,20 @@ +FaceTrackNoIR for Free-track 'enabled' games. + +FaceTrackNoIR was made compatible with the Free-track protocol, for which the Free-track source (a well, part of it) was +translated from Delphi Pascal to C++ (Visual Studio C++, with Qt). + +To start the Free-track protocol-server in FaceTrackNoIR, select Free-track in the 'game-protocol' listbox. The program +'FreeTrackTest.exe' is provided to check, if the protocol-server is running. + +FreeTrackTest.exe was created by the Free-track team. + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + + + +Disclaimer: For usage of 3rd party software like FreeTrackTest, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/facetracknoir/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE b/facetracknoir/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE new file mode 100644 index 00000000..745da7c6 --- /dev/null +++ b/facetracknoir/ClientFiles/GlovePIE/FaceTrackNoIR2TrackIR.PIE @@ -0,0 +1,16 @@ +// +// 6 Degrees of Freedom Headtracking with FaceTrackNoIR +// 2010 by Wim Vriend +// +pie.FrameRate = 120Hz +var.multiply = 1.5 +var.R2D = 57.295781 +FakeTrackIR.pitch=(Joystick.pitch - 0.10) * var.R2D * var.multiply +FakeTrackIR.yaw=(Joystick.yaw - 0.10) * var.R2D * var.multiply +FakeTrackIR.roll=(Joystick.roll - 0.10) * var.R2D * var.multiply +FakeTrackIR.x=(Joystick.x - 0.10) * var.R2D * var.multiply +FakeTrackIR.y=(Joystick.y - 0.10) * var.R2D * var.multiply +FakeTrackIR.z=(Joystick.z - 0.10) * var.R2D * var.multiply +debug = 'pitch='+FakeTrackIR.pitch+' roll='+FakeTrackIR.roll+' yaw='+FakeTrackIR.yaw+' xyz=('+FakeTrackIR.x+','+FakeTrackIR.y+','+FakeTrackIR.z+')' +//debug = FakeTrackIR.active + diff --git a/facetracknoir/ClientFiles/GlovePIE/Readme.txt b/facetracknoir/ClientFiles/GlovePIE/Readme.txt new file mode 100644 index 00000000..db88fdc8 --- /dev/null +++ b/facetracknoir/ClientFiles/GlovePIE/Readme.txt @@ -0,0 +1,24 @@ +FaceTrackNoIR for PPJoy 'enabled' games/programs. + +FaceTrackNoIR was made compatible with the PPJoy virtual joystick(s), that can be used by various other programs as input. GlovePIE is one of the most powerfull we know (we have also tried tir4fun, but that is quite limited). + +To start the PPJoy protocol-server in FaceTrackNoIR, select Virtual Joystick in the 'game-protocol' listbox. The +settings, necessary to configure PPJoy for FaceTrackNoIR as included in the PPJoy folder. + +GlovePIE was made by Carl Kenner and may NOT be used for military purposes. You can download it from the website +http://glovepie.org/glovepie.php + +The script FaceTrackNoIR2TrackIR.PIE, which was included in this folder, surves as an example for GlovePIE. If anyone +want to use, change or improve it: feel free to do so. In fact, if you do, we would like to receive a copy :-) + +Regards, + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + + + +Disclaimer: For usage of 3rd party software like GlovePIE, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/facetracknoir/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg b/facetracknoir/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg new file mode 100644 index 00000000..052c6899 Binary files /dev/null and b/facetracknoir/ClientFiles/PPJoy/PPJoy mapping for FaceTrackNoIR.jpg differ diff --git a/facetracknoir/ClientFiles/PPJoy/Readme.txt b/facetracknoir/ClientFiles/PPJoy/Readme.txt new file mode 100644 index 00000000..3000ece6 --- /dev/null +++ b/facetracknoir/ClientFiles/PPJoy/Readme.txt @@ -0,0 +1,24 @@ +FaceTrackNoIR for PPJoy 'enabled' games/programs. + +FaceTrackNoIR was made compatible with the PPJoy virtual joystick(s), that can be used by various other programs as input. + +To start the PPJoy protocol-server in FaceTrackNoIR, select Virtual Joystick in the 'game-protocol' listbox. The +settings, necessary to configure PPJoy for FaceTrackNoIR as included in the PPJoy folder, in the file +PPJoy mapping for FaceTrackNoIR.jpg. + +PPJoy was made by Deon van der Westhuysen and is unfortunately not updated anymore. You can download it from the website +http://shareware.pcmag.com/free/Miscellaneous-Utilities/PPJoy/75176.html, but possibly from others as well... + + +Regards, + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + + + + +Disclaimer: For usage of 3rd party software like PPJoy, the FaceTrackNoIR team is not responsible. Use it at your own risk. \ No newline at end of file diff --git a/facetracknoir/ClientFiles/Tir4Fun/NPClient.dll b/facetracknoir/ClientFiles/Tir4Fun/NPClient.dll new file mode 100644 index 00000000..e392442e Binary files /dev/null and b/facetracknoir/ClientFiles/Tir4Fun/NPClient.dll differ diff --git a/facetracknoir/ClientFiles/Tir4Fun/readme.txt b/facetracknoir/ClientFiles/Tir4Fun/readme.txt new file mode 100644 index 00000000..010510db --- /dev/null +++ b/facetracknoir/ClientFiles/Tir4Fun/readme.txt @@ -0,0 +1,9 @@ +What is TIR4FUN? + +TIR4FUN is a free utility for dedicated gamers. It enables 6DOF POV control with mouse and joystick axes. + +Software is provided as it is. Configuration is straightforward. GUI says it all! + +Installation: + +Copy all files to a directory. Launch tir4fun.exe to bring up the GUI. diff --git a/facetracknoir/ClientFiles/Tir4Fun/tir4fun.exe b/facetracknoir/ClientFiles/Tir4Fun/tir4fun.exe new file mode 100644 index 00000000..a51eced0 Binary files /dev/null and b/facetracknoir/ClientFiles/Tir4Fun/tir4fun.exe differ diff --git a/facetracknoir/FSUIPCServer.cpp b/facetracknoir/FSUIPCServer.cpp new file mode 100644 index 00000000..3006b430 --- /dev/null +++ b/facetracknoir/FSUIPCServer.cpp @@ -0,0 +1,308 @@ +/******************************************************************************** +* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * +* to games, using the FSUIPC.dll. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Testing and Research) * +* * +* 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 . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "FSUIPCServer.h" +#include + +/** constructor **/ +FSUIPCServer::FSUIPCServer() { + + loadSettings(); + ProgramName = "Microsoft FS2004"; + + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; + +} + +/** destructor **/ +FSUIPCServer::~FSUIPCServer() { + + // + // Free the DLL + // + FSUIPCLib.unload(); +} + +// +// Update Headpose in Game. +// +void FSUIPCServer::sendHeadposeToGame() { +DWORD result; +TFSState pitch; +TFSState yaw; +TFSState roll; +WORD FSZoom; + + qDebug() << "FSUIPCServer::run() says: started!"; + + // + // Init. the FSUIPC offsets (derived from Free-track...) + // + pitch.Control = 66503; + yaw.Control = 66504; + roll.Control = 66505; + + // + // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. + // + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { + // + // Open the connection + // + FSUIPC_Open(SIM_ANY, &result); + + // + // Check the FS-version + // + if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && + ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { +// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; + // + // Write the 4! DOF-data to FS. Only rotations and zoom are possible. + // + pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); + FSUIPC_Write(0x3110, 8, &pitch, &result); + + yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); + FSUIPC_Write(0x3110, 8, &yaw, &result); + + roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); + FSUIPC_Write(0x3110, 8, &roll, &result); + + FSZoom = (WORD) (64/50) * virtPosZ + 64; + FSUIPC_Write(0x832E, 2, &FSZoom, &result); + + // + // Write the data, in one go! + // + FSUIPC_Process(&result); + if (result == FSUIPC_ERR_SENDMSG) { + FSUIPC_Close(); //timeout (1 second) so assume FS closed + } + } + } + + prevPosX = virtPosX; + prevPosY = virtPosY; + prevPosZ = virtPosZ; + prevRotX = virtRotX; + prevRotY = virtRotY; + prevRotZ = virtRotZ; + +} + +// +// Check if the Client DLL exists and load it (to test it), if so. +// Returns 'true' if all seems OK. +// +bool FSUIPCServer::checkServerInstallationOK() +{ + qDebug() << "FSUIPCCheckClientDLL says: Starting Function"; + + // + // Load the DLL. + // + FSUIPCLib.setFileName( LocationOfDLL ); + if (FSUIPCLib.load() != true) { + qDebug() << "FSUIPCCheckClientDLL says: Error loading FSUIPC DLL"; + return false; + } + + return true; +} + +// +// Scale the measured value to the Joystick values +// +int FSUIPCServer::scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; +double local_x; + + local_x = x; + if (local_x > max_x) { + local_x = max_x; + } + if (local_x < min_x) { + local_x = min_x; + } + y = ( 16383 * local_x ) / max_x; + + return (int) y; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FSUIPCServer::loadSettings() { + + 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 ( "FSUIPC" ); + LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); + iniFile.endGroup (); +} + +// +// Constructor for server-settings-dialog +// +FSUIPCControls::FSUIPCControls( QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FSUIPCControls::~FSUIPCControls() { + qDebug() << "~FSUIPCControls() says: started"; +} + +// +// OK clicked on server-dialog +// +void FSUIPCControls::doOK() { + save(); + this->close(); +} + +// override show event +void FSUIPCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FSUIPCControls::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 FSUIPCControls::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 ( "FSUIPC" ); + ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); + iniFile.endGroup (); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FSUIPCControls::save() { + + qDebug() << "save() says: started"; + + 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 ( "FSUIPC" ); + iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Show the Dialog to set the DLL's location +// +void FSUIPCControls::getLocationOfDLL() +{ + // + // Get the new filename of the INI-file. + // + QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), + ui.txtLocationOfDLL->text(), + tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); + if (!fileName.isEmpty()) { + ui.txtLocationOfDLL->setText( fileName ); + settingsDirty = true; + } +} + + +//END diff --git a/facetracknoir/FSUIPCServer.h b/facetracknoir/FSUIPCServer.h new file mode 100644 index 00000000..caba2f33 --- /dev/null +++ b/facetracknoir/FSUIPCServer.h @@ -0,0 +1,121 @@ +/******************************************************************************** +* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * +* to games, using the FSUIPC.dll. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Testing and Research) * +* * +* 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 . * +* * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FSUIPCSERVER_H +#define INCLUDED_FSUIPCSERVER_H + +#include "Windows.h" +#include +#include "FTNoIR_cxx_protocolserver.h" +#include "FSUIPC_User.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "ui_FTNoIR_FSUIPCcontrols.h" + +using namespace std; +using namespace v4friend::ftnoir; + +static const char* FSUIPC_FILENAME = "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll"; + +// +// Define the structures necessary for the FSUIPC_Write calls +// +#pragma pack(push,1) // All fields in structure must be byte aligned. +typedef struct +{ + int Control; // Control identifier + int Value; // Value of DOF +} TFSState; +#pragma pack(pop) + +class FSUIPCServer : public ProtocolServerBase { + Q_OBJECT + +public: + + // public member methods + FSUIPCServer(); + ~FSUIPCServer(); + + // protected member methods +protected: + bool checkServerInstallationOK(); + void sendHeadposeToGame(); + +private: + // Private properties + QString ProgramName; + QLibrary FSUIPCLib; + QString LocationOfDLL; + void loadSettings(); + float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + +public: + + // Settings for calculating the Virtual Pose + void setVirtRotX(float rot) { virtRotX = -1.0f * rot; } // degrees + void setVirtRotY(float rot) { virtRotY = rot; } + void setVirtRotZ(float rot) { virtRotZ = rot; } + + void setVirtPosX(float pos) { virtPosX = 0.0f; } // cm, X and Y are not working for FS2002/2004! + void setVirtPosY(float pos) { virtPosY = 0.0f; } + void setVirtPosZ(float pos) { virtPosZ = -1.0f * pos; } + + static int scale2AnalogLimits( float x, float min_x, float max_x ); +}; + +// Widget that has controls for FSUIPC server-settings. +class FSUIPCControls: public QWidget, public Ui::UICFSUIPCControls +{ + Q_OBJECT +public: + + explicit FSUIPCControls( QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~FSUIPCControls(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICFSUIPCControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void getLocationOfDLL(); + +}; + + +#endif//INCLUDED_FSUIPCSERVER_H +//END diff --git a/facetracknoir/FTNServer.cpp b/facetracknoir/FTNServer.cpp new file mode 100644 index 00000000..101d06a5 --- /dev/null +++ b/facetracknoir/FTNServer.cpp @@ -0,0 +1,294 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNServer FTNServer is the Class, that communicates headpose-data * +* to another FaceTrackNoIR program, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +/* + Modifications (last one on top): + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include +#include +#include "FTNServer.h" +#include "Tracker.h" +#include + +/** constructor **/ +FTNServer::FTNServer( Tracker *parent ) { + + // Save the parent + headTracker = parent; + loadSettings(); +} + +/** destructor **/ +FTNServer::~FTNServer() { + if (inSocket != 0) { + inSocket->close(); + delete inSocket; + } + + if (outSocket != 0) { + outSocket->close(); + delete outSocket; + } +} + +// +// Update Headpose in Game. +// +void FTNServer::sendHeadposeToGame() { +int no_bytes; +QHostAddress sender; +quint16 senderPort; + + // + // Create UDP-sockets if they don't exist already. + // They must be created here, because they must be in the Tracker thread (Tracker::run()) + // + if (inSocket == 0) { + qDebug() << "FTNServer::sendHeadposeToGame creating sockets"; + inSocket = new QUdpSocket(); + // Connect the inSocket to the port, to receive messages + if (!inSocket->bind(QHostAddress::Any, destPort+1)) { + qDebug() << "FTNServer::writePendingDatagrams says: unable to bind inSocket!"; + delete inSocket; + inSocket = 0; + } + } + + if (outSocket == 0) { + outSocket = new QUdpSocket(); + } + + // + // Copy the Raw measurements directly to the client. + // + TestData.x = virtPosX; + TestData.y = virtPosY; + TestData.z = virtPosZ; + TestData.pitch = virtRotX; + TestData.yaw = virtRotY; + TestData.roll = virtRotZ; + + // + // Try to send an UDP-message to the receiver + // + + //! [1] + no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort); + if ( no_bytes > 0) { +// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); + } + else { + qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; + } + + // + // Receiver may send data, so we must read that here. + // + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { + + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); + + inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); + + fg_cmd = cmd; // Let's just accept that command for now... + if ( cmd > 0 ) { + qDebug() << "FTNServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; + headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle + } + } + } +} + +// +// Check if the Client DLL exists and load it (to test it), if so. +// Returns 'true' if all seems OK. +// +bool FTNServer::checkServerInstallationOK( HANDLE handle ) +{ + // Init. the data + TestData.x = 0.0f; + TestData.y = 0.0f; + TestData.z = 0.0f; + TestData.yaw = 0.0f; + TestData.pitch = 0.0f; + TestData.roll = 0.0f; +// TestData.status = 0; + fg_cmd = 1; + + inSocket = 0; + outSocket = 0; + + return true; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNServer::loadSettings() { + + 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 ( "FTN" ); + + QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); + destIP = QHostAddress( destAddr ); + destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + + iniFile.endGroup (); +} + +// +// Constructor for server-settings-dialog +// +FTNServerControls::FTNServerControls( QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + // 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 +// +FTNServerControls::~FTNServerControls() { + qDebug() << "~FTNServerControls() says: started"; +} + +// +// OK clicked on server-dialog +// +void FTNServerControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTNServerControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTNServerControls::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 FTNServerControls::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 ( "FTN" ); + 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 FTNServerControls::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 ( "FTN" ); + 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; +} + +//END diff --git a/facetracknoir/FTNServer.h b/facetracknoir/FTNServer.h new file mode 100644 index 00000000..f392e708 --- /dev/null +++ b/facetracknoir/FTNServer.h @@ -0,0 +1,107 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNServer FTNServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTNSERVER_H +#define INCLUDED_FTNSERVER_H + +#include "FTNoIR_cxx_protocolserver.h" +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace std; +using namespace v4friend::ftnoir; + +#include "ui_FTNoIR_FTNServercontrols.h" + +class Tracker; // pre-define parent-class to avoid circular includes + +class FTNServer : public ProtocolServerBase { + Q_OBJECT + +public: + + // public member methods + FTNServer( Tracker *parent ); + ~FTNServer(); + + // protected member methods +protected: + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame(); + void setVirtPosX(float pos) { virtPosX = pos; } + void setVirtPosY(float pos) { virtPosY = pos; } + void setVirtPosZ(float pos) { virtPosZ = pos; } + +private: + Tracker *headTracker; // For upstream messages... + THeadPoseData TestData; + QUdpSocket *inSocket; // Receive from FligthGear + QUdpSocket *outSocket; // Send to FligthGear + qint32 cmd; + qint32 fg_cmd; // Command from FlightGear + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + void loadSettings(); +}; + +// Widget that has controls for FTNoIR protocol server-settings. +class FTNServerControls: public QWidget, public Ui::UICFTNServerControls +{ + Q_OBJECT +public: + + explicit FTNServerControls( QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~FTNServerControls(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICFTNServerControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; +}; + + + +#endif//INCLUDED_FTNSERVER_H +//END diff --git a/facetracknoir/FTNoIR_Curves.ui b/facetracknoir/FTNoIR_Curves.ui new file mode 100644 index 00000000..19c68cf0 --- /dev/null +++ b/facetracknoir/FTNoIR_Curves.ui @@ -0,0 +1,608 @@ + + + UICCurveConfigurationDialog + + + + 0 + 0 + 901 + 661 + + + + FaceTrackNoIR tracking curves + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + /* Customize any plain widget that is a child of a QMainWindow. */ +QMainWindow > .QWidget { +background-color: rgb(100, 100, 100); +} + +/* Set the selection colors for all widgets. */ +QWidget { +selection-color: black; +selection-background-color: Silver; +color: black; +} + +/* Specials for individual widget(s) */ +QWidget#UICCurveConfigurationDialog { +background-color: #484848; +} + +QWidget#tabWidget { +background-color: #595959; +} + +/* +QWidget#widgetTop { +background-color: #595959; +border-bottom: 1px solid #000; +} +*/ + +/* Make text in message boxes selectable. */ +QMessageBox { +/* LinksAccessibleByMouse | TextSelectableByMouse */ +messagebox-text-interaction-flags: 5; +} +/* Make the entire row selected in item views. */ +QAbstractItemView { +show-decoration-selected: 1; +} + +/* Nice WindowsXP-style password character for password line edits. */ +QLineEdit[echoMode="2"] { +lineedit-password-character: 9679; +} + +/* Customize tooltips. */ +QToolTip { +background-color: rgb(170, 255, 127); +opacity: 200; +} + +/* Customize push buttons and comboboxes. Our read-only combobox +is very similar to a push button, so they share the same border image. */ + +QPushButton { +min-width: 4em; +} + +QPushButton:disabled { +color: rgb(128, 128, 128); +} + +QGroupBox { +color: rgb(255, 255, 255); +} + + + + + + + + + + + 0 + + + + + :/images/rotation_DOFs.png:/images/rotation_DOFs.png + + + Rotations + + + + + 10 + 10 + 794 + 548 + + + + + + + + 0 + 0 + + + + + 260 + 240 + + + + + 260 + 500 + + + + 180 + + + 1 + + + + 0 + 255 + 255 + + + + + 192 + 192 + 192 + + + + Input Pitch Up (degr.) + + + Output Pitch Up (degr.) + + + + + + + + 0 + 0 + + + + + 260 + 240 + + + + + 260 + 500 + + + + 1 + + + + 0 + 255 + 0 + + + + + 192 + 192 + 192 + + + + Input Roll (degr.) + + + Output Roll (degr.) + + + + + + + + 0 + 0 + + + + + 260 + 240 + + + + + 400 + 500 + + + + 1 + + + + 255 + 170 + 0 + + + + + 192 + 192 + 192 + + + + Input Yaw (degr.) + + + Output Yaw (degr.) + + + + + + + + 0 + 0 + + + + + 260 + 240 + + + + + 260 + 500 + + + + 90 + + + 2 + + + + 0 + 255 + 255 + + + + + 192 + 192 + 192 + + + + Input Pitch Down (degr.) + + + Output Pitch Down (degr.) + + + + + + + + 16777215 + 25 + + + + Left-click the graph to place a new point, right-click a point to remove. Left-click and drag to move a point. + + + true + + + + + + + + 170 + 140 + + + + image: url(:/images/rotation_DOFs.png); + + + + + + + + + + :/images/translation_DOFs.png:/images/translation_DOFs.png + + + Translations + + + + + 30 + 10 + 794 + 390 + + + + + + + + 260 + 240 + + + + + 260 + 240 + + + + + 255 + 255 + 0 + + + + + 192 + 192 + 192 + + + + Left/Right Input X (cm.) + + + Output X (cm.) + + + + + + + + 260 + 240 + + + + + 260 + 240 + + + + + 85 + 0 + 255 + + + + + 192 + 192 + 192 + + + + Up/Down Input Y (cm.) + + + Output Y (cm.) + + + + + + + + 260 + 240 + + + + + 260 + 240 + + + + + 255 + 0 + 0 + + + + + 192 + 192 + 192 + + + + Forward/Backward Input Z (cm.) + + + Output Z (cm.) + + + + + + + + 16777215 + 25 + + + + Left-click the graph to place a new point, right-click a point to remove. Left-click and drag to move a point. + + + true + + + + + + + + 170 + 140 + + + + image: url(:/images/translation_DOFs.png); + + + + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 52 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 52 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + QFunctionConfigurator + QWidget +
qfunctionconfigurator.h
+
+
+ + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/facetracknoir/FTNoIR_FSUIPCcontrols.ui b/facetracknoir/FTNoIR_FSUIPCcontrols.ui new file mode 100644 index 00000000..b6120378 --- /dev/null +++ b/facetracknoir/FTNoIR_FSUIPCcontrols.ui @@ -0,0 +1,228 @@ + + + UICFSUIPCControls + + + + 0 + 0 + 541 + 127 + + + + FSUIPC settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + Location of FSUIPC.dll: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + + 35 + 16777215 + + + + ... + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + The DLL should be placed in the Modules folder of MS Flight Simulator + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/facetracknoir/FTNoIR_FTNServerControls.ui b/facetracknoir/FTNoIR_FTNServerControls.ui new file mode 100644 index 00000000..44c7e99f --- /dev/null +++ b/facetracknoir/FTNoIR_FTNServerControls.ui @@ -0,0 +1,261 @@ + + + UICFTNServerControls + + + + 0 + 0 + 411 + 156 + + + + FTNoIR protocol settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Port-number + + + + + + + 5550 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/facetracknoir/FTNoIR_KeyboardShortcuts.ui b/facetracknoir/FTNoIR_KeyboardShortcuts.ui new file mode 100644 index 00000000..2a5ad691 --- /dev/null +++ b/facetracknoir/FTNoIR_KeyboardShortcuts.ui @@ -0,0 +1,1018 @@ + + + UICKeyboardShortcutDialog + + + + 0 + 0 + 687 + 438 + + + + FaceTrackNoIR Keyboard and Mouse shortcuts + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + + Disables: + + + + + + + When OFF: + + + + + + + + 0 + 0 + + + + Center + + + false + + + + + + + Axis Inhibitor + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 90 + 0 + + + + + + + + + 90 + 0 + + + + + + + + + 0 + 80 + + + + color: rgb(0, 0, 0); + + + Rotations + + + + + 10 + 20 + 50 + 17 + + + + + 50 + 16777215 + + + + Yaw + + + + + + 10 + 40 + 46 + 17 + + + + + 50 + 16777215 + + + + Pitch + + + + + + 10 + 60 + 50 + 17 + + + + + 50 + 16777215 + + + + Roll + + + + + + + + + 60 + 60 + + + + color: rgb(0, 0, 0); + + + View + + + + + 10 + 20 + 46 + 17 + + + + Zero + + + + + + 10 + 40 + 45 + 17 + + + + Stay + + + + + + + + Start/stop + + + Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter + + + + + + + color: rgb(0, 0, 0); + + + Translations + + + + + 10 + 20 + 30 + 17 + + + + + 30 + 16777215 + + + + X + + + + + + 10 + 40 + 30 + 17 + + + + + 30 + 16777215 + + + + Y + + + + + + 10 + 60 + 30 + 17 + + + + + 30 + 16777215 + + + + Z + + + + + + + + + 100 + 0 + + + + color: rgb(0, 0, 0); + + + Engine tracker + + + + + 10 + 20 + 81 + 17 + + + + Stop Engine + + + + + + 10 + 40 + 91 + 17 + + + + Keep tracking + + + + + + + + + 0 + 0 + + + + Game Zero + + + false + + + + + + + + 50 + 16777215 + + + + Shift + + + + + + + + 50 + 16777215 + + + + Ctrl + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 50 + 16777215 + + + + Alt + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Keyboard + + + Qt::AlignCenter + + + false + + + + + + + + 0 + 0 + + + + Mouse + + + Qt::AlignCenter + + + false + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 90 + 0 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 90 + 0 + + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + Qt::Vertical + + + + + + + + 85 + 16777215 + + + + Disable Beep + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + The axis inhibitor shortkey toggles the selected axis Off/On + + + + + + + + + Qt::Horizontal + + + + + + + + + + + Yaw angle for Reverse Axis + + + + + + + + 50 + 0 + + + + + 60 + 16777215 + + + + 90 + + + 45 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + degrees + + + + + + + Z-position for Reverse Axis + + + + + + + + 50 + 0 + + + + + 60 + 16777215 + + + + -50 + + + 150 + + + 50 + + + + + + + cm + + + + + + + When Reverse: + + + + + + + + 50 + 0 + + + + + 60 + 16777215 + + + + -50 + + + 150 + + + -20 + + + + + + + cm + + + + + + + Enable Revers Axis + + + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + These settings are saved 'per game' (INI-file) + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/facetracknoir/FTNoIR_Preferences.ui b/facetracknoir/FTNoIR_Preferences.ui new file mode 100644 index 00000000..bb440fc6 --- /dev/null +++ b/facetracknoir/FTNoIR_Preferences.ui @@ -0,0 +1,240 @@ + + + UICPreferencesDialog + + + + 0 + 0 + 485 + 151 + + + + FaceTrackNoIR Preferences + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + Auto Minimize FaceTrackNoIR (0 = disable): + + + false + + + + + + + + + + 1000 + + + 5 + + + + + + + sec. (after 'Start') + + + + + + + Automatically Start tracking on Startup + + + + + + + Taskbar + + + + + + + Tray + + + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + These settings are saved globally (Registry) + + + false + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/facetracknoir/FaceApp.cpp b/facetracknoir/FaceApp.cpp new file mode 100644 index 00000000..2811974c --- /dev/null +++ b/facetracknoir/FaceApp.cpp @@ -0,0 +1,60 @@ +#include "FaceApp.h" +#include "windows.h" +#include "..\FTNoIR_Protocol_FT\FTTypes.h" +#include "..\FTNoIR_Protocol_FTIR\FTIRTypes.h" +#include + +// +// Override the Application MessageFilter, to receive messages from the game(s) +// +bool FaceApp::winEventFilter( MSG * msg, long * result ) +{ + int msgType = msg->message; // test line + + if (msgType == msgID_FTClient) { + qDebug() << "FaceApp::winEventFilter says: game tickles me =" << msgType << "hwnd =" << msg->hwnd; + if (mainWindow != NULL) { + mainWindow->getGameProgramName(); + } + } + + ////if (msgType == WM_HOTKEY) { + //// switch ( msg->wParam ) { + //// case 777: + //// qDebug() << "FaceApp::winEventFilter says: HOME pressed"; + //// break; + //// case 778: + //// qDebug() << "FaceApp::winEventFilter says: END pressed"; + //// break; + //// default: + //// qDebug() << "FaceApp::winEventFilter says: unknown HotKey pressed"; + //// break; + //// } + ////} + return( false ); +} + +// +// Setup the EventFilter +// +void FaceApp::SetupEventFilter( FaceTrackNoIR *window ) { + + mainWindow = window; + msgID_FTClient = RegisterWindowMessageA ( FT_PROGRAMID ); + qDebug() << "FaceApp::SetupEventFilter says: Message ID =" << msgID_FTClient; + msgID_FTIR_Register = RegisterWindowMessageA ( FTIR_REGISTER_PROGRAMHANDLE ); + msgID_FTIR_UnRegister = RegisterWindowMessageA ( FTIR_UNREGISTER_PROGRAMHANDLE ); + + ////if ( RegisterHotKey( window->winId(), 777, MOD_WIN, VK_HOME ) ) { + //// qDebug() << "FaceApp::SetupEventFilter says: RegisterHotKey HOME =" << VK_HOME; + ////} + ////if ( RegisterHotKey( window->winId(), 778, MOD_WIN, VK_END ) ) { + //// qDebug() << "FaceApp::SetupEventFilter says: RegisterHotKey END =" << VK_END; + ////} + //// + ////QAbstractEventDispatcher *evtdis = QAbstractEventDispatcher::instance(); + ////if (evtdis != NULL) { + //// qDebug() << "FaceApp::SetupEventFilter says: EventDispatcher found!"; + ////} + +} \ No newline at end of file diff --git a/facetracknoir/FaceApp.h b/facetracknoir/FaceApp.h new file mode 100644 index 00000000..39fd4b2f --- /dev/null +++ b/facetracknoir/FaceApp.h @@ -0,0 +1,27 @@ +#ifndef FACEAPP_H +#define FACEAPP_H + +#include +#include "FaceTrackNoIR.h" + +class FaceApp : public QApplication +{ + Q_OBJECT +public: + FaceApp( int &argc, char **argv ) : QApplication( argc, argv ) {} + ~FaceApp() {} + + void SetupEventFilter( FaceTrackNoIR *window ); + +protected: + bool winEventFilter( MSG * msg, long * result ); + +private: + FaceTrackNoIR *mainWindow; + int msgID_FTClient; + int msgID_FTIR_Register; + int msgID_FTIR_UnRegister; + int msgID_FilterSettingChanged; +}; + +#endif // FACEAPP_H diff --git a/facetracknoir/FaceTrackNoIR.cpp b/facetracknoir/FaceTrackNoIR.cpp new file mode 100644 index 00000000..cd4e0a4d --- /dev/null +++ b/facetracknoir/FaceTrackNoIR.cpp @@ -0,0 +1,2220 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +/* + Modifications (last one on top): + 20130201 - WVR: Load FreeTrack 2.0 protocol instead of fake TrackIR (which is now obsolete). + 20130101 - WVR: Added "None" to filter-listbox to remove "use advanced filtering". + 20121209 - WVR: Pre-v170 DLLs will not be added to the Listbox. Initial selection was changed (made case-insensitive). + 20121014 - WVR: Added second Tracker Source for Arduino solution. The two will be mutually exclusive. + 20120929 - WVR: Disable button Filter-settings when StartTracker. + 20120918 - WVR: When AutoStart is TRUE, the program is not directly minimized any more. + This now depends on the AutoMinimize time. Fixed the 'not showing' of the MIB. + Also disable combo and buttons after 'Start'. + 20120917 - WVR: Added Mouse-buttons to ShortKeys. + 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. + 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled ´statically´. Now, a Dir() of the + EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs + 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. 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. + 20110328 - WVR: Added the display for output-pose. + 20110207 - WVR: RadioButtons for 'Stop engine' added. It is now possible to choose Stop or Keep tracking. + 20110109 - WVR: Added minimizeTaskBar option added. It is now possible to choose minimized or tray. +*/ +#include "FaceTrackNoIR.h" +#include "tracker.h" + +//#define USE_VISAGE + +// +// Setup the Main Dialog +// +FaceTrackNoIR::FaceTrackNoIR(QWidget *parent, Qt::WFlags flags) : +QMainWindow(parent, flags), +pTrackerDialog(NULL), +pSecondTrackerDialog(NULL), +pProtocolDialog(NULL), +pFilterDialog(NULL) +{ + cameraDetected = false; + + // + // Initialize Widget handles, to prevent memory-access errors. + // + _keyboard_shortcuts = 0; + _preferences = 0; + _keyboard_shortcuts = 0; + _curve_config = 0; + + tracker = 0; +// _display = 0; + l = 0; + trayIcon = 0; + + setupFaceTrackNoIR(); + + // + // Read the AutoStartTracking value from the registry. If it is '1', start the Tracker and Minimize... + // + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + if (settings.value ( "AutoStartTracking", 0 ).toBool()) { + startTracker(); + } + + Q_INIT_RESOURCE(PoseWidget); + _pose_display = new GLWidget(ui.widget4logo, 0); + _pose_display->rotateBy(0, 0, 0); + + ui.lblX->setVisible(false); + ui.lblY->setVisible(false); + ui.lblZ->setVisible(false); + ui.lblRotX->setVisible(false); + ui.lblRotY->setVisible(false); + ui.lblRotZ->setVisible(false); + + ui.lcdNumOutputPosX->setVisible(false); + ui.lcdNumOutputPosY->setVisible(false); + ui.lcdNumOutputPosZ->setVisible(false); + ui.lcdNumOutputRotX->setVisible(false); + ui.lcdNumOutputRotY->setVisible(false); + ui.lcdNumOutputRotZ->setVisible(false); +} + +/** sets up all objects and connections to buttons */ +void FaceTrackNoIR::setupFaceTrackNoIR() { + + ui.setupUi(this); + + ui.headPoseWidget->show(); + ui.video_frame->hide(); + + // menu objects will be connected with the functions in FaceTrackNoIR class + connect(ui.actionOpen, SIGNAL(triggered()), this, SLOT(open())); + connect(ui.btnLoad, SIGNAL(clicked()), this, SLOT(open())); + connect(ui.actionSave, SIGNAL(triggered()), this, SLOT(save())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); + connect(ui.actionSave_As, SIGNAL(triggered()), this, SLOT(saveAs())); + connect(ui.btnSaveAs, SIGNAL(clicked()), this, SLOT(saveAs())); + connect(ui.actionExit, SIGNAL(triggered()), this, SLOT(exit())); + + connect(ui.actionPreferences, SIGNAL(triggered()), this, SLOT(showPreferences())); + connect(ui.actionKeyboard_Shortcuts, SIGNAL(triggered()), this, SLOT(showKeyboardShortcuts())); + connect(ui.actionCurve_Configuration, SIGNAL(triggered()), this, SLOT(showCurveConfiguration())); + connect(ui.btnEditCurves, SIGNAL(clicked()), this, SLOT(showCurveConfiguration())); + connect(ui.btnShortcuts, SIGNAL(clicked()), this, SLOT(showKeyboardShortcuts())); + + connect(ui.actionSupport, SIGNAL(triggered()), this, SLOT(openurl_support())); + connect(ui.actionYour_Support, SIGNAL(triggered()), this, SLOT(openurl_donation())); + connect(ui.btnDonate, SIGNAL(clicked()), this, SLOT(openurl_donation())); + connect(ui.actionAbout, SIGNAL(triggered()), this, SLOT(about())); + + connect(ui.actionVideoWidget, SIGNAL(triggered()), this, SLOT(showVideoWidget())); + connect(ui.actionHeadPoseWidget, SIGNAL(triggered()), this, SLOT(showHeadPoseWidget())); + connect(ui.btnShowEngineControls, SIGNAL(clicked()), this, SLOT(showTrackerSettings())); + connect(ui.btnShowSecondTrackerSettings, SIGNAL(clicked()), this, SLOT(showSecondTrackerSettings())); + connect(ui.btnShowServerControls, SIGNAL(clicked()), this, SLOT(showServerControls())); + connect(ui.btnShowFilterControls, SIGNAL(clicked()), this, SLOT(showFilterControls())); + + // Connect checkboxes + connect(ui.chkInvertYaw, SIGNAL(stateChanged(int)), this, SLOT(setInvertYaw(int))); + connect(ui.chkInvertRoll, SIGNAL(stateChanged(int)), this, SLOT(setInvertRoll(int))); + connect(ui.chkInvertPitch, SIGNAL(stateChanged(int)), this, SLOT(setInvertPitch(int))); + connect(ui.chkInvertX, SIGNAL(stateChanged(int)), this, SLOT(setInvertX(int))); + connect(ui.chkInvertY, SIGNAL(stateChanged(int)), this, SLOT(setInvertY(int))); + connect(ui.chkInvertZ, SIGNAL(stateChanged(int)), this, SLOT(setInvertZ(int))); + + // button methods connect with methods in this class + connect(ui.btnStartTracker, SIGNAL(clicked()), this, SLOT(startTracker())); + connect(ui.btnStopTracker, SIGNAL(clicked()), this, SLOT(stopTracker())); + + // Connect slider for smoothing + connect(ui.slideSmoothing, SIGNAL(valueChanged(int)), this, SLOT(setSmoothing(int))); + + //read the camera-name, using DirectShow + GetCameraNameDX(); + + //Create the system-tray and connect the events for that. + createIconGroupBox(); + createActions(); + createTrayIcon(); + + connect(trayIcon, SIGNAL(activated(QSystemTrayIcon::ActivationReason)), this, SLOT(iconActivated(QSystemTrayIcon::ActivationReason))); + + //Load the tracker-settings, from the INI-file + loadSettings(); + trayIcon->show(); + + connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + + //Setup the timer for automatically minimizing after StartTracker. + timMinimizeFTN = new QTimer(this); + connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized())); + + //Setup the timer for showing the headpose. + timUpdateHeadPose = new QTimer(this); + connect(timUpdateHeadPose, SIGNAL(timeout()), this, SLOT(showHeadPose())); + ui.txtTracking->setVisible(false); + ui.txtAxisReverse->setVisible(false); + ui.gameName->setText(""); +} + +/** destructor stops the engine and quits the faceapi **/ +FaceTrackNoIR::~FaceTrackNoIR() { + + // + // Stop the tracker, by simulating a button-push + // + stopTracker(); + + // + // 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::Discard ); + + switch (ret) { + case QMessageBox::Save: + saveAs(); + break; + case QMessageBox::Discard: + // Don't Save was clicked + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } +} + +// +// Get the ProgramName from a connected game and display it. +// +void FaceTrackNoIR::getGameProgramName() { + if ( tracker != NULL ) { + ui.gameName->setText( tracker->getGameProgramName() ); + } +} + +// +// Update the Settings, after a value has changed. This way, the Tracker does not have to re-start. +// +void FaceTrackNoIR::updateSettings() { + if ( tracker != NULL ) { + tracker->loadSettings(); + } +} + +// +// Get a pointer to the video-widget, to use in the DLL +// +QFrame *FaceTrackNoIR::getVideoWidget() { + return ui.video_frame; +} + +// +// Return the name of the Protocol-DLL +// +QString FaceTrackNoIR::getCurrentProtocolName() +{ + if (ui.iconcomboProtocol->currentIndex() < 0) { + return QString(""); + } + else { + return protocolFileList.at(ui.iconcomboProtocol->currentIndex()); + } +} + +// +// Return the name of the Filter-DLL +// +QString FaceTrackNoIR::getCurrentFilterName() +{ + qDebug() << "getCurrentFilterName says: " << ui.iconcomboFilter->currentIndex(); + if (ui.iconcomboFilter->currentIndex() <= 0) { + return QString("None"); + } + else { + return filterFileList.at(ui.iconcomboFilter->currentIndex() - 1 ); + } +} + +// +// Return the name of the Tracker-DLL +// +QString FaceTrackNoIR::getCurrentTrackerName() +{ + if (ui.iconcomboTrackerSource->currentIndex() < 0) { + return QString(""); + } + else { + qDebug() << "FaceTrackNoIR::getCurrentTrackerName libName = " << trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); + return trackerFileList.at(ui.iconcomboTrackerSource->currentIndex()); + } +} + +// +// Return the name of the second Tracker-DLL +// +QString FaceTrackNoIR::getSecondTrackerName() +{ + if (ui.cbxSecondTrackerSource->currentIndex() <= 0) { + return QString("None"); + } + else { + return trackerFileList.at(ui.cbxSecondTrackerSource->currentIndex() - 1 ); + } +} + +/** read the name of the first video-capturing device at start up **/ +/** FaceAPI can only use this first one... **/ +void FaceTrackNoIR::GetCameraNameDX() { + +//// ui.widget->setCameraName("No video-capturing device was found in your system: check if it's connected!"); + + ui.cameraName->setText("No video-capturing device was found in your system: check if it's connected!"); + + // Create the System Device Enumerator. + HRESULT hr; + ICreateDevEnum *pSysDevEnum = NULL; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); + if (FAILED(hr)) + { + qDebug() << "GetWDM says: CoCreateInstance Failed!"; + return; + } + + qDebug() << "GetWDM says: CoCreateInstance succeeded!"; + + // Obtain a class enumerator for the video compressor category. + IEnumMoniker *pEnumCat = NULL; + hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); + + if (hr == S_OK) { + qDebug() << "GetWDM says: CreateClassEnumerator succeeded!"; + + // Enumerate the monikers. + IMoniker *pMoniker = NULL; + ULONG cFetched; + if (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { + IPropertyBag *pPropBag; + hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); + if (SUCCEEDED(hr)) { + // To retrieve the filter's friendly name, do the following: + VARIANT varName; + VariantInit(&varName); + hr = pPropBag->Read(L"FriendlyName", &varName, 0); + if (SUCCEEDED(hr)) + { + // Display the name in your UI somehow. + QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); + qDebug() << "GetWDM says: Moniker found:" << str; + ui.cameraName->setText(str); + } + VariantClear(&varName); + + ////// To create an instance of the filter, do the following: + ////IBaseFilter *pFilter; + ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, + //// (void**)&pFilter); + // Now add the filter to the graph. + //Remember to release pFilter later. + pPropBag->Release(); + } + pMoniker->Release(); + } + pEnumCat->Release(); + } + pSysDevEnum->Release(); + +} + +// +// Open an INI-file with the QFileDialog +// If succesfull, the settings in it will be read +// +void FaceTrackNoIR::open() { + QFileDialog::Options options; + QFileDialog::FileMode mode; + + options |= QFileDialog::DontUseNativeDialog; + mode = QFileDialog::ExistingFile; + QString selectedFilter; + QStringList fileNames = QFileDialog::getOpenFileNames( + this, + tr("Select one FTNoir settings file"), + QCoreApplication::applicationDirPath() + "/Settings", + tr("Settings file (*.ini);;All Files (*)")); + + // + // If a file was selected, save it's name and read it's contents. + // + if (! fileNames.isEmpty() ) { + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + settings.setValue ("SettingsFile", fileNames.at(0)); + loadSettings(); + } +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FaceTrackNoIR::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 ( "Tracking" ); + iniFile.setValue ( "Smooth", ui.slideSmoothing->value() ); + iniFile.setValue ( "invertYaw", ui.chkInvertYaw->isChecked() ); + iniFile.setValue ( "invertPitch", ui.chkInvertPitch->isChecked() ); + iniFile.setValue ( "invertRoll", ui.chkInvertRoll->isChecked() ); + iniFile.setValue ( "invertX", ui.chkInvertX->isChecked() ); + iniFile.setValue ( "invertY", ui.chkInvertY->isChecked() ); + iniFile.setValue ( "invertZ", ui.chkInvertZ->isChecked() ); + iniFile.endGroup (); + + iniFile.beginGroup ( "GameProtocol" ); + iniFile.setValue ( "Selection", ui.iconcomboProtocol->currentIndex() ); + iniFile.setValue ( "DLL", getCurrentProtocolName() ); + iniFile.endGroup (); + + iniFile.beginGroup ( "TrackerSource" ); + iniFile.setValue ( "Selection", ui.iconcomboTrackerSource->currentIndex() ); + iniFile.setValue ( "DLL", getCurrentTrackerName() ); + iniFile.setValue ( "2ndDLL", getSecondTrackerName() ); + iniFile.endGroup (); + + // + // Save the name of the filter in the INI-file. + // + iniFile.beginGroup ( "Filter" ); + iniFile.setValue ( "DLL", getCurrentFilterName() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Get the new name of the INI-file and save the settings to it. +// +// The user may choose to overwrite an existing file. This will be deleted, before copying the current file to it. +// +void FaceTrackNoIR::saveAs() +{ + // + // Get the current filename of the INI-file. + // + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + QString oldFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + // + // Get the new filename of the INI-file. + // + QString fileName = QFileDialog::getSaveFileName(this, tr("Save file"), + oldFile, +// QCoreApplication::applicationDirPath() + "/Settings", + tr("Settings file (*.ini);;All Files (*)")); + if (!fileName.isEmpty()) { + + // + // Remove the file, if it already exists. + // + QFileInfo newFileInfo ( fileName ); + if ((newFileInfo.exists()) && (oldFile != fileName)) { + QFile newFileFile ( fileName ); + newFileFile.remove(); + } + + // + // Copy the current INI-file to the new name. + // + QFileInfo oldFileInfo ( oldFile ); + if (oldFileInfo.exists()) { + QFile oldFileFile ( oldFile ); + oldFileFile.copy( fileName ); + } + + // + // Write the new name to the Registry and save the other INI-values. + // + settings.setValue ("SettingsFile", fileName); + save(); + + // + // Reload the settings, to get the GUI right again... + // + loadSettings(); + } +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FaceTrackNoIR::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) + + // + // Put the filename in the window-title. + // + QFileInfo pathInfo ( currentFile ); + setWindowTitle ( "FaceTrackNoIR (1.7) - " + pathInfo.fileName() ); + + // + // Get a List of all the INI-files in the (currently active) Settings-folder. + // + QDir settingsDir( pathInfo.dir() ); + QStringList filters; + filters << "*.ini"; + iniFileList.clear(); + iniFileList = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + + // + // Add strings to the Listbox. + // + disconnect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + ui.iconcomboProfile->clear(); + for ( int i = 0; i < iniFileList.size(); i++) { + ui.iconcomboProfile->addItem(QIcon(":/images/Settings16.png"), iniFileList.at(i)); + if (iniFileList.at(i) == pathInfo.fileName()) { + ui.iconcomboProfile->setItemIcon(i, QIcon(":/images/SettingsOpen16.png")); + ui.iconcomboProfile->setCurrentIndex( i ); + } + } + connect(ui.iconcomboProfile, SIGNAL(currentIndexChanged(int)), this, SLOT(profileSelected(int))); + + qDebug() << "loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Tracking" ); + ui.slideSmoothing->setValue (iniFile.value ( "Smooth", 10 ).toInt()); + ui.chkInvertYaw->setChecked (iniFile.value ( "invertYaw", 0 ).toBool()); + ui.chkInvertPitch->setChecked (iniFile.value ( "invertPitch", 0 ).toBool()); + ui.chkInvertRoll->setChecked (iniFile.value ( "invertRoll", 0 ).toBool()); + ui.chkInvertX->setChecked (iniFile.value ( "invertX", 0 ).toBool()); + ui.chkInvertY->setChecked (iniFile.value ( "invertY", 0 ).toBool()); + ui.chkInvertZ->setChecked (iniFile.value ( "invertZ", 0 ).toBool()); + iniFile.endGroup (); + + // + // Read the currently selected Protocol from the INI-file. + // If the setting "DLL" isn't found (pre-1.7 version of INI), then the setting 'Selection' is evaluated. + // + iniFile.beginGroup ( "GameProtocol" ); + + QString selectedProtocolName = iniFile.value ( "DLL", "" ).toString(); + qDebug() << "loadSettings says: selectedProtocolName = " << selectedProtocolName; + + if (selectedProtocolName.length() == 0) { + int index = iniFile.value ( "Selection", 0 ).toInt(); + switch ( index ) { + case TRACKIR: + case FREE_TRACK: + selectedProtocolName = QString("FTNoIR_Protocol_FT.dll"); + break; + + case SIMCONNECT: + selectedProtocolName = QString("FTNoIR_Protocol_SC.dll"); + break; + + case PPJOY: + selectedProtocolName = QString("FTNoIR_Protocol_PPJOY.dll"); + break; + + case FSUIPC: + selectedProtocolName = QString("FTNoIR_Protocol_FSUIPC.dll"); + break; + + case FLIGHTGEAR: + selectedProtocolName = QString("FTNoIR_Protocol_FG.dll"); + break; + + case FTNOIR: + selectedProtocolName = QString("FTNoIR_Protocol_FTN.dll"); + break; + + case MOUSE: + selectedProtocolName = QString("FTNoIR_Protocol_MOUSE.dll"); + break; + + default: + selectedProtocolName = QString("FTNoIR_Protocol_MOUSE.dll"); + break; + } + } + iniFile.endGroup (); + + // + // Find the Index of the DLL and set the selection. + // + for ( int i = 0; i < protocolFileList.size(); i++) { + if (protocolFileList.at(i).compare( selectedProtocolName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboProtocol->setCurrentIndex( i ); + break; + } + } + + // + // 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" ); + QString selectedTrackerName = iniFile.value ( "DLL", "" ).toString(); + qDebug() << "loadSettings 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; + } + } + QString secondTrackerName = iniFile.value ( "2ndDLL", "None" ).toString(); + qDebug() << "loadSettings says: secondTrackerName = " << secondTrackerName; + + iniFile.endGroup (); + + disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + for ( int i = 0; i < trackerFileList.size(); i++) { + if (trackerFileList.at(i).compare( selectedTrackerName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboTrackerSource->setCurrentIndex( i ); + } + if (trackerFileList.at(i).compare( secondTrackerName, Qt::CaseInsensitive ) == 0) { + ui.cbxSecondTrackerSource->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 + } + } + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + + // + // Read the currently selected Filter from the INI-file. + // + iniFile.beginGroup ( "Filter" ); + QString selectedFilterName = iniFile.value ( "DLL", "FTNoIR_Filter_EWMA2.dll" ).toString(); + qDebug() << "createIconGroupBox says: selectedFilterName = " << selectedFilterName; + iniFile.endGroup (); + + // + // Find the Index of the DLL and set the selection. + // + for ( int i = 0; i < filterFileList.size(); i++) { + if (filterFileList.at(i).compare( selectedFilterName, Qt::CaseInsensitive ) == 0) { + ui.iconcomboFilter->setCurrentIndex( i + 1 ); // The first value = "None", so add 1 + break; + } + } + + settingsDirty = false; +} + +/** show support page in web-browser **/ +void FaceTrackNoIR::openurl_support() { + QDesktopServices::openUrl(QUrl("http://facetracknoir.sourceforge.net/manual/manual.htm", QUrl::TolerantMode)); +} + +/** show donations page in web-browser **/ +void FaceTrackNoIR::openurl_donation() { + QDesktopServices::openUrl(QUrl("http://facetracknoir.sourceforge.net/information_links/donate.htm", QUrl::TolerantMode)); +} + + +/** show about dialog **/ +void FaceTrackNoIR::about() { + + QPoint offsetpos(100, 100); + aboutDialog.move(this->pos() + offsetpos); + aboutDialog.show(); + + /** ABOUT DIALOG **/ + aboutDialog.setBaseSize(270, 440); + + aboutDialog.setMaximumWidth(270); + aboutDialog.setMaximumHeight(440); + + aboutDialog.setMinimumWidth(270); + aboutDialog.setMinimumHeight(440); + aboutDialog.setStyleSheet("background:#fff url(:/UIElements/aboutFaceTrackNoIR.png) no-repeat;"); +} + +/** start tracking the face **/ +void FaceTrackNoIR::startTracker( ) { + + // + // Disable buttons + // + ui.iconcomboProfile->setEnabled ( false ); + ui.btnLoad->setEnabled ( false ); + ui.btnSave->setEnabled ( false ); + ui.btnSaveAs->setEnabled ( false ); + ui.btnShowFilterControls->setEnabled ( false ); + + // + // Create the Tracker and setup + // + tracker = new Tracker ( this ); + + // + // Setup the Tracker and send the settings. + // This is necessary, because the events are only triggered 'on change' + // + tracker->setup(); + tracker->setSmoothing ( ui.slideSmoothing->value() ); + tracker->setInvertYaw (ui.chkInvertYaw->isChecked() ); + tracker->setInvertPitch (ui.chkInvertPitch->isChecked() ); + tracker->setInvertRoll (ui.chkInvertRoll->isChecked() ); + tracker->setInvertX (ui.chkInvertX->isChecked() ); + tracker->setInvertY (ui.chkInvertY->isChecked() ); + tracker->setInvertZ (ui.chkInvertZ->isChecked() ); + + tracker->start( QThread::TimeCriticalPriority ); + + // + // Register the Tracker instance with the Tracker Dialog (if open) + // + if (pTrackerDialog) { + pTrackerDialog->registerTracker( tracker->getTrackerPtr() ); + } + + ui.headPoseWidget->show(); + + // + ui.btnStartTracker->setEnabled ( false ); + ui.btnStopTracker->setEnabled ( true ); + + // Enable/disable Protocol-server Settings + ui.iconcomboTrackerSource->setEnabled ( false ); + ui.cbxSecondTrackerSource->setEnabled ( false ); + ui.iconcomboProtocol->setEnabled ( false ); +// ui.btnShowServerControls->setEnabled ( false ); + ui.iconcomboFilter->setEnabled ( false ); + + // + // Update the camera-name, FaceAPI can only use the 1st one found! + // + GetCameraNameDX(); + + + // + // Get the TimeOut value for minimizing FaceTrackNoIR + // Only start the Timer if value > 0 + // + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + int timevalue = settings.value ( "AutoMinimizeTime", 0 ).toInt() * 1000; + if (timevalue > 0) { + + bool minimizeTaskBar = settings.value ( "MinimizeTaskBar", 1 ).toBool(); + if (minimizeTaskBar) { + connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(showMinimized())); + } + else { + connect(timMinimizeFTN, SIGNAL(timeout()), this, SLOT(hide())); + } + + timMinimizeFTN->setSingleShot( true ); + timMinimizeFTN->start(timevalue); + } + + // + // Start the timer to update the head-pose (digits and 'man in black') + // + timUpdateHeadPose->start(50); + + ui.lblX->setVisible(true); + ui.lblY->setVisible(true); + ui.lblZ->setVisible(true); + ui.lblRotX->setVisible(true); + ui.lblRotY->setVisible(true); + ui.lblRotZ->setVisible(true); + + ui.lcdNumOutputPosX->setVisible(true); + ui.lcdNumOutputPosY->setVisible(true); + ui.lcdNumOutputPosZ->setVisible(true); + ui.lcdNumOutputRotX->setVisible(true); + ui.lcdNumOutputRotY->setVisible(true); + ui.lcdNumOutputRotZ->setVisible(true); +} + +/** stop tracking the face **/ +void FaceTrackNoIR::stopTracker( ) { + + // + // Stop displaying the head-pose. + // + timUpdateHeadPose->stop(); + _pose_display->rotateBy(0, 0, 0); + + + ui.lblX->setVisible(false); + ui.lblY->setVisible(false); + ui.lblZ->setVisible(false); + ui.lblRotX->setVisible(false); + ui.lblRotY->setVisible(false); + ui.lblRotZ->setVisible(false); + + ui.lcdNumOutputPosX->setVisible(false); + ui.lcdNumOutputPosY->setVisible(false); + ui.lcdNumOutputPosZ->setVisible(false); + ui.lcdNumOutputRotX->setVisible(false); + ui.lcdNumOutputRotY->setVisible(false); + ui.lcdNumOutputRotZ->setVisible(false); + ui.txtTracking->setVisible(false); + ui.txtAxisReverse->setVisible(false); + + // + // UnRegister the Tracker instance with the Tracker Dialog (if open) + // + if (pTrackerDialog) { + pTrackerDialog->unRegisterTracker(); + } + if (pProtocolDialog) { + pProtocolDialog->unRegisterProtocol(); + } + + // + // Delete the tracker (after stopping things and all). + // + if ( tracker ) { + qDebug() << "stopTracker says: Deleting tracker!"; + delete tracker; + qDebug() << "stopTracker says: Tracker deleted!"; + tracker = 0; + } + ui.btnStartTracker->setEnabled ( true ); + ui.btnStopTracker->setEnabled ( false ); +// ui.btnShowEngineControls->setEnabled ( false ); + ui.iconcomboProtocol->setEnabled ( true ); + ui.iconcomboTrackerSource->setEnabled ( true ); + ui.cbxSecondTrackerSource->setEnabled ( true ); + ui.iconcomboFilter->setEnabled ( true ); + + // Enable/disable Protocol-server Settings + ui.btnShowServerControls->setEnabled ( true ); + ui.video_frame->hide(); + + // + ui.iconcomboProfile->setEnabled ( true ); + ui.btnLoad->setEnabled ( true ); + ui.btnSave->setEnabled ( true ); + ui.btnSaveAs->setEnabled ( true ); + ui.btnShowFilterControls->setEnabled ( true ); + + // + // Stop the timer, so it won't go off again... + // + timMinimizeFTN->stop(); + +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertYaw( int invert ) { + Tracker::setInvertYaw ( (invert != 0)?true:false ); + settingsDirty = true; +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertPitch( int invert ) { + Tracker::setInvertPitch ( (invert != 0)?true:false ); + settingsDirty = true; +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertRoll( int invert ) { + Tracker::setInvertRoll ( (invert != 0)?true:false ); + settingsDirty = true; +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertX( int invert ) { + Tracker::setInvertX ( (invert != 0)?true:false ); + settingsDirty = true; +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertY( int invert ) { + Tracker::setInvertY ( (invert != 0)?true:false ); + settingsDirty = true; +} + +/** set the invert from the checkbox **/ +void FaceTrackNoIR::setInvertZ( int invert ) { + Tracker::setInvertZ ( (invert != 0)?true:false ); + settingsDirty = true; +} + +/** Show the headpose in the widget (triggered by timer) **/ +void FaceTrackNoIR::showHeadPose() { +THeadPoseData newdata; + + ui.lblX->setVisible(true); + ui.lblY->setVisible(true); + ui.lblZ->setVisible(true); + ui.lblRotX->setVisible(true); + ui.lblRotY->setVisible(true); + ui.lblRotZ->setVisible(true); + + ui.lcdNumOutputPosX->setVisible(true); + ui.lcdNumOutputPosY->setVisible(true); + ui.lcdNumOutputPosZ->setVisible(true); + ui.lcdNumOutputRotX->setVisible(true); + ui.lcdNumOutputRotY->setVisible(true); + ui.lcdNumOutputRotZ->setVisible(true); + + if (!isMinimized()) { + + // + // Get the pose and also display it. + // Updating the pose from within the Tracker-class caused crashes... + // + Tracker::getHeadPose(&newdata); + ui.lcdNumX->display(QString("%1").arg(newdata.x, 0, 'f', 1)); + ui.lcdNumY->display(QString("%1").arg(newdata.y, 0, 'f', 1)); + ui.lcdNumZ->display(QString("%1").arg(newdata.z, 0, 'f', 1)); + + ui.lcdNumRotX->display(QString("%1").arg(newdata.yaw, 0, 'f', 1)); + ui.lcdNumRotY->display(QString("%1").arg(newdata.pitch, 0, 'f', 1)); + ui.lcdNumRotZ->display(QString("%1").arg(newdata.roll, 0, 'f', 1)); + + ui.txtTracking->setVisible(Tracker::getTrackingActive()); + ui.txtAxisReverse->setVisible(Tracker::getAxisReverse()); + + // + // Get the output-pose and also display it. + // + if (_pose_display) { + Tracker::getOutputHeadPose(&newdata); + _pose_display->rotateBy(newdata.pitch, newdata.yaw, newdata.roll); + + ui.lcdNumOutputPosX->display(QString("%1").arg(newdata.x, 0, 'f', 1)); + ui.lcdNumOutputPosY->display(QString("%1").arg(newdata.y, 0, 'f', 1)); + ui.lcdNumOutputPosZ->display(QString("%1").arg(newdata.z, 0, 'f', 1)); + + ui.lcdNumOutputRotX->display(QString("%1").arg(newdata.yaw, 0, 'f', 1)); + 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 + // + if (tracker) { + ITracker * theTracker = tracker->getTrackerPtr(); + if (theTracker) { + theTracker->refreshVideo(); + } + } + // Tracker::doRefreshVideo(); + + if (_curve_config) { + _curve_config->update(); + } + } + //else { + // qDebug() << "FaceTrackNoIR::showHeadPose status: window = minimized."; + //} +} + +/** set the smoothing from the slider **/ +void FaceTrackNoIR::setSmoothing( int smooth ) { + + // + // Pass the smoothing setting, if the Tracker exists. + // + if ( tracker ) { + tracker->setSmoothing ( smooth ); + settingsDirty = true; + } +} + + +/** toggles Video Widget **/ +void FaceTrackNoIR::showVideoWidget() { + if(ui.video_frame->isHidden()) + ui.video_frame->show(); + else + ui.video_frame->hide(); +} + +/** toggles Video Widget **/ +void FaceTrackNoIR::showHeadPoseWidget() { + if(ui.headPoseWidget->isHidden()) + ui.headPoseWidget->show(); + else + ui.headPoseWidget->hide(); +} + +/** toggles Engine Controls Dialog **/ +void FaceTrackNoIR::showTrackerSettings() { +importGetTrackerDialog getIT; +QLibrary *trackerLib; +QString libName; + + qDebug() << "FaceTrackNoIR::showTrackerSettings started."; + + // + // Delete the existing QDialog + // + if (pTrackerDialog) { + delete pTrackerDialog; + pTrackerDialog = NULL; + } + + // Show the appropriate Tracker Settings + libName.clear(); + libName = getCurrentTrackerName(); + + // + // Load the Server-settings dialog (if any) and show it. + // + if (!libName.isEmpty()) { + trackerLib = new QLibrary(libName); + +// qDebug() << "FaceTrackNoIR::showTrackerSettings Loaded trackerLib." << trackerLib; + + getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); + +// qDebug() << "FaceTrackNoIR::showTrackerSettings resolved." << getIT; + + if (getIT) { + ITrackerDialog *ptrXyz(getIT()); + if (ptrXyz) + { + pTrackerDialog = ptrXyz; + pTrackerDialog->Initialize( this ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings GetTrackerDialog Function Resolved!"; + if (tracker) { + pTrackerDialog->registerTracker( tracker->getTrackerPtr() ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings RegisterTracker Function Executed"; + } + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } + +} + +// Show the Settings dialog for the secondary Tracker +void FaceTrackNoIR::showSecondTrackerSettings() { +importGetTrackerDialog getIT; +QLibrary *trackerLib; +QString libName; + + qDebug() << "FaceTrackNoIR::showSecondTrackerSettings started."; + + // + // Delete the existing QDialog + // + if (pSecondTrackerDialog) { + delete pSecondTrackerDialog; + pSecondTrackerDialog = NULL; + } + + // Show the appropriate Tracker Settings + libName.clear(); + libName = getSecondTrackerName(); + + // + // Load the Server-settings dialog (if any) and show it. + // + if ((!libName.isEmpty()) && (libName != "None")) { + trackerLib = new QLibrary(libName); + +// qDebug() << "FaceTrackNoIR::showTrackerSettings Loaded trackerLib." << trackerLib; + + getIT = (importGetTrackerDialog) trackerLib->resolve("GetTrackerDialog"); + +// qDebug() << "FaceTrackNoIR::showTrackerSettings resolved." << getIT; + + if (getIT) { + ITrackerDialog *ptrXyz(getIT()); + if (ptrXyz) + { + pSecondTrackerDialog = ptrXyz; + pSecondTrackerDialog->Initialize( this ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings GetTrackerDialog Function Resolved!"; + if (tracker) { + pSecondTrackerDialog->registerTracker( tracker->getSecondTrackerPtr() ); +// qDebug() << "FaceTrackNoIR::showTrackerSettings RegisterTracker Function Executed"; + } + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } + +} + +/** toggles Server Controls Dialog **/ +void FaceTrackNoIR::showServerControls() { +importGetProtocolDialog getIT; +QLibrary *protocolLib; +QString libName; + + // + // Delete the existing QDialog + // + if (pProtocolDialog) { + delete pProtocolDialog; + } + + // Show the appropriate Protocol-server Settings + libName.clear(); + libName = getCurrentProtocolName(); + + // + // Load the Server-settings dialog (if any) and show it. + // + if (!libName.isEmpty()) { + protocolLib = new QLibrary(libName); + + getIT = (importGetProtocolDialog) protocolLib->resolve("GetProtocolDialog"); + if (getIT) { + IProtocolDialogPtr ptrXyz(getIT()); + if (ptrXyz) + { + pProtocolDialog = ptrXyz; + pProtocolDialog->Initialize( this ); + if (tracker) { + pProtocolDialog->registerProtocol( tracker->getProtocolPtr() ); + qDebug() << "FaceTrackNoIR::showServerControls RegisterProtocol Function Executed"; + } + qDebug() << "FaceTrackNoIR::showServerControls GetProtocolDialog Function Resolved!"; + } + else { + qDebug() << "FaceTrackNoIR::showServerControls Function NOT Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } +} + +/** toggles Filter Controls Dialog **/ +void FaceTrackNoIR::showFilterControls() { +importGetFilterDialog getIT; +QLibrary *filterLib; +QString libName; + + // + // Delete the existing QDialog + // + if (pFilterDialog) { + delete pFilterDialog; + pFilterDialog = NULL; + } + + // Get the currently selected Filter + libName.clear(); + libName = getCurrentFilterName(); + + // + // Load the Filter-settings dialog (if any) and show it. + // + if (!libName.isEmpty()) { + filterLib = new QLibrary(libName); + + getIT = (importGetFilterDialog) filterLib->resolve("GetFilterDialog"); + if (getIT) { + IFilterDialogPtr ptrXyz(getIT()); + if (ptrXyz) + { + pFilterDialog = ptrXyz; + pFilterDialog->Initialize( this, Tracker::getFilterPtr() ); + qDebug() << "FaceTrackNoIR::showFilterControls GetFilterDialog Function Resolved!"; + } + else { + qDebug() << "FaceTrackNoIR::showFilterControls Function NOT Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } +} + +/** toggles FaceTrackNoIR Preferences Dialog **/ +void FaceTrackNoIR::showPreferences() { + + // Create if new + if (!_preferences) + { + _preferences = new PreferencesDialog( this, this, Qt::Dialog ); + } + + // Show if already created + if (_preferences) { + _preferences->show(); + _preferences->raise(); + } +} + +/** toggles Keyboard Shortcut Dialog **/ +void FaceTrackNoIR::showKeyboardShortcuts() { + + // Create if new + if (!_keyboard_shortcuts) + { + _keyboard_shortcuts = new KeyboardShortcutDialog( this, this, Qt::Dialog ); + } + + // Show if already created + if (_keyboard_shortcuts) { + _keyboard_shortcuts->show(); + _keyboard_shortcuts->raise(); + } +} + +/** toggles Curve Configuration Dialog **/ +void FaceTrackNoIR::showCurveConfiguration() { + + // Create if new + if (!_curve_config) + { + _curve_config = new CurveConfigurationDialog( this, this, Qt::Dialog ); + } + + // Show if already created + if (_curve_config) { + _curve_config->show(); + _curve_config->raise(); + } +} + +/** exit application **/ +void FaceTrackNoIR::exit() { + QCoreApplication::exit(0); +} + +// +// Setup the icons for the comboBoxes +// +void FaceTrackNoIR::createIconGroupBox() +{ +importGetProtocolDll getProtocol; +IProtocolDllPtr pProtocolDll; // Pointer to Protocol info instance (in DLL) +importGetFilterDll getFilter; +IFilterDllPtr pFilterDll; // Pointer to Filter info instance (in DLL) +importGetTrackerDll getTracker; +ITrackerDll *pTrackerDll; // Pointer to Tracker info instance (in DLL) +QStringList listDLLs; // List of specific DLLs + + 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) + + // + // Get a List of all the Protocol-DLL-files in the Program-folder. + // + QDir settingsDir( QCoreApplication::applicationDirPath() ); + QStringList filters; + filters.clear(); + filters << "FTNoIR_Protocol_*.dll"; + protocolFileList.clear(); + listDLLs.clear(); + listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + + // + // Add strings to the Listbox. + // + disconnect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + ui.iconcomboProtocol->clear(); + for ( int i = 0; i < listDLLs.size(); i++) { + + // Try to load the DLL and get the Icon and Name + QLibrary *protocolLib = new QLibrary(listDLLs.at(i)); + QString *protocolName = new QString(""); + QIcon *protocolIcon = new QIcon(); + + getProtocol = (importGetProtocolDll) protocolLib->resolve("GetProtocolDll"); + if (getProtocol) { + IProtocolDllPtr ptrXyz(getProtocol()); + if (ptrXyz) + { + pProtocolDll = ptrXyz; + pProtocolDll->getFullName( protocolName ); + pProtocolDll->getIcon( protocolIcon ); + + // + // Add the Icon and the Name to the Listbox and update the fileList + // + ui.iconcomboProtocol->addItem(*protocolIcon, *protocolName ); + protocolFileList.append(listDLLs.at(i)); + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); + } + + } + connect(ui.iconcomboProtocol, SIGNAL(currentIndexChanged(int)), this, SLOT(protocolSelected(int))); + + // + // Get a List of all the Filter-DLL-files in the Program-folder. + // + filters.clear(); + filters << "FTNoIR_Filter_*.dll"; + filterFileList.clear(); + listDLLs.clear(); + listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + + // + // Add strings to the Listbox. + // + disconnect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + ui.iconcomboFilter->clear(); + ui.iconcomboFilter->addItem("None"); + + for ( int i = 0; i < listDLLs.size(); i++) { + + // Try to load the DLL and get the Icon and Name + QLibrary *filterLib = new QLibrary(listDLLs.at(i)); + QString *filterName = new QString(""); + QIcon *filterIcon = new QIcon(); + + getFilter = (importGetFilterDll) filterLib->resolve("GetFilterDll"); + if (getFilter) { + IFilterDllPtr ptrXyz(getFilter()); + if (ptrXyz) + { + pFilterDll = ptrXyz; + pFilterDll->getFullName( filterName ); + pFilterDll->getIcon( filterIcon ); + + // + // Add the Icon and the Name to the Listbox and update the fileList + // + ui.iconcomboFilter->addItem(*filterIcon, *filterName ); + filterFileList.append(listDLLs.at(i)); + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); + } + + } + connect(ui.iconcomboFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(filterSelected(int))); + + // + // Get a List of all the Tracker-DLL-files in the Program-folder. + // + filters.clear(); + filters << "FTNoIR_Tracker_*.dll"; + trackerFileList.clear(); + listDLLs.clear(); + listDLLs = settingsDir.entryList( filters, QDir::Files, QDir::Name ); + + // + // Add strings to the Listbox(es). + // + disconnect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + ui.iconcomboTrackerSource->clear(); + + disconnect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + ui.cbxSecondTrackerSource->clear(); + ui.cbxSecondTrackerSource->addItem("None"); + + for ( int i = 0; i < listDLLs.size(); i++) { + + // Try to load the DLL and get the Icon and Name + QLibrary *trackerLib = new QLibrary(listDLLs.at(i)); + QString *trackerName = new QString(""); + QIcon *trackerIcon = new QIcon(); + + getTracker = (importGetTrackerDll) trackerLib->resolve("GetTrackerDll"); + if (getTracker) { + ITrackerDll *ptrXyz(getTracker()); + if (ptrXyz) + { + pTrackerDll = ptrXyz; + pTrackerDll->getFullName( trackerName ); + pTrackerDll->getIcon( trackerIcon ); + + // + // Add the Icon and the Name to the Listbox and update the fileList + // + ui.iconcomboTrackerSource->addItem(*trackerIcon, *trackerName ); + ui.cbxSecondTrackerSource->addItem(*trackerIcon, *trackerName ); + trackerFileList.append(listDLLs.at(i)); + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Tracker-DLL not loaded, please check if the DLL is version 1.7 \nand all dependencies are installed. \n(" + listDLLs.at(i) + ")",QMessageBox::Ok,QMessageBox::NoButton); + } + + } + connect(ui.iconcomboTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); + connect(ui.cbxSecondTrackerSource, SIGNAL(currentIndexChanged(int)), this, SLOT(trackingSourceSelected(int))); +} + +// +// Create the Actions in the System tray and connect them to Application events +// +void FaceTrackNoIR::createActions() +{ + minimizeAction = new QAction(tr("Mi&nimize FaceTrackNoIR"), this); + connect(minimizeAction, SIGNAL(triggered()), this, SLOT(hide())); + + //maximizeAction = new QAction(tr("Ma&ximize"), this); + //connect(maximizeAction, SIGNAL(triggered()), this, SLOT(showMaximized())); + + restoreAction = new QAction(tr("&Restore FaceTrackNoIR"), this); + connect(restoreAction, SIGNAL(triggered()), this, SLOT(showNormal())); + + quitAction = new QAction(tr("&Quit FaceTrackNoIR"), this); + connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); +} + +// +// Create the SystemTray and set the default Icon +// +void FaceTrackNoIR::createTrayIcon() +{ + if (QSystemTrayIcon::isSystemTrayAvailable()) { + trayIconMenu = new QMenu(this); + trayIconMenu->addAction(minimizeAction); + trayIconMenu->addAction(restoreAction); + trayIconMenu->addSeparator(); + trayIconMenu->addAction(quitAction); + + trayIcon = new QSystemTrayIcon(this); + trayIcon->setContextMenu(trayIconMenu); + + trayIcon->setIcon(QIcon(QCoreApplication::applicationDirPath() + "/images/FaceTrackNoIR.ico")); + } +} + +// +// Handle SystemTray events +// +void FaceTrackNoIR::iconActivated(QSystemTrayIcon::ActivationReason reason) +{ + switch (reason) { + case QSystemTrayIcon::Trigger: + case QSystemTrayIcon::DoubleClick: + //ui.iconcomboProtocol->setCurrentIndex((ui.iconcomboProtocol->currentIndex() + 1) + // % ui.iconcomboProtocol->count()); + break; + ////case QSystemTrayIcon::MiddleClick: + //// showMessage(); + //// break; + default: + ; + } + } + +// +// Handle changes of the Protocol selection +// +void FaceTrackNoIR::protocolSelected(int index) +{ + settingsDirty = true; + ui.btnShowServerControls->setEnabled ( true ); + + // + // Set the Icon for the tray and update the Icon for the Settings button. + // + QIcon icon = ui.iconcomboProtocol->itemIcon(index); + if (trayIcon != 0) { + trayIcon->setIcon(icon); + trayIcon->setToolTip(ui.iconcomboProtocol->itemText(index)); + trayIcon->show(); + trayIcon->showMessage( "FaceTrackNoIR", ui.iconcomboProtocol->itemText(index)); + } + setWindowIcon(QIcon(":/images/FaceTrackNoIR.ico")); + ui.btnShowServerControls->setIcon(icon); +} + +// +// Handle changes of the Tracking Source selection +// +void FaceTrackNoIR::trackingSourceSelected(int index) +{ + settingsDirty = true; + ui.btnShowEngineControls->setEnabled ( true ); +} + +// +// Handle changes of the Profile selection +// +void FaceTrackNoIR::profileSelected(int index) +{ + // + // Read the current INI-file setting, to get the folder in which it's located... + // + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QFileInfo pathInfo ( currentFile ); + + // + // Save the name of the INI-file in the Registry. + // + settings.setValue ("SettingsFile", pathInfo.absolutePath() + "/" + iniFileList.at(ui.iconcomboProfile->currentIndex())); + loadSettings(); +} + +// +// Handle changes of the Filter selection +// +void FaceTrackNoIR::filterSelected(int index) +{ + settingsDirty = true; + + //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) + + ui.btnShowFilterControls->setEnabled ( true ); +} + +// +// Constructor for FaceTrackNoIR=Preferences-dialog +// +PreferencesDialog::PreferencesDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + connect(ui.spinAutoMinimizeTime, SIGNAL(valueChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkAutoStartTracking, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.radioMinimize, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +PreferencesDialog::~PreferencesDialog() { + qDebug() << "~PreferencesDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void PreferencesDialog::doOK() { + save(); + this->close(); +} + +// override show event +void PreferencesDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void PreferencesDialog::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 PreferencesDialog::loadSettings() { + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + ui.spinAutoMinimizeTime->setValue( settings.value ( "AutoMinimizeTime", 0 ).toInt() ); + ui.chkAutoStartTracking->setChecked( settings.value ( "AutoStartTracking", 0 ).toBool() ); + ui.radioMinimize->setChecked( settings.value ( "MinimizeTaskBar", 1 ).toBool() ); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void PreferencesDialog::save() { + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + settings.setValue( "AutoMinimizeTime", ui.spinAutoMinimizeTime->value() ); + settings.setValue( "AutoStartTracking", ui.chkAutoStartTracking->isChecked() ); + settings.setValue( "MinimizeTaskBar", ui.radioMinimize->isChecked() ); + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); + + settingsDirty = false; +} + +//**************************************************************************************************// +//**************************************************************************************************// +// +// Constructor for Keyboard-shortcuts-dialog +// +KeyboardShortcutDialog::KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + connect(ui.cbxCenterKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.cbxCenterMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkCenterShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkCenterCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkCenterAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + connect(ui.cbxGameZeroKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.cbxGameZeroMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkGameZeroShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkGameZeroCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkGameZeroAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + connect(ui.cbxStartStopKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.cbxStartStopMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkStartStopShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkStartStopCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkStartStopAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.radioSetZero, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool))); + connect(ui.radioSetEngineStop, SIGNAL(toggled(bool)), this, SLOT(keyChanged(bool))); + + connect(ui.cbxInhibitKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.cbxInhibitMouseKey, SIGNAL(currentIndexChanged(int)), this, SLOT(keyChanged( int ))); + connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitCtrl, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitAlt, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + // Also add events for the Axis-checkboxes + connect(ui.chkInhibitShift, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitYaw, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitRoll, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitX, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitY, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + connect(ui.chkInhibitZ, SIGNAL(stateChanged(int)), this, SLOT(keyChanged(int))); + + // + // Clear the Lists with key-descriptions and keycodes and build the Lists + // The strings will all be added to the ListBoxes for each Shortkey + // + stringList.clear(); + stringList.append("NONE"); + stringList.append("F1"); + stringList.append("F2"); + stringList.append("F3"); + stringList.append("F4"); + stringList.append("F5"); + stringList.append("F6"); + stringList.append("F7"); + stringList.append("F8"); + stringList.append("F9"); + stringList.append("F10"); + stringList.append("F11"); + stringList.append("F12"); + stringList.append("MINUS"); + stringList.append("EQUALS"); + stringList.append("BACK"); + stringList.append("A"); + stringList.append("B"); + stringList.append("C"); + stringList.append("D"); + stringList.append("E"); + stringList.append("F"); + stringList.append("G"); + stringList.append("H"); + stringList.append("I"); + stringList.append("J"); + stringList.append("K"); + stringList.append("L"); + stringList.append("M"); + stringList.append("N"); + stringList.append("O"); + stringList.append("P"); + stringList.append("Q"); + stringList.append("R"); + stringList.append("S"); + stringList.append("T"); + stringList.append("U"); + stringList.append("V"); + stringList.append("W"); + stringList.append("X"); + stringList.append("Y"); + stringList.append("Z"); + stringList.append("NUMPAD0"); + stringList.append("NUMPAD1"); + stringList.append("NUMPAD2"); + stringList.append("NUMPAD3"); + stringList.append("NUMPAD4"); + stringList.append("NUMPAD5"); + stringList.append("NUMPAD6"); + stringList.append("NUMPAD7"); + stringList.append("NUMPAD8"); + stringList.append("NUMPAD9"); + stringList.append("HOME"); + stringList.append("UP"); + stringList.append("PGUP"); /* PgUp on arrow keypad */ + stringList.append("LEFT"); + stringList.append("RIGHT"); + stringList.append("END"); + stringList.append("DOWN"); + stringList.append("PGDWN"); /* PgDn on arrow keypad */ + stringList.append("INSERT"); + stringList.append("DELETE"); + + keyList.clear(); + keyList.append(0); // NONE = 0 + keyList.append(DIK_F1); + keyList.append(DIK_F2); + keyList.append(DIK_F3); + keyList.append(DIK_F4); + keyList.append(DIK_F5); + keyList.append(DIK_F6); + keyList.append(DIK_F7); + keyList.append(DIK_F8); + keyList.append(DIK_F9); + keyList.append(DIK_F10); + keyList.append(DIK_F11); + keyList.append(DIK_F12); + keyList.append(DIK_MINUS); + keyList.append(DIK_EQUALS); + keyList.append(DIK_BACK); + keyList.append(DIK_A); + keyList.append(DIK_B); + keyList.append(DIK_C); + keyList.append(DIK_D); + keyList.append(DIK_E); + keyList.append(DIK_F); + keyList.append(DIK_G); + keyList.append(DIK_H); + keyList.append(DIK_I); + keyList.append(DIK_J); + keyList.append(DIK_K); + keyList.append(DIK_L); + keyList.append(DIK_M); + keyList.append(DIK_N); + keyList.append(DIK_O); + keyList.append(DIK_P); + keyList.append(DIK_Q); + keyList.append(DIK_R); + keyList.append(DIK_S); + keyList.append(DIK_T); + keyList.append(DIK_U); + keyList.append(DIK_V); + keyList.append(DIK_W); + keyList.append(DIK_X); + keyList.append(DIK_Y); + keyList.append(DIK_Z); + keyList.append(DIK_NUMPAD0); + keyList.append(DIK_NUMPAD1); + keyList.append(DIK_NUMPAD2); + keyList.append(DIK_NUMPAD3); + keyList.append(DIK_NUMPAD4); + keyList.append(DIK_NUMPAD5); + keyList.append(DIK_NUMPAD6); + keyList.append(DIK_NUMPAD7); + keyList.append(DIK_NUMPAD8); + keyList.append(DIK_NUMPAD9); + keyList.append(DIK_HOME); + keyList.append(DIK_UP); + keyList.append(DIK_PRIOR); /* PgUp on arrow keypad */ + keyList.append(DIK_LEFT); + keyList.append(DIK_RIGHT); + keyList.append(DIK_END); + keyList.append(DIK_DOWN); + keyList.append(DIK_NEXT); /* PgDn on arrow keypad */ + keyList.append(DIK_INSERT); + keyList.append(DIK_DELETE); + + // + // Add strings to the Listboxes. + // + for ( int i = 0; i < stringList.size(); i++) { + ui.cbxCenterKey->addItem(stringList.at(i)); + ui.cbxGameZeroKey->addItem(stringList.at(i)); + ui.cbxStartStopKey->addItem(stringList.at(i)); + ui.cbxInhibitKey->addItem(stringList.at(i)); + } + + // + // Clear the Lists with key-descriptions and keycodes and build the Lists + // The strings will all be added to the ListBoxes for each Shortkey + // + stringListMouse.clear(); + stringListMouse.append("NONE"); + stringListMouse.append("LEFT"); + stringListMouse.append("RIGHT"); + stringListMouse.append("MIDDLE"); + stringListMouse.append("BACK"); + stringListMouse.append("FORWARD"); + + // + // Add strings to the Listboxes. + // + for ( int i = 0; i < stringListMouse.size(); i++) { + ui.cbxCenterMouseKey->addItem(stringListMouse.at(i)); + ui.cbxGameZeroMouseKey->addItem(stringListMouse.at(i)); + ui.cbxStartStopMouseKey->addItem(stringListMouse.at(i)); + ui.cbxInhibitMouseKey->addItem(stringListMouse.at(i)); + } + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +KeyboardShortcutDialog::~KeyboardShortcutDialog() { + qDebug() << "~KeyboardShortcutDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void KeyboardShortcutDialog::doOK() { + save(); + this->close(); +} + +// override show event +void KeyboardShortcutDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void KeyboardShortcutDialog::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 KeyboardShortcutDialog::loadSettings() { +int keyindex; + + 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 ( "KB_Shortcuts" ); + + // Center key + ui.cbxCenterMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_Center", 0 ).toInt() ); + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Center", DIK_HOME ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxCenterKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxCenterKey->setCurrentIndex( 0 ); + } + ui.chkCenterShift->setChecked (iniFile.value ( "Shift_Center", 0 ).toBool()); + ui.chkCenterCtrl->setChecked (iniFile.value ( "Ctrl_Center", 0 ).toBool()); + ui.chkCenterAlt->setChecked (iniFile.value ( "Alt_Center", 0 ).toBool()); + ui.chkDisableBeep->setChecked (iniFile.value ( "Disable_Beep", 0 ).toBool()); + + // GameZero key + ui.cbxGameZeroMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_GameZero", 0 ).toInt() ); + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_GameZero", 1 ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxGameZeroKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxGameZeroKey->setCurrentIndex( 0 ); + } + ui.chkGameZeroShift->setChecked (iniFile.value ( "Shift_GameZero", 0 ).toBool()); + ui.chkGameZeroCtrl->setChecked (iniFile.value ( "Ctrl_GameZero", 0 ).toBool()); + ui.chkGameZeroAlt->setChecked (iniFile.value ( "Alt_GameZero", 0 ).toBool()); + + // Start/stop key + ui.cbxStartStopMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_StartStop", 0 ).toInt() ); + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_StartStop", DIK_END ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxStartStopKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxStartStopKey->setCurrentIndex( 0 ); + } + ui.chkStartStopShift->setChecked (iniFile.value ( "Shift_StartStop", 0 ).toBool()); + ui.chkStartStopCtrl->setChecked (iniFile.value ( "Ctrl_StartStop", 0 ).toBool()); + ui.chkStartStopAlt->setChecked (iniFile.value ( "Alt_StartStop", 0 ).toBool()); + ui.radioSetZero->setChecked (iniFile.value ( "SetZero", 1 ).toBool()); + ui.radioSetFreeze->setChecked(!ui.radioSetZero->isChecked()); + ui.radioSetEngineStop->setChecked (iniFile.value ( "SetEngineStop", 1 ).toBool()); + ui.radioSetKeepTracking->setChecked(!ui.radioSetEngineStop->isChecked()); + + // Axis-inhibitor key + ui.cbxInhibitMouseKey->setCurrentIndex( iniFile.value ( "MouseKey_Inhibit", 0 ).toInt() ); + keyindex = keyList.indexOf ( iniFile.value ( "Keycode_Inhibit", 1 ).toInt() ); + if ( keyindex > 0 ) { + ui.cbxInhibitKey->setCurrentIndex( keyindex ); + } + else { + ui.cbxInhibitKey->setCurrentIndex( 0 ); + } + ui.chkInhibitShift->setChecked (iniFile.value ( "Shift_Inhibit", 0 ).toBool()); + ui.chkInhibitCtrl->setChecked (iniFile.value ( "Ctrl_Inhibit", 0 ).toBool()); + ui.chkInhibitAlt->setChecked (iniFile.value ( "Alt_Inhibit", 0 ).toBool()); + + ui.chkInhibitPitch->setChecked (iniFile.value ( "Inhibit_Pitch", 0 ).toBool()); + ui.chkInhibitYaw->setChecked (iniFile.value ( "Inhibit_Yaw", 0 ).toBool()); + ui.chkInhibitRoll->setChecked (iniFile.value ( "Inhibit_Roll", 0 ).toBool()); + ui.chkInhibitX->setChecked (iniFile.value ( "Inhibit_X", 0 ).toBool()); + ui.chkInhibitY->setChecked (iniFile.value ( "Inhibit_Y", 0 ).toBool()); + ui.chkInhibitZ->setChecked (iniFile.value ( "Inhibit_Z", 0 ).toBool()); + + + // Reverse Axis + ui.chkEnableReverseAxis->setChecked (iniFile.value ( "Enable_ReverseAxis", 0 ).toBool()); + ui.spinYawAngle4ReverseAxis->setValue( iniFile.value ( "RA_Yaw", 40 ).toInt() ); + ui.spinZ_Pos4ReverseAxis->setValue( iniFile.value ( "RA_ZPos", -20 ).toInt() ); + ui.spinZ_PosWhenReverseAxis->setValue( iniFile.value ( "RA_ToZPos", 50 ).toInt() ); + + iniFile.endGroup (); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void KeyboardShortcutDialog::save() { + + qDebug() << "save() says: started"; + + 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 ( "KB_Shortcuts" ); + iniFile.setValue ( "MouseKey_Center", ui.cbxCenterMouseKey->currentIndex()); + iniFile.setValue ( "Keycode_Center", keyList.at( ui.cbxCenterKey->currentIndex() ) ); + iniFile.setValue ( "Shift_Center", ui.chkCenterShift->isChecked() ); + iniFile.setValue ( "Ctrl_Center", ui.chkCenterCtrl->isChecked() ); + iniFile.setValue ( "Alt_Center", ui.chkCenterAlt->isChecked() ); + iniFile.setValue ( "Disable_Beep", ui.chkDisableBeep->isChecked() ); + + iniFile.setValue ( "MouseKey_GameZero", ui.cbxGameZeroMouseKey->currentIndex()); + iniFile.setValue ( "Keycode_GameZero", keyList.at( ui.cbxGameZeroKey->currentIndex() ) ); + iniFile.setValue ( "Shift_GameZero", ui.chkGameZeroShift->isChecked() ); + iniFile.setValue ( "Ctrl_GameZero", ui.chkGameZeroCtrl->isChecked() ); + iniFile.setValue ( "Alt_GameZero", ui.chkGameZeroAlt->isChecked() ); + + iniFile.setValue ( "MouseKey_StartStop", ui.cbxStartStopMouseKey->currentIndex()); + iniFile.setValue ( "Keycode_StartStop", keyList.at( ui.cbxStartStopKey->currentIndex() ) ); + iniFile.setValue ( "Shift_StartStop", ui.chkStartStopShift->isChecked() ); + iniFile.setValue ( "Ctrl_StartStop", ui.chkStartStopCtrl->isChecked() ); + iniFile.setValue ( "Alt_StartStop", ui.chkStartStopAlt->isChecked() ); + iniFile.setValue ( "SetZero", ui.radioSetZero->isChecked() ); + iniFile.setValue ( "SetEngineStop", ui.radioSetEngineStop->isChecked() ); + + iniFile.setValue ( "MouseKey_Inhibit", ui.cbxInhibitMouseKey->currentIndex()); + iniFile.setValue ( "Keycode_Inhibit", keyList.at( ui.cbxInhibitKey->currentIndex() ) ); + iniFile.setValue ( "Shift_Inhibit", ui.chkInhibitShift->isChecked() ); + iniFile.setValue ( "Ctrl_Inhibit", ui.chkInhibitCtrl->isChecked() ); + iniFile.setValue ( "Alt_Inhibit", ui.chkInhibitAlt->isChecked() ); + + iniFile.setValue ( "Inhibit_Pitch", ui.chkInhibitPitch->isChecked() ); + iniFile.setValue ( "Inhibit_Yaw", ui.chkInhibitYaw->isChecked() ); + iniFile.setValue ( "Inhibit_Roll", ui.chkInhibitRoll->isChecked() ); + iniFile.setValue ( "Inhibit_X", ui.chkInhibitX->isChecked() ); + iniFile.setValue ( "Inhibit_Y", ui.chkInhibitY->isChecked() ); + iniFile.setValue ( "Inhibit_Z", ui.chkInhibitZ->isChecked() ); + + // Reverse Axis + iniFile.setValue ( "Enable_ReverseAxis", ui.chkEnableReverseAxis->isChecked() ); + iniFile.setValue( "RA_Yaw", ui.spinYawAngle4ReverseAxis->value() ); + iniFile.setValue( "RA_ZPos", ui.spinZ_Pos4ReverseAxis->value() ); + iniFile.setValue( "RA_ToZPos", ui.spinZ_PosWhenReverseAxis->value() ); + + iniFile.endGroup (); + + settingsDirty = false; + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); +} + +//**************************************************************************************************// +//**************************************************************************************************// +// +// Constructor for Curve-configuration-dialog +// +CurveConfigurationDialog::CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent, Qt::WindowFlags f ) : +QWidget( parent , f) +{ + ui.setupUi( this ); + + QPoint offsetpos(120, 30); + this->move(parent->pos() + offsetpos); + + mainApp = ftnoir; // Preserve a pointer to FTNoIR + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); // Registry settings (in HK_USER) + QString currentFile = settings.value ( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + + ui.qFunctionX->setConfig(Tracker::X.curvePtr, currentFile); + connect(ui.qFunctionX, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionY->setConfig(Tracker::Y.curvePtr, currentFile); + connect(ui.qFunctionY, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionZ->setConfig(Tracker::Z.curvePtr, currentFile); + connect(ui.qFunctionZ, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + + ui.qFunctionYaw->setConfig(Tracker::Yaw.curvePtr, currentFile); + connect(ui.qFunctionYaw, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + // + // There are 2 curves for Pitch: Up and Down. Users have indicated that, to be able to use visual Flight controls, it is necessary to have a 'slow' curve for Down... + // + ui.qFunctionPitch->setConfig(Tracker::Pitch.curvePtr, currentFile); + connect(ui.qFunctionPitch, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + ui.qFunctionPitchDown->setConfig(Tracker::Pitch.curvePtrAlt, currentFile); + connect(ui.qFunctionPitchDown, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + + ui.qFunctionRoll->setConfig(Tracker::Roll.curvePtr, currentFile); + connect(ui.qFunctionRoll, SIGNAL(CurveChanged(bool)), this, SLOT(curveChanged(bool))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +CurveConfigurationDialog::~CurveConfigurationDialog() { + qDebug() << "~CurveConfigurationDialog() says: started"; +} + +// +// OK clicked on server-dialog +// +void CurveConfigurationDialog::doOK() { + save(); + this->close(); +} + +// override show event +void CurveConfigurationDialog::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void CurveConfigurationDialog::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 CurveConfigurationDialog::loadSettings() { +int NeutralZone; +int sensYaw, sensPitch, sensRoll; +int sensX, sensY, sensZ; + + 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 ( "Tracking" ); + NeutralZone = iniFile.value ( "NeutralZone", 5 ).toInt(); + sensYaw = iniFile.value ( "sensYaw", 100 ).toInt(); + sensPitch = iniFile.value ( "sensPitch", 100 ).toInt(); + sensRoll = iniFile.value ( "sensRoll", 100 ).toInt(); + sensX = iniFile.value ( "sensX", 100 ).toInt(); + sensY = iniFile.value ( "sensY", 100 ).toInt(); + sensZ = iniFile.value ( "sensZ", 100 ).toInt(); + + iniFile.endGroup (); + + ui.qFunctionYaw->loadSettings(currentFile); + ui.qFunctionPitch->loadSettings(currentFile); + ui.qFunctionPitchDown->loadSettings(currentFile); + ui.qFunctionRoll->loadSettings(currentFile); + + settingsDirty = false; + +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void CurveConfigurationDialog::save() { + + qDebug() << "save() says: started"; + + 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) + + ui.qFunctionYaw->saveSettings(currentFile); + ui.qFunctionPitch->saveSettings(currentFile); + ui.qFunctionPitchDown->saveSettings(currentFile); + ui.qFunctionRoll->saveSettings(currentFile); + + ui.qFunctionX->saveSettings(currentFile); + ui.qFunctionY->saveSettings(currentFile); + ui.qFunctionZ->saveSettings(currentFile); + + settingsDirty = false; + + // + // Send a message to the main program, to update the Settings (for the tracker) + // + mainApp->updateSettings(); +} diff --git a/facetracknoir/FaceTrackNoIR.h b/facetracknoir/FaceTrackNoIR.h new file mode 100644 index 00000000..756b5867 --- /dev/null +++ b/facetracknoir/FaceTrackNoIR.h @@ -0,0 +1,249 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#ifndef FaceTrackNoIR_H +#define FaceTrackNoIR_H + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "../FTNoIR_PoseWidget/glwidget.h" + +#include "ui_FaceTrackNoIR.h" +#include "ui_FTNoIR_KeyboardShortcuts.h" +#include "ui_FTNoIR_Preferences.h" +#include "ui_FTNoIR_Curves.h" + +#include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h" +#include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h" +#include "..\ftnoir_filter_base\FTNoIR_Filter_base.h" + +typedef ITrackerDialogPtr (WINAPI *importGetTrackerDialog)(void); +typedef ITrackerDllPtr (WINAPI *importGetTrackerDll)(void); +typedef IProtocolDialogPtr (WINAPI *importGetProtocolDialog)(void); +typedef IProtocolDllPtr (WINAPI *importGetProtocolDll)(void); +typedef IFilterDialogPtr (WINAPI *importGetFilterDialog)(void); +typedef IFilterDllPtr (WINAPI *importGetFilterDll)(void); + +#include + +class Tracker; // pre-define class to avoid circular includes + +class FaceTrackNoIR : public QMainWindow +{ + Q_OBJECT + +public: + FaceTrackNoIR(QWidget *parent = 0, Qt::WFlags flags = 0); + ~FaceTrackNoIR(); + + void getGameProgramName(); // Get the ProgramName from the game and display it. + 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 getCurrentProtocolName(); // Get the name of the selected protocol + QString getCurrentFilterName(); // Get the name of the selected filter + QString getCurrentTrackerName(); // Get the name of the selected face-tracker + QString getSecondTrackerName(); // Get the name of the second face-tracker ("None" if no selection) + +private: + Ui::FaceTrackNoIRClass ui; + Tracker *tracker; + QTimer *timMinimizeFTN; // Timer to Auto-minimize + QTimer *timUpdateHeadPose; // Timer to display headpose + QStringList iniFileList; // List of INI-files, that are present in the Settings folder + QStringList protocolFileList; // List of Protocol-DLL-files, that are present in the program-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) + ITrackerDialogPtr pSecondTrackerDialog; // Pointer to the second Tracker dialog instance (in DLL) + IProtocolDialogPtr pProtocolDialog; // Pointer to Protocol dialog instance (in DLL) + IFilterDialogPtr pFilterDialog; // Pointer to Filter dialog instance (in DLL) + + /** Widget variables **/ + QVBoxLayout *l; + QWidget *_preferences; + QWidget *_keyboard_shortcuts; + QWidget *_curve_config; + GLWidget *_pose_display; + + /** QT objects **/ + QDialog aboutDialog; + QDesktopWidget desktop; + + QAction *minimizeAction; + QAction *restoreAction; + QAction *quitAction; + + QSystemTrayIcon *trayIcon; + QMenu *trayIconMenu; + + void createIconGroupBox(); +// void createMessageGroupBox(); + void createActions(); + void createTrayIcon(); + + /** helper **/ + bool cameraDetected; + bool settingsDirty; + + void GetCameraNameDX(); + void loadSettings(); + void setupFaceTrackNoIR(); + + private slots: + //file menu + void open(); + void save(); + void saveAs(); + void exit(); + + //about menu + void openurl_support(); + void openurl_donation(); + void about(); + +// void setIcon(int index); + void iconActivated(QSystemTrayIcon::ActivationReason reason); + void profileSelected(int index); + void protocolSelected(int index); + void filterSelected(int index); + void trackingSourceSelected(int index); + + void showVideoWidget(); + void showHeadPoseWidget(); + void showTrackerSettings(); + void showSecondTrackerSettings(); + + void showServerControls(); + void showFilterControls(); + void showPreferences(); + void showKeyboardShortcuts(); + void showCurveConfiguration(); + + void setInvertYaw( int invert ); + void setInvertPitch( int invert ); + void setInvertRoll( int invert ); + void setInvertX( int invert ); + void setInvertY( int invert ); + void setInvertZ( int invert ); + + void showHeadPose(); + + //smoothing slider + void setSmoothing( int smooth ); + + void startTracker(); + void stopTracker(); +}; + +// Widget that has controls for FaceTrackNoIR Preferences. +class PreferencesDialog: public QWidget, public Ui::UICPreferencesDialog +{ + Q_OBJECT +public: + + explicit PreferencesDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~PreferencesDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICPreferencesDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FaceTrackNoIR *mainApp; + +private slots: + void doOK(); + void doCancel(); + void keyChanged( int index ) { settingsDirty = true; }; +}; + +// Widget that has controls for Keyboard shortcuts. +class KeyboardShortcutDialog: public QWidget, public Ui::UICKeyboardShortcutDialog +{ + Q_OBJECT +public: + + explicit KeyboardShortcutDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~KeyboardShortcutDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICKeyboardShortcutDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FaceTrackNoIR *mainApp; + QList stringList; // List of strings, that describe the keyboard-keys + QList keyList; // List of keys, with the values of the keyboard-keys + QList stringListMouse; // List of strings, that describe the mouse-keys + +private slots: + void doOK(); + void doCancel(); + void keyChanged( int index ) { settingsDirty = true; }; + void keyChanged( bool index ) { settingsDirty = true; }; +}; + +// Widget that has controls for Keyboard shortcuts. +class CurveConfigurationDialog: public QWidget, public Ui::UICCurveConfigurationDialog +{ + Q_OBJECT +public: + + explicit CurveConfigurationDialog( FaceTrackNoIR *ftnoir, QWidget *parent=0, Qt::WindowFlags f=0 ); + virtual ~CurveConfigurationDialog(); + void showEvent ( QShowEvent * event ); + +private: + Ui::UICCurveConfigurationDialog ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FaceTrackNoIR *mainApp; + +private slots: + void doOK(); + void doCancel(); + void curveChanged( bool change ) { settingsDirty = true; }; +}; + + +#endif // FaceTrackNoIR_H diff --git a/facetracknoir/FaceTrackNoIR.ico b/facetracknoir/FaceTrackNoIR.ico new file mode 100644 index 00000000..5115066c Binary files /dev/null and b/facetracknoir/FaceTrackNoIR.ico differ diff --git a/facetracknoir/FaceTrackNoIR.qrc b/facetracknoir/FaceTrackNoIR.qrc new file mode 100644 index 00000000..60e4da7b --- /dev/null +++ b/facetracknoir/FaceTrackNoIR.qrc @@ -0,0 +1,14 @@ + + + UIElements/Tools.png + images/Settings16.png + images/SettingsOpen16.png + UIElements/Donate.png + UIElements/Curves.png + images/rotation_DOFs.png + images/translation_DOFs.png + images/330px-6DOF_en.png + images/FaceTrackNoIR.ico + UIElements/aboutFaceTrackNoIR.png + + diff --git a/facetracknoir/FaceTrackNoIR.rc b/facetracknoir/FaceTrackNoIR.rc new file mode 100644 index 00000000..ed8a68c1 --- /dev/null +++ b/facetracknoir/FaceTrackNoIR.rc @@ -0,0 +1,84 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Dutch (Neutral) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) +#ifdef _WIN32 +LANGUAGE LANG_DUTCH, SUBLANG_NEUTRAL +#pragma code_page(1252) +#endif //_WIN32 + +///////////////////////////////////////////////////////////////////////////// +// +// Icon +// + +// Icon with lowest ID value placed first to ensure application icon +// remains consistent on all systems. +IDI_ICON1 ICON "FaceTrackNoIR.ico" +#endif // Dutch (Neutral) resources +///////////////////////////////////////////////////////////////////////////// + + +///////////////////////////////////////////////////////////////////////////// +// German (Germany) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_DEU) +#ifdef _WIN32 +LANGUAGE LANG_GERMAN, SUBLANG_GERMAN +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // German (Germany) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/facetracknoir/FaceTrackNoIR.ui b/facetracknoir/FaceTrackNoIR.ui new file mode 100644 index 00000000..8c3db4a4 --- /dev/null +++ b/facetracknoir/FaceTrackNoIR.ui @@ -0,0 +1,2375 @@ + + + WVR + FaceTrackNoIRClass + + + Qt::NonModal + + + + 0 + 0 + 925 + 415 + + + + + 0 + 0 + + + + + 0 + 415 + + + + + 16777215 + 415 + + + + Qt::DefaultContextMenu + + + FaceTrackNoIR + + + + UIElements/FaceTrackNoIR.icoUIElements/FaceTrackNoIR.ico + + + + + + /* Customize any plain widget that is a child of a QMainWindow. */ +QMainWindow > .QWidget { + background-color: rgb(100, 100, 100); +} + +/* Set the selection colors for all widgets. */ +QWidget { + selection-color: black; + selection-background-color: Silver; + color: black; +} + +/* Specials for individual widget(s) */ +QWidget#widget { +/* background-color: #484848;*/ + background-color: #595959; + border-left: 1px solid #000; +} + +/* Specials for individual widget(s) */ +QWidget#widget4logo { + background-color: #000000; +} + +/* Specials for individual widget(s) */ +QWidget#headPoseWidget { + background-color: #595959; +} + +QWidget#widget4video { +/* background-color: #595959;*/ +} + +QWidget#Leftwidget { + background-color: ; +} + +QWidget#widgetTop { + background-color: #595959; + border-bottom: 1px solid #000; +} + +/* Make text in message boxes selectable. */ +QMessageBox { + /* LinksAccessibleByMouse | TextSelectableByMouse */ + messagebox-text-interaction-flags: 5; +} + +/* Make the entire row selected in item views. */ +QAbstractItemView { + show-decoration-selected: 1; +} + +/* Nice WindowsXP-style password character for password line edits. */ +QLineEdit[echoMode="2"] { + lineedit-password-character: 9679; +} + +/* Customize tooltips. */ +QToolTip { + background-color: rgb(170, 255, 127); + opacity: 200; +} + +/* Customize push buttons and comboboxes. Our read-only combobox + is very similar to a push button, so they share the same border image. */ + +QPushButton { + min-width: 4em; +} + +QCheckBox { + background:none; +} + +QPushButton:disabled { + color: rgb(128, 128, 128); +} + +QGroupBox { + color: rgb(255, 255, 255); +} + + + + + + Qt::ToolButtonIconOnly + + + true + + + + + 925 + 350 + + + + + + + + 0 + + + 0 + + + + + 0 + + + + + 0 + + + 0 + + + 6 + + + + + + 250 + 170 + + + + + + 0 + 0 + 250 + 170 + + + + + 250 + 150 + + + + + 500 + 500 + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + 0 + 90 + + + + + 16777215 + 90 + + + + + + 100 + 1 + 145 + 34 + + + + PointingHandCursor + + + Please help us: make gaming fun... + + + Click here to +Support FaceTrackNoIR! + + + + :/UIElements/Donate.png:/UIElements/Donate.png + + + + 18 + 18 + + + + + + + 196 + 34 + 50 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 5 + + + QLCDNumber::Flat + + + + + + 196 + 52 + 50 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 5 + + + QLCDNumber::Flat + + + + + + 196 + 70 + 50 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 5 + + + QLCDNumber::Flat + + + + + + 112 + 34 + 50 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 5 + + + QLCDNumber::Flat + + + + + + 112 + 52 + 50 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 5 + + + QLCDNumber::Flat + + + + + + 112 + 70 + 50 + 21 + + + + false + + + color: rgb(0, 255, 0); + + + QFrame::NoFrame + + + QFrame::Raised + + + 5 + + + QLCDNumber::Flat + + + + + + 104 + 35 + 16 + 16 + + + + color: rgb(0, 255, 0); + + + X + + + + + + 105 + 55 + 16 + 16 + + + + color: rgb(0, 255, 0); + + + Y + + + + + + 105 + 74 + 16 + 16 + + + + color: rgb(0, 255, 0); + + + Z + + + + + + 164 + 74 + 20 + 16 + + + + color: rgb(0, 255, 0); + + + roll + + + + + + 166 + 35 + 20 + 16 + + + + color: rgb(0, 255, 0); + + + yaw + + + + + + 164 + 55 + 25 + 16 + + + + color: rgb(0, 255, 0); + + + pitch + + + + + + + + + + + 0 + 160 + + + + + 16777215 + 160 + + + + + + + + + 10 + 60 + 231 + 80 + + + + Raw Input + + + true + + + + + 150 + 60 + 71 + 21 + + + + QFrame::NoFrame + + + 6 + + + + + + 150 + 20 + 71 + 21 + + + + QFrame::NoFrame + + + 6 + + + + + + 10 + 20 + 21 + 16 + + + + border:none; +color:white + + + X + + + + + + 10 + 40 + 21 + 16 + + + + border:none; +color:white; + + + Y + + + + + + 30 + 60 + 61 + 21 + + + + QFrame::NoFrame + + + + + + 10 + 60 + 21 + 16 + + + + color:white; +border:none; + + + Z + + + + + + 30 + 40 + 61 + 21 + + + + QFrame::NoFrame + + + + + + 108 + 58 + 31 + 20 + + + + border:none; +color:white; + + + roll + + + + + + 109 + 38 + 31 + 20 + + + + color:white; +border:none; + + + pitch + + + + + + 108 + 18 + 31 + 20 + + + + border:none; +color:white; + + + yaw + + + + + + 150 + 40 + 71 + 21 + + + + QFrame::NoFrame + + + 6 + + + + + + 30 + 20 + 61 + 21 + + + + QFrame::NoFrame + + + 5 + + + + + + + 10 + 10 + 231 + 50 + + + + Status + + + true + + + + + 110 + 10 + 101 + 16 + + + + border:none; +color: rgb(0, 255, 0); + + + Tracking + + + + + + 110 + 30 + 101 + 16 + + + + border:none; +color: rgb(0, 255, 0); + + + Axis Reverse + + + + + + + + + + + true + + + + 0 + 0 + + + + + 400 + 300 + + + + + + + + + 0 + 0 + 0 + + + + + + + 89 + 89 + 89 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 89 + 89 + 89 + + + + + + + 89 + 89 + 89 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 72 + 72 + 72 + + + + + + + + + 0 + 0 + 0 + + + + + + + 89 + 89 + 89 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 89 + 89 + 89 + + + + + + + 89 + 89 + 89 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 72 + 72 + 72 + + + + + + + + + 0 + 0 + 0 + + + + + + + 89 + 89 + 89 + + + + + + + 0 + 0 + 0 + + + + + + + 0 + 0 + 0 + + + + + + + 89 + 89 + 89 + + + + + + + 89 + 89 + 89 + + + + + + + 192 + 192 + 192 + + + + + + + 0 + 0 + 0 + + + + + + + 72 + 72 + 72 + + + + + + + + false + + + + + + + + + + + + + + 10 + + + 10 + + + + + + 206 + 120 + + + + + 210 + 120 + + + + Profile + + + + + 10 + 20 + 180 + 22 + + + + + + + -1 + + + 10 + + + + + true + + + + 10 + 80 + 180 + 23 + + + + Save the INI-file under another name + + + + + + Save As ... + + + + + + 10 + 50 + 81 + 23 + + + + Load an INI-file from a folder + + + + + + Load + + + + + true + + + + 110 + 50 + 81 + 23 + + + + Save the current INI-file + + + + + + Save + + + + + + + + + 420 + 120 + + + + + 16777215 + 120 + + + + Global Settings + + + + + 9 + 20 + 171 + 80 + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#ccc; +background:none; + + + Smoothing: + + + + + + + color:#ccc; +background:none; + + + (samples) + + + + + + + + 50 + 15 + + + + 1 + + + 50 + + + 5 + + + 10 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 35 + 22 + + + + background:none; + + + 1 + + + 50 + + + 10 + + + + + + + + + 190 + 20 + 211 + 81 + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + Qt::RightToLeft + + + color:#ccc; +background:none; + + + Roll + + + + + + + background:none; + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + Qt::RightToLeft + + + color:#ccc; +background:none; + + + Z + + + + + + + background:none; + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + Qt::RightToLeft + + + color:#ccc; +background:none; + + + Pitch + + + + + + + background:none; + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + Qt::RightToLeft + + + color:#ccc; +background:none; + + + Y + + + + + + + background:none; + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + Qt::RightToLeft + + + color:#ccc; +background:none; + + + Yaw + + + + + + + background:none; + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + Qt::RightToLeft + + + color:#ccc; +background:none; + + + X + + + + + + + background:none; + + + + + + + + + + + 0 + 0 + + + + + 30 + 16777215 + + + + color:#ccc; +background:none; + + + Invert + + + + + + + + 0 + 0 + + + + + 30 + 16777215 + + + + color:#ccc; +background:none; + + + Invert + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 500 + 67 + + + + + 700 + 67 + + + + true + + + background: url("UIElements/bubble_1_small.png") no-repeat; +opacity:100; + + + + 0 + + + 15 + + + 10 + + + 10 + + + 10 + + + + + + + + + + 400 + 25 + + + + + 600 + 30 + + + + color:#ccc; +background:none; + + + Camera Name + + + + + + + + 400 + 20 + + + + + 600 + 30 + + + + color:#ccc; +background:none; + + + Game Name + + + + + + + + + + + + + + + + 10 + + + 6 + + + + + + 200 + 80 + + + + + 200 + 80 + + + + + + + Tracker Source(1st = Master) + + + + + 10 + 20 + 180 + 22 + + + + + + + -1 + + + 5 + + + + + true + + + + 10 + 50 + 180 + 23 + + + + Change tracker settings + + + + + + Settings + + + + + + + + + 200 + 70 + + + + + 200 + 80 + + + + + + + Filter + + + + + 10 + 20 + 180 + 22 + + + + + + + -1 + + + 7 + + + + + true + + + + 10 + 50 + 180 + 23 + + + + Change game protocol settings + + + + + + Settings + + + + + + + + + 200 + 80 + + + + + 200 + 80 + + + + + + + Game protocol + + + + + 10 + 20 + 180 + 22 + + + + + + + -1 + + + 7 + + + + + true + + + + 10 + 50 + 180 + 23 + + + + Change game protocol settings + + + + + + Settings + + + + + + + + + 200 + 80 + + + + + 16777215 + 80 + + + + GO! + + + + + 10 + 20 + 81 + 23 + + + + Start the Tracker + + + + + + Start + + + + + false + + + + 100 + 20 + 81 + 23 + + + + Stop the Tracker + + + + + + Stop + + + + + + + + + 200 + 80 + + + + + 200 + 80 + + + + Tracker Source (2nd) + + + + true + + + + 10 + 50 + 180 + 23 + + + + Change tracker settings + + + + + + Settings + + + + + + 10 + 20 + 180 + 22 + + + + + + + -1 + + + 5 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 52 + 38 + + + + + 200 + 16777215 + + + + PointingHandCursor + + + Edit the Keyboard and mouse shortcuts + + + Shortkeys + + + + :/UIElements/Tools.png:/UIElements/Tools.png + + + + 24 + 24 + + + + + + + + + 52 + 38 + + + + + 200 + 16777215 + + + + PointingHandCursor + + + Edit the Curve settings + + + Qt::LeftToRight + + + background:none; + + + Curves + + + + :/UIElements/Curves.png:/UIElements/Curves.png + + + + 120 + 24 + + + + + + + + + + + + + + + + + + + + + 0 + 0 + 925 + 21 + + + + b + + + + File + + + + + + + + + + View + + + + + + Options + + + + + + + + + Help + + + + + + + + + + + + + + &Open + + + Ctrl+O + + + false + + + + + &Exit + + + Ctrl+Q + + + QAction::QuitRole + + + false + + + + + true + + + Play / Pause + + + false + + + + + Next + + + Ctrl+. + + + false + + + + + Previews + + + Ctrl+, + + + false + + + + + Volume Up + + + Ctrl++ + + + false + + + + + Volume Down + + + Ctrl+- + + + false + + + + + true + + + true + + + Video Widget + + + Ctrl+V + + + + + true + + + HeadPose Widget + + + Ctrl+W + + + + + About FaceTrackNoIR + + + Ctrl+A + + + + + true + + + Mute + + + Ctrl+M + + + + + Save + + + + + Save As + + + + + Keyboard and Mouse Shortcuts + + + + + Preferences + + + + + Curve Configuration + + + + + Support + + + + + Your Support + + + + + + iconcomboTrackerSource + btnStartTracker + btnStopTracker + btnShowEngineControls + iconcomboProtocol + + + + + + + slideSmoothing + valueChanged(int) + spinSmoothing + setValue(int) + + + 442 + 387 + + + 494 + 389 + + + + + spinSmoothing + valueChanged(int) + slideSmoothing + setValue(int) + + + 494 + 389 + + + 442 + 387 + + + + + diff --git a/facetracknoir/FaceTrackNoIR_vc8.vcproj b/facetracknoir/FaceTrackNoIR_vc8.vcproj new file mode 100644 index 00000000..524e7826 --- /dev/null +++ b/facetracknoir/FaceTrackNoIR_vc8.vcproj @@ -0,0 +1,892 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/facetracknoir/FaceTrackNoIR_vc9.vcproj b/facetracknoir/FaceTrackNoIR_vc9.vcproj new file mode 100644 index 00000000..56b5e1d5 --- /dev/null +++ b/facetracknoir/FaceTrackNoIR_vc9.vcproj @@ -0,0 +1,886 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/facetracknoir/Readme.txt b/facetracknoir/Readme.txt new file mode 100644 index 00000000..8bd28966 --- /dev/null +++ b/facetracknoir/Readme.txt @@ -0,0 +1,31 @@ +FaceTrackNoIR (v. 1.6.0). + +FaceTrackNoIR is a head-tracker, which uses the FaceAPI provided by SeeingMachines. It was made using Visual Studio 2005 and Qt. +The major advantage over other headtrackers is, that it uses a simple webcam to track the face of 'the gamer'. There is no need +for expensive equipment or even Borg-like devices with LED's and such. + + +Installation: +To install the program, simply start Setup.exe and follow the directions. Use the desktop-icon to start FaceTrackNoIR. + +Compatibility: +FaceTrackNoIR is made for Windows and tested on XP, Vista and Windows7. The FaceAPI creators recommend a dual-core processor or better. +Because the 'non-commercial' version of the FaceAPI is used, the webcam can not be 'chosen': it always uses the first webcam it finds! When FaceTrackNoIR is started, the name of this webcam is displayed. + + +Games: +FaceTrackNoIR supports several protocols, so it can be used with several games, flight-sims and other. Check out the website for a +list: http://facetracknoir.sourceforge.net/compatibility/games.htm + +Visit the website for the latest info! + + +Please let us know if you like the program, if you have ideas for improvements or any questions you might have. +The source is also available! + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks +and others... diff --git a/facetracknoir/Readme_Update_20100615.txt b/facetracknoir/Readme_Update_20100615.txt new file mode 100644 index 00000000..e43d954c --- /dev/null +++ b/facetracknoir/Readme_Update_20100615.txt @@ -0,0 +1,51 @@ +FaceTrackNoIR (v. 20100615). + +From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep +improving FaceTrackNoIR... + +Installation: +Unzip the .exe to the installation folder of FaceTrackNoIR (best rename the old .exe first). The folders in the ZIP-file +contain support info and examples of a .INI-file (IL-2) and a script for GlovePIE. + + +The following upgrades have been applied: + +- ‘=’ is center view + +- ‘BACKSPACE’ = start (+center)/stop tracking. A messagebeep is generated when tracking is resumed and the + headpose-data is valid again (faceAPI has 'locked on'... ). + +- Checkbox ‘use EWMA filter’: Ticking this checkbox will make FaceTrackNoIR filter the headpose data with + a so-called 'Exponentially Weighed Moving Average'. This technique was adopted from FlightGear, where + Melchior Franz had 'invented' it. + If the filter is active, the factor for each of the 6 DOF's are used. These factors determine the weight that is + given to previous measurements and goes from 0 - 1 (in the GUI this setting is 0 - 100). A lower value will give a quicker response (but less stable). + + Remark: for FlightGear, the EWMA checkbox does nothing: the filter is embedded in the FlightGear script. + +- Some timing-issues with the faceAPI were resolved, so now the scanning-frequency can be higher that 20Hz. + We do not know yet, how this influences performance of both FaceTrackNoIR and your CPU. Experience learns, that + the headtracking is influenced by many factors, like CPU, video-card, framerate of the game etc. + +- The protocol-server that is selected in the combobox is now the only one that is started, when the tracker is started. + Before loading an .INI-file, please stop the tracker. + +- PPJoy support is added, so now FaceTrackNoIR can be used for other games too. We tested this feature with IL-2, + using GlovePIE to generate TrackIR data. Check out the files in the ZIP-file for instructions. PPjoy was created by + Deon van der Westhuysen and GlovePIE by Carl Kenner. We thank them both for their effort! + + + +Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge +(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. + +If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive +examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + diff --git a/facetracknoir/Readme_Update_20100716.txt b/facetracknoir/Readme_Update_20100716.txt new file mode 100644 index 00000000..e99111a1 --- /dev/null +++ b/facetracknoir/Readme_Update_20100716.txt @@ -0,0 +1,35 @@ +FaceTrackNoIR (v. 20100716). + +From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep +improving FaceTrackNoIR... + +Installation: +Unzip the .exe and .dll to the installation folder of FaceTrackNoIR (best rename the old .exe first). The folders in the ZIP-file contain icons for the protocols and an .INI-file (FreeFalcon). Extract these to the folder 'Settings' and 'Images'. + + +The following upgrades have been applied: + +- TrackIR support is added. Start FaceTrackNoIR and the TrackIR-protocol before starting the game (at least once).. + A registry-entry is added/changed, that the game or flightsim needs. + +Hints from the previous update: +- ‘=’ is center view + +- ‘BACKSPACE’ = start (+center)/stop tracking. A messagebeep is generated when tracking is resumed and the + headpose-data is valid again (faceAPI has 'locked on'... ). + + + +Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge +(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. + +If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive +examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + diff --git a/facetracknoir/Readme_Update_20100822.txt b/facetracknoir/Readme_Update_20100822.txt new file mode 100644 index 00000000..e121fe9f --- /dev/null +++ b/facetracknoir/Readme_Update_20100822.txt @@ -0,0 +1,32 @@ +FaceTrackNoIR (v. 20100822). + +From various users we received requests for improvements and features. If you keep sending us your ideas, we can keep +improving FaceTrackNoIR... + +Installation: +Unzip all files to the installation folder of FaceTrackNoIR (typicaly c:\program files\abbequerque inc\facetracknoir\): overwrite files when asked. + + +The following upgrades have been applied: + +- The program-menu now contains a Tools menu. Via this menu the program preferences and keyboard shortcuts can be modified. + +- The preferences dialog contains the 'Auto-minimize' setting: FaceTrackNoIR will minimize x sec. after starting the face-tracker. + Entering 0 will disable auto-minimize. This setting is global, for all INI-files. + +- The keyboard shortcuts for 'center' and 'start/stop' can be assigned here. These settings are stored in the INI-file. + + +Please let us know what you think of our little gadget. Posts can be made on the FaceTrackNoIR forum on SourceForge +(http://sourceforge.net/projects/facetracknoir/forums/forum/1150910) or on the various game-forums. + +If anyone has used FaceTrackNoIR successfully with other games, please let us know. If you can, we would also like to receive +examples of the .INI-file you used for that and maybe settings of other utilities needed. Thanks! + + + +The FaceTrackNoIR team: + +Wim Vriend +Ron Hendriks + diff --git a/facetracknoir/UIElements/ButtonIcoBlack.bmp b/facetracknoir/UIElements/ButtonIcoBlack.bmp new file mode 100644 index 00000000..9bc402aa Binary files /dev/null and b/facetracknoir/UIElements/ButtonIcoBlack.bmp differ diff --git a/facetracknoir/UIElements/Curves.png b/facetracknoir/UIElements/Curves.png new file mode 100644 index 00000000..fe21fa15 Binary files /dev/null and b/facetracknoir/UIElements/Curves.png differ diff --git a/facetracknoir/UIElements/Donate.png b/facetracknoir/UIElements/Donate.png new file mode 100644 index 00000000..cf4223fb Binary files /dev/null and b/facetracknoir/UIElements/Donate.png differ diff --git a/facetracknoir/UIElements/FaceTrackNoIR.ico b/facetracknoir/UIElements/FaceTrackNoIR.ico new file mode 100644 index 00000000..af36ec30 Binary files /dev/null and b/facetracknoir/UIElements/FaceTrackNoIR.ico differ diff --git a/facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.jpg b/facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.jpg new file mode 100644 index 00000000..73ead853 Binary files /dev/null and b/facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.jpg differ diff --git a/facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.png b/facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.png new file mode 100644 index 00000000..c4e63c76 Binary files /dev/null and b/facetracknoir/UIElements/Logo_FaceTrackNoIR_32px.png differ diff --git a/facetracknoir/UIElements/Logo_NoIR.png b/facetracknoir/UIElements/Logo_NoIR.png new file mode 100644 index 00000000..bb654a07 Binary files /dev/null and b/facetracknoir/UIElements/Logo_NoIR.png differ diff --git a/facetracknoir/UIElements/Logo_NoIR_small.png b/facetracknoir/UIElements/Logo_NoIR_small.png new file mode 100644 index 00000000..5d49e0b1 Binary files /dev/null and b/facetracknoir/UIElements/Logo_NoIR_small.png differ diff --git a/facetracknoir/UIElements/Logo_NoIR_small_target.png b/facetracknoir/UIElements/Logo_NoIR_small_target.png new file mode 100644 index 00000000..4bbaf41f Binary files /dev/null and b/facetracknoir/UIElements/Logo_NoIR_small_target.png differ diff --git a/facetracknoir/UIElements/Logo_NoIR_small_target90px.png b/facetracknoir/UIElements/Logo_NoIR_small_target90px.png new file mode 100644 index 00000000..ecaa4e12 Binary files /dev/null and b/facetracknoir/UIElements/Logo_NoIR_small_target90px.png differ diff --git a/facetracknoir/UIElements/Tools.png b/facetracknoir/UIElements/Tools.png new file mode 100644 index 00000000..2da8f9f5 Binary files /dev/null and b/facetracknoir/UIElements/Tools.png differ diff --git a/facetracknoir/UIElements/aboutFaceTrackNoIR.png b/facetracknoir/UIElements/aboutFaceTrackNoIR.png new file mode 100644 index 00000000..90f8f792 Binary files /dev/null and b/facetracknoir/UIElements/aboutFaceTrackNoIR.png differ diff --git a/facetracknoir/UIElements/bubble_1_small.png b/facetracknoir/UIElements/bubble_1_small.png new file mode 100644 index 00000000..ebd4e66f Binary files /dev/null and b/facetracknoir/UIElements/bubble_1_small.png differ diff --git a/facetracknoir/UIElements/bubble_2_big.png b/facetracknoir/UIElements/bubble_2_big.png new file mode 100644 index 00000000..5dc40254 Binary files /dev/null and b/facetracknoir/UIElements/bubble_2_big.png differ diff --git a/facetracknoir/UIElements/logoFaceTrackNoIR.png b/facetracknoir/UIElements/logoFaceTrackNoIR.png new file mode 100644 index 00000000..a1a3407b Binary files /dev/null and b/facetracknoir/UIElements/logoFaceTrackNoIR.png differ diff --git a/facetracknoir/UIElements/logoFaceTrackNoIR60px.png b/facetracknoir/UIElements/logoFaceTrackNoIR60px.png new file mode 100644 index 00000000..f01f6024 Binary files /dev/null and b/facetracknoir/UIElements/logoFaceTrackNoIR60px.png differ diff --git a/facetracknoir/images/330px-6DOF_en.png b/facetracknoir/images/330px-6DOF_en.png new file mode 100644 index 00000000..9d1d72ff Binary files /dev/null and b/facetracknoir/images/330px-6DOF_en.png differ diff --git a/facetracknoir/images/FaceTrackNoIR.ico b/facetracknoir/images/FaceTrackNoIR.ico new file mode 100644 index 00000000..5115066c Binary files /dev/null and b/facetracknoir/images/FaceTrackNoIR.ico differ diff --git a/facetracknoir/images/Settings16.png b/facetracknoir/images/Settings16.png new file mode 100644 index 00000000..3b31623b Binary files /dev/null and b/facetracknoir/images/Settings16.png differ diff --git a/facetracknoir/images/SettingsOpen16.png b/facetracknoir/images/SettingsOpen16.png new file mode 100644 index 00000000..5bf65f0d Binary files /dev/null and b/facetracknoir/images/SettingsOpen16.png differ diff --git a/facetracknoir/images/rotation_DOFs.png b/facetracknoir/images/rotation_DOFs.png new file mode 100644 index 00000000..68682d88 Binary files /dev/null and b/facetracknoir/images/rotation_DOFs.png differ diff --git a/facetracknoir/images/translation_DOFs.png b/facetracknoir/images/translation_DOFs.png new file mode 100644 index 00000000..886c586e Binary files /dev/null and b/facetracknoir/images/translation_DOFs.png differ diff --git a/facetracknoir/main.cpp b/facetracknoir/main.cpp new file mode 100644 index 00000000..6e0549d7 --- /dev/null +++ b/facetracknoir/main.cpp @@ -0,0 +1,59 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +/* + Modifications (last one on top): + 20100520 - WVR: Added class FaceApp, to override winEventFilter. It receives + messages from the Game. +*/ + +#include "FaceApp.h" +#include "FaceTrackNoIR.h" +#include +#include +#include +#include + +int main(int argc, char *argv[]) +{ +//// QApplication a(argc, argv); + FaceApp a(argc, argv); + QFont font; + font.setFamily(font.defaultFamily()); + font.setPointSize(9); + a.setFont(font); + + // + // Create the Main Window and DeskTop and Exec! + // + FaceTrackNoIR w; + a.SetupEventFilter(&w); + + QDesktopWidget desktop; + w.move(desktop.screenGeometry().width()/2-w.width()/2, 100); + w.show(); + qApp->exec(); + + return 0; +} + diff --git a/facetracknoir/paintwidget.h b/facetracknoir/paintwidget.h new file mode 100644 index 00000000..e69de29b diff --git a/facetracknoir/postbuild.bat b/facetracknoir/postbuild.bat new file mode 100644 index 00000000..6653067e --- /dev/null +++ b/facetracknoir/postbuild.bat @@ -0,0 +1,27 @@ +@echo off +rem Copies required DLL files into output folder. + +setlocal +set COPY=xcopy /D /S /C /I /H /R /Y +set FILTER=find /v "File(s) copied" + +echo parameters %1 en %2 en %3 + +set API_BIN=%1 +set OUTDIR=%2 +set CONFIG=%3 + +if %CONFIG%==Debug (goto Debug) +if %CONFIG%==Release (goto Release) + +echo Unknown build configuration %CONFIG% +exit /b -1 + +:Debug +%COPY% %API_BIN% %OUTDIR%\ | %FILTER% +exit /b 0 + +:Release +%COPY% %API_BIN% %OUTDIR%\ | %FILTER% +exit /b 0 + diff --git a/facetracknoir/resource.h b/facetracknoir/resource.h new file mode 100644 index 00000000..75059fe3 --- /dev/null +++ b/facetracknoir/resource.h @@ -0,0 +1,16 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by Sweetspotter.rc +// +#define IDI_ICON1 102 + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 103 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/facetracknoir/rotation.cpp b/facetracknoir/rotation.cpp new file mode 100644 index 00000000..1c89d775 --- /dev/null +++ b/facetracknoir/rotation.cpp @@ -0,0 +1,48 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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 "rotation.h" + +#include + +// ---------------------------------------------------------------------------- +Rotation Rotation::inv() +{ + return Rotation(a,-b,-c,-d); +} + +// conversions +// see http://en.wikipedia.org/wiki/Conversion_between_quaternions_and_Euler_angles +void Rotation::fromEuler(double yaw, double pitch, double roll) +{ + double sin_phi = sin(roll/2.0); + double cos_phi = cos(roll/2.0); + double sin_the = sin(pitch/2.0); + double cos_the = cos(pitch/2.0); + double sin_psi = sin(yaw/2.0); + double cos_psi = cos(yaw/2.0); + + a = cos_phi*cos_the*cos_psi + sin_phi*sin_the*sin_psi; + b = sin_phi*cos_the*cos_psi - cos_phi*sin_the*sin_psi; + c = cos_phi*sin_the*cos_psi + sin_phi*cos_the*sin_psi; + d = cos_phi*cos_the*sin_psi - sin_phi*sin_the*cos_psi; +} + +void Rotation::toEuler(double& yaw, double& pitch, double& roll) +{ + roll = atan2(2.0*(a*b + c*d), 1.0 - 2.0*(b*b + c*c)); + pitch = asin(2.0*(a*c - b*d)); + yaw = atan2(2.0*(a*d + b*c), 1.0 - 2.0*(c*c + d*d)); +} + +Rotation operator*(const Rotation& A, const Rotation& B) +{ + return Rotation(A.a*B.a - A.b*B.b - A.c*B.c - A.d*B.d, // quaternion multiplication + A.a*B.b + A.b*B.a + A.c*B.d - A.d*B.c, + A.a*B.c - A.b*B.d + A.c*B.a + A.d*B.b, + A.a*B.d + A.b*B.c - A.c*B.b + A.d*B.a); +} \ No newline at end of file diff --git a/facetracknoir/rotation.h b/facetracknoir/rotation.h new file mode 100644 index 00000000..967d6661 --- /dev/null +++ b/facetracknoir/rotation.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef ROTATION_H +#define ROTATION_H + +// ---------------------------------------------------------------------------- +class Rotation { + friend Rotation operator*(const Rotation& A, const Rotation& B); +public: + Rotation() : a(1.0),b(0.0),c(0.0),d(0.0) {} + Rotation(double yaw, double pitch, double roll) { fromEuler(yaw, pitch, roll); } + Rotation(double a, double b, double c, double d) : a(a),b(b),c(c),d(d) {} + + Rotation inv(); // inverse + + // conversions + void fromEuler(double yaw, double pitch, double roll); + void toEuler(double& yaw, double& pitch, double& roll); + +protected: + double a,b,c,d; // quaternion coefficients +}; + +Rotation operator*(const Rotation& A, const Rotation& B); // composition of rotations + +#endif //ROTATION_H diff --git a/facetracknoir/spot.h b/facetracknoir/spot.h new file mode 100644 index 00000000..38518c74 --- /dev/null +++ b/facetracknoir/spot.h @@ -0,0 +1,27 @@ +#ifndef __SPOT_H__ +#define __SPOT_H__ + +class Spot { + +private: + QPoint distance; + QPoint position; + QImage image; + QRect target; + QRect source; + +public: + Spot(); + + void setDistance(QPoint distance); + QPoint getDistance(); + + void setPosition(QPoint position); + QPoint getPosition(); + + QRect getTarget(); + QRect getSource(); + QImage getImage(); +}; + +#endif \ No newline at end of file diff --git a/facetracknoir/tracker.cpp b/facetracknoir/tracker.cpp new file mode 100644 index 00000000..5396c95b --- /dev/null +++ b/facetracknoir/tracker.cpp @@ -0,0 +1,1081 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 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 . * +*********************************************************************************/ +/* + Modifications (last one on top): + 20130201 - WVR: Remove the Protocol, when stopping the Thread. + 20121215 - WVR: Fixed crash after message: protocol not installed correctly... by terminating the thread. + 20120921 - WVR: Fixed centering when no filter is selected. + 20120917 - WVR: Added Mouse-buttons to ShortKeys. + 20120827 - WVR: Signal tracking = false to Curve-widget(s) when quitting run(). Also when Alternative Pitch curve is used. + 20120805 - WVR: The FunctionConfig-widget is used to configure the Curves. It was tweaked some more, because the Accela filter now also + uses the Curve(s). ToDo: make the ranges configurable by the user. Development on the Toradex IMU makes us realize, that + a fixed input-range may not be so handy after all.. + 20120427 - WVR: The Protocol-code was already in separate DLLs, but the ListBox was still filled ´statically´. Now, a Dir() of the + EXE-folder is done, to locate Protocol-DLLs. The Icons were also moved to the DLLs + 20120317 - WVR: The Filter and Tracker-code was moved to separate DLLs. 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. + 20110328 - WVR: Changed the camera-structs into class-instances. This makes initialisation + easier and hopefully solves the remaining 'start-up problem'. + 20110313 - WVR: Removed 'set_initial'. Less is more. + 20110109 - WVR: Added setZero option to define behaviour after STOP tracking via shortkey. + 20110104 - WVR: Removed a few nasty bugs (it was impossible to stop tracker without crash). + 20101224 - WVR: Removed the QThread inheritance of the Base Class for the protocol-servers. + Again, this drastically simplifies the code in the protocols. + 20101217 - WVR: Created Base Class for the protocol-servers. This drastically simplifies + the code needed here. + 20101024 - WVR: Added shortkey to disable/enable one or more axis during tracking. + 20101021 - WVR: Added FSUIPC server for FS2004. + 20101011 - WVR: Added SimConnect server. + 20101007 - WVR: Created 6DOF-curves and drastically changed the tracker for that. + Also eliminated a 'glitch' in the process. + 20100607 - WVR: Re-installed Rotation Neutral Zone and improved reaction + after 'start/stop'. MessageBeep when confidence is back... + 20100604 - WVR: Created structure for DOF-data and changed timing of + ReceiveHeadPose end run(). + 20100602 - WVR: Implemented EWMA-filtering, according to the example of + Melchior Franz. Works like a charm... + 20100601 - WVR: Added DirectInput keyboard-handling. '=' used for center, + 'BACK' for start (+center)/stop. + 20100517 - WVR: Added upstream command(s) from FlightGear + 20100523 - WVR: Checkboxes to invert 6DOF's was implemented. Multiply by + 1 or (-1). +*/ +#include "tracker.h" +#include "FaceTrackNoIR.h" + +// Flags +bool Tracker::confid = false; +bool Tracker::do_tracking = true; +bool Tracker::do_center = false; +bool Tracker::do_inhibit = false; +bool Tracker::do_game_zero = false; +bool Tracker::do_axis_reverse = false; + +bool Tracker::setZero = true; +bool Tracker::setEngineStop = true; +HANDLE Tracker::hTrackMutex = 0; + +bool Tracker::useAxisReverse = false; // Use Axis Reverse +float Tracker::YawAngle4ReverseAxis = 40.0f; // Axis Reverse settings +float Tracker::Z_Pos4ReverseAxis = -20.0f; +float Tracker::Z_PosWhenReverseAxis = 50.0f; + + +T6DOF Tracker::current_camera(0,0,0,0,0,0); // Used for filtering +T6DOF Tracker::target_camera(0,0,0,0,0,0); +T6DOF Tracker::new_camera(0,0,0,0,0,0); +T6DOF Tracker::output_camera(0,0,0,0,0,0); // Position sent to game protocol + +THeadPoseDOF Tracker::Pitch("PitchUp", "PitchDown", 50, 180, 50, 90); // One structure for each of 6DOF's +THeadPoseDOF Tracker::Yaw("Yaw", "", 50, 180); +THeadPoseDOF Tracker::Roll("Roll", "", 50, 180); +THeadPoseDOF Tracker::X("X","", 50, 180); +THeadPoseDOF Tracker::Y("Y","", 50, 180); +THeadPoseDOF Tracker::Z("Z","", 50, 180); + +TShortKey Tracker::CenterKey; // ShortKey to Center headposition +TShortKey Tracker::StartStopKey; // ShortKey to Start/stop tracking +TShortKey Tracker::InhibitKey; // ShortKey to inhibit axis while tracking +TShortKey Tracker::GameZeroKey; // ShortKey to Set Game Zero +bool Tracker::DisableBeep = false; // Disable beep when center +//TShortKey Tracker::AxisReverseKey; // ShortKey to start/stop axis reverse while tracking + +int Tracker::CenterMouseKey; // ShortKey to Center headposition +int Tracker::StartStopMouseKey; // ShortKey to Start/stop tracking +int Tracker::InhibitMouseKey; // ShortKey to inhibit axis while tracking +int Tracker::GameZeroMouseKey; // ShortKey to Set Game Zero + +//ITrackerPtr Tracker::pTracker; // Pointer to Tracker instance (in DLL) +IProtocolPtr Tracker::pProtocol; // Pointer to Protocol instance (in DLL) +IFilterPtr Tracker::pFilter; // Pointer to Filter instance (in DLL) + + +/** constructor **/ +Tracker::Tracker( FaceTrackNoIR *parent ) { +QString libName; +importGetTracker getIT; +QLibrary *trackerLib; +importGetFilter getFilter; +QLibrary *filterLib; +importGetProtocol getProtocol; +QLibrary *protocolLib; +QFrame *video_frame; + + // Retieve the pointer to the parent + mainApp = parent; + + // Create events + m_StopThread = CreateEvent(0, TRUE, FALSE, 0); + m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); + + Tracker::hTrackMutex = CreateMutexA(NULL, false, "HeadPose_mutex"); + + // + // Initialize the headpose-data + // + Tracker::Yaw.initHeadPoseData(); + Tracker::Pitch.initHeadPoseData(); + Tracker::Roll.initHeadPoseData(); + Tracker::X.initHeadPoseData(); + Tracker::Y.initHeadPoseData(); + Tracker::Z.initHeadPoseData(); + + // + // Locate the video-frame, for the DLL + // + video_frame = 0; + video_frame = mainApp->getVideoWidget(); + qDebug() << "Tracker::Tracker VideoFrame = " << video_frame; + + // + // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... + // + pTracker = NULL; + libName = mainApp->getCurrentTrackerName(); + if (!libName.isEmpty()) { + trackerLib = new QLibrary(libName); + getIT = (importGetTracker) trackerLib->resolve("GetTracker"); + qDebug() << "Tracker::Tracker libName = " << libName; + + if (getIT) { + ITracker *ptrXyz(getIT()); // Get the Class + if (ptrXyz) + { + pTracker = ptrXyz; + pTracker->Initialize( video_frame ); + qDebug() << "Tracker::setup Function Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", libName + " DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } + // + // Load the Tracker-engine DLL, get the tracker-class from it and do stuff... + // + pSecondTracker = NULL; + libName = mainApp->getSecondTrackerName(); + if ((!libName.isEmpty()) && (libName != "None")) { + trackerLib = new QLibrary(libName); + getIT = (importGetTracker) trackerLib->resolve("GetTracker"); + + if (getIT) { + ITracker *ptrXyz(getIT()); // Get the Class + if (ptrXyz) + { + pSecondTracker = ptrXyz; + pSecondTracker->Initialize( NULL ); + qDebug() << "Tracker::setup Function Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", libName + " DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + } + } + + // + // Load the DLL with the protocol-logic and retrieve a pointer to the Protocol-class. + // + libName = mainApp->getCurrentProtocolName(); + if (!libName.isEmpty()) { + protocolLib = new QLibrary(libName); + getProtocol = (importGetProtocol) protocolLib->resolve("GetProtocol"); + if (getProtocol) { + IProtocolPtr ptrXyz(getProtocol()); + if (ptrXyz) + { + pProtocol = ptrXyz; + pProtocol->Initialize(); + qDebug() << "Protocol::setup Function Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Protocol-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + return; + } + } + + // + // Load the DLL with the filter-logic and retrieve a pointer to the Filter-class. + // + pFilter = NULL; + libName = mainApp->getCurrentFilterName(); + + if ((!libName.isEmpty()) && (libName != "None")) { + filterLib = new QLibrary(libName); + + getFilter = (importGetFilter) filterLib->resolve("GetFilter"); + if (getFilter) { + IFilterPtr ptrXyz(getFilter()); + if (ptrXyz) + { + pFilter = ptrXyz; + qDebug() << "Filter::setup Function Resolved!"; + } + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Filter-DLL not loaded",QMessageBox::Ok,QMessageBox::NoButton); + return; + } + } + + // Load the settings from the INI-file + loadSettings(); +} + +/** destructor empty **/ +Tracker::~Tracker() { + + // Stop the Tracker(s) + if (pTracker) { + pTracker->StopTracker( true ); + } + if (pSecondTracker) { + pSecondTracker->StopTracker( true ); + } + + // Trigger thread to stop + ::SetEvent(m_StopThread); + + // Wait until thread finished + if (isRunning()) { + ::WaitForSingleObject(m_WaitThread, INFINITE); + } + + // + // Remove the Tracker + // 20120615, WVR: As suggested by Stanislaw + if (pTracker) { + delete pTracker; + pTracker = NULL; + } + if (pSecondTracker) { + delete pSecondTracker; + pSecondTracker = NULL; + } + + // + // Remove the Protocol + // + if (pProtocol) { + delete pProtocol; + pProtocol = NULL; + } + + // Close handles + ::CloseHandle(m_StopThread); + ::CloseHandle(m_WaitThread); + + if (Tracker::hTrackMutex != 0) { + ::CloseHandle( Tracker::hTrackMutex ); + } + +# ifdef USE_DEBUG_CLIENT + debug_Client->deleteLater(); // Delete Excel protocol-server +# endif + + qDebug() << "Tracker::~Tracker Finished..."; + +} + +/** setting up the tracker engine **/ +void Tracker::setup() { + bool DLL_Ok; + + // retrieve pointers to the User Interface and the main Application + if (pTracker) { + pTracker->StartTracker( mainApp->winId() ); + } + if (pSecondTracker) { + pSecondTracker->StartTracker( mainApp->winId() ); + } + + // + // Check if the Protocol-server files were installed OK. + // Some servers also create a memory-mapping, for Inter Process Communication. + // The handle of the MainWindow is sent to 'The Game', so it can send a message back. + // + if (pProtocol) { + + DLL_Ok = pProtocol->checkServerInstallationOK( mainApp->winId() ); + if (!DLL_Ok) { + // Trigger thread to stop + ::SetEvent(m_StopThread); + QMessageBox::information(mainApp, "FaceTrackNoIR error", "Protocol is not (correctly) installed!"); + } + } + +# ifdef USE_DEBUG_CLIENT + DLL_Ok = debug_Client->checkServerInstallationOK( mainApp->winId() ); // Check installation + if (!DLL_Ok) { + QMessageBox::information(mainApp, "FaceTrackNoIR error", "Excel Protocol is not (correctly) installed!"); + } +# endif + +} + +/** QThread run method @override **/ +void Tracker::run() { +/** Direct Input variables **/ +// +// The DirectX stuff was found here: http://www.directxtutorial.com/tutorial9/e-directinput/dx9e2.aspx +// +LPDIRECTINPUT8 din; // the pointer to our DirectInput interface +LPDIRECTINPUTDEVICE8 dinkeyboard; // the pointer to the keyboard device +LPDIRECTINPUTDEVICE8 dinmouse; // the pointer to the mouse device +BYTE keystate[256]; // the storage for the key-information +DIMOUSESTATE mousestate; // the storage for the mouse-information +HRESULT retAcquire; +bool lastCenterKey = false; // Remember state, to detect rising edge +bool lastStartStopKey = false; +bool lastInhibitKey = false; +bool lastGameZeroKey = false; + +bool lastCenterMouseKey = false; // Remember state, to detect rising edge +bool lastStartStopMouseKey = false; +bool lastInhibitMouseKey = false; +bool lastGameZeroMouseKey = false; + +bool waitAxisReverse = false; +bool waitThroughZero = false; +double actualYaw = 0.0f; +double actualZ = 0.0f; +T6DOF offset_camera(0,0,0,0,0,0); +T6DOF gamezero_camera(0,0,0,0,0,0); +T6DOF gameoutput_camera(0,0,0,0,0,0); + +bool bInitialCenter1 = true; +bool bInitialCenter2 = true; +bool bTracker1Confid = false; +bool bTracker2Confid = false; + + Tracker::do_tracking = true; // Start initially + Tracker::do_center = false; // Center initially + + // + // Test some Filter-stuff + // + if (pFilter) { + QString filterName; + //pFilter->getFullName(&filterName); + //qDebug() << "Tracker::run() FilterName = " << filterName; + } + + // + // Setup the DirectInput for keyboard strokes + // + // create the DirectInput interface + if (DirectInput8Create(GetModuleHandle(NULL), DIRECTINPUT_VERSION, IID_IDirectInput8, + (void**)&din, NULL) != DI_OK) { // COM stuff, so we'll set it to NULL + qDebug() << "Tracker::setup DirectInput8 Creation failed!" << GetLastError(); + } + + // create the keyboard device + if (din->CreateDevice(GUID_SysKeyboard, &dinkeyboard, NULL) != DI_OK) { + qDebug() << "Tracker::setup CreateDevice function failed!" << GetLastError(); + } + // create the mouse device + din->CreateDevice(GUID_SysMouse, &dinmouse, NULL); + + // set the data format to keyboard format + if (dinkeyboard->SetDataFormat(&c_dfDIKeyboard) != DI_OK) { + qDebug() << "Tracker::setup SetDataFormat function failed!" << GetLastError(); + } + // set the data format to mouse format + dinmouse->SetDataFormat(&c_dfDIMouse); + + // set the control you will have over the keyboard + if (dinkeyboard->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND) != DI_OK) { + qDebug() << "Tracker::setup SetCooperativeLevel function failed!" << GetLastError(); + } + // set the control you will have over the mouse + dinmouse->SetCooperativeLevel(mainApp->winId(), DISCL_NONEXCLUSIVE | DISCL_BACKGROUND); + + forever + { + + // Check event for stop thread + if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) + { + dinkeyboard->Unacquire(); // Unacquire keyboard + dinkeyboard->Release(); + dinmouse->Unacquire(); // Unacquire mouse + dinmouse->Release(); + din->Release(); // Release DirectInput + + // Set event + ::SetEvent(m_WaitThread); + qDebug() << "Tracker::run terminated run()"; + X.curvePtr->setTrackingActive( false ); + Y.curvePtr->setTrackingActive( false ); + Z.curvePtr->setTrackingActive( false ); + Yaw.curvePtr->setTrackingActive( false ); + Pitch.curvePtr->setTrackingActive( false ); + Pitch.curvePtrAlt->setTrackingActive( false ); + Roll.curvePtr->setTrackingActive( false ); + + return; + } + + // + // Check the mouse + // + // get access if we don't have it already + retAcquire = dinmouse->Acquire(); + if ( (retAcquire != DI_OK) && (retAcquire != S_FALSE) ) { + qDebug() << "Tracker::run Acquire function failed!" << GetLastError(); + } + else { + if (dinmouse->GetDeviceState(sizeof(DIMOUSESTATE), (LPVOID)&mousestate) != DI_OK) { + qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); + } + else { + // + // Check the state of the StartStop MouseKey + // + if ( isMouseKeyPressed( &StartStopMouseKey, &mousestate ) && (!lastStartStopMouseKey) ) { + Tracker::do_tracking = !Tracker::do_tracking; + + // + // To start tracking again and to be at '0', execute Center command too + // + if (Tracker::do_tracking) { + Tracker::confid = false; + if (pTracker) { + pTracker->StartTracker( mainApp->winId() ); + } + if (pSecondTracker) { + pSecondTracker->StartTracker( mainApp->winId() ); + } + } + else { + if (setEngineStop) { // Only stop engine when option is checked + if (pTracker) { + pTracker->StopTracker( false ); + } + if (pSecondTracker) { + pSecondTracker->StopTracker( false ); + } + } + } + qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; + } + lastStartStopMouseKey = isMouseKeyPressed( &StartStopMouseKey, &mousestate ); // Remember + + // + // Check the state of the Center MouseKey + // + if ( isMouseKeyPressed( &CenterMouseKey, &mousestate ) && (!lastCenterMouseKey) ) { + Tracker::do_center = true; + qDebug() << "Tracker::run() says Center MouseKey pressed"; + } + lastCenterMouseKey = isMouseKeyPressed( &CenterMouseKey, &mousestate ); // Remember + + // + // Check the state of the GameZero MouseKey + // + if ( isMouseKeyPressed( &GameZeroMouseKey, &mousestate ) && (!lastGameZeroMouseKey) ) { + Tracker::do_game_zero = true; + qDebug() << "Tracker::run() says GameZero MouseKey pressed"; + } + lastGameZeroMouseKey = isMouseKeyPressed( &GameZeroMouseKey, &mousestate ); // Remember + + // + // Check the state of the Inhibit MouseKey + // + if ( isMouseKeyPressed( &InhibitMouseKey, &mousestate ) && (!lastInhibitMouseKey) ) { + Tracker::do_inhibit = !Tracker::do_inhibit; + qDebug() << "Tracker::run() says Inhibit MouseKey pressed"; + // + // Execute Center command too, when inhibition ends. + // + if (!Tracker::do_inhibit) { + Tracker::do_center = true; + } + } + lastInhibitMouseKey = isMouseKeyPressed( &InhibitMouseKey, &mousestate ); // Remember + } + } + + // + // Check the keyboard + // + // get access if we don't have it already + retAcquire = dinkeyboard->Acquire(); + if ( (retAcquire != DI_OK) && (retAcquire != S_FALSE) ) { + qDebug() << "Tracker::run Acquire function failed!" << GetLastError(); + } + else { + // get the input data + if (dinkeyboard->GetDeviceState(256, (LPVOID)keystate) != DI_OK) { + qDebug() << "Tracker::run GetDeviceState function failed!" << GetLastError(); + } + else { + // + // Check the state of the Start/Stop key + // + if ( isShortKeyPressed( &StartStopKey, &keystate[0] ) && (!lastStartStopKey) ) { + Tracker::do_tracking = !Tracker::do_tracking; + + // + // To start tracking again and to be at '0', execute Center command too + // + if (Tracker::do_tracking) { + Tracker::confid = false; + if (pTracker) { + pTracker->StartTracker( mainApp->winId() ); + } + if (pSecondTracker) { + pSecondTracker->StartTracker( mainApp->winId() ); + } + } + else { + if (setEngineStop) { // Only stop engine when option is checked + if (pTracker) { + pTracker->StopTracker( false ); + } + if (pSecondTracker) { + pSecondTracker->StopTracker( false ); + } + } + } + qDebug() << "Tracker::run() says StartStop pressed, do_tracking =" << Tracker::do_tracking; + } + lastStartStopKey = isShortKeyPressed( &StartStopKey, &keystate[0] ); // Remember + + // + // Check the state of the Center key + // + if ( isShortKeyPressed( &CenterKey, &keystate[0] ) && (!lastCenterKey) ) { + Tracker::do_center = true; + qDebug() << "Tracker::run() says Center pressed"; + } + lastCenterKey = isShortKeyPressed( &CenterKey, &keystate[0] ); // Remember + + // + // Check the state of the GameZero key + // + if ( isShortKeyPressed( &GameZeroKey, &keystate[0] ) && (!lastGameZeroKey) ) { + Tracker::do_game_zero = true; + qDebug() << "Tracker::run() says GameZero pressed"; + } + lastGameZeroKey = isShortKeyPressed( &GameZeroKey, &keystate[0] ); // Remember + + // + // Check the state of the Inhibit key + // + if ( isShortKeyPressed( &InhibitKey, &keystate[0] ) && (!lastInhibitKey) ) { + Tracker::do_inhibit = !Tracker::do_inhibit; + qDebug() << "Tracker::run() says Inhibit pressed"; + // + // Execute Center command too, when inhibition ends. + // + if (!Tracker::do_inhibit) { + Tracker::do_center = true; + } + } + lastInhibitKey = isShortKeyPressed( &InhibitKey, &keystate[0] ); // Remember + } + } + + // + // Reset the 'wait' flag. Moving above 90 with the key pressed, will (de-)activate Axis Reverse. + // +// qDebug() << "Tracker::run() says actualZ = " << actualZ << ", terwijl Z_Pos4 = " << Z_Pos4ReverseAxis; + if (useAxisReverse) { + Tracker::do_axis_reverse = ((fabs(actualYaw) > YawAngle4ReverseAxis) && (actualZ < Z_Pos4ReverseAxis)); + } + else { + Tracker::do_axis_reverse = false; + } + + + if (WaitForSingleObject(Tracker::hTrackMutex, 100) == WAIT_OBJECT_0) { + + THeadPoseData newpose; + newpose.pitch = 0.0f; + newpose.roll = 0.0f; + newpose.yaw = 0.0f; + newpose.x = 0.0f; + newpose.y = 0.0f; + newpose.z = 0.0f; + + // + // The second tracker serves as 'secondary'. So if an axis is written by the second tracker it CAN be overwritten by the Primary tracker. + // This is enforced by the sequence below. + // + if (pSecondTracker) { + bTracker2Confid = pSecondTracker->GiveHeadPoseData(&newpose); + } + else { + bTracker2Confid = false; + bInitialCenter2 = false; + } + if (pTracker) { + bTracker1Confid = pTracker->GiveHeadPoseData(&newpose); +// qDebug() << "Tracker::run() says Roll = " << newpose.roll; + } + else { + bTracker1Confid = false; + bInitialCenter1 = false; + } + + Tracker::confid = (bTracker1Confid || bTracker2Confid); + if ( Tracker::confid ) { + addHeadPose(newpose); + } + + // + // If Center is pressed, copy the current values to the offsets. + // + if ((Tracker::do_center) || ((bInitialCenter1 && bTracker1Confid ) || (bInitialCenter2 && bTracker2Confid))) { + + if (!DisableBeep) { + MessageBeep (MB_ICONASTERISK); // Acknowledge the key-press with a beep. + } + if (pTracker && bTracker1Confid) { + pTracker->notifyCenter(); // Send 'center' to the tracker + bInitialCenter1 = false; + } + if (pSecondTracker && bTracker2Confid) { + pSecondTracker->notifyCenter(); // Send 'center' to the second tracker + bInitialCenter2 = false; + } + + // + // Only copy valid values + // + if (Tracker::confid) { + + offset_camera.x = getSmoothFromList( &X.rawList ); + offset_camera.y = getSmoothFromList( &Y.rawList ); + offset_camera.z = getSmoothFromList( &Z.rawList ); + offset_camera.pitch = getSmoothFromList( &Pitch.rawList ); + offset_camera.yaw = getSmoothFromList( &Yaw.rawList ); + offset_camera.roll = getSmoothFromList( &Roll.rawList ); + } + + Tracker::do_center = false; + } + + // + // If Set Game Zero is pressed, copy the current values to the offsets. + // Change requested by Stanislaw + // + if (Tracker::confid && Tracker::do_game_zero) { + if (pTracker) { + if (!pTracker->notifyZeroed()) + gamezero_camera = gameoutput_camera; + } +// gamezero_camera = gameoutput_camera; + + Tracker::do_game_zero = false; + } + + if (Tracker::do_tracking && Tracker::confid) { + + // get values + target_camera.x = getSmoothFromList( &X.rawList ); + target_camera.y = getSmoothFromList( &Y.rawList ); + target_camera.z = getSmoothFromList( &Z.rawList ); + target_camera.pitch = getSmoothFromList( &Pitch.rawList ); + target_camera.yaw = getSmoothFromList( &Yaw.rawList ); + target_camera.roll = getSmoothFromList( &Roll.rawList ); +// qDebug() << "Tracker::run() says Roll from Smoothing = " << target_camera.roll; + + // do the centering + target_camera = target_camera - offset_camera; + + // + // Use advanced filtering, when a filter was selected. + // + if (pFilter) { + pFilter->FilterHeadPoseData(¤t_camera, &target_camera, &new_camera, Tracker::Pitch.newSample); +// qDebug() << "Tracker::run() says Roll in Filter = " << current_camera.roll << ", Roll to output = " << new_camera.roll; + } + else { + new_camera = target_camera; +// qDebug() << "Tracker::run() says Roll to output = " << new_camera.roll; + } + output_camera.x = X.invert * X.curvePtr->getValue(new_camera.x); + output_camera.y = Y.invert * Y.curvePtr->getValue(new_camera.y); + output_camera.z = Z.invert * Z.curvePtr->getValue(new_camera.z); + + // + // Determine, which curve (Up or Down) must be used for Pitch + // + bool altp = (new_camera.pitch < 0); + if (altp) { + output_camera.pitch = Pitch.invert * Pitch.curvePtrAlt->getValue(new_camera.pitch); + Pitch.curvePtr->setTrackingActive( false ); + Pitch.curvePtrAlt->setTrackingActive( true ); + } + else { + output_camera.pitch = Pitch.invert * Pitch.curvePtr->getValue(new_camera.pitch); + Pitch.curvePtr->setTrackingActive( true ); + Pitch.curvePtrAlt->setTrackingActive( false ); + } + output_camera.yaw = Yaw.invert * Yaw.curvePtr->getValue(new_camera.yaw); + output_camera.roll = Roll.invert * Roll.curvePtr->getValue(new_camera.roll); + + X.curvePtr->setTrackingActive( true ); + Y.curvePtr->setTrackingActive( true ); + Z.curvePtr->setTrackingActive( true ); + Yaw.curvePtr->setTrackingActive( true ); + Roll.curvePtr->setTrackingActive( true ); + + // + // Reverse Axis. + // + actualYaw = output_camera.yaw; // Save the actual Yaw, otherwise we can't check for +90 + actualZ = output_camera.z; // Also the Z + if (Tracker::do_axis_reverse) { + output_camera.z = Z_PosWhenReverseAxis; // Set the desired Z-position + } + + // + // Reset value for the selected axis, if inhibition is active + // + if (Tracker::do_inhibit) { + if (InhibitKey.doPitch) output_camera.pitch = 0.0f; + if (InhibitKey.doYaw) output_camera.yaw = 0.0f; + if (InhibitKey.doRoll) output_camera.roll = 0.0f; + if (InhibitKey.doX) output_camera.x = 0.0f; + if (InhibitKey.doY) output_camera.y = 0.0f; + if (InhibitKey.doZ) output_camera.z = 0.0f; + } + + // + // Send the headpose to the game + // + if (pProtocol) { + gameoutput_camera = output_camera + gamezero_camera; + pProtocol->sendHeadposeToGame( &gameoutput_camera, &newpose ); // degrees & centimeters + } + } + else { + // + // Go to initial position + // + if (pProtocol && setZero) { + output_camera.pitch = 0.0f; + output_camera.yaw = 0.0f; + output_camera.roll = 0.0f; + output_camera.x = 0.0f; + output_camera.y = 0.0f; + output_camera.z = 0.0f; + gameoutput_camera = output_camera + gamezero_camera; + pProtocol->sendHeadposeToGame( &gameoutput_camera, &newpose ); // degrees & centimeters + } + X.curvePtr->setTrackingActive( false ); + Y.curvePtr->setTrackingActive( false ); + Z.curvePtr->setTrackingActive( false ); + Yaw.curvePtr->setTrackingActive( false ); + Pitch.curvePtr->setTrackingActive( false ); + Pitch.curvePtrAlt->setTrackingActive( false ); + Roll.curvePtr->setTrackingActive( false ); + } + } + + Tracker::Pitch.newSample = false; + ReleaseMutex(Tracker::hTrackMutex); + + //for lower cpu load + usleep(10000); + yieldCurrentThread(); + } +} + +/** Add the headpose-data to the Lists **/ +void Tracker::addHeadPose( THeadPoseData head_pose ) +{ + // Pitch + Tracker::Pitch.headPos = head_pose.pitch; // degrees + addRaw2List ( &Pitch.rawList, Pitch.maxItems, Tracker::Pitch.headPos ); +// Tracker::Pitch.confidence = head_pose.confidence; // Just this one ... + Tracker::Pitch.newSample = true; + + // Yaw + Tracker::Yaw.headPos = head_pose.yaw; // degrees + addRaw2List ( &Yaw.rawList, Yaw.maxItems, Tracker::Yaw.headPos ); + + // Roll + Tracker::Roll.headPos = head_pose.roll; // degrees + addRaw2List ( &Roll.rawList, Roll.maxItems, Tracker::Roll.headPos ); + + // X-position + Tracker::X.headPos = head_pose.x; // centimeters + addRaw2List ( &X.rawList, X.maxItems, Tracker::X.headPos ); + + // Y-position + Tracker::Y.headPos = head_pose.y; // centimeters + addRaw2List ( &Y.rawList, Y.maxItems, Tracker::Y.headPos ); + + // Z-position (distance to camera, absolute!) + Tracker::Z.headPos = head_pose.z; // centimeters + addRaw2List ( &Z.rawList, Z.maxItems, Tracker::Z.headPos ); +} + +// +// Get the ProgramName from the Game and return it. +// +QString Tracker::getGameProgramName() { +QString str; +char dest[100]; + + str = QString("No protocol active?"); + if (pProtocol) { + pProtocol->getNameFromGame( dest ); + str = QString( dest ); + } + return str; +} + +// +// Handle the command, send upstream by the game. +// Valid values are: +// 1 = reset Headpose +// +bool Tracker::handleGameCommand ( int command ) { + + qDebug() << "handleGameCommand says: Command =" << command; + + switch ( command ) { + case 1: // reset headtracker + Tracker::do_center = true; + break; + default: + break; + } + return false; +} + +// +// Add the new Raw value to the QList. +// Remove the last item(s), depending on the set maximum list-items. +// +void Tracker::addRaw2List ( QList *rawList, float maxIndex, float raw ) { + // + // Remove old values from the end of the QList. + // If the setting for MaxItems was lowered, the QList is shortened here... + // + while (rawList->size() >= maxIndex) { + rawList->removeLast(); + } + + // + // Insert the newest at the beginning. + // + rawList->prepend ( raw ); +} + +// +// Get the raw headpose, so it can be displayed. +// +void Tracker::getHeadPose( THeadPoseData *data ) { + data->x = Tracker::X.headPos; // centimeters + data->y = Tracker::Y.headPos; + data->z = Tracker::Z.headPos; + + data->pitch = Tracker::Pitch.headPos; // degrees + data->yaw = Tracker::Yaw.headPos; + data->roll = Tracker::Roll.headPos; +} + +// +// Get the output-headpose, so it can be displayed. +// +void Tracker::getOutputHeadPose( THeadPoseData *data ) { + data->x = output_camera.x; // centimeters + data->y = output_camera.y; + data->z = output_camera.z; + + data->pitch = output_camera.pitch; // degrees + data->yaw = output_camera.yaw; + data->roll = output_camera.roll; +} + +// +// Get the Smoothed value from the QList. +// +float Tracker::getSmoothFromList ( QList *rawList ) { +float sum = 0; + + if (rawList->isEmpty()) return 0.0f; + + // + // Add the Raw values and divide. + // + for ( int i = 0; i < rawList->size(); i++) { + sum += rawList->at(i); + } + return sum / rawList->size(); +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void Tracker::loadSettings() { +//int NeutralZone; +//int sensYaw, sensPitch, sensRoll; +//int sensX, sensY, sensZ; + + qDebug() << "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() << "loadSettings says: iniFile = " << currentFile; + + // + // Read the Tracking settings, to fill the curves. + // + //iniFile.beginGroup ( "Tracking" ); + //NeutralZone = iniFile.value ( "NeutralZone", 5 ).toInt(); + //sensYaw = iniFile.value ( "sensYaw", 100 ).toInt(); + //sensPitch = iniFile.value ( "sensPitch", 100 ).toInt(); + //sensRoll = iniFile.value ( "sensRoll", 100 ).toInt(); + //sensX = iniFile.value ( "sensX", 100 ).toInt(); + //sensY = iniFile.value ( "sensY", 100 ).toInt(); + //sensZ = iniFile.value ( "sensZ", 100 ).toInt(); + //iniFile.endGroup (); + + // + // Read the keyboard shortcuts. + // + iniFile.beginGroup ( "KB_Shortcuts" ); + + // Center key + CenterMouseKey = iniFile.value ( "MouseKey_Center", 0 ).toInt(); + CenterKey.keycode = iniFile.value ( "Keycode_Center", DIK_HOME ).toInt(); + CenterKey.shift = iniFile.value ( "Shift_Center", 0 ).toBool(); + CenterKey.ctrl = iniFile.value ( "Ctrl_Center", 0 ).toBool(); + CenterKey.alt = iniFile.value ( "Alt_Center", 0 ).toBool(); + DisableBeep = iniFile.value ( "Disable_Beep", 0 ).toBool(); + + // StartStop key + StartStopMouseKey = iniFile.value ( "MouseKey_StartStop", 0 ).toInt(); + StartStopKey.keycode = iniFile.value ( "Keycode_StartStop", DIK_END ).toInt(); + StartStopKey.shift = iniFile.value ( "Shift_StartStop", 0 ).toBool(); + StartStopKey.ctrl = iniFile.value ( "Ctrl_StartStop", 0 ).toBool(); + StartStopKey.alt = iniFile.value ( "Alt_StartStop", 0 ).toBool(); + setZero = iniFile.value ( "SetZero", 1 ).toBool(); + setEngineStop = iniFile.value ( "SetEngineStop", 1 ).toBool(); + + // Inhibit key + InhibitMouseKey = iniFile.value ( "MouseKey_Inhibit", 0 ).toInt(); + InhibitKey.keycode = iniFile.value ( "Keycode_Inhibit", 0 ).toInt(); + InhibitKey.shift = iniFile.value ( "Shift_Inhibit", 0 ).toBool(); + InhibitKey.ctrl = iniFile.value ( "Ctrl_Inhibit", 0 ).toBool(); + InhibitKey.alt = iniFile.value ( "Alt_Inhibit", 0 ).toBool(); + InhibitKey.doPitch = iniFile.value ( "Inhibit_Pitch", 0 ).toBool(); + InhibitKey.doYaw = iniFile.value ( "Inhibit_Yaw", 0 ).toBool(); + InhibitKey.doRoll = iniFile.value ( "Inhibit_Roll", 0 ).toBool(); + InhibitKey.doX = iniFile.value ( "Inhibit_X", 0 ).toBool(); + InhibitKey.doY = iniFile.value ( "Inhibit_Y", 0 ).toBool(); + InhibitKey.doZ = iniFile.value ( "Inhibit_Z", 0 ).toBool(); + + // Game Zero key + GameZeroMouseKey = iniFile.value ( "MouseKey_GameZero", 0 ).toInt(); + GameZeroKey.keycode = iniFile.value ( "Keycode_GameZero", 0 ).toInt(); + GameZeroKey.shift = iniFile.value ( "Shift_GameZero", 0 ).toBool(); + GameZeroKey.ctrl = iniFile.value ( "Ctrl_GameZero", 0 ).toBool(); + GameZeroKey.alt = iniFile.value ( "Alt_GameZero", 0 ).toBool(); + + // Axis Reverse key + //AxisReverseKey.keycode = DIK_R; + //AxisReverseKey.shift = false; + //AxisReverseKey.ctrl = false; + //AxisReverseKey.alt = false; + + // Reverse Axis + useAxisReverse = iniFile.value ( "Enable_ReverseAxis", 0 ).toBool(); + YawAngle4ReverseAxis = iniFile.value ( "RA_Yaw", 40 ).toInt(); + Z_Pos4ReverseAxis = iniFile.value ( "RA_ZPos", 50 ).toInt(); + Z_PosWhenReverseAxis = iniFile.value ( "RA_ToZPos", 80 ).toInt(); + + iniFile.endGroup (); +} + +// +// Determine if the ShortKey (incl. CTRL, SHIFT and/or ALT) is pressed. +// +bool Tracker::isShortKeyPressed( TShortKey *key, BYTE *keystate ){ +bool shift; +bool ctrl; +bool alt; + + // + // First, check if the right key is pressed. If so, check the modifiers + // + if (keystate[key->keycode] & 0x80) { + shift = ( (keystate[DIK_LSHIFT] & 0x80) || (keystate[DIK_RSHIFT] & 0x80) ); + ctrl = ( (keystate[DIK_LCONTROL] & 0x80) || (keystate[DIK_RCONTROL] & 0x80) ); + alt = ( (keystate[DIK_LALT] & 0x80) || (keystate[DIK_RALT] & 0x80) ); + + // + // If one of the modifiers is needed and not pressed, return false. + // + if (key->shift && !shift) return false; + if (key->ctrl && !ctrl) return false; + if (key->alt && !alt) return false; + + // + // All is well! + // + return true; + } + else { + return false; + } +} + +// +// Determine if the MouseKey is pressed. +// +bool Tracker::isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate ){ + + // + // If key == NONE, or invalid: ready! + // + if ((*key <= 0) || (*key > 5)) { + return false; + } + + // + // Now, check if the right key is pressed. + // + if (mousestate->rgbButtons[*key-1] & 0x80) { + return true; + } + else { + return false; + } +} diff --git a/facetracknoir/tracker.h b/facetracknoir/tracker.h new file mode 100644 index 00000000..4b161293 --- /dev/null +++ b/facetracknoir/tracker.h @@ -0,0 +1,282 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +/* + Modifications (last one on top): + 20120717 - WVR: FunctionConfig is now used for the Curves, instead of BezierConfig. +*/ +#ifndef __TRACKER_H__ +#define __TRACKER_H__ + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#define DIRECTINPUT_VERSION 0x0800 +#include + +#include "FunctionConfig.h" + +#include "..\ftnoir_tracker_base\FTNoIR_Tracker_base.h" +#include "..\ftnoir_protocol_base\FTNoIR_Protocol_base.h" +#include "..\ftnoir_filter_base\FTNoIR_Filter_base.h" +#include "tracker_types.h" + +typedef ITrackerPtr (WINAPI *importGetTracker)(void); +typedef IProtocolPtr (WINAPI *importGetProtocol)(void); +typedef IFilterPtr (WINAPI *importGetFilter)(void); + +// include the DirectX Library files +#pragma comment (lib, "dinput8.lib") +#pragma comment (lib, "dxguid.lib") + +enum AngleName { + PITCH = 0, + YAW = 1, + ROLL = 2, + X = 3, + Y = 4, + Z = 5 +}; + +enum FTNoIR_Client { + FREE_TRACK = 0, + FLIGHTGEAR = 1, + FTNOIR = 2, + PPJOY = 3, + TRACKIR = 4, + SIMCONNECT = 5, + FSUIPC = 6, + MOUSE = 7 +}; + +//enum FTNoIR_Face_Tracker { +// FT_SM_FACEAPI = 0, +// FT_FTNOIR = 1, +// FT_VISAGE = 2 +//}; + +enum FTNoIR_Tracker_Status { + TRACKER_OFF = 0, + TRACKER_ON = 1 +}; + +class FaceTrackNoIR; // pre-define parent-class to avoid circular includes + +// +// Structure to hold all variables concerning one of 6 DOF's +// +class THeadPoseDOF { +public: + + THeadPoseDOF(QString primary, QString secondary = "", int maxInput1 = 50, int maxOutput1 = 180, int maxInput2 = 50, int maxOutput2 = 90) { + 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) + + curvePtr = new FunctionConfig(primary, maxInput1, maxOutput1); // Create the Function-config for input-output translation + curvePtr->loadSettings(iniFile); // Load the settings from the INI-file + if (secondary != "") { + curvePtrAlt = new FunctionConfig(secondary, maxInput2, maxOutput2); + curvePtrAlt->loadSettings(iniFile); + } + + } + + void initHeadPoseData(){ + headPos = 0.0f; + invert = 0.0f; + red = 0.0f; + rawList.clear(); + maxItems = 10.0f; + prevPos = 0.0f; + prevRawPos = 0.0f; + NeutralZone = 0; + MaxInput = 0; + confidence = 0.0f; + newSample = FALSE; + + qDebug() << "initHeadPoseData: " << curvePtr->getTitle(); + + } + float headPos; // Current position (from faceTracker, radials or meters) + float invert; // Invert measured value (= 1.0f or -1.0f) + float red; // Reduction factor (used for EWMA-filtering, between 0.0f and 1.0f) + QList rawList; // List of 'n' headPos values (used for moving average) + int maxItems; // Maximum number of elements in rawList + float prevPos; // Previous Position + float prevRawPos; // Previous Raw Position + + FunctionConfig* curvePtr; // Function to translate input -> output + FunctionConfig* curvePtrAlt; + + int NeutralZone; // Neutral zone + int MaxInput; // Maximum raw input + float confidence; // Current confidence + bool newSample; // Indicate new sample from tracker +}; + +// +// Structure to hold keycode and CTRL, SHIFT, ALT for shortkeys +// +struct TShortKey { + BYTE keycode; // Required Key + bool shift; // Modifiers to examine + bool ctrl; + bool alt; + bool doPitch; // Modifiers to act on axis + bool doYaw; + bool doRoll; + bool doX; + bool doY; + bool doZ; +}; + +class Tracker : public QThread { + Q_OBJECT + +private: + // Handles to neatly terminate thread... + HANDLE m_StopThread; + HANDLE m_WaitThread; + + static T6DOF current_camera; // Used for filtering + static T6DOF target_camera; + static T6DOF new_camera; + static T6DOF output_camera; + + ITrackerPtr pTracker; // Pointer to Tracker instance (in DLL) + ITrackerPtr pSecondTracker; // Pointer to second Tracker instance (in DLL) + static IProtocolPtr pProtocol; // Pointer to Protocol instance (in DLL) + static IFilterPtr pFilter; // Pointer to Filter instance (in DLL) + + static void addHeadPose( THeadPoseData head_pose ); + static void addRaw2List ( QList *rawList, float maxIndex, float raw ); + + static TShortKey CenterKey; // ShortKey to Center headposition + static TShortKey StartStopKey; // ShortKey to Start/stop tracking + static TShortKey InhibitKey; // ShortKey to disable one or more axis during tracking + static TShortKey GameZeroKey; // ShortKey to Set Game Zero +// static TShortKey AxisReverseKey; // ShortKey to reverse axis during tracking + + static int CenterMouseKey; // ShortKey to Center headposition + static int StartStopMouseKey; // ShortKey to Start/stop tracking + static int InhibitMouseKey; // ShortKey to disable one or more axis during tracking + static int GameZeroMouseKey; // ShortKey to Set Game Zero + static bool DisableBeep; // Disable Beep when center is pressed + + // Flags to start/stop/reset tracking + static bool confid; // Tracker data is OK + static bool do_tracking; // Start/stop tracking, using the shortkey + static bool do_center; // Center head-position, using the shortkey + static bool do_inhibit; // Inhibit DOF-axis, using the shortkey + static bool do_game_zero; // Set in-game zero, using the shortkey + static bool do_axis_reverse; // Axis reverse, using the shortkey + + static HANDLE hTrackMutex; // Prevent reading/writing the headpose simultaneously + + static bool setZero; // Set to zero's, when OFF (one-shot) + static bool setEngineStop; // Stop tracker->engine, when OFF + + static bool useAxisReverse; // Use Axis Reverse + static float YawAngle4ReverseAxis; // Axis Reverse settings + static float Z_Pos4ReverseAxis; + static float Z_PosWhenReverseAxis; + + FaceTrackNoIR *mainApp; + +protected: + // qthread override run method + void run(); + +public: + Tracker( FaceTrackNoIR *parent ); + ~Tracker(); + + /** static member variables for saving the head pose **/ + static THeadPoseDOF Pitch; // Head-rotation X-direction (Up/Down) + static THeadPoseDOF Yaw; // Head-rotation Y-direction () + static THeadPoseDOF Roll; // Head-rotation Z-direction () + static THeadPoseDOF X; // Head-movement X-direction (Left/Right) + static THeadPoseDOF Y; // Head-movement Y-direction (Up/Down) + static THeadPoseDOF Z; // Head-movement Z-direction (To/From camera) + + void setup(); + +// void registerHeadPoseCallback(); + bool handleGameCommand ( int command ); + QString getGameProgramName(); // Get the ProgramName from the game and display it. + void loadSettings(); // Load settings from the INI-file + bool isShortKeyPressed( TShortKey *key, BYTE *keystate ); + bool isMouseKeyPressed( int *key, DIMOUSESTATE *mousestate ); + + static bool getTrackingActive() { return do_tracking && confid; } + static bool getAxisReverse() { return do_axis_reverse; } + + static bool getConfid() { return confid; } + + static void setInvertPitch(bool invert) { Pitch.invert = invert?-1.0f:+1.0f; } + static void setInvertYaw(bool invert) { Yaw.invert = invert?-1.0f:+1.0f; } + static void setInvertRoll(bool invert) { Roll.invert = invert?-1.0f:+1.0f; } + static void setInvertX(bool invert) { X.invert = invert?-1.0f:+1.0f; } + static void setInvertY(bool invert) { Y.invert = invert?-1.0f:+1.0f; } + static void setInvertZ(bool invert) { Z.invert = invert?-1.0f:+1.0f; } + + 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; } // Return the pointer for the active Filter + ITracker *getTrackerPtr() { return pTracker; } // Return the pointer for the active Tracker + ITracker *getSecondTrackerPtr() { return pSecondTracker; } // Return the pointer for the secondary Tracker + IProtocol *getProtocolPtr() { return pProtocol; } // Return the pointer for the active Protocol + + void doRefreshVideo() { // Call the face-tracker-function RefreshVideo + if (pTracker) { + pTracker->refreshVideo(); + } + if (pSecondTracker) { + pSecondTracker->refreshVideo(); + } + }; + + static float getSmoothFromList ( QList *rawList ); + static float getDegreesFromRads ( float rads ) { return (rads * 57.295781f); } + static float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } + + // For now, use one slider for all + void setSmoothing(int x) { + Pitch.maxItems = x; + Yaw.maxItems = x; + Roll.maxItems = x; + X.maxItems = x; + Y.maxItems = x; + Z.maxItems = x; + } + +}; + +#endif \ No newline at end of file diff --git a/facetracknoir/tracker_types.cpp b/facetracknoir/tracker_types.cpp new file mode 100644 index 00000000..cdd8d239 --- /dev/null +++ b/facetracknoir/tracker_types.cpp @@ -0,0 +1,44 @@ +#include "tracker_types.h" +#include "rotation.h" + +const double PI = 3.14159265358979323846264; +const double D2R = PI/180.0; +const double R2D = 180.0/PI; + +T6DOF operator-(const T6DOF& A, const T6DOF& B) +{ + Rotation R_A(A.yaw*D2R, A.pitch*D2R, A.roll*D2R); + Rotation R_B(B.yaw*D2R, B.pitch*D2R, B.roll*D2R); + Rotation R_C = R_A * R_B.inv(); + + T6DOF C; + R_C.toEuler(C.yaw, C.pitch, C.roll); + C.yaw *= R2D; + C.pitch *= R2D; + C.roll *= R2D; + + C.x = A.x - B.x; + C.y = A.y - B.y; + C.z = A.z - B.z; + //C.frame_number? + return C; +} + +T6DOF operator+(const T6DOF& A, const T6DOF& B) +{ + Rotation R_A(A.yaw*D2R, A.pitch*D2R, A.roll*D2R); + Rotation R_B(B.yaw*D2R, B.pitch*D2R, B.roll*D2R); + Rotation R_C = R_A * R_B; + + T6DOF C; + R_C.toEuler(C.yaw, C.pitch, C.roll); + C.yaw *= R2D; + C.pitch *= R2D; + C.roll *= R2D; + + C.x = A.x + B.x; + C.y = A.y + B.y; + C.z = A.z + B.z; + //C.frame_number? + return C; +} diff --git a/facetracknoir/tracker_types.h b/facetracknoir/tracker_types.h new file mode 100644 index 00000000..5a13af85 --- /dev/null +++ b/facetracknoir/tracker_types.h @@ -0,0 +1,45 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 - 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ +/* + Modifications (last one on top): + 20120924 - C14: Moved tracker types only used by Tracker to this file (should not be part of public interface) + Modified operators to represent correct frame transitions +*/ +#ifndef __TRACKER_TYPES_H__ +#define __TRACKER_TYPES_H__ + +#include "..\ftnoir_tracker_base\ftnoir_tracker_types.h" + +class T6DOF : public THeadPoseData +{ +public: + T6DOF() : THeadPoseData() {} + + T6DOF(double x, double y, double z, double yaw, double pitch, double roll) + : THeadPoseData(x,y,z, yaw,pitch,roll) {} +}; + +T6DOF operator-(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B +T6DOF operator+(const T6DOF& A, const T6DOF& B); // get new pose with respect to reference pose B^-1 + +#endif //__TRACKER_TYPES_H__ \ No newline at end of file diff --git a/facetracknoir_vc8.sln b/facetracknoir_vc8.sln new file mode 100644 index 00000000..65577c99 --- /dev/null +++ b/facetracknoir_vc8.sln @@ -0,0 +1,82 @@ +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_EWMA2", "FTNoIR_Filter_EWMA2\FTNoIR_Filter_EWMA2_vc8.vcproj", "{7DD9F1AA-B7C0-4056-AC4A-1501840E6438}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_SM", "FTNoIR_Tracker_SM\FTNoIR_Tracker_SM_vc8.vcproj", "{26346BCF-92A5-47A7-B4CF-73C402F7C3AD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_FaceAPI_EXE", "faceAPI\FaceAPI2FSX_vc8.vcproj", "{EF743D32-0980-44D9-BA9E-B9D2456251AC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FTIR", "FTNoIR_Protocol_FTIR\FTNoIR_Protocol_FTIR_vc8.vcproj", "{BC5B8583-036A-4A9B-84AE-01158EE6F5A4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FT", "FTNoIR_Protocol_FT\FTNoIR_Protocol_FT_vc8.vcproj", "{FE2FF09B-207D-468C-9763-23861956F388}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FaceTrackNoIR", "FaceTrackNoIR\FaceTrackNoIR_vc8.vcproj", "{9DCDB5B9-941E-42F7-AF76-DF794AA3C013}" + ProjectSection(ProjectDependencies) = postProject + {2527B683-7EFC-4D51-B25A-843668649C54} = {2527B683-7EFC-4D51-B25A-843668649C54} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QFunctionConfigurator", "QFunctionConfigurator\QFunctionConfigurator\QFunctionConfigurator.vcproj", "{2527B683-7EFC-4D51-B25A-843668649C54}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_Accela", "FTNoIR_Filter_Accela\FTNoIR_Filter_accela_vc8.vcproj", "{2212857A-7634-4E30-BA83-539EC70176E6}" + ProjectSection(ProjectDependencies) = postProject + {2527B683-7EFC-4D51-B25A-843668649C54} = {2527B683-7EFC-4D51-B25A-843668649C54} + EndProjectSection +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_UDP", "FTNoIR_Tracker_UDP\FTNoIR_Tracker_UDP_vc8.vcproj", "{507B92A6-8725-4921-9432-2864EF2B64D9}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_HT", "FTNoIR_Tracker_HT\FTNoIR_Tracker_HT_vc8.vcproj", "{61F2B142-F7DD-4070-8A68-53AD63A5D528}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.ActiveCfg = Debug|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.Build.0 = Debug|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.ActiveCfg = Release|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.Build.0 = Release|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.ActiveCfg = Debug|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.Build.0 = Debug|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.ActiveCfg = Release|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.Build.0 = Release|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.ActiveCfg = Debug|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.Build.0 = Debug|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.ActiveCfg = Release|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.Build.0 = Release|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.ActiveCfg = Debug|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.Build.0 = Debug|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.ActiveCfg = Release|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.Build.0 = Release|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.ActiveCfg = Debug|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.Build.0 = Debug|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.ActiveCfg = Release|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.Build.0 = Release|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.ActiveCfg = Debug|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.Build.0 = Debug|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.ActiveCfg = Release|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.Build.0 = Release|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.ActiveCfg = Debug|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.Build.0 = Debug|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.ActiveCfg = Release|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.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 + {2212857A-7634-4E30-BA83-539EC70176E6}.Release|Win32.Build.0 = Release|Win32 + {507B92A6-8725-4921-9432-2864EF2B64D9}.Debug|Win32.ActiveCfg = Debug|Win32 + {507B92A6-8725-4921-9432-2864EF2B64D9}.Debug|Win32.Build.0 = Debug|Win32 + {507B92A6-8725-4921-9432-2864EF2B64D9}.Release|Win32.ActiveCfg = Release|Win32 + {507B92A6-8725-4921-9432-2864EF2B64D9}.Release|Win32.Build.0 = Release|Win32 + {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Debug|Win32.ActiveCfg = Debug|Win32 + {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Debug|Win32.Build.0 = Debug|Win32 + {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Release|Win32.ActiveCfg = Release|Win32 + {61F2B142-F7DD-4070-8A68-53AD63A5D528}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + QtVersion = qt-everywhere-opensource-src-4.6.2 + EndGlobalSection +EndGlobal diff --git a/facetracknoir_vc9.sln b/facetracknoir_vc9.sln new file mode 100644 index 00000000..1ba0c10e --- /dev/null +++ b/facetracknoir_vc9.sln @@ -0,0 +1,119 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_UDP", "FTNoIR_Tracker_UDP\FTNoIR_Tracker_UDP_vc9.vcproj", "{A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_EWMA2", "FTNoIR_Filter_EWMA2\FTNoIR_Filter_EWMA2_vc9.vcproj", "{7DD9F1AA-B7C0-4056-AC4A-1501840E6438}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_SM", "FTNoIR_Tracker_SM\FTNoIR_Tracker_SM_vc9.vcproj", "{26346BCF-92A5-47A7-B4CF-73C402F7C3AD}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_FaceAPI_EXE", "faceAPI\FaceAPI2FSX_vc9.vcproj", "{EF743D32-0980-44D9-BA9E-B9D2456251AC}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FG", "FTNoIR_Protocol_FG\FTNoIR_Protocol_FG_vc9.vcproj", "{7C77C833-5687-4A35-B219-4CF4D3D8E626}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FTIR", "FTNoIR_Protocol_FTIR\FTNoIR_Protocol_FTIR_vc9.vcproj", "{BC5B8583-036A-4A9B-84AE-01158EE6F5A4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FT", "FTNoIR_Protocol_FT\FTNoIR_Protocol_FT_vc9.vcproj", "{FE2FF09B-207D-468C-9763-23861956F388}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_PPJOY", "FTNoIR_Protocol_PPJOY\FTNoIR_Protocol_PPJOY_vc9.vcproj", "{8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_SC", "FTNoIR_Protocol_SC\FTNoIR_Protocol_SC_vc9.vcproj", "{B8F3B67B-6C25-4E06-8076-0513D2368A1F}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FSUIPC", "FTNoIR_Protocol_FSUIPC\FTNoIR_Protocol_FSUIPC_vc9.vcproj", "{46E66901-0212-410A-99B6-793F7ACD2ED0}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_FTN", "FTNoIR_Protocol_FTN\FTNoIR_Protocol_FTN_vc9.vcproj", "{166A9AF8-90E0-4889-ADAA-5E6E3DD20194}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Protocol_MOUSE", "FTNoIR_Protocol_MOUSE\FTNoIR_Protocol_MOUSE_vc9.vcproj", "{BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FaceTrackNoIR", "FaceTrackNoIR\FaceTrackNoIR_vc9.vcproj", "{9DCDB5B9-941E-42F7-AF76-DF794AA3C013}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_FD", "FTNoIR_Tracker_FD\FTNoIR_Tracker_FD_vc9.vcproj", "{0FE16301-240D-42B9-9141-12294BA08AC4}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Filter_Accela", "FTNoIR_Filter_Accela\FTNoIR_Filter_accela_vc9.vcproj", "{2212857A-7634-4E30-BA83-539EC70176E6}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FTNoIR_Tracker_PT", "FTNoIR_Tracker_PT\FTNoIR_Tracker_PT_vc9.vcproj", "{7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}" +EndProject +Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "SetupFaceTrackNoIR", "SetupFaceTrackNoIR\SetupFaceTrackNoIR_vc9.vdproj", "{043D4535-6CF9-439A-A144-80208CA0313B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Debug|Win32.ActiveCfg = Debug|Win32 + {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Debug|Win32.Build.0 = Debug|Win32 + {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Release|Win32.ActiveCfg = Release|Win32 + {A42E7DE9-C1C5-48A2-8FEA-86D31CE3DA31}.Release|Win32.Build.0 = Release|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.ActiveCfg = Debug|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Debug|Win32.Build.0 = Debug|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.ActiveCfg = Release|Win32 + {7DD9F1AA-B7C0-4056-AC4A-1501840E6438}.Release|Win32.Build.0 = Release|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.ActiveCfg = Debug|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Debug|Win32.Build.0 = Debug|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.ActiveCfg = Release|Win32 + {26346BCF-92A5-47A7-B4CF-73C402F7C3AD}.Release|Win32.Build.0 = Release|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.ActiveCfg = Debug|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Debug|Win32.Build.0 = Debug|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.ActiveCfg = Release|Win32 + {EF743D32-0980-44D9-BA9E-B9D2456251AC}.Release|Win32.Build.0 = Release|Win32 + {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Debug|Win32.ActiveCfg = Debug|Win32 + {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Debug|Win32.Build.0 = Debug|Win32 + {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Release|Win32.ActiveCfg = Release|Win32 + {7C77C833-5687-4A35-B219-4CF4D3D8E626}.Release|Win32.Build.0 = Release|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.ActiveCfg = Debug|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Debug|Win32.Build.0 = Debug|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.ActiveCfg = Release|Win32 + {BC5B8583-036A-4A9B-84AE-01158EE6F5A4}.Release|Win32.Build.0 = Release|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.ActiveCfg = Debug|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Debug|Win32.Build.0 = Debug|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.ActiveCfg = Release|Win32 + {FE2FF09B-207D-468C-9763-23861956F388}.Release|Win32.Build.0 = Release|Win32 + {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Debug|Win32.ActiveCfg = Debug|Win32 + {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Debug|Win32.Build.0 = Debug|Win32 + {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Release|Win32.ActiveCfg = Release|Win32 + {8751C6A1-A504-49C6-9D82-A66CDCBFA2AB}.Release|Win32.Build.0 = Release|Win32 + {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Debug|Win32.ActiveCfg = Debug|Win32 + {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Debug|Win32.Build.0 = Debug|Win32 + {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Release|Win32.ActiveCfg = Release|Win32 + {B8F3B67B-6C25-4E06-8076-0513D2368A1F}.Release|Win32.Build.0 = Release|Win32 + {46E66901-0212-410A-99B6-793F7ACD2ED0}.Debug|Win32.ActiveCfg = Debug|Win32 + {46E66901-0212-410A-99B6-793F7ACD2ED0}.Debug|Win32.Build.0 = Debug|Win32 + {46E66901-0212-410A-99B6-793F7ACD2ED0}.Release|Win32.ActiveCfg = Release|Win32 + {46E66901-0212-410A-99B6-793F7ACD2ED0}.Release|Win32.Build.0 = Release|Win32 + {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Debug|Win32.ActiveCfg = Debug|Win32 + {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Debug|Win32.Build.0 = Debug|Win32 + {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Release|Win32.ActiveCfg = Release|Win32 + {166A9AF8-90E0-4889-ADAA-5E6E3DD20194}.Release|Win32.Build.0 = Release|Win32 + {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Debug|Win32.ActiveCfg = Debug|Win32 + {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Debug|Win32.Build.0 = Debug|Win32 + {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Release|Win32.ActiveCfg = Release|Win32 + {BD90CC3A-965C-4DAF-8D3D-8AABA455BA9E}.Release|Win32.Build.0 = Release|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.ActiveCfg = Debug|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Debug|Win32.Build.0 = Debug|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.ActiveCfg = Release|Win32 + {9DCDB5B9-941E-42F7-AF76-DF794AA3C013}.Release|Win32.Build.0 = Release|Win32 + {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 + {2212857A-7634-4E30-BA83-539EC70176E6}.Release|Win32.Build.0 = Release|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Debug|Win32.ActiveCfg = Debug|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Debug|Win32.Build.0 = Debug|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Release|Win32.ActiveCfg = Release|Win32 + {7A2A2560-9253-4CC8-A9D5-4B9D9C224D9D}.Release|Win32.Build.0 = Release|Win32 + {043D4535-6CF9-439A-A144-80208CA0313B}.Debug|Win32.ActiveCfg = Debug + {043D4535-6CF9-439A-A144-80208CA0313B}.Debug|Win32.Build.0 = Debug + {043D4535-6CF9-439A-A144-80208CA0313B}.Release|Win32.ActiveCfg = Release + {043D4535-6CF9-439A-A144-80208CA0313B}.Release|Win32.Build.0 = Release + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + QtVersion = QT114 + EndGlobalSection +EndGlobal diff --git a/freetrackclient/FTClient.cpp b/freetrackclient/FTClient.cpp new file mode 100644 index 00000000..d48a2c28 --- /dev/null +++ b/freetrackclient/FTClient.cpp @@ -0,0 +1,119 @@ +/** @file + @brief +*/ +#include "FTClient.h" + + + + + static double/*?*/ const FT_PROGRAMID = "FT_ProgramID"; + + + HANDLE hFTMemMap; + PFreetrackData FTData; + unsigned long lastDataID; + PHandle FTHandle; + PAnsiChar FTProgramName; + HANDLE FTMutex; + + +bool FTGetData(PFreetrackData data) +{ bool result; + result = false; + if( !! FTData ) { + if( FTData->DataID != lastDataID ) { + Move( FTData/*?*/^ , data/*?*/^ , SizeOf( TFreetrackData ) ); + lastDataID = FTData->DataID; + result = true; + } + } else + OpenMapping; +return result; +} + + +void FTReportName(PAnsiChar name) +{ + unsigned long MsgResult; + + if( OpenMapping && ( WaitForSingleObject( FTMutex , 100 ) == WAIT_OBJECT_0 ) ) { + Move( name/*?*/^ , FTProgramName/*?*/^ , 100 ); + SendMessageTimeout( FTHandle/*?*/^ , RegisterWindowMessage( FT_PROGRAMID ) , 0 , 0 , 0 , 2000 , MsgResult ); + ReleaseMutex( FTMutex ); + } +} + + +char* FTGetDllVersion() +{ char* result; + unsigned long VerInfoSize; + Pointer VerInfo; + unsigned long VerValueSize; + PVSFixedFileInfo VerValue; + unsigned long Dummy; + std::string verString; + char* dllName[100]; + + result = ""; + GetModuleFilename( HInstance , &dllName , 100 ); + VerInfoSize = GetFileVersionInfoSize( &dllName , Dummy ); + if( !( VerInfoSize == 0 ) ) { + GetMem( VerInfo , VerInfoSize ); + GetFileVersionInfo( &dllName , 0 , VerInfoSize , VerInfo ); + VerQueryValue( VerInfo , "\\" , Pointer( VerValue ) , VerValueSize ); + /*?*//* WITH VerValue/*?*/^ */ + { + verString = IntToStr( dwFileVersionMS >> 16 ); + verString = verString + "." + IntToStr( dwFileVersionMS && 0xFFFF ); + verString = verString + "." + IntToStr( dwFileVersionLS >> 16 ); + verString = verString + "." + IntToStr( dwFileVersionLS && 0xFFFF ); + result = char*( verString ); + } + FreeMem( VerInfo , VerInfoSize ); + } +return result; +} + + +char* FTProvider() +{ char* result; + result = FREETRACK;return result; +} + + + + + +bool OpenMapping() +{ bool result; + if( hFTMemMap != 0 ) + result = true;else { + hFTMemMap = OpenFileMapping( FILE_MAP_ALL_ACCESS , false , FT_MM_DATA ); + if( ( hFTMemMap != 0 ) ) { + FTData = MapViewOfFile( hFTMemMap , FILE_MAP_ALL_ACCESS , 0 , 0 , SizeOf( TFreetrackData ) + SizeOf( HANDLE ) + 100 ); + FTHandle = Pointer( unsigned long( FTData ) + SizeOf( TFreetrackData ) ); + FTProgramName = Pointer( unsigned long( FTHandle ) + SizeOf( HANDLE ) ); + FTMutex = OpenMutex( MUTEX_ALL_ACCESS , false , FREETRACK_MUTEX ); + } + result = !! FTData; + } +return result; +} + + +void DestroyMapping() +{ + if( FTData != 00 ) { + UnMapViewofFile( FTData ); + FTData = 00; + } + + CloseHandle( FTMutex ); + CloseHandle( hFTMemMap ); + hFTMemMap = 0; +} + + + + +//END diff --git a/freetrackclient/FTClient.h b/freetrackclient/FTClient.h new file mode 100644 index 00000000..406e1237 --- /dev/null +++ b/freetrackclient/FTClient.h @@ -0,0 +1,30 @@ +/** @file + @brief +*/ +#pragma once +#ifndef INCLUDED_FTCLIENT_H +#define INCLUDED_FTCLIENT_H + + + + + + +#include "Windows.h" +#include "SysUtils.h" +#include "FTTypes.h" + +/*__stdcall*/ bool FTGetData(PFreetrackData data); +/*__stdcall*/ void FTReportName(PAnsiChar name); +/*__stdcall*/ char* FTGetDllVersion(); +/*__stdcall*/ char* FTProvider(); + + +bool OpenMapping(); +void DestroyMapping(); + + + + +#endif//INCLUDED_FTCLIENT_H +//END diff --git a/freetrackclient/FreeTrackClient.sln b/freetrackclient/FreeTrackClient.sln new file mode 100644 index 00000000..5bbc5a5b --- /dev/null +++ b/freetrackclient/FreeTrackClient.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "FreeTrackClient", "FreeTrackClient\FreeTrackClient.vcproj", "{74CE36A5-0E38-4252-AAD1-7B2066247F0E}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + Release64|Win32 = Release64|Win32 + Release64|x64 = Release64|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|Win32.ActiveCfg = Release|Win32 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|Win32.Build.0 = Release|Win32 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|x64.ActiveCfg = Release|x64 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release|x64.Build.0 = Release|x64 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|Win32.ActiveCfg = Release64|Win32 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|Win32.Build.0 = Release64|Win32 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|x64.ActiveCfg = Release64|x64 + {74CE36A5-0E38-4252-AAD1-7B2066247F0E}.Release64|x64.Build.0 = Release64|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/freetrackclient/FreeTrackClient/FreeTrackClient.cpp b/freetrackclient/FreeTrackClient/FreeTrackClient.cpp new file mode 100644 index 00000000..e02f2fe8 --- /dev/null +++ b/freetrackclient/FreeTrackClient/FreeTrackClient.cpp @@ -0,0 +1,294 @@ +/******************************************************************************** +* FreeTrackClientDll Implements the FreeTrack 2.0 interface for FT-enabled * +* games. * +* It uses the FreeTrack protocol (memory mapping) to * +* receive data from FaceTrackNoIR (or FreeTrack, or ...). * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Testing and Research) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + + 20130208 - WVR: The old DLL from FreeTrack seems to crash ArmA2. And we need 64-bit support. + +*/ + +#ifdef WIN64 +#pragma comment(linker, "/export:FTGetData") +#pragma comment(linker, "/export:FTReportName") +#pragma comment(linker, "/export:FTGetDllVersion") +#pragma comment(linker, "/export:FTProvider") +#endif + +#ifdef WIN64 +# define FT_DECLSPEC __declspec(dllexport) +#else +# define FT_DECLSPEC +#endif + +#define FT_EXPORT(t) extern "C" t FT_DECLSPEC __stdcall +#define NP_AXIS_MAX 16383 + +#include +#include +#include +#include +#include +#include + +#include "..\..\FTNOIR_PROTOCOL_FT\FTTypes.h" + +// +// Functions to create/open the file-mapping +// and to destroy it again. +// +bool FTCreateMapping(); +void FTDestroyMapping(); +float scale2AnalogLimits( float x, float min_x, float max_x ); +float getDegreesFromRads ( float rads ); + +#if 1 +static FILE *debug_stream = fopen("c:\\FreeTrackClient.log", "a"); +#define dbg_report(...) if (debug_stream) { fprintf(debug_stream, __VA_ARGS__); fflush(debug_stream); } +#else +#define dbg_report(...) +#endif + +// +// Handles to 'handle' the memory mapping +// +static HANDLE hFTMemMap = 0; +static FTMemMap *pMemData = 0; +static HANDLE hFTMutex = 0; +static char* dllVersion = "1.0.0.0"; +static char* dllProvider = "FreeTrack"; + +static unsigned short gameid = 0; + +// +// DllMain gets called, when the DLL is (un)loaded or a process attaches. +// +BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved) +{ + switch (fdwReason) { + case DLL_PROCESS_ATTACH: +#ifdef WIN64 + dbg_report("\n= WIN64 =========================================================================================\n"); +#else + dbg_report("\n= WIN32 =========================================================================================\n"); +#endif + dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + dbg_report("DllMain: Attach request\n"); + DisableThreadLibraryCalls(hinstDLL); + break; + + case DLL_PROCESS_DETACH: + dbg_report("DllMain: Detach\n"); + dbg_report("DllMain: (0x%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved); + dbg_report("==========================================================================================\n"); + break; + } + return TRUE; +} + +/****************************************************************** + * FTGetData (FreeTrackClient.1) + */ +#pragma comment(linker, "/export:FTGetData@4=FTGetData") +FT_EXPORT(bool) FTGetData(PFreetrackData data) +{ + static int frame = 0; + static int prevDataID = 0; + static int dlyTrackingOff = 0; + static int tracking = 0; + +// dbg_report("NP_GetData called."); + if (FTCreateMapping() == false) return false; + + if (hFTMutex && WaitForSingleObject(hFTMutex, 5) == WAIT_OBJECT_0) { + if (pMemData) { + + // + // When FaceTrackNoIR does not update frames (any more), don't update the data. + // + if (prevDataID != pMemData->data.DataID) { + memcpy(data, &pMemData->data, sizeof(TFreeTrackData)); + dlyTrackingOff = 0; + } + else { + dlyTrackingOff++; + if (dlyTrackingOff > 20) { + dlyTrackingOff = 100; + tracking = false; + } + } + prevDataID = pMemData->data.DataID; + + // + // Limit the range of DataID + // + if (pMemData->data.DataID > 1000) { + pMemData->data.DataID = 0; + } + data->DataID = pMemData->data.DataID; + + // + // Send the ID to FaceTrackNoIR, so it can display the game-name. + // This could be a FreeTrack-specific ID + // + sprintf_s(pMemData->GameID, 19, "%d", gameid ); + + } + ReleaseMutex(hFTMutex); + } + return true; +} + +/****************************************************************** + * FTReportName (FreeTrackClient.2) + */ +#pragma comment(linker, "/export:FTReportName@4=FTReportName") +// +// For some mysterious reason, the previously existing function FTReportID has been changed to FTReportName, but with an integer as argument. +// The Delphi-code from the FreeTrack repo suggest a char * as argument, so it cost me an afternoon to figure it out (and keep ArmA2 from crashing). +// Thanks guys! +// +FT_EXPORT(void) FTReportName( int name ) +{ + dbg_report("FTReportName request (ID = %d).\n", name); + gameid = name; // They might have really passed the name here... but they didn't! + return; +} + +/****************************************************************** + * FTGetDllVersion (FreeTrackClient.3) + */ +#pragma comment(linker, "/export:FTGetDllVersion@0=FTGetDllVersion") +extern "C" __declspec( dllexport ) char* FTGetDllVersion(void) +{ + dbg_report("FTGetDllVersion request.\n"); + + return dllVersion; +} + +/****************************************************************** + * FTProvider (FreeTrackClient.4) + */ +#pragma comment(linker, "/export:FTProvider@0=FTProvider") +extern "C" __declspec( dllexport ) char* FTProvider(void) +{ + dbg_report("FTProvider request.\n"); + + return dllProvider; +} + +// +// Create a memory-mapping to the Freetrack data. +// It contains the tracking data, a handle to the main-window and the program-name of the Game! +// +// +bool FTCreateMapping() +{ + bool bMappingExists = false; + PDWORD_PTR MsgResult = 0; + + // + // Memory-mapping already exists! + // + if ( pMemData != NULL ) { + return true; + } + + dbg_report("FTCreateMapping request (pMemData == NULL).\n"); + + // + // A FileMapping is used to create 'shared memory' between the FTClient and the FTServer. + // + // Try to create a FileMapping to the Shared Memory. This is done to check if it's already there (what + // may mean the face-tracker program is already running). + // + // If one already exists: close it and open the file-mapping to the existing one. + // + hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , + sizeof( FTMemMap ), + (LPCSTR) FT_MM_DATA ); + + if ( ( hFTMemMap != 0 ) && ( GetLastError() == ERROR_ALREADY_EXISTS ) ) { + dbg_report("FTCreateMapping: Mapping already exists.\n"); + bMappingExists = true; // So the server was (probably) already started! + CloseHandle( hFTMemMap ); + hFTMemMap = 0; + } + + // + // Create a new FileMapping, Read/Write access + // + hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA ); + if ( ( hFTMemMap != 0 ) ) { + dbg_report("FTCreateMapping: Mapping opened.\n"); + pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof( FTMemMap ) ); + hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); + } + else { + return false; + } + return true; +} + +// +// Destory the FileMapping to the shared memory +// +void FTDestroyMapping() +{ + if ( pMemData != NULL ) { + UnmapViewOfFile ( pMemData ); + } + + CloseHandle( hFTMutex ); + CloseHandle( hFTMemMap ); + pMemData = 0; + hFTMemMap = 0; +} + +// +// 4 convenience +// +float getDegreesFromRads ( float rads ) { + return (rads * 57.295781f); +} + +// +// Scale the measured value to the TIR values +// +float scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; +double local_x; + + local_x = x; + if (local_x > max_x) { + local_x = max_x; + } + if (local_x < min_x) { + local_x = min_x; + } + y = ( NP_AXIS_MAX * local_x ) / max_x; + + return (float) y; +} diff --git a/freetrackclient/FreeTrackClient/FreeTrackClient.rc b/freetrackclient/FreeTrackClient/FreeTrackClient.rc new file mode 100644 index 00000000..299beb82 --- /dev/null +++ b/freetrackclient/FreeTrackClient/FreeTrackClient.rc @@ -0,0 +1,103 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// Dutch (Netherlands) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_NLD) +#ifdef _WIN32 +LANGUAGE LANG_DUTCH, SUBLANG_DUTCH +#pragma code_page(1252) +#endif //_WIN32 + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + + +///////////////////////////////////////////////////////////////////////////// +// +// Version +// + +VS_VERSION_INFO VERSIONINFO + FILEVERSION 1,0,0,1 + PRODUCTVERSION 1,0,0,1 + FILEFLAGSMASK 0x17L +#ifdef _DEBUG + FILEFLAGS 0x1L +#else + FILEFLAGS 0x0L +#endif + FILEOS 0x4L + FILETYPE 0x2L + FILESUBTYPE 0x0L +BEGIN + BLOCK "StringFileInfo" + BEGIN + BLOCK "041304b0" + BEGIN + VALUE "Comments", "FreeTrack interface for FaceTrackNoIR." + VALUE "CompanyName", "FaceTrackNoIR Team" + VALUE "FileDescription", "64-bit interface for FreeTrack-enables games." + VALUE "FileVersion", "1, 0, 0, 1" + VALUE "InternalName", "FreeTrackClient" + VALUE "LegalCopyright", "Copyright (C) 2013, FaceTrackNoIR Team" + VALUE "OriginalFilename", "FreeTrackClient64.dll" + VALUE "ProductName", "Interface DLL for FreeTrack 2.0" + VALUE "ProductVersion", "1, 0, 0, 1" + END + END + BLOCK "VarFileInfo" + BEGIN + VALUE "Translation", 0x413, 1200 + END +END + +#endif // Dutch (Netherlands) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/freetrackclient/FreeTrackClient/FreeTrackClient.vcproj b/freetrackclient/FreeTrackClient/FreeTrackClient.vcproj new file mode 100644 index 00000000..7d69802e --- /dev/null +++ b/freetrackclient/FreeTrackClient/FreeTrackClient.vcproj @@ -0,0 +1,556 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/freetrackclient/FreeTrackClient/postbuild.bat b/freetrackclient/FreeTrackClient/postbuild.bat new file mode 100644 index 00000000..87c192d1 --- /dev/null +++ b/freetrackclient/FreeTrackClient/postbuild.bat @@ -0,0 +1,15 @@ +@echo off +rem Copies required DLL files into output folder. + +setlocal +set COPY=xcopy /D /S /C /I /H /R /Y +set FILTER=find /v "File(s) copied" + +echo parameters %1 en %2 + +set API_BIN=%1 +set FTN_BIN=%2 + +%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% +exit /b 0 + diff --git a/freetrackclient/FreeTrackClient/resource.h b/freetrackclient/FreeTrackClient/resource.h new file mode 100644 index 00000000..e517577e --- /dev/null +++ b/freetrackclient/FreeTrackClient/resource.h @@ -0,0 +1,15 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by FreeTrackClient.rc +// + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/ftnoir_filter_accela/FTNoIR_FilterControls.ui b/ftnoir_filter_accela/FTNoIR_FilterControls.ui new file mode 100644 index 00000000..af6522ce --- /dev/null +++ b/ftnoir_filter_accela/FTNoIR_FilterControls.ui @@ -0,0 +1,363 @@ + + + UICFilterControls + + + Qt::ApplicationModal + + + + 0 + 0 + 880 + 673 + + + + Filter settings + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + true + + + + 0 + 0 + + + + + 850 + 574 + + + + + 300 + 574 + + + + 0 + + + + Rotation + + + + + 20 + 20 + 819 + 510 + + + + 4 + + + 6 + + + 191 + + + 75 + + + 1 + + + 1 + + + + 255 + 170 + 0 + + + + + 192 + 192 + 192 + + + + Input + + + Output + + + Translation + + + + + + Translation + + + + + 20 + 20 + 819 + 510 + + + + 4 + + + 6 + + + 191 + + + 75 + + + 1 + + + 1 + + + + 85 + 255 + 0 + + + + + 192 + 192 + 192 + + + + Input + + + Output + + + + + + + + + + + + 25 + 0 + + + + + 150 + 16777215 + + + + color:#0; +background:none; + + + Reduction factor: + + + + + + + + 50 + 15 + + + + 1 + + + 100 + + + 5 + + + 100 + + + Qt::Horizontal + + + QSlider::NoTicks + + + + + + + + 35 + 22 + + + + background:none; + + + 1 + + + 100 + + + 100 + + + + + + + + 25 + 0 + + + + + 400 + 16777215 + + + + color:#0; +background:none; + + + (lowering this value will speed up response (in exchange for stability) + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + OK + + + + + + + Cancel + + + + + + + + + + QFunctionConfigurator + QWidget +
qfunctionconfigurator.h
+
+
+ + + + slideReduction + valueChanged(int) + spinReduction + setValue(int) + + + 219 + 620 + + + 310 + 622 + + + + + spinReduction + valueChanged(int) + slideReduction + setValue(int) + + + 315 + 613 + + + 170 + 621 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + +
diff --git a/ftnoir_filter_accela/FTNoIR_Filter_accela.h b/ftnoir_filter_accela/FTNoIR_Filter_accela.h new file mode 100644 index 00000000..77aa59ea --- /dev/null +++ b/ftnoir_filter_accela/FTNoIR_Filter_accela.h @@ -0,0 +1,150 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTN_FILTER_H +#define INCLUDED_FTN_FILTER_H + +#include "..\ftnoir_filter_base\ftnoir_filter_base.h" +#include "ui_FTNoIR_FilterControls.h" +#include + +const QPointF defScaleRotation[] = +{ + QPointF(0, 0), + QPointF(0.308900523560209, 0.0666666666666667), + QPointF(0.565445026178011, 0.226666666666667), + QPointF(0.769633507853403, 0.506666666666667), + QPointF(0.994764397905759, 1), + QPointF(1.23560209424084, 1.61333333333333), + QPointF(1.47643979057592, 2.37333333333333), + QPointF(1.66492146596859, 3.12), + QPointF(1.80628272251309, 3.92), + QPointF(1.91623036649215, 4.70666666666667), + QPointF(2.00523560209424, 5.44), + QPointF(2.07329842931937, 6) +}; + +const QPointF defScaleTranslation[] = +{ + QPointF(0, 0), + QPointF(0.282722513089005, 0.08), + QPointF(0.492146596858639, 0.306666666666667), + QPointF(0.764397905759162, 0.84), + QPointF(1.00523560209424, 1.62666666666667), + QPointF(1.17277486910995, 2.78666666666667), + QPointF(1.25130890052356, 3.6), + QPointF(1.31937172774869, 4.29333333333333), + QPointF(1.38219895287958, 4.90666666666667), + QPointF(1.43455497382199, 5.65333333333333) +}; + +// +// Macro to determine array-size +// +#define NUM_OF(x) (sizeof (x) / sizeof *(x)) + +//******************************************************************************************************* +// FaceTrackNoIR Filter class. +//******************************************************************************************************* +class FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + ~FTNoIR_Filter(); + + void Release(); + void Initialize(); + void StartFilter(); + void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); + +private: + void loadSettings(); // Load the settings from the INI-file + THeadPoseData newHeadPose; // Structure with new headpose + + bool first_run; + double kFactor, kFactorTranslation; + double kSensitivity, kSensitivityTranslation; + double kMagicNumber; // Stanislaws' magic number (should be 100 according to him...) + + FunctionConfig functionConfig; + FunctionConfig translationFunctionConfig; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* + +// Widget that has controls for FTNoIR protocol filter-settings. +class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog +{ + Q_OBJECT +public: + + explicit FilterControls(); + virtual ~FilterControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent, IFilterPtr ptr); + +private: + Ui::UICFilterControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + + IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance + FunctionConfig functionConfig; + FunctionConfig translationFunctionConfig; + +private slots: + void doOK(); + void doCancel(); + void settingChanged(bool) { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter +//******************************************************************************************************* +class FTNoIR_FilterDll : public IFilterDll +{ +public: + FTNoIR_FilterDll(); + ~FTNoIR_FilterDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Filter Mk2"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Accela Mk2"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Accela filter Mk2"); }; + + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; +}; + + +#endif //INCLUDED_FTN_FILTER_H +//END + diff --git a/ftnoir_filter_accela/FTNoIR_Filter_accela_vc8.vcproj b/ftnoir_filter_accela/FTNoIR_Filter_accela_vc8.vcproj new file mode 100644 index 00000000..e20c5ba0 --- /dev/null +++ b/ftnoir_filter_accela/FTNoIR_Filter_accela_vc8.vcproj @@ -0,0 +1,387 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_filter_accela/FTNoIR_Filter_accela_vc9.vcproj b/ftnoir_filter_accela/FTNoIR_Filter_accela_vc9.vcproj new file mode 100644 index 00000000..3999ca41 --- /dev/null +++ b/ftnoir_filter_accela/FTNoIR_Filter_accela_vc9.vcproj @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_filter_accela/Filter.qrc b/ftnoir_filter_accela/Filter.qrc new file mode 100644 index 00000000..9a7d75fa --- /dev/null +++ b/ftnoir_filter_accela/Filter.qrc @@ -0,0 +1,5 @@ + + + images/filter-16-ac.png + + diff --git a/ftnoir_filter_accela/ftnoir_filter_accela.cpp b/ftnoir_filter_accela/ftnoir_filter_accela.cpp new file mode 100644 index 00000000..3e4c3bf6 --- /dev/null +++ b/ftnoir_filter_accela/ftnoir_filter_accela.cpp @@ -0,0 +1,176 @@ +/* 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. + */ +/* + Modifications (last one on top): + 20120807 - WVR: FunctionConfig is now also used for the Filter. The extrapolation was adapted from Stanislaw. + Additional changes: I have added two parameters to the constructor of FunctionConfig and + renamed 3 member-functions (getFilterFullName is now called getFullName). +*/ +#include "ftnoir_filter_Accela.h" +#include "math.h" +#include +#include +#include + +FTNoIR_Filter::FTNoIR_Filter() : + functionConfig("Accela-Scaling-Rotation", 4, 6), + translationFunctionConfig("Accela-Scaling-Translation", 4, 6) +{ + first_run = true; + kMagicNumber = 100.0f; + loadSettings(); // Load the Settings +} + +FTNoIR_Filter::~FTNoIR_Filter() +{ + +} + +void FTNoIR_Filter::Initialize() +{ + loadSettings(); + return; +} + +void FTNoIR_Filter::loadSettings() { + QList defPoints; + + 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) + + defPoints.clear(); + for (int i = 0; i < NUM_OF(defScaleRotation); i++) { // Get the default points (hardcoded!) + defPoints.append(defScaleRotation[i]); + } + functionConfig.loadSettings(iniFile, defPoints); + + defPoints.clear(); + for (int i = 0; i < NUM_OF(defScaleTranslation); i++) { // Get the default points (hardcoded!) + defPoints.append(defScaleTranslation[i]); + } + translationFunctionConfig.loadSettings(iniFile, defPoints); + + iniFile.beginGroup ( "Accela" ); + kMagicNumber = iniFile.value ( "Reduction", 100 ).toFloat(); + iniFile.endGroup (); + +} + +void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) +{ + double target[6]; + double prev_output[6]; + float output[6]; + int i=0; + + prev_output[0]=current_camera_position->x; + prev_output[1]=current_camera_position->y; + prev_output[2]=current_camera_position->z; + prev_output[3]=current_camera_position->yaw; + prev_output[4]=current_camera_position->pitch; + prev_output[5]=current_camera_position->roll; + + target[0]=target_camera_position->x; + target[1]=target_camera_position->y; + target[2]=target_camera_position->z; + target[3]=target_camera_position->yaw; + target[4]=target_camera_position->pitch; + target[5]=target_camera_position->roll; + + if (first_run) + { + functionConfig.setTrackingActive(true); + translationFunctionConfig.setTrackingActive(true); + new_camera_position->x=target[0]; + new_camera_position->y=target[1]; + new_camera_position->z=target[2]; + new_camera_position->yaw=target[3]; + new_camera_position->pitch=target[4]; + new_camera_position->roll=target[5]; + + first_run=false; + return; + } + + for (i=0;i<6;i++) + { + if (_isnan(target[i])) + return; + + if (_isnan(prev_output[i])) + return; + + double e2 = target[i]; + double start = prev_output[i]; + double vec = e2 - start; + int sign = vec < 0 ? -1 : 1; + double x = fabs(vec); + QList points = (i >= 3 ? functionConfig : translationFunctionConfig).getPoints(); + int extrapolatep = 0; + double ratio; + double maxx; + double add; + // extrapolation of a spline + if (points.size() > 1) { + QPointF last = points[points.size() - 1]; + QPointF penultimate = points[points.size() - 2]; + ratio = (last.y() - penultimate.y()) / (last.x() - penultimate.x()); + extrapolatep = 1; + add = last.y(); + maxx = last.x(); + } + double foo = extrapolatep && x > maxx ? add + ratio * (x - maxx) : (i >= 3 ? functionConfig : translationFunctionConfig).getValue(x); + // the idea is that "empty" updates without new head pose data are still + // useful for filtering, as skipping them would result in jerky output. + // the magic "100" is the amount of calls to the filter by FTNOIR per sec. + // WVR: Added kMagicNumber for Patrick + double velocity = foo / 100.0; + if (kMagicNumber > 0.0f) { + double velocity = foo / kMagicNumber; + } + double sum = start + velocity * sign; + bool done = (sign > 0 ? sum >= e2 : sum <= e2); + if (done) { + output[i] = e2; + } else { + output[i] = sum; + } + + if (_isnan(output[i])) + return; + } + + new_camera_position->x=output[0]; + new_camera_position->y=output[1]; + new_camera_position->z=output[2]; + new_camera_position->yaw=output[3]; + new_camera_position->pitch=output[4]; + new_camera_position->roll=output[5]; + + current_camera_position->x=output[0]; + current_camera_position->y=output[1]; + current_camera_position->z=output[2]; + current_camera_position->yaw=output[3]; + current_camera_position->pitch=output[4]; + current_camera_position->roll=output[5]; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilter - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilter@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilter=_GetFilter@0") + +FTNOIR_FILTER_BASE_EXPORT IFilterPtr __stdcall GetFilter() +{ + return new FTNoIR_Filter; +} diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp new file mode 100644 index 00000000..c230eed8 --- /dev/null +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dialog.cpp @@ -0,0 +1,210 @@ +/******************************************************************************** +* 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) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20130102 - WVR: Added 'reduction factor' to accommodate Patrick's need for speed. +*/ +#include "ftnoir_filter_Accela.h" +#include "math.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* +// +// Constructor for server-settings-dialog +// +FilterControls::FilterControls() : + QWidget(), + functionConfig("Accela-Scaling-Rotation", 4, 8), + translationFunctionConfig("Accela-Scaling-Translation", 4, 8) +{ + ui.setupUi( this ); + + // Load the settings from the current .INI-file + loadSettings(); + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.scalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); + connect(ui.translationScalingConfig, SIGNAL(CurveChanged(bool)), this, SLOT(settingChanged(bool))); + + // Connect slider for reduction + connect(ui.slideReduction, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + + qDebug() << "FilterControls() says: started"; +} + +// +// Destructor for server-dialog +// +FilterControls::~FilterControls() { + qDebug() << "~FilterControls() says: started"; +} + +void FilterControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { + + // + // The dialog can be opened, while the Tracker is running. + // In that case, ptr will point to the active Filter-instance. + // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... + // + pFilter = ptr; + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FilterControls::doOK() { + save(); + if (pFilter) { + pFilter->Initialize(); + } + this->close(); +} + +// override show event +void FilterControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FilterControls::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 FilterControls::loadSettings() { +QList defPoints; + + 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_Filter::loadSettings2 says: iniFile = " << currentFile; + + + qDebug() << "FTNoIR_Filter::loadSettings2 says: size = " << NUM_OF(defScaleRotation); + + defPoints.clear(); + for (int i = 0; i < NUM_OF(defScaleRotation); i++) { // Get the default points (hardcoded!) + defPoints.append(defScaleRotation[i]); + } + functionConfig.loadSettings(iniFile, defPoints); + + defPoints.clear(); + for (int i = 0; i < NUM_OF(defScaleTranslation); i++) { // Get the default points (hardcoded!) + defPoints.append(defScaleTranslation[i]); + } + translationFunctionConfig.loadSettings(iniFile, defPoints); + + ui.translationScalingConfig->setConfig(&translationFunctionConfig, currentFile); + ui.scalingConfig->setConfig(&functionConfig, currentFile); + + iniFile.beginGroup ( "Accela" ); + ui.slideReduction->setValue (iniFile.value ( "Reduction", 100 ).toInt()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FilterControls::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) + + qDebug() << "FTNoIR_Filter::save() says: iniFile = " << currentFile; + + iniFile.beginGroup ( "Accela" ); + iniFile.setValue ( "Reduction", ui.slideReduction->value() ); + iniFile.endGroup (); + + functionConfig.saveSettings(iniFile); + translationFunctionConfig.saveSettings(iniFile); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter-settings dialog object. + +// Export both decorated and undecorated names. +// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") + +FTNOIR_FILTER_BASE_EXPORT IFilterDialogPtr __stdcall GetFilterDialog( ) +{ + return new FilterControls; +} diff --git a/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp new file mode 100644 index 00000000..e1452bf2 --- /dev/null +++ b/ftnoir_filter_accela/ftnoir_filter_accela_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The FilterDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_filter_Accela.h" +#include + +FTNoIR_FilterDll::FTNoIR_FilterDll() { +} + +FTNoIR_FilterDll::~FTNoIR_FilterDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") + +FTNOIR_FILTER_BASE_EXPORT IFilterDllPtr __stdcall GetFilterDll() +{ + return new FTNoIR_FilterDll; +} diff --git a/ftnoir_filter_accela/images/filter-16-ac.png b/ftnoir_filter_accela/images/filter-16-ac.png new file mode 100644 index 00000000..d263db2d Binary files /dev/null and b/ftnoir_filter_accela/images/filter-16-ac.png differ diff --git a/ftnoir_filter_base/ftnoir_filter_base.h b/ftnoir_filter_base/ftnoir_filter_base.h new file mode 100644 index 00000000..44ce3d72 --- /dev/null +++ b/ftnoir_filter_base/ftnoir_filter_base.h @@ -0,0 +1,91 @@ +#ifndef FTNOIR_FILTER_BASE_H +#define FTNOIR_FILTER_BASE_H + +#include "ftnoir_filter_base_global.h" +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include +#include +#include +#include +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C +#endif // __cplusplus + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IFilter +{ + virtual ~IFilter() {} + virtual void Initialize() = 0; + virtual void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) = 0; +}; + +typedef IFilter* IFilterPtr; +//typedef IFilter *(__stdcall *importGetFilter)(void); + +// Factory function that creates instances of the Filter object. +EXTERN_C +FTNOIR_FILTER_BASE_EXPORT +IFilterPtr +__stdcall +GetFilter(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IFilterDialog +{ + virtual ~IFilterDialog() {} + virtual void Initialize(QWidget *parent, IFilterPtr ptr) = 0; +}; + +typedef IFilterDialog* IFilterDialogPtr; + + +// Factory function that creates instances of the Filter object. +EXTERN_C +FTNOIR_FILTER_BASE_EXPORT +IFilterDialogPtr +__stdcall +GetFilterDialog(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IFilterDll +{ + virtual ~IFilterDll() {} + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; +}; + +typedef IFilterDll* IFilterDllPtr; + +// Factory function that creates instances of the Filter object. +EXTERN_C +FTNOIR_FILTER_BASE_EXPORT +IFilterDllPtr +__stdcall +GetFilterDll(void); + + +#endif // FTNOIR_FILTER_BASE_H diff --git a/ftnoir_filter_base/ftnoir_filter_base_global.h b/ftnoir_filter_base/ftnoir_filter_base_global.h new file mode 100644 index 00000000..aac4048e --- /dev/null +++ b/ftnoir_filter_base/ftnoir_filter_base_global.h @@ -0,0 +1,12 @@ +#ifndef FTNOIR_FILTER_BASE_GLOBAL_H +#define FTNOIR_FILTER_BASE_GLOBAL_H + +#include + +#ifdef FTNOIR_FILTER_BASE_LIB +# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_EXPORT +#else +# define FTNOIR_FILTER_BASE_EXPORT Q_DECL_IMPORT +#endif + +#endif // FTNOIR_FILTER_BASE_GLOBAL_H diff --git a/ftnoir_filter_ewma2/FTNoIR_FilterControls.ui b/ftnoir_filter_ewma2/FTNoIR_FilterControls.ui new file mode 100644 index 00000000..e9419a73 --- /dev/null +++ b/ftnoir_filter_ewma2/FTNoIR_FilterControls.ui @@ -0,0 +1,586 @@ + + + UICFilterControls + + + + 0 + 0 + 371 + 380 + + + + + 0 + 380 + + + + EWMA2 Filter settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 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 + 204 + + + + background-color: rgb(214, 214, 214); +border-color: rgb(0, 0, 0); + + + QFrame::Box + + + <!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 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 52 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 52 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + btnOK + btnCancel + + + + + minSmooth + valueChanged(int) + spinMinSmooth + setValue(int) + + + 199 + 22 + + + 337 + 23 + + + + + spinMinSmooth + valueChanged(int) + minSmooth + setValue(int) + + + 330 + 12 + + + 185 + 17 + + + + + maxSmooth + valueChanged(int) + spinMaxSmooth + setValue(int) + + + 181 + 48 + + + 335 + 54 + + + + + spinMaxSmooth + valueChanged(int) + maxSmooth + setValue(int) + + + 324 + 42 + + + 259 + 43 + + + + + powCurve + valueChanged(int) + spinPowCurve + setValue(int) + + + 145 + 74 + + + 339 + 78 + + + + + spinPowCurve + valueChanged(int) + powCurve + setValue(int) + + + 330 + 69 + + + 176 + 76 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2.h b/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2.h new file mode 100644 index 00000000..18afe3bd --- /dev/null +++ b/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2.h @@ -0,0 +1,119 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTN_FILTER_H +#define INCLUDED_FTN_FILTER_H + +#include "..\ftnoir_filter_base\ftnoir_filter_base.h" +#include "ui_FTNoIR_FilterControls.h" + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +class FTNoIR_Filter : public IFilter +{ +public: + FTNoIR_Filter(); + ~FTNoIR_Filter(); + + void Release(); + void Initialize(); + void StartFilter(); + void FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget); + +private: + void loadSettings(); // Load the settings from the INI-file + THeadPoseData newHeadPose; // Structure with new headpose + + bool first_run; + float smoothing_frames_range; + float alpha_smoothing; + float prev_alpha[6]; + float alpha[6]; + float smoothed_alpha[6]; + + float kMinSmoothing; + float kMaxSmoothing; + float kSmoothingScaleCurve; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* + +// Widget that has controls for FTNoIR protocol filter-settings. +class FilterControls: public QWidget, Ui::UICFilterControls, public IFilterDialog +{ + Q_OBJECT +public: + + explicit FilterControls(); + virtual ~FilterControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent, IFilterPtr ptr); + +private: + Ui::UICFilterControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + + IFilterPtr pFilter; // If the filter was active when the dialog was opened, this will hold a pointer to the Filter instance + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged( int ) { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Filter DLL. Functions used to get general info on the Filter +//******************************************************************************************************* +class FTNoIR_FilterDll : public IFilterDll +{ +public: + FTNoIR_FilterDll(); + ~FTNoIR_FilterDll(); + + void Release(); + void Initialize(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA Filter Mk2"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("EWMA"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Exponentially Weighted Moving Average filter with dynamic smoothing parameter"); }; + + void getIcon(QIcon *icon){ *icon = QIcon(":/images/filter-16.png"); }; +}; + +#endif //INCLUDED_FTN_FILTER_H +//END + diff --git a/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc8.vcproj b/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc8.vcproj new file mode 100644 index 00000000..3a185272 --- /dev/null +++ b/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc8.vcproj @@ -0,0 +1,388 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc9.vcproj b/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc9.vcproj new file mode 100644 index 00000000..d692d8cd --- /dev/null +++ b/ftnoir_filter_ewma2/FTNoIR_Filter_EWMA2_vc9.vcproj @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_filter_ewma2/Filter.qrc b/ftnoir_filter_ewma2/Filter.qrc new file mode 100644 index 00000000..e64ec35a --- /dev/null +++ b/ftnoir_filter_ewma2/Filter.qrc @@ -0,0 +1,5 @@ + + + images/filter-16.png + + diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp new file mode 100644 index 00000000..fac0e13c --- /dev/null +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2.cpp @@ -0,0 +1,236 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_ewma2.h" +#include "math.h" +#include + +//#define LOG_OUTPUT + +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// +// +// EWMA Filter: Exponentially Weighted Moving Average filter with dynamic smoothing parameter +// +////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// + +FTNoIR_Filter::FTNoIR_Filter() +{ + first_run = true; + alpha_smoothing = 0.02f; // this is a constant for now, might be a parameter later + loadSettings(); // Load the Settings + +} + +FTNoIR_Filter::~FTNoIR_Filter() +{ + +} + +void FTNoIR_Filter::Release() +{ + delete this; +} + +void FTNoIR_Filter::Initialize() +{ + qDebug() << "FTNoIR_Filter::Initialize says: Starting "; + loadSettings(); + return; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Filter::loadSettings() { + qDebug() << "FTNoIR_Filter::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_Filter::loadSettings says: iniFile = " << currentFile; + + // + // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR + // + iniFile.beginGroup ( "Tracking" ); + kMinSmoothing = iniFile.value ( "minSmooth", 15 ).toInt(); + kMaxSmoothing = iniFile.value ( "maxSmooth", 50 ).toInt(); + kSmoothingScaleCurve = iniFile.value ( "powCurve", 10 ).toInt(); + iniFile.endGroup (); + +} + +void FTNoIR_Filter::FilterHeadPoseData(THeadPoseData *current_camera_position, THeadPoseData *target_camera_position, THeadPoseData *new_camera_position, bool newTarget) +{ + //non-optimised version for clarity + float prev_output[6]; + float target[6]; + float output_delta[6]; + float scale[]={0.025f,0.025f,0.025f,6.0f,6.0f,6.0f}; + float norm_output_delta[6]; + float output[6]; + int i=0; + + #if PRE_FILTER_SCALING + //compensate for any prefilter scaling + scale[0]*=X_POS_SCALE; + scale[1]*=Y_POS_SCALE; + scale[2]*=Z_POS_SCALE; + scale[3]*=X_ROT_SCALE; + scale[4]*=Y_ROT_SCALE; + scale[5]*=Z_ROT_SCALE; + #endif + + //find out how far the head has moved + prev_output[0]=current_camera_position->x; + prev_output[1]=current_camera_position->y; + prev_output[2]=current_camera_position->z; + prev_output[3]=current_camera_position->yaw; + prev_output[4]=current_camera_position->pitch; + prev_output[5]=current_camera_position->roll; + + target[0]=target_camera_position->x; + target[1]=target_camera_position->y; + target[2]=target_camera_position->z; + target[3]=target_camera_position->yaw; + target[4]=target_camera_position->pitch; + target[5]=target_camera_position->roll; + + if (first_run==true) + { + //on the first run, output=target + for (i=0;i<6;i++) + { + output[i]=target[i]; + prev_alpha[i] = 0.0f; + } + + new_camera_position->x=target[0]; + new_camera_position->y=target[1]; + new_camera_position->z=target[2]; + new_camera_position->yaw=target[3]; + new_camera_position->pitch=target[4]; + new_camera_position->roll=target[5]; + + first_run=false; + + //we can bail + return; + } + + //how far does the camera need to move to catch up? + for (i=0;i<6;i++) + { + output_delta[i]=(target[i]-prev_output[i]); + } + + //normalise the deltas + for (i=0;i<6;i++) + { + norm_output_delta[i]=std::min(std::max(fabs(output_delta[i])/scale[i],0.0f),1.0f); + } + + //calculate the alphas + //work out the dynamic smoothing factors +// if (newTarget) { + for (i=0;i<6;i++) + { + alpha[i]=1.0f/(kMinSmoothing+((1.0f-pow(norm_output_delta[i],kSmoothingScaleCurve))*smoothing_frames_range)); + smoothed_alpha[i]=(alpha_smoothing*alpha[i])+((1.0f-alpha_smoothing)*prev_alpha[i]); + } +// } + + //qDebug() << "FTNoIR_Filter::FilterHeadPoseData() smoothing frames = " << smoothing_frames_range; + //qDebug() << "FTNoIR_Filter::FilterHeadPoseData() alpha[3] = " << alpha[3]; + + //use the same (largest) smoothed alpha for each channel + //NB: larger alpha = *less* lag (opposite to what you'd expect) + float largest_alpha=0.0f; + for (i=0;i<6;i++) + { + if (smoothed_alpha[i]>=largest_alpha) + { + largest_alpha=smoothed_alpha[i]; + } + } + + //move the camera + for (i=0;i<6;i++) + { + output[i]=(largest_alpha*target[i])+((1.0f-largest_alpha)*prev_output[i]); +// output[i]=(smoothed_alpha[i]*target[i])+((1.0f-smoothed_alpha[i])*prev_output[i]); + } + + + #ifdef LOG_OUTPUT + // Use this for some debug-output to file... + QFile data(QCoreApplication::applicationDirPath() + "\\EWMA_output.txt"); + if (data.open(QFile::WriteOnly | QFile::Append)) { + QTextStream out(&data); + out << "output:\t" << output[0] << "\t" << output[1] << "\t" << output[2] << "\t" << output[3] << "\t" << output[4] << "\t" << output[5] << '\n'; + out << "target:\t" << target[0] << "\t" << target[1] << "\t" << target[2] << "\t" << target[3] << "\t" << target[4] << "\t" << target[5] << '\n'; + out << "prev_output:\t" << prev_output[0] << "\t" << prev_output[1] << "\t" << prev_output[2] << "\t" << prev_output[3] << "\t" << prev_output[4] << "\t" << prev_output[5] << '\n'; + out << "largest_alpha:\t" << largest_alpha << '\n'; + } + #endif + + new_camera_position->x=output[0]; + new_camera_position->y=output[1]; + new_camera_position->z=output[2]; + new_camera_position->yaw=output[3]; + new_camera_position->pitch=output[4]; + new_camera_position->roll=output[5]; + + // + // Also update the 'current' position, for the next iteration. + // + current_camera_position->x=output[0]; + current_camera_position->y=output[1]; + current_camera_position->z=output[2]; + current_camera_position->yaw=output[3]; + current_camera_position->pitch=output[4]; + current_camera_position->roll=output[5]; + + //update filter memories ready for next sample + for (i=0;i<6;i++) + { + prev_alpha[i]=smoothed_alpha[i]; + } + return; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilter - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilter@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilter=_GetFilter@0") + +FTNOIR_FILTER_BASE_EXPORT IFilterPtr __stdcall GetFilter() +{ + return new FTNoIR_Filter; +} diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp new file mode 100644 index 00000000..c7798ac0 --- /dev/null +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma2_dialog.cpp @@ -0,0 +1,197 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "ftnoir_filter_EWMA2.h" +#include "math.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Filter Settings-dialog. +//******************************************************************************************************* +// +// Constructor for server-settings-dialog +// +FilterControls::FilterControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + + // Connect sliders for reduction factor + connect(ui.minSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.maxSmooth, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.powCurve, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + + qDebug() << "FilterControls() says: started"; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FilterControls::~FilterControls() { + qDebug() << "~FilterControls() says: started"; +} + +void FilterControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FilterControls::Initialize(QWidget *parent, IFilterPtr ptr) { + + // + // The dialog can be opened, while the Tracker is running. + // In that case, ptr will point to the active Filter-instance. + // This can be used to update settings, while Tracking and may also be handy to display logging-data and such... + // + pFilter = ptr; + + // + // + // + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FilterControls::doOK() { + save(); + if (pFilter) { + pFilter->Initialize(); + } + this->close(); +} + +// override show event +void FilterControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FilterControls::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 FilterControls::loadSettings() { + qDebug() << "FilterControls::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() << "FilterControls::loadSettings says: iniFile = " << currentFile; + + // + // The EWMA2-filter-settings are in the Tracking group: this is because they used to be on the Main Form of FaceTrackNoIR + // + iniFile.beginGroup ( "Tracking" ); + ui.minSmooth->setValue (iniFile.value ( "minSmooth", 15 ).toInt()); + ui.maxSmooth->setValue (iniFile.value ( "maxSmooth", 50 ).toInt()); + ui.powCurve->setValue (iniFile.value ( "powCurve", 10 ).toInt()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FilterControls::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 ( "Tracking" ); + iniFile.setValue ( "minSmooth", ui.minSmooth->value() ); + iniFile.setValue ( "powCurve", ui.powCurve->value() ); + iniFile.setValue ( "maxSmooth", ui.maxSmooth->value() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter-settings dialog object. + +// Export both decorated and undecorated names. +// GetFilterDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilterDialog=_GetFilterDialog@0") + +FTNOIR_FILTER_BASE_EXPORT IFilterDialogPtr __stdcall GetFilterDialog( ) +{ + return new FilterControls; +} diff --git a/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp new file mode 100644 index 00000000..4e644446 --- /dev/null +++ b/ftnoir_filter_ewma2/ftnoir_filter_ewma_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The FilterDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_filter_ewma2.h" +#include + +FTNoIR_FilterDll::FTNoIR_FilterDll() { +} + +FTNoIR_FilterDll::~FTNoIR_FilterDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Filter object. + +// Export both decorated and undecorated names. +// GetFilterDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetFilterDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetFilterDll=_GetFilterDll@0") + +FTNOIR_FILTER_BASE_EXPORT IFilterDllPtr __stdcall GetFilterDll() +{ + return new FTNoIR_FilterDll; +} diff --git a/ftnoir_filter_ewma2/images/filter-16.png b/ftnoir_filter_ewma2/images/filter-16.png new file mode 100644 index 00000000..ecde6a10 Binary files /dev/null and b/ftnoir_filter_ewma2/images/filter-16.png differ diff --git a/ftnoir_filter_ewma2/images/filter-32.png b/ftnoir_filter_ewma2/images/filter-32.png new file mode 100644 index 00000000..12b02caf Binary files /dev/null and b/ftnoir_filter_ewma2/images/filter-32.png differ diff --git a/ftnoir_posewidget/PoseWidget.qrc b/ftnoir_posewidget/PoseWidget.qrc new file mode 100644 index 00000000..65038eba --- /dev/null +++ b/ftnoir_posewidget/PoseWidget.qrc @@ -0,0 +1,10 @@ + + + images/side1.png + images/side2.png + images/side3.png + images/side4.png + images/side5.png + images/side6.png + + diff --git a/ftnoir_posewidget/glwidget.cpp b/ftnoir_posewidget/glwidget.cpp new file mode 100644 index 00000000..55b65619 --- /dev/null +++ b/ftnoir_posewidget/glwidget.cpp @@ -0,0 +1,210 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#include +#include + +#include "glwidget.h" + +GLWidget::GLWidget(QWidget *parent, QGLWidget *shareWidget) + : QGLWidget(parent, shareWidget) +{ + clearColor = Qt::black; + xRot = 0; + yRot = 0; + zRot = 0; + +#ifdef QT_OPENGL_ES_2 + program = 0; +#endif +} + +GLWidget::~GLWidget() +{ +} + +QSize GLWidget::minimumSizeHint() const +{ + return QSize(60, 60); +} + +QSize GLWidget::sizeHint() const +{ + return QSize(90, 90); +} + +void GLWidget::rotateBy(int xAngle, int yAngle, int zAngle) +{ + xRot = xAngle; + yRot = yAngle; + zRot = zAngle; + updateGL(); +} + +void GLWidget::setClearColor(const QColor &color) +{ + clearColor = color; + updateGL(); +} + +void GLWidget::initializeGL() +{ + makeObject(); + + glEnable(GL_DEPTH_TEST); + glEnable(GL_CULL_FACE); +#ifndef QT_OPENGL_ES_2 + glEnable(GL_TEXTURE_2D); +#endif + +#ifdef QT_OPENGL_ES_2 + +#define PROGRAM_VERTEX_ATTRIBUTE 0 +#define PROGRAM_TEXCOORD_ATTRIBUTE 1 + + QGLShader *vshader = new QGLShader(QGLShader::Vertex, this); + const char *vsrc = + "attribute highp vec4 vertex;\n" + "attribute mediump vec4 texCoord;\n" + "varying mediump vec4 texc;\n" + "uniform mediump mat4 matrix;\n" + "void main(void)\n" + "{\n" + " gl_Position = matrix * vertex;\n" + " texc = texCoord;\n" + "}\n"; + vshader->compileSourceCode(vsrc); + + QGLShader *fshader = new QGLShader(QGLShader::Fragment, this); + const char *fsrc = + "uniform sampler2D texture;\n" + "varying mediump vec4 texc;\n" + "void main(void)\n" + "{\n" + " gl_FragColor = texture2D(texture, texc.st);\n" + "}\n"; + fshader->compileSourceCode(fsrc); + + program = new QGLShaderProgram(this); + program->addShader(vshader); + program->addShader(fshader); + program->bindAttributeLocation("vertex", PROGRAM_VERTEX_ATTRIBUTE); + program->bindAttributeLocation("texCoord", PROGRAM_TEXCOORD_ATTRIBUTE); + program->link(); + + program->bind(); + program->setUniformValue("texture", 0); + +#endif +} + +void GLWidget::paintGL() +{ + qglClearColor(clearColor); + glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); + +#if !defined(QT_OPENGL_ES_2) + + glLoadIdentity(); + glTranslatef(0.0f, 0.0f, -10.0f); + + glRotatef(xRot, 1.0f, 0.0f, 0.0f); + glRotatef(yRot, 0.0f, 1.0f, 0.0f); + glRotatef(-1.0f * zRot, 0.0f, 0.0f, 1.0f); + + glVertexPointer(3, GL_FLOAT, 0, vertices.constData()); + glTexCoordPointer(2, GL_FLOAT, 0, texCoords.constData()); + glEnableClientState(GL_VERTEX_ARRAY); + glEnableClientState(GL_TEXTURE_COORD_ARRAY); + +#else + + QMatrix4x4 m; + m.ortho(-0.5f, +0.5f, +0.5f, -0.5f, 4.0f, 15.0f); + m.translate(0.0f, 0.0f, -10.0f); + m.rotate(xRot / 16.0f, 1.0f, 0.0f, 0.0f); + m.rotate(yRot / 16.0f, 0.0f, 1.0f, 0.0f); + m.rotate(zRot / 16.0f, 0.0f, 0.0f, 1.0f); + + program->setUniformValue("matrix", m); + program->enableAttributeArray(PROGRAM_VERTEX_ATTRIBUTE); + program->enableAttributeArray(PROGRAM_TEXCOORD_ATTRIBUTE); + program->setAttributeArray + (PROGRAM_VERTEX_ATTRIBUTE, vertices.constData()); + program->setAttributeArray + (PROGRAM_TEXCOORD_ATTRIBUTE, texCoords.constData()); + +#endif + + for (int i = 0; i < 6; ++i) { + glBindTexture(GL_TEXTURE_2D, textures[i]); + glDrawArrays(GL_TRIANGLE_FAN, i * 4, 4); + } +} + +void GLWidget::resizeGL(int width, int height) +{ + int side = qMin(width, height); + glViewport((width - side) / 2, (height - side) / 2, side, side); + +#if !defined(QT_OPENGL_ES_2) + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); +#ifndef QT_OPENGL_ES + glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#else + glOrthof(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0); +#endif + glMatrixMode(GL_MODELVIEW); +#endif +} + +void GLWidget::makeObject() +{ + static const int coords[6][4][3] = { + { { +1, -1, -1 }, { -1, -1, -1 }, { -1, +1, -1 }, { +1, +1, -1 } }, + { { +1, +1, -1 }, { -1, +1, -1 }, { -1, +1, +1 }, { +1, +1, +1 } }, + { { +1, -1, +1 }, { +1, -1, -1 }, { +1, +1, -1 }, { +1, +1, +1 } }, + { { -1, -1, -1 }, { -1, -1, +1 }, { -1, +1, +1 }, { -1, +1, -1 } }, + { { +1, -1, +1 }, { -1, -1, +1 }, { -1, -1, -1 }, { +1, -1, -1 } }, + { { -1, -1, +1 }, { +1, -1, +1 }, { +1, +1, +1 }, { -1, +1, +1 } } + }; + + for (int j=0; j < 6; ++j) { + textures[j] = bindTexture + (QPixmap(QString(":/images/side%1.png").arg(j + 1)), GL_TEXTURE_2D); + } + + for (int i = 0; i < 6; ++i) { + for (int j = 0; j < 4; ++j) { + texCoords.append + (QVector2D(j == 0 || j == 3, j == 0 || j == 1)); + vertices.append + (QVector3D(0.4 * coords[i][j][0], 0.4 * coords[i][j][1], + 0.02 * coords[i][j][2])); + } + } +} diff --git a/ftnoir_posewidget/glwidget.h b/ftnoir_posewidget/glwidget.h new file mode 100644 index 00000000..cff8cb83 --- /dev/null +++ b/ftnoir_posewidget/glwidget.h @@ -0,0 +1,72 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* Adopted this widget from the 'textures' sample of the Nokia Qt toolkit. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +*********************************************************************************/ + +#ifndef GLWIDGET_H +#define GLWIDGET_H + +#include +#include + +class QGLShaderProgram; + +class GLWidget : public QGLWidget +{ + Q_OBJECT + +public: + GLWidget(QWidget *parent = 0, QGLWidget *shareWidget = 0); + ~GLWidget(); + + QSize minimumSizeHint() const; + QSize sizeHint() const; + void rotateBy(int xAngle, int yAngle, int zAngle); + void setClearColor(const QColor &color); + +signals: + void clicked(); + +protected: + void initializeGL(); + void paintGL(); + void resizeGL(int width, int height); + +private: + void makeObject(); + + QColor clearColor; + QPoint lastPos; + int xRot; + int yRot; + int zRot; + GLuint textures[6]; + QVector vertices; + QVector texCoords; +#ifdef QT_OPENGL_ES_2 + QGLShaderProgram *program; +#endif +}; + +#endif diff --git a/ftnoir_posewidget/images/side1.bmp b/ftnoir_posewidget/images/side1.bmp new file mode 100644 index 00000000..29c28d80 Binary files /dev/null and b/ftnoir_posewidget/images/side1.bmp differ diff --git a/ftnoir_posewidget/images/side1.png b/ftnoir_posewidget/images/side1.png new file mode 100644 index 00000000..e0315b77 Binary files /dev/null and b/ftnoir_posewidget/images/side1.png differ diff --git a/ftnoir_posewidget/images/side2.png b/ftnoir_posewidget/images/side2.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/ftnoir_posewidget/images/side2.png differ diff --git a/ftnoir_posewidget/images/side3.png b/ftnoir_posewidget/images/side3.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/ftnoir_posewidget/images/side3.png differ diff --git a/ftnoir_posewidget/images/side4.png b/ftnoir_posewidget/images/side4.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/ftnoir_posewidget/images/side4.png differ diff --git a/ftnoir_posewidget/images/side5.png b/ftnoir_posewidget/images/side5.png new file mode 100644 index 00000000..67eb060b Binary files /dev/null and b/ftnoir_posewidget/images/side5.png differ diff --git a/ftnoir_posewidget/images/side6.png b/ftnoir_posewidget/images/side6.png new file mode 100644 index 00000000..f4160001 Binary files /dev/null and b/ftnoir_posewidget/images/side6.png differ diff --git a/ftnoir_protocol_base/ftnoir_protocol_base.h b/ftnoir_protocol_base/ftnoir_protocol_base.h new file mode 100644 index 00000000..3f598d35 --- /dev/null +++ b/ftnoir_protocol_base/ftnoir_protocol_base.h @@ -0,0 +1,124 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* This class implements a tracker-base * +*********************************************************************************/ +/* + Modifications (last one on top): + + 20121115 - WVR: Added RegisterProtocol() and unRegisterProtocol() to Dialog Class + 20110415 - WVR: Added overloaded operator - and -= +*/ + +#ifndef FTNOIR_PROTOCOL_BASE_H +#define FTNOIR_PROTOCOL_BASE_H + +#include "ftnoir_protocol_base_global.h" +#include "..\ftnoir_tracker_base\ftnoir_tracker_types.h" +#include +#include +//#include "winbase.h" + +#include "windows.h" +//#include "winable.h" + +//////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C +#endif // __cplusplus + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IProtocol +{ + virtual ~IProtocol() {} + virtual void Initialize() = 0; + virtual bool checkServerInstallationOK ( HANDLE handle ) = 0; + virtual void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) = 0; + virtual void getNameFromGame( char *dest ) = 0; // Take care dest can handle up to 100 chars... +}; + +typedef IProtocol* IProtocolPtr; + +// Factory function that creates instances of the Protocol object. +EXTERN_C +FTNOIR_PROTOCOL_BASE_EXPORT +IProtocolPtr +__stdcall +GetProtocol(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IProtocolDialog +{ + virtual ~IProtocolDialog() {} + virtual void Initialize(QWidget *parent) = 0; + virtual void registerProtocol(IProtocol *protocol) = 0; + virtual void unRegisterProtocol() = 0; +}; + +typedef IProtocolDialog* IProtocolDialogPtr; + +// Factory function that creates instances of the Protocol object. +EXTERN_C +FTNOIR_PROTOCOL_BASE_EXPORT +IProtocolDialogPtr +__stdcall +GetProtocolDialog(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct IProtocolDll +{ + virtual ~IProtocolDll() {} + + virtual void getFullName(QString *strToBeFilled) = 0; + virtual void getShortName(QString *strToBeFilled) = 0; + virtual void getDescription(QString *strToBeFilled) = 0; + virtual void getIcon(QIcon *icon) = 0; +}; + +typedef IProtocolDll* IProtocolDllPtr; + +// Factory function that creates instances of the Protocol object. +EXTERN_C +FTNOIR_PROTOCOL_BASE_EXPORT +IProtocolDllPtr +__stdcall +GetProtocolDll(void); + + +#endif // FTNOIR_PROTOCOL_BASE_H diff --git a/ftnoir_protocol_base/ftnoir_protocol_base_global.h b/ftnoir_protocol_base/ftnoir_protocol_base_global.h new file mode 100644 index 00000000..3527bad7 --- /dev/null +++ b/ftnoir_protocol_base/ftnoir_protocol_base_global.h @@ -0,0 +1,12 @@ +#ifndef FTNOIR_PROTOCOL_BASE_GLOBAL_H +#define FTNOIR_PROTOCOL_BASE_GLOBAL_H + +#include + +#ifdef FTNOIR_PROTOCOL_BASE_LIB +# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_EXPORT +#else +# define FTNOIR_PROTOCOL_BASE_EXPORT Q_DECL_IMPORT +#endif + +#endif // FTNOIR_PROTOCOL_BASE_GLOBAL_H diff --git a/ftnoir_protocol_fg/FGTypes.h b/ftnoir_protocol_fg/FGTypes.h new file mode 100644 index 00000000..949dc213 --- /dev/null +++ b/ftnoir_protocol_fg/FGTypes.h @@ -0,0 +1,28 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* Type definitions for the FlightGear server. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FGTYPES_H +#define INCLUDED_FGTYPES_H + +#include "Windows.h" + +// +// x,y,z position in metres, heading, pitch and roll in degrees... +// +#pragma pack(2) +struct TFlightGearData { + double x, y, z, h, p, r; + int status; +}; + +#endif//INCLUDED_FGTYPES_H diff --git a/ftnoir_protocol_fg/FTNoIR_FGcontrols.ui b/ftnoir_protocol_fg/FTNoIR_FGcontrols.ui new file mode 100644 index 00000000..3469e7aa --- /dev/null +++ b/ftnoir_protocol_fg/FTNoIR_FGcontrols.ui @@ -0,0 +1,279 @@ + + + UICFGControls + + + + 0 + 0 + 411 + 194 + + + + FlightGear settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Qt::RightToLeft + + + Local PC only + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + If FlightGear is on the same PC as FaceTrackNoIR, tick the 'Local PC only' box. + + + + + + + Otherwise: enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + chkLocalPC + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_fg/FTNoIR_Protocol_FG.cpp b/ftnoir_protocol_fg/FTNoIR_Protocol_FG.cpp new file mode 100644 index 00000000..5506f534 --- /dev/null +++ b/ftnoir_protocol_fg/FTNoIR_Protocol_FG.cpp @@ -0,0 +1,257 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_fg.h" +#include + +// For Todd and Arda Kutlu +//#define SEND_ASCII_DATA +//#define LOG_OUTPUT + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + blnConnectionActive = false; + hMainWindow = NULL; + loadSettings(); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (inSocket != 0) { + inSocket->close(); + delete inSocket; + } + + if (outSocket != 0) { + outSocket->close(); + delete outSocket; + } +} + +/** helper to Auto-destruct **/ +void FTNoIR_Protocol::Release() +{ + delete this; +} + +void FTNoIR_Protocol::Initialize() +{ + return; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + 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 ( "FG" ); + + bool blnLocalPC = iniFile.value ( "LocalPCOnly", 1 ).toBool(); + if (blnLocalPC) { + destIP = QHostAddress::LocalHost; + } + else { + QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); + destIP = QHostAddress( destAddr ); + } + destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + + iniFile.endGroup (); + +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +int no_bytes; +QHostAddress sender; +quint16 senderPort; +PDWORD_PTR MsgResult = 0; + +#ifdef SEND_ASCII_DATA +char data[100]; +#endif + + // + // Copy the Raw measurements directly to the client. + // + FlightData.x = headpose->x; + FlightData.y = headpose->y; + FlightData.z = headpose->z; + FlightData.p = headpose->pitch; + FlightData.h = headpose->yaw; + FlightData.r = headpose->roll; + FlightData.status = fg_cmd; + + // + // Try to send an UDP-message to the FlightGear + // + +#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); + + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) &data, strlen( data ), destIP, destPort); + if ( no_bytes > 0) { + qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << data; + } + else { + qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; + } + } + +#endif + + #ifdef LOG_OUTPUT + // Use this for some debug-output to file... + QFile datafile(QCoreApplication::applicationDirPath() + "\\FG_output.txt"); + if (datafile.open(QFile::WriteOnly | QFile::Append)) { + QTextStream out(&datafile); + out << "output:\t" << FlightData.x << "\t" << FlightData.y << "\t" << FlightData.z << "\t" << FlightData.p << "\t" << FlightData.h << "\t" << FlightData.r << '\n'; + } + #endif + + #ifndef SEND_ASCII_DATA + //! [1] +// no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), QHostAddress::LocalHost, 5550); + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) &FlightData, sizeof( FlightData ), destIP, destPort); + if ( no_bytes > 0) { + // qDebug() << "FGServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); + } + else { + qDebug() << "FGServer::writePendingDatagrams says: nothing sent!"; + } + } + #endif + + // + // FlightGear keeps sending data, so we must read that here. + // + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { + + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); + + inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); + + fg_cmd = cmd; // Let's just accept that command for now... + if ( cmd > 0 ) { + qDebug() << "FGServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; +// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle + } + + if (!blnConnectionActive) { + blnConnectionActive = true; + if (hMainWindow != NULL) { + SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); + } + } + } + } +} + +// +// Check if the Client DLL exists and load it (to test it), if so. +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) +{ + // Init. the data + FlightData.x = 0.0f; + FlightData.y = 0.0f; + FlightData.z = 0.0f; + FlightData.h = 0.0f; + FlightData.p = 0.0f; + FlightData.r = 0.0f; + FlightData.status = 0; + fg_cmd = 1; + + inSocket = 0; + outSocket = 0; + + hMainWindow = handle; + + // + // Create UDP-sockets. + // + if (inSocket == 0) { + qDebug() << "FGServer::sendHeadposeToGame creating insocket"; + inSocket = new QUdpSocket(); + + // Connect the inSocket to the port, to receive messages + if (!inSocket->bind(QHostAddress::Any, destPort+1)) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + return false; + } + } + + if (outSocket == 0) { + outSocket = new QUdpSocket(); + } + + return true; +} + +// +// Return a name, if present the name from the Game, that is connected... +// +void FTNoIR_Protocol::getNameFromGame( char *dest ) +{ + sprintf_s(dest, 99, "FlightGear"); + return; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_fg/FTNoIR_Protocol_FG.h b/ftnoir_protocol_fg/FTNoIR_Protocol_FG.h new file mode 100644 index 00000000..34773540 --- /dev/null +++ b/ftnoir_protocol_fg/FTNoIR_Protocol_FG.h @@ -0,0 +1,127 @@ +/******************************************************************************** +* 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) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FGSERVER_H +#define INCLUDED_FGSERVER_H + +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "ui_FTNoIR_FGcontrols.h" +#include "FGTypes.h" +#include +#include +#include +#include +#include "Windows.h" +#include "math.h" + +static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Release(); + void Initialize(); + + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... + +private: + + bool blnConnectionActive; + HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window + + // Tracker *headTracker; // For upstream messages... + TFlightGearData FlightData; + QUdpSocket *inSocket; // Receive from FligthGear + QUdpSocket *outSocket; // Send to FligthGear + qint32 cmd; + qint32 fg_cmd; // Command from FlightGear + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + void loadSettings(); + +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FGControls: public QWidget, Ui::UICFGControls, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FGControls(); + virtual ~FGControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + }; + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + }; + +private: + Ui::UICFGControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void chkLocalPCOnlyChanged(); + void settingChanged() { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FlightGear UDP protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FlightGear.ico"); }; +}; + + +#endif//INCLUDED_FGSERVER_H +//END diff --git a/ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc8.vcproj b/ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc8.vcproj new file mode 100644 index 00000000..47da021d --- /dev/null +++ b/ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc8.vcproj @@ -0,0 +1,380 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc9.vcproj b/ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc9.vcproj new file mode 100644 index 00000000..9dd85008 --- /dev/null +++ b/ftnoir_protocol_fg/FTNoIR_Protocol_FG_vc9.vcproj @@ -0,0 +1,385 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_fg/Protocol.qrc b/ftnoir_protocol_fg/Protocol.qrc new file mode 100644 index 00000000..1e715ac9 --- /dev/null +++ b/ftnoir_protocol_fg/Protocol.qrc @@ -0,0 +1,5 @@ + + + images/FlightGear.ico + + diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp new file mode 100644 index 00000000..0138a4c1 --- /dev/null +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dialog.cpp @@ -0,0 +1,225 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FGServer FGServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_fg.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FGControls::FGControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.chkLocalPC, SIGNAL(stateChanged(int)), this, SLOT(chkLocalPCOnlyChanged())); + 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())); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FGControls::~FGControls() { + qDebug() << "~FGControls() says: started"; +} + +void FGControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FGControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FGControls::doOK() { + save(); + this->close(); +} + +// override show event +void FGControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FGControls::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 FGControls::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 ( "FG" ); + ui.chkLocalPC->setChecked (iniFile.value ( "LocalPCOnly", 1 ).toBool()); + + 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 (); + + chkLocalPCOnlyChanged(); + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FGControls::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 ( "FG" ); + iniFile.setValue ( "LocalPCOnly", ui.chkLocalPC->isChecked() ); + 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; +} + +// +// Handle change of the checkbox. +// +void FGControls::chkLocalPCOnlyChanged() { + + if ( ui.chkLocalPC->isChecked() ) { + ui.spinIPFirstNibble->setValue( 127 ); + ui.spinIPFirstNibble->setEnabled ( false ); + ui.spinIPSecondNibble->setValue( 0 ); + ui.spinIPSecondNibble->setEnabled ( false ); + ui.spinIPThirdNibble->setValue( 0 ); + ui.spinIPThirdNibble->setEnabled ( false ); + ui.spinIPFourthNibble->setValue( 1 ); + ui.spinIPFourthNibble->setEnabled ( false ); + } + else { + ui.spinIPFirstNibble->setEnabled ( true ); + ui.spinIPSecondNibble->setEnabled ( true ); + ui.spinIPThirdNibble->setEnabled ( true ); + ui.spinIPFourthNibble->setEnabled ( true ); + } + + settingsDirty = true; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FGControls; +} \ No newline at end of file diff --git a/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp new file mode 100644 index 00000000..ca71063b --- /dev/null +++ b/ftnoir_protocol_fg/ftnoir_protocol_fg_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_fg.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_fg/images/FlightGear.ico b/ftnoir_protocol_fg/images/FlightGear.ico new file mode 100644 index 00000000..f96c0f88 Binary files /dev/null and b/ftnoir_protocol_fg/images/FlightGear.ico differ diff --git a/ftnoir_protocol_fsuipc/FTNoIR_FSUIPCcontrols.ui b/ftnoir_protocol_fsuipc/FTNoIR_FSUIPCcontrols.ui new file mode 100644 index 00000000..b6120378 --- /dev/null +++ b/ftnoir_protocol_fsuipc/FTNoIR_FSUIPCcontrols.ui @@ -0,0 +1,228 @@ + + + UICFSUIPCControls + + + + 0 + 0 + 541 + 127 + + + + FSUIPC settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + Location of FSUIPC.dll: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + + 230 + 0 + + + + Location of FSUIPC.dll + + + QFrame::Box + + + QFrame::Sunken + + + 1 + + + Location of FSUIPC.dll + + + + + + + + 35 + 16777215 + + + + ... + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + The DLL should be placed in the Modules folder of MS Flight Simulator + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.cpp b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.cpp new file mode 100644 index 00000000..5a4663a1 --- /dev/null +++ b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.cpp @@ -0,0 +1,233 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * +* to games, using the FSUIPC.dll. * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_fsuipc.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + loadSettings(); + ProgramName = "Microsoft FS2004"; + + blnConnectionActive = false; + hMainWindow = NULL; + + prevPosX = 0.0f; + prevPosY = 0.0f; + prevPosZ = 0.0f; + prevRotX = 0.0f; + prevRotY = 0.0f; + prevRotZ = 0.0f; +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + // + // Free the DLL + // + FSUIPCLib.unload(); +} + +/** helper to Auto-destruct **/ +void FTNoIR_Protocol::Release() +{ + delete this; +} + +void FTNoIR_Protocol::Initialize() +{ + return; +} + +// +// Scale the measured value to the Joystick values +// +int FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; +double local_x; + + local_x = x; + if (local_x > max_x) { + local_x = max_x; + } + if (local_x < min_x) { + local_x = min_x; + } + y = ( 16383 * local_x ) / max_x; + + return (int) y; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + 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 ( "FSUIPC" ); + LocationOfDLL = iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString(); + qDebug() << "FSUIPCServer::loadSettings() says: Location of DLL = " << LocationOfDLL; + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +DWORD result; +TFSState pitch; +TFSState yaw; +TFSState roll; +WORD FSZoom; + +float virtPosX; +float virtPosY; +float virtPosZ; + +float virtRotX; +float virtRotY; +float virtRotZ; + +PDWORD_PTR MsgResult = 0; + +// qDebug() << "FSUIPCServer::run() says: started!"; + + virtRotX = -1.0f * headpose->pitch; // degrees + virtRotY = headpose->yaw; + virtRotZ = headpose->roll; + + virtPosX = 0.0f; // cm, X and Y are not working for FS2002/2004! + virtPosY = 0.0f; + virtPosZ = -1.0f * headpose->z; + + // + // Init. the FSUIPC offsets (derived from Free-track...) + // + pitch.Control = 66503; + yaw.Control = 66504; + roll.Control = 66505; + + // + // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. + // + if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || + (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { + // + // Open the connection + // + FSUIPC_Open(SIM_ANY, &result); + + // + // Check the FS-version + // + if (((result == FSUIPC_ERR_OK) || (result == FSUIPC_ERR_OPEN)) && + ((FSUIPC_FS_Version == SIM_FS2K2) || (FSUIPC_FS_Version == SIM_FS2K4))) { +// qDebug() << "FSUIPCServer::run() says: FSUIPC opened succesfully"; + // + // Write the 4! DOF-data to FS. Only rotations and zoom are possible. + // + pitch.Value = scale2AnalogLimits(virtRotX, -180, 180); + FSUIPC_Write(0x3110, 8, &pitch, &result); + + yaw.Value = scale2AnalogLimits(virtRotY, -180, 180); + FSUIPC_Write(0x3110, 8, &yaw, &result); + + roll.Value = scale2AnalogLimits(virtRotZ, -180, 180); + FSUIPC_Write(0x3110, 8, &roll, &result); + + FSZoom = (WORD) (64/50) * virtPosZ + 64; + FSUIPC_Write(0x832E, 2, &FSZoom, &result); + + // + // Write the data, in one go! + // + FSUIPC_Process(&result); + if (result == FSUIPC_ERR_SENDMSG) { + FSUIPC_Close(); //timeout (1 second) so assume FS closed + } + + if (!blnConnectionActive) { + blnConnectionActive = true; + if (hMainWindow != NULL) { + SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); + } + } + + } + } + + prevPosX = virtPosX; + prevPosY = virtPosY; + prevPosZ = virtPosZ; + prevRotX = virtRotX; + prevRotY = virtRotY; + prevRotZ = virtRotZ; +} + +// +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) +{ + qDebug() << "checkServerInstallationOK says: Starting Function"; + + hMainWindow = handle; + + return true; +} + +// +// Return a name, if present the name from the Game, that is connected... +// +void FTNoIR_Protocol::getNameFromGame( char *dest ) +{ + sprintf_s(dest, 99, "Microsoft FS2002/2004"); + return; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.h b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.h new file mode 100644 index 00000000..8503f6e7 --- /dev/null +++ b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC.h @@ -0,0 +1,139 @@ +/******************************************************************************** +* 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) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FSUIPCServer FSUIPCServer is the Class, that communicates headpose-data * +* to games, using the FSUIPC.dll. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FSUIPCSERVER_H +#define INCLUDED_FSUIPCSERVER_H + +#include "Windows.h" +#include +#include "FSUIPC_User.h" + +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "ui_FTNoIR_FSUIPCcontrols.h" +#include +#include +#include +#include +#include +#include +#include + +static const char* FSUIPC_FILENAME = "C:\\Program Files\\Microsoft Games\\Flight Simulator 9\\Modules\\FSUIPC.dll"; +static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. + +// +// Define the structures necessary for the FSUIPC_Write calls +// +#pragma pack(push,1) // All fields in structure must be byte aligned. +typedef struct +{ + int Control; // Control identifier + int Value; // Value of DOF +} TFSState; +#pragma pack(pop) + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Release(); + void Initialize(); + + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... + +private: + // Private properties + QString ProgramName; + QLibrary FSUIPCLib; + QString LocationOfDLL; + float prevPosX, prevPosY, prevPosZ, prevRotX, prevRotY, prevRotZ; + + bool blnConnectionActive; + HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window + + static int scale2AnalogLimits( float x, float min_x, float max_x ); + void loadSettings(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FSUIPCControls: public QWidget, Ui::UICFSUIPCControls, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FSUIPCControls(); + virtual ~FSUIPCControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + }; + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + }; + +private: + Ui::UICFSUIPCControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void getLocationOfDLL(); +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FS2002/FS2004"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FSUIPC"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft FS2004 protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FS9.ico"); }; +}; + + +#endif//INCLUDED_FSUIPCSERVER_H +//END diff --git a/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc8.vcproj b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc8.vcproj new file mode 100644 index 00000000..9bcd5580 --- /dev/null +++ b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc8.vcproj @@ -0,0 +1,377 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc9.vcproj b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc9.vcproj new file mode 100644 index 00000000..ff7d27d3 --- /dev/null +++ b/ftnoir_protocol_fsuipc/FTNoIR_Protocol_FSUIPC_vc9.vcproj @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_fsuipc/Protocol.qrc b/ftnoir_protocol_fsuipc/Protocol.qrc new file mode 100644 index 00000000..2830d09a --- /dev/null +++ b/ftnoir_protocol_fsuipc/Protocol.qrc @@ -0,0 +1,5 @@ + + + images/FS9.ico + + diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dialog.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dialog.cpp new file mode 100644 index 00000000..08c13c08 --- /dev/null +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dialog.cpp @@ -0,0 +1,197 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_fsuipc.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FSUIPCControls::FSUIPCControls() : +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.btnFindDLL, SIGNAL(clicked()), this, SLOT(getLocationOfDLL())); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FSUIPCControls::~FSUIPCControls() { + qDebug() << "~FSUIPCControls() says: started"; +} + +void FSUIPCControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FSUIPCControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FSUIPCControls::doOK() { + save(); + this->close(); +} + +// override show event +void FSUIPCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FSUIPCControls::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 FSUIPCControls::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 ( "FSUIPC" ); + ui.txtLocationOfDLL->setText(iniFile.value ( "LocationOfDLL", FSUIPC_FILENAME ).toString() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FSUIPCControls::save() { + + qDebug() << "save() says: started"; + + 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 ( "FSUIPC" ); + iniFile.setValue ( "LocationOfDLL", ui.txtLocationOfDLL->text() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Show the Dialog to set the DLL's location +// +void FSUIPCControls::getLocationOfDLL() +{ + // + // Get the new filename of the INI-file. + // + QString fileName = QFileDialog::getOpenFileName(this, tr("Locate file"), + ui.txtLocationOfDLL->text(), + tr("FSUIPC DLL file (FSUIPC*.dll);;All Files (*)")); + if (!fileName.isEmpty()) { + ui.txtLocationOfDLL->setText( fileName ); + settingsDirty = true; + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FSUIPCControls; +} diff --git a/ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dll.cpp b/ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dll.cpp new file mode 100644 index 00000000..d61c2d83 --- /dev/null +++ b/ftnoir_protocol_fsuipc/ftnoir_protocol_FSUIPC_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_fsuipc.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_fsuipc/images/FS9.ico b/ftnoir_protocol_fsuipc/images/FS9.ico new file mode 100644 index 00000000..9afd1953 Binary files /dev/null and b/ftnoir_protocol_fsuipc/images/FS9.ico differ diff --git a/ftnoir_protocol_ft/FTNoIR_FTcontrols.ui b/ftnoir_protocol_ft/FTNoIR_FTcontrols.ui new file mode 100644 index 00000000..fc5abbcf --- /dev/null +++ b/ftnoir_protocol_ft/FTNoIR_FTcontrols.ui @@ -0,0 +1,437 @@ + + + UICFTControls + + + + 0 + 0 + 645 + 416 + + + + + 645 + 0 + + + + FreeTrack 2.0 settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 70 + + + + TIRViews + + + + + 80 + 30 + 88 + 17 + + + + Qt::RightToLeft + + + Use TIRViews + + + + + + 189 + 10 + 421 + 16 + + + + TIRViews is only required for some older games (like CFS3). For it to work, TIRViews.dll + + + + + + 189 + 30 + 421 + 16 + + + + must be placed in the FaceTrackNoIR program folder. If the checkbox is disabled, the + + + true + + + + + + 189 + 50 + 411 + 16 + + + + the DLL was not found. You can get it from NaturalPoint. + + + + + + + + + 0 + 70 + + + + TrackIR.exe + + + + + 20 + 30 + 145 + 17 + + + + Qt::RightToLeft + + + Start dummy TrackIR.exe + + + + + + 189 + 10 + 351 + 16 + + + + Some programs check, to see if a process called TrackIR.exe is running, + + + + + + 189 + 30 + 261 + 16 + + + + before enabling head-tracking (EZCA is one of them). + + + true + + + + + + 189 + 50 + 231 + 16 + + + + Check the checkbox, to overcome this problem. + + + + + + + + + 0 + 70 + + + + Select interface + + + + + 189 + 10 + 351 + 16 + + + + Some games support both FreeTrack and TrackIR and may get confused, + + + + + + 189 + 30 + 261 + 16 + + + + when both interfaces are visible. + + + true + + + + + + 189 + 50 + 381 + 16 + + + + Try to disable one interface, if you experience problems. + + + + + + 6 + 30 + 168 + 22 + + + + + + + + + + 0 + 70 + + + + Repair NPClient location + + + + + 188 + 10 + 381 + 20 + + + + Users who use other software with an NPClient DLL (like TrackIR, FreeTrack or + + + + + + 184 + 30 + 411 + 20 + + + + GlovePIE) may need to repair the location of the DLL, after running FaceTrackNoIR. + + + true + + + + + + 187 + 50 + 391 + 20 + + + + Use this button to locate the desired NPClient DLL. + + + + + + 4 + 30 + 171 + 23 + + + + Locate DLL + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_ft/FTNoIR_Protocol_FT.cpp b/ftnoir_protocol_ft/FTNoIR_Protocol_FT.cpp new file mode 100644 index 00000000..b8461993 --- /dev/null +++ b/ftnoir_protocol_ft/FTNoIR_Protocol_FT.cpp @@ -0,0 +1,513 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTServer FTServer is the Class, that communicates headpose-data * +* to games, using the FreeTrackClient.dll. * +********************************************************************************/ +/* + Modifications (last one on top): + 20130209 - WVR: Some games support both interfaces and cause trouble. Added ComboBox to fix this (hide one interface + by clearing the appropriate Registry-setting). + 20130203 - WVR: Added Tirviews and dummy checkboxes to the Settings dialog. This is necessary for CFS3 etc. + 20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games. + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp + 20100601 - WVR: Added Mutex-bit in run(). Thought it wasn't so important (still do...). + 20100523 - WVR: Implemented the Freetrack-protocol just like Freetrack does. Earlier + FaceTrackNoIR only worked with an adapted DLL, with a putdata function. + Now it works direcly in shared memory! +*/ +#include "ftnoir_protocol_ft.h" +#include "csv.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + comhandle = 0; + useTIRViews = false; + useDummyExe = false; + intUsedInterface = 0; + + // + // Load the INI-settings. + // + loadSettings(); + + ProgramName = ""; + intGameID = 0; + + dummyTrackIR = 0; + viewsStart = 0; + viewsStop = 0; + +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + + qDebug()<< "~FTNoIR_Protocol: Destructor started."; + + // + // Stop if started + // + if (viewsStop != NULL) { + qDebug()<< "~FTNoIR_Protocol: Stopping TIRViews."; + viewsStop(); + FTIRViewsLib.unload(); + } + + // + // Kill the dummy TrackIR process. + // + qDebug() << "~FTNoIR_Protocol() about to kill TrackIR.exe process"; + try { + if (dummyTrackIR) { + qDebug() << "FTServer::~FTServer() about to kill TrackIR.exe process"; +// dummyTrackIR->close(); + dummyTrackIR->kill(); + } + } + catch (...) + { + qDebug() << "~FTServer says: some error occurred"; + } + + // + // Destroy the File-mapping + // + FTDestroyMapping(); +} + +void FTNoIR_Protocol::Initialize() +{ + return; +} + +// +// Read the game-data from CSV +// +bool FTNoIR_Protocol::getGameData( QString gameID ){ +QStringList gameLine; + + qDebug() << "getGameData, ID = " << gameID; + + // + // Open the supported games list, to get the Name. + // + QFile file(QCoreApplication::applicationDirPath() + "/Settings/FaceTrackNoIR Supported Games.csv"); + if (!file.open(QIODevice::ReadOnly | QIODevice::Text)){ + QString strError( "Cannot load file: FaceTrackNoIR Supported Games.csv" ); + sprintf_s(pMemData->ProgramName, 99, strError.toAscii()); + sprintf_s(pMemData->FTNVERSION, 9, "V160"); + + // + // Return true anyway, because maybe it's V160 compatible. + // + return true; + } + CSV csv(&file); + gameLine = csv.parseLine(); + + while (gameLine.count() > 2) { + //qDebug() << "Column 0: " << gameLine.at(0); // No. + //qDebug() << "Column 1: " << gameLine.at(1); // Game Name + //qDebug() << "Column 2: " << gameLine.at(2); // Game Protocol + //qDebug() << "Column 3: " << gameLine.at(3); // Supported since version + //qDebug() << "Column 4: " << gameLine.at(4); // Verified + //qDebug() << "Column 5: " << gameLine.at(5); // By + //qDebug() << "Column 6: " << gameLine.at(6); // International ID + //qDebug() << "Column 7: " << gameLine.at(7); // FaceTrackNoIR ID + + // + // If the gameID was found, fill the shared memory + // + if (gameLine.count() > 6) { + if (gameLine.at(6).compare( gameID, Qt::CaseInsensitive ) == 0) { + if (pMemData != NULL) { + sprintf_s(pMemData->ProgramName, 99, gameLine.at(1).toAscii()); + sprintf_s(pMemData->FTNVERSION, 9, gameLine.at(3).toAscii()); + sprintf_s(pMemData->FTNID, 24, gameLine.at(7).toAscii()); + } + file.close(); + return true; + } + } + + gameLine = csv.parseLine(); + } + + // + // If the gameID was NOT found, fill only the name "Unknown game connected" + // + QString strUnknown("Unknown game connected (ID = " + gameID + ")"); + sprintf_s(pMemData->ProgramName, 99, strUnknown.toAscii()); + file.close(); + return true; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + 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 ( "FT" ); + intUsedInterface = iniFile.value ( "UsedInterface", 0 ).toInt(); + iniFile.endGroup (); + + // + // Use the settings-section from the deprecated fake-TIR protocol, as they are most likely to be found there. + // + iniFile.beginGroup ( "FTIR" ); + useTIRViews = iniFile.value ( "useTIRViews", 0 ).toBool(); + useDummyExe = iniFile.value ( "useDummyExe", 1 ).toBool(); + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +float virtPosX; +float virtPosY; +float virtPosZ; + +float virtRotX; +float virtRotY; +float virtRotZ; + +float headPosX; +float headPosY; +float headPosZ; + +float headRotX; +float headRotY; +float headRotZ; + +PDWORD_PTR MsgResult = 0; + + + // + // Scale the Raw measurements to the client measurements. + // + headRotX = getRadsFromDegrees(headpose->pitch); + headRotY = getRadsFromDegrees(headpose->yaw); + headRotZ = getRadsFromDegrees(headpose->roll); + headPosX = headpose->x * 10; + headPosY = headpose->y * 10; + headPosZ = headpose->z * 10; + + virtRotX = getRadsFromDegrees(headpose->pitch); + virtRotY = getRadsFromDegrees(headpose->yaw); + virtRotZ = getRadsFromDegrees(headpose->roll); + virtPosX = headpose->x * 10; + virtPosY = headpose->y * 10; + virtPosZ = headpose->z * 10; + + // + // Check if the pointer is OK and wait for the Mutex. + // + if ( (pMemData != NULL) && (WaitForSingleObject(hFTMutex, 100) == WAIT_OBJECT_0) ) { + + // + // Copy the Raw measurements directly to the client. + // + pMemData->data.RawX = headPosX; + pMemData->data.RawY = headPosY; + pMemData->data.RawZ = headPosZ; + pMemData->data.RawPitch = headRotX; + pMemData->data.RawYaw = headRotY; + pMemData->data.RawRoll = headRotZ; + + // + // + pMemData->data.X = virtPosX; + pMemData->data.Y = virtPosY; + pMemData->data.Z = virtPosZ; + pMemData->data.Pitch = virtRotX; + pMemData->data.Yaw = virtRotY; + pMemData->data.Roll = virtRotZ; + + // + // Leave some values 0 yet... + // + pMemData->data.X1 = pMemData->data.DataID + 10; + pMemData->data.X2 = 0; + pMemData->data.X3 = 0; + pMemData->data.X4 = 0; + pMemData->data.Y1 = 0; + pMemData->data.Y2 = 0; + pMemData->data.Y3 = 0; + pMemData->data.Y4 = 0; + + // + // Check if the handle that was sent to the Game, was changed (on x64, this will be done by the ED-API) + // If the "Report Program Name" command arrives (which is a '1', for now), raise the event from here! + // + if (hMainWindow != pMemData->handle) { // Handle in memory-mapping was changed! + comhandle = (__int32) pMemData->handle; // Get the command from the Game. + if (comhandle == 1) { // "Report Program Name" + SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); + pMemData->handle = 0; // Reset the command, to enable future commands... + } + } + + // + // The game-ID was changed? + // + QString gameID = QString(pMemData->GameID); + //QString gameID = QString("9999"); + +// qDebug() << "sendHeadposeToGame: gameID = " << gameID; + if (gameID.length() > 0) { + if ( gameID.toInt() != intGameID ) { + if (getGameData( gameID ) ) { + SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); + } + intGameID = gameID.toInt(); + } + } + else { + intGameID = 0; + pMemData->ProgramName[0] = NULL; + pMemData->FTNID[0] = NULL; + pMemData->FTNVERSION[0] = NULL; + } + + ReleaseMutex(hFTMutex); + } + + pMemData->data.DataID += 1; +} + +// +// Set the Path variables and load the memory-mapping. +// Simplified function: No need to check if the DLL's actually exist. The are installed by the installer. +// If they are absent, something went terribly wrong anyway... +// +// Returns 'true' if all seems OK. +// +// +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) +{ + QSettings settings("Freetrack", "FreetrackClient"); // Registry settings (in HK_USER) + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) + QString aLocation; // Location of Client DLL + + qDebug() << "checkServerInstallationOK says: Starting Function"; + + try { + + // + // Write the path in the registry (for FreeTrack and FreeTrack20), for the game(s). + // + aLocation = QCoreApplication::applicationDirPath() + "/"; + + qDebug() << "checkServerInstallationOK says: used interface = " << intUsedInterface; + switch (intUsedInterface) { + case 0: // Use both interfaces + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , aLocation ); + break; + case 1: // Use FreeTrack, disable TrackIR + settings.setValue( "Path" , aLocation ); + settingsTIR.setValue( "Path" , "" ); + break; + case 2: // Use TrackIR, disable FreeTrack + settings.setValue( "Path" , "" ); + settingsTIR.setValue( "Path" , aLocation ); + break; + default: + // should never be reached + break; + } + + // + // TIRViews must be started first, or the NPClient DLL will never be loaded. + // + if (useTIRViews) { + + QString aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( QFile::exists( aFileName ) ) { + + FTIRViewsLib.setFileName(aFileName); + FTIRViewsLib.load(); + + viewsStart = (importTIRViewsStart) FTIRViewsLib.resolve("TIRViewsStart"); + if (viewsStart == NULL) { + qDebug() << "FTServer::run() says: TIRViewsStart function not found in DLL!"; + } + else { + qDebug() << "FTServer::run() says: TIRViewsStart executed!"; + viewsStart(); + } + + // + // Load the Stop function from TIRViews.dll. Call it when terminating the thread. + // + viewsStop = (importTIRViewsStop) FTIRViewsLib.resolve("TIRViewsStop"); + if (viewsStop == NULL) { + qDebug() << "FTServer::run() says: TIRViewsStop function not found in DLL!"; + } + } + } + + // + // Check if TIRViews or dummy TrackIR.exe is required for this game + // + if (useDummyExe) { + QString program = QCoreApplication::applicationDirPath() + "/TrackIR.exe"; + dummyTrackIR = new QProcess(); + dummyTrackIR->start(program); + + qDebug() << "FTServer::run() says: TrackIR.exe executed!"; + } + + + } catch(...) { + settings.~QSettings(); + } + return FTCreateMapping( handle ); +} + +// +// Create a memory-mapping to the FreeTrack data. +// It contains the tracking data, a handle to the main-window and the program-name of the Game! +// +// +bool FTNoIR_Protocol::FTCreateMapping( HANDLE handle ) +{ +bool bFirst = false; + + qDebug() << "FTCreateMapping says: Starting Function"; + + // + // A FileMapping is used to create 'shared memory' between the FTServer and the FTClient. + // + // Try to create a FileMapping to the Shared Memory. + // If one already exists: close it. + // + hFTMemMap = CreateFileMappingA( INVALID_HANDLE_VALUE , 00 , PAGE_READWRITE , 0 , +// sizeof( TFreeTrackData ) + sizeof( HANDLE ) + 100, + sizeof( FTMemMap ), + (LPCSTR) FT_MM_DATA ); + + if ( hFTMemMap != 0 ) { + bFirst = true; + qDebug() << "FTCreateMapping says: FileMapping Created!" << hFTMemMap; + } + + if ( ( hFTMemMap != 0 ) && ( (long) GetLastError == ERROR_ALREADY_EXISTS ) ) { + bFirst = false; + qDebug() << "FTCreateMapping says: FileMapping already exists!" << hFTMemMap; + CloseHandle( hFTMemMap ); + hFTMemMap = 0; + } + + // + // Create a new FileMapping, Read/Write access + // + hFTMemMap = OpenFileMappingA( FILE_MAP_ALL_ACCESS , false , (LPCSTR) FT_MM_DATA ); + if ( ( hFTMemMap != 0 ) ) { + qDebug() << "FTCreateMapping says: FileMapping Opened:" << hFTMemMap; + pMemData = (FTMemMap *) MapViewOfFile(hFTMemMap, FILE_MAP_ALL_ACCESS, 0, 0, +// sizeof(TFreeTrackData) + sizeof(hFTMemMap) + 100); + sizeof(FTMemMap)); + if (pMemData != NULL) { + if (bFirst) { + memset(pMemData, 0, sizeof(FTMemMap)); // Write zero's, if first... + } + pMemData->handle = handle; // The game uses the handle, to send a message that the Program-Name was set! + hMainWindow = handle; + } + hFTMutex = CreateMutexA(NULL, false, FREETRACK_MUTEX); + } + else { + QMessageBox::information(0, "FaceTrackNoIR error", QString("FTServer Error! \n")); + return false; + } + + if (pMemData != NULL) { + pMemData->data.DataID = 1; + pMemData->data.CamWidth = 100; + pMemData->data.CamHeight = 250; + } + + return true; +} + +// +// Destory the FileMapping to the shared memory +// +void FTNoIR_Protocol::FTDestroyMapping() +{ + if ( pMemData != NULL ) { + UnmapViewOfFile ( pMemData ); + } + + CloseHandle( hFTMutex ); + CloseHandle( hFTMemMap ); + hFTMemMap = 0; + +} + +// +// Return a name, if present the name from the Game, that is connected... +// +void FTNoIR_Protocol::getNameFromGame( char *dest ) +{ + sprintf_s(dest, 99, "FreeTrack interface"); + + qDebug() << "FTNoIR_Protocol::getNameFromGame says: Started, pMemData = " << pMemData << ", mutex = " << hFTMutex; + + // + // Check if the pointer is OK and wait for the Mutex. + // +// if ( (pMemData != NULL) && (WaitForSingleObject(hFTMutex, 100) == WAIT_OBJECT_0) ) { + if (pMemData != NULL) { + qDebug() << "FTNoIR_Protocol::getNameFromGame says: Inside MemData"; + sprintf_s(dest, 99, "%s", pMemData->ProgramName); + } + + return; +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_ft/FTNoIR_Protocol_FT.h b/ftnoir_protocol_ft/FTNoIR_Protocol_FT.h new file mode 100644 index 00000000..c82c3e79 --- /dev/null +++ b/ftnoir_protocol_ft/FTNoIR_Protocol_FT.h @@ -0,0 +1,143 @@ +/******************************************************************************** +* 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) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTServer FTServer is the Class, that communicates headpose-data * +* to games, using the FreeTrackClient.dll. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTSERVER_H +#define INCLUDED_FTSERVER_H + +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "ui_FTNoIR_FTcontrols.h" +#include "FTTypes.h" +#include +#include +#include +#include +#include +#include +#include "Windows.h" +//#include "math.h" + +//typedef char *(WINAPI *importProvider)(void); +typedef void (WINAPI *importTIRViewsStart)(void); +typedef void (WINAPI *importTIRViewsStop)(void); + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Release(); + void Initialize(); + + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... + +private: + bool FTCreateMapping(HANDLE handle); + void FTDestroyMapping(); + + importTIRViewsStart viewsStart; // Functions inside TIRViews.dll + importTIRViewsStop viewsStop; + + HANDLE hFTMemMap; + FTMemMap *pMemData; + HANDLE hFTMutex; + + HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window + __int32 comhandle; // Handle on x32, command on x64 + + // Private properties + QString ProgramName; + QLibrary FTIRViewsLib; + QProcess *dummyTrackIR; + int intGameID; + int intUsedInterface; // Determine which interface to use (or to hide from the game) + bool useTIRViews; // Needs to be in the Settings dialog + bool useDummyExe; + + float getRadsFromDegrees ( float degrees ) { return (degrees * 0.017453f); } + bool getGameData( QString gameID ); + void loadSettings(); + +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTControls: public QWidget, Ui::UICFTControls, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FTControls(); + virtual ~FTControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + }; + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + }; + +private: + Ui::UICFTControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void selectDLL(); + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FreeTrack 2.0"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Enhanced FreeTrack protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/Freetrack.ico"); }; +}; + + +#endif//INCLUDED_FTSERVER_H +//END diff --git a/ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc8.vcproj b/ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc8.vcproj new file mode 100644 index 00000000..f8f80412 --- /dev/null +++ b/ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc8.vcproj @@ -0,0 +1,393 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc9.vcproj b/ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc9.vcproj new file mode 100644 index 00000000..e5146727 --- /dev/null +++ b/ftnoir_protocol_ft/FTNoIR_Protocol_FT_vc9.vcproj @@ -0,0 +1,385 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_ft/FTTypes.h b/ftnoir_protocol_ft/FTTypes.h new file mode 100644 index 00000000..1f389711 --- /dev/null +++ b/ftnoir_protocol_ft/FTTypes.h @@ -0,0 +1,104 @@ +/******************************************************************************** +* FTTypes FTTypes contains th specific type definitions for the * +* FreeTrack protocol. * +* It was loosely translated from FTTypes.pas * +* which was created by the FreeTrack-team. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Testing and Research) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* We would like to extend our grattitude to the creators of SweetSpotter, * +* which has become the basis of this program: "Great work guys!" * +********************************************************************************/ +/* + Modifications (last one on top): + 20130125 - WVR: Upgraded to FT2.0: now the FreeTrack protocol supports all TIR-enabled games. The memory-mapping was expanded for this purpose. +*/ +#pragma once +#ifndef INCLUDED_FTTYPES_H +#define INCLUDED_FTTYPES_H + +#include "Windows.h" +#include +#include + +//#include "Registry.h" + +// static const char* FT_CLIENT_LOCATION = "Software\\Freetrack\\FreetrackClient"; + static const char* FT_CLIENT_FILENAME = "FreeTrackClient.Dll"; + static const char* FT_MM_DATA = "FT_SharedMem"; + static const char* FREETRACK = "Freetrack"; + static const char* FREETRACK_MUTEX = "FT_Mutext"; + static const char* FT_PROGRAMID = "FT_ProgramID"; + + +struct TFreeTrackData { + int DataID; + int CamWidth; + int CamHeight; + // virtual pose + float Yaw; // positive yaw to the left + float Pitch; // positive pitch up + float Roll; // positive roll to the left + float X; + float Y; + float Z; + // raw pose with no smoothing, sensitivity, response curve etc. + float RawYaw; + float RawPitch; + float RawRoll; + float RawX; + float RawY; + float RawZ; + // raw points, sorted by Y, origin top left corner + float X1; + float Y1; + float X2; + float Y2; + float X3; + float Y3; + float X4; + float Y4; +}; +typedef TFreeTrackData * PFreetrackData; + +struct FTMemMap { + TFreeTrackData data; + +#ifdef WIN64 + __int32 command; +#else + HANDLE handle; +#endif + char ProgramName[100]; // The name of the game + char GameID[10]; // The international game-ID + char FTNID[30]; // The FaceTrackNoIR game-ID + char FTNVERSION[10]; // The version of FaceTrackNoIR, in which the game was first supported +}; +typedef FTMemMap * PFTMemMap; + +//extern bool (*FTGetData) (PFreetrackData data); +// DLL function signatures +// These match those given in FTTypes.pas +// WINAPI is macro for __stdcall defined somewhere in the depths of windows.h +typedef bool (WINAPI *importGetData)(TFreeTrackData * data); +typedef char *(WINAPI *importGetDllVersion)(void); +typedef void (WINAPI *importReportID)(int name); +typedef char *(WINAPI *importProvider)(void); + +#endif//INCLUDED_FTTYPES_H diff --git a/ftnoir_protocol_ft/Protocol.qrc b/ftnoir_protocol_ft/Protocol.qrc new file mode 100644 index 00000000..25ecc6fe --- /dev/null +++ b/ftnoir_protocol_ft/Protocol.qrc @@ -0,0 +1,5 @@ + + + images/Freetrack.ico + + diff --git a/ftnoir_protocol_ft/csv.cpp b/ftnoir_protocol_ft/csv.cpp new file mode 100644 index 00000000..22852f89 --- /dev/null +++ b/ftnoir_protocol_ft/csv.cpp @@ -0,0 +1,99 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2013 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +#include "csv.h" +#include + +CSV::CSV(QIODevice * device) +{ + m_device = device; + m_codec = QTextCodec::codecForLocale(); + m_pos = 0; + m_rx = QRegExp("((?:(?:[^;\\n]*;?)|(?:\"[^\"]*\";?))*)\\n"); +} +CSV::CSV(QString &string){ + m_device = NULL; + m_codec = QTextCodec::codecForLocale(); + m_string = string; + m_pos = 0; + m_rx = QRegExp("((?:(?:[^;\\n]*;?)|(?:\"[^\"]*\";?))*)\\n"); +} + +CSV::~CSV() +{ + //delete m_codec; +} + + +void CSV::setCodec(const char* codecName){ + //delete m_codec; + m_codec = QTextCodec::codecForName(codecName); +} + +QString CSV::readLine(){ + QString line; + + if(m_string.isNull()){ + //READ DATA FROM DEVICE + if(m_device && m_device->isReadable()){ + QTextDecoder dec(m_codec); + m_string = dec.toUnicode(m_device->readAll()); + }else{ + return QString(); + } + } + + //PARSE + if((m_pos = m_rx.indexIn(m_string,m_pos)) != -1) { + line = m_rx.cap(1); + m_pos += m_rx.matchedLength(); + } + return line; + +} +QStringList CSV::parseLine(){ + return parseLine(readLine()); +} +QStringList CSV::parseLine(QString line){ + QStringList list; + int pos2 = 0; + QRegExp rx2("(?:\"([^\"]*)\";?)|(?:([^;]*);?)"); + if(line.size()<1){ + list << ""; + }else while (line.size()>pos2 && (pos2 = rx2.indexIn(line, pos2)) != -1) { + QString col; + if(rx2.cap(1).size()>0) + col = rx2.cap(1); + else if(rx2.cap(2).size()>0) + col = rx2.cap(2); + + list << col; + + if(col.size()) + pos2 += rx2.matchedLength(); + else + pos2++; + } + return list; +} \ No newline at end of file diff --git a/ftnoir_protocol_ft/csv.h b/ftnoir_protocol_ft/csv.h new file mode 100644 index 00000000..13231293 --- /dev/null +++ b/ftnoir_protocol_ft/csv.h @@ -0,0 +1,38 @@ +/*dummy CSV reader for QT4*/ +/*version 0.1*/ +/*11.1.2009*/ +#ifndef CSV_H +#define CSV_H + +//#include "myclass_api.h" + +#include +#include +#include +#include +#include + +class /*MYCLASS_API*/ CSV /*: public QObject*/ +{ + /*Q_OBJECT*/ + +public: + CSV(QIODevice * device); + CSV(QString &string); + ~CSV(); + + QString readLine(); + QStringList parseLine(); + static QStringList parseLine(QString line); + + void setCodec(const char* codecName); +private: + QIODevice *m_device; + QTextCodec *m_codec; + QString m_string; + int m_pos; + QRegExp m_rx; + +}; + +#endif // CSV_H diff --git a/ftnoir_protocol_ft/ftnoir_protocol_FT_dialog.cpp b/ftnoir_protocol_ft/ftnoir_protocol_FT_dialog.cpp new file mode 100644 index 00000000..2e6c91f7 --- /dev/null +++ b/ftnoir_protocol_ft/ftnoir_protocol_FT_dialog.cpp @@ -0,0 +1,235 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ft.h" +#include +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTControls::FTControls() : +QWidget() +{ + QString aFileName; // File Path and Name + + 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.bntLocateNPClient, SIGNAL(clicked()), this, SLOT(selectDLL())); + connect(ui.chkTIRViews, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); + connect(ui.chkStartDummy, SIGNAL(stateChanged(int)), this, SLOT(settingChanged())); + connect(ui.cbxSelectInterface, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + + ui.cbxSelectInterface->addItem("Enable both"); + ui.cbxSelectInterface->addItem("Use FreeTrack, hide TrackIR"); + ui.cbxSelectInterface->addItem("Use TrackIR, hide FreeTrack"); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); + + + aFileName = QCoreApplication::applicationDirPath() + "/TIRViews.dll"; + if ( !QFile::exists( aFileName ) ) { + ui.chkTIRViews->setChecked( false ); + ui.chkTIRViews->setEnabled ( false ); + + // + // Best do this save() last, or it will continually reset the settings... :-( + // + save(); + } + else { + ui.chkTIRViews->setEnabled ( true ); + } + + +} + +// +// Destructor for server-dialog +// +FTControls::~FTControls() { + qDebug() << "~FTControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void FTControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTControls::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 FTControls::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 ( "FT" ); + ui.cbxSelectInterface->setCurrentIndex( iniFile.value ( "UsedInterface", 0 ).toInt() ); + iniFile.endGroup (); + + iniFile.beginGroup ( "FTIR" ); + ui.chkTIRViews->setChecked (iniFile.value ( "useTIRViews", 0 ).toBool()); + ui.chkStartDummy->setChecked (iniFile.value ( "useDummyExe", 1 ).toBool()); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void FTControls::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 ( "FT" ); + iniFile.setValue ( "UsedInterface", ui.cbxSelectInterface->currentIndex()); + iniFile.endGroup (); + + iniFile.beginGroup ( "FTIR" ); + iniFile.setValue ( "useTIRViews", ui.chkTIRViews->isChecked() ); + iniFile.setValue ( "useDummyExe", ui.chkStartDummy->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Select a NPClient.dll file, to repair the Location in the Registry. +// Several program distribute their own version of this file. +// +void FTControls::selectDLL() { + QFileDialog::Options options; + QFileDialog::FileMode mode; + + options |= QFileDialog::DontUseNativeDialog; + mode = QFileDialog::ExistingFile; + QString selectedFilter; + QString fileName = QFileDialog::getOpenFileName( this, tr("Select the desired NPClient DLL"), QCoreApplication::applicationDirPath() + "/NPClient.dll", tr("Dll file (*.dll);;All Files (*)")); + + // + // Write the location of the file in the required Registry-key. + // + if (! fileName.isEmpty() ) { + if (fileName.endsWith("NPClient.dll", Qt::CaseInsensitive) ) { + QSettings settingsTIR("NaturalPoint", "NATURALPOINT\\NPClient Location"); // Registry settings (in HK_USER) + QString aLocation = fileName.left(fileName.length() - 12); // Location of Client DLL + + settingsTIR.setValue( "Path" , aLocation ); + } + } +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FTControls; +} diff --git a/ftnoir_protocol_ft/ftnoir_protocol_FT_dll.cpp b/ftnoir_protocol_ft/ftnoir_protocol_FT_dll.cpp new file mode 100644 index 00000000..4513c6ba --- /dev/null +++ b/ftnoir_protocol_ft/ftnoir_protocol_FT_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ft.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_ft/images/Freetrack.ico b/ftnoir_protocol_ft/images/Freetrack.ico new file mode 100644 index 00000000..02554c3d Binary files /dev/null and b/ftnoir_protocol_ft/images/Freetrack.ico differ diff --git a/ftnoir_protocol_ftn/FTNoIR_FTNControls.ui b/ftnoir_protocol_ftn/FTNoIR_FTNControls.ui new file mode 100644 index 00000000..56983fbe --- /dev/null +++ b/ftnoir_protocol_ftn/FTNoIR_FTNControls.ui @@ -0,0 +1,261 @@ + + + UICFTNControls + + + + 0 + 0 + 411 + 156 + + + + FTNoIR protocol settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + + 60 + 16777215 + + + + 255 + + + 1 + + + + + + + IP-address remote PC + + + + + + + Port-number + + + + + + + 1000 + + + 10000 + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter IP-address and port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinIPFirstNibble + spinIPSecondNibble + spinIPThirdNibble + spinIPFourthNibble + spinPortNumber + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.cpp b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.cpp new file mode 100644 index 00000000..cfb6c618 --- /dev/null +++ b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.cpp @@ -0,0 +1,200 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNServer FTNServer is the Class, that communicates headpose-data * +* to another FaceTrackNoIR program, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_ftn.h" +#include + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + loadSettings(); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + if (inSocket != 0) { + inSocket->close(); + delete inSocket; + } + + if (outSocket != 0) { + outSocket->close(); + delete outSocket; + } +} + +/** helper to Auto-destruct **/ +void FTNoIR_Protocol::Release() +{ + delete this; +} + +void FTNoIR_Protocol::Initialize() +{ + return; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + 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 ( "FTN" ); + + QString destAddr = iniFile.value ( "IP-1", 192 ).toString() + "." + iniFile.value ( "IP-2", 168 ).toString() + "." + iniFile.value ( "IP-3", 2 ).toString() + "." + iniFile.value ( "IP-4", 1 ).toString(); + destIP = QHostAddress( destAddr ); + destPort = iniFile.value ( "PortNumber", 5550 ).toInt(); + + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +int no_bytes; +QHostAddress sender; +quint16 senderPort; + + // + // Copy the Raw measurements directly to the client. + // + frame_counter += 1; + TestData = *headpose; + TestData.frame_number = frame_counter; + + // + // Try to send an UDP-message to the receiver + // + + //! [1] + if (outSocket != 0) { + no_bytes = outSocket->writeDatagram((const char *) &TestData, sizeof( TestData ), destIP, destPort); + if ( no_bytes > 0) { +// qDebug() << "FTNServer::writePendingDatagrams says: bytes send =" << no_bytes << sizeof( double ); + } + else { + qDebug() << "FTNServer::writePendingDatagrams says: nothing sent!"; + } + } + + // + // Receiver may send data, so we must read that here. + // + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { + + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); + + inSocket->readDatagram( (char * ) &cmd, sizeof(cmd), &sender, &senderPort); + + fg_cmd = cmd; // Let's just accept that command for now... + if ( cmd > 0 ) { + qDebug() << "FTNServer::sendHeadposeToGame hasPendingDatagrams, cmd = " << cmd; +// headTracker->handleGameCommand ( cmd ); // Send it upstream, for the Tracker to handle + } + } + } +} + +// +// Check if the Client DLL exists and load it (to test it), if so. +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) +{ + // Init. the data + TestData.x = 0.0f; + TestData.y = 0.0f; + TestData.z = 0.0f; + TestData.yaw = 0.0f; + TestData.pitch = 0.0f; + TestData.roll = 0.0f; + fg_cmd = 1; + + inSocket = 0; + outSocket = 0; + + frame_counter = 0; + + // + // Create UDP-sockets. + // + if (inSocket == 0) { + qDebug() << "FGServer::sendHeadposeToGame creating insocket"; + inSocket = new QUdpSocket(); + + // Connect the inSocket to the port, to receive messages + if (!inSocket->bind(QHostAddress::Any, destPort+1, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + return false; + } + } + + if (outSocket == 0) { + outSocket = new QUdpSocket(); + } + + return true; +} + +// +// Return a name, if present the name from the Game, that is connected... +// +void FTNoIR_Protocol::getNameFromGame( char *dest ) +{ + sprintf_s(dest, 99, "FaceTrackNoIR"); + return; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.h b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.h new file mode 100644 index 00000000..24f760c5 --- /dev/null +++ b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN.h @@ -0,0 +1,119 @@ +/******************************************************************************** +* 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) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNServer FTNServer is the Class, that communicates headpose-data * +* to FlightGear, using UDP. * +* It is based on the (Linux) example made by Melchior FRANZ. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_FTNSERVER_H +#define INCLUDED_FTNSERVER_H + +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "ui_FTNoIR_FTNcontrols.h" +#include +#include +#include +#include +#include "Windows.h" +#include "math.h" + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Release(); + void Initialize(); + + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... + +private: + THeadPoseData TestData; + long frame_counter; + QUdpSocket *inSocket; // Receive from FaceTrackNoIR + QUdpSocket *outSocket; // Send to FaceTrackNoIR + qint32 cmd; + qint32 fg_cmd; // Command from FlightGear + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + void loadSettings(); + +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class FTNControls: public QWidget, Ui::UICFTNControls, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit FTNControls(); + virtual ~FTNControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + }; + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + }; + +private: + Ui::UICFTNControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("FTN Client"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("FaceTrackNoIR Client protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FaceTrackNoIR.ico"); }; +}; + +#endif//INCLUDED_FTNSERVER_H +//END diff --git a/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc8.vcproj b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc8.vcproj new file mode 100644 index 00000000..1133119f --- /dev/null +++ b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc8.vcproj @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc9.vcproj b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc9.vcproj new file mode 100644 index 00000000..d1955180 --- /dev/null +++ b/ftnoir_protocol_ftn/FTNoIR_Protocol_FTN_vc9.vcproj @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_ftn/Protocol.qrc b/ftnoir_protocol_ftn/Protocol.qrc new file mode 100644 index 00000000..b69d1f3f --- /dev/null +++ b/ftnoir_protocol_ftn/Protocol.qrc @@ -0,0 +1,5 @@ + + + images/FaceTrackNoIR.ico + + diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_FTN_dll.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_FTN_dll.cpp new file mode 100644 index 00000000..00badedf --- /dev/null +++ b/ftnoir_protocol_ftn/ftnoir_protocol_FTN_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ftn.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp new file mode 100644 index 00000000..58dbfbad --- /dev/null +++ b/ftnoir_protocol_ftn/ftnoir_protocol_ftn_dialog.cpp @@ -0,0 +1,194 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_ftn.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +FTNControls::FTNControls() : +QWidget() +{ + ui.setupUi( this ); + + QPoint offsetpos(100, 100); + //if (parent) { + // this->move(parent->pos() + offsetpos); + //} + + // 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())); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +FTNControls::~FTNControls() { + qDebug() << "~FTNControls() says: started"; +} + +void FTNControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void FTNControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void FTNControls::doOK() { + save(); + this->close(); +} + +// override show event +void FTNControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void FTNControls::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 FTNControls::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 ( "FTN" ); + 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 FTNControls::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 ( "FTN" ); + 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 Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new FTNControls; +} diff --git a/ftnoir_protocol_ftn/images/FaceTrackNoIR.ico b/ftnoir_protocol_ftn/images/FaceTrackNoIR.ico new file mode 100644 index 00000000..5115066c Binary files /dev/null and b/ftnoir_protocol_ftn/images/FaceTrackNoIR.ico differ diff --git a/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.cpp b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.cpp new file mode 100644 index 00000000..f81a38f7 --- /dev/null +++ b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.cpp @@ -0,0 +1,294 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * +* generating Mouse commands. * +* Many games (like FPS's) support Mouse-look features, * +* but no face-tracking. * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_mouse.h" + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + prev_fMouse_X = 0.0f; + prev_fMouse_Y = 0.0f; + prev_fMouse_Wheel = 0.0f; + frame_delay = 0; + + loadSettings(); +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ +} + +/** helper to Auto-destruct **/ +void FTNoIR_Protocol::Release() +{ + delete this; +} + +void FTNoIR_Protocol::Initialize() +{ +int ScreenX, ScreenY; + + ScreenX = GetSystemMetrics(SM_CXSCREEN); + ScreenY = GetSystemMetrics(SM_CYSCREEN); + + qDebug() << "Initialize(): Screen width (x) = " << ScreenX << ", height (y) = " << ScreenY; + + return; +} + +// +// Scale the measured value to the Joystick values +// +long FTNoIR_Protocol::scale2AnalogLimits( float x, float min_x, float max_x ) { +double y; + + y = ((MOUSE_AXIS_MAX - MOUSE_AXIS_MIN)/(max_x - min_x)) * x + ((MOUSE_AXIS_MAX - MOUSE_AXIS_MIN)/2) + MOUSE_AXIS_MIN; + return (long) y; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { + 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 ( "Mouse" ); + Mouse_Style = (FTN_MouseStyle) (iniFile.value ( "Style", 1 ).toInt() - 1); + Mouse_X = (FTN_AngleName) (iniFile.value ( "Mouse_X", 1 ).toInt() - 1); + Mouse_Y = (FTN_AngleName) (iniFile.value ( "Mouse_Y", 1 ).toInt() - 1); + Mouse_Wheel = (FTN_AngleName) (iniFile.value ( "Mouse_Wheel", 1 ).toInt() - 1); + + mouse_X_factor = iniFile.value("SensX", 10).toFloat() / 10.0f; + mouse_Y_factor = iniFile.value("SensY", 10).toFloat() / 10.0f; + mouse_Wheel_factor = iniFile.value("SensWheel", 10).toFloat() / 10.0f; + + useVirtualDesk = iniFile.value ( "useVirtualDesk", 0 ).toBool(); + + iniFile.endGroup (); +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +float fMouse_X; // The actual value +float fMouse_Y; +float fMouse_Wheel; + + + // + // Determine which of the 6DOF's is used. + // The rotations are from -180 to +180 and the translations from -50cm to +50cm. + // Let's scale the translations to the degrees for simplicity sake... + // + switch (Mouse_X) { + case FTN_PITCH: + fMouse_X = headpose->pitch; + break; + + case FTN_YAW: + fMouse_X = headpose->yaw; + break; + + case FTN_ROLL: + fMouse_X = headpose->roll; + break; + + case FTN_X: + fMouse_X = headpose->x * 3.0f; + break; + + case FTN_Y: + fMouse_X = headpose->y * 3.0f; + break; + + case FTN_Z: + fMouse_X = headpose->z * 3.0f; + break; + + default: + break; + } + + // + // Determine which of the 6DOF's is used. + // The rotations are from -180 to +180 and the translations from -50cm to +50cm. + // Let's scale the translations to the degrees for simplicity sake... + // + switch (Mouse_Y) { + case FTN_PITCH: + fMouse_Y = headpose->pitch; + break; + + case FTN_YAW: + fMouse_Y = headpose->yaw; + break; + + case FTN_ROLL: + fMouse_Y = headpose->roll; + break; + + case FTN_X: + fMouse_Y = headpose->x * 3.0f; + break; + + case FTN_Y: + fMouse_Y = headpose->y * 3.0f; + break; + + case FTN_Z: + fMouse_Y = headpose->z * 3.0f; + break; + + default: + break; + } + + // + // Determine which of the 6DOF's is used. + // The rotations are from -180 to +180 and the translations from -50cm to +50cm. + // Let's scale the translations to the degrees for simplicity sake... + // + switch (Mouse_Wheel) { + case FTN_PITCH: + fMouse_Wheel = headpose->pitch; + break; + + case FTN_YAW: + fMouse_Wheel = headpose->yaw; + break; + + case FTN_ROLL: + fMouse_Wheel = headpose->roll; + break; + + case FTN_X: + fMouse_Wheel = headpose->x * 3.0f; + break; + + case FTN_Y: + fMouse_Wheel = headpose->y * 3.0f; + break; + + case FTN_Z: + fMouse_Wheel = headpose->z * 3.0f; + break; + + default: + break; + } + + // + // Determine which style is used. + // + SecureZeroMemory(&MouseStruct, sizeof(MouseStruct)); + MouseStruct.type = INPUT_MOUSE; + switch (Mouse_Style) { + case FTN_ABSOLUTE: + MouseStruct.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_WHEEL | MOUSEEVENTF_ABSOLUTE; + if (useVirtualDesk) { + MouseStruct.mi.dwFlags |= MOUSEEVENTF_VIRTUALDESK; + } + MouseStruct.mi.dx = scale2AnalogLimits(-1.0f * fMouse_X * mouse_X_factor, -150, 150); + MouseStruct.mi.dy = scale2AnalogLimits(fMouse_Y * mouse_Y_factor, -150, 150); + MouseStruct.mi.mouseData = mouse_Wheel_factor * (fMouse_Wheel - prev_fMouse_Wheel); + + frame_delay = 9999; // Seems no problem with Absolute positioning + break; + + case FTN_RELATIVE: + MouseStruct.mi.dwFlags = MOUSEEVENTF_MOVE | MOUSEEVENTF_WHEEL; + MouseStruct.mi.dx = -1.0f * mouse_X_factor * (fMouse_X - prev_fMouse_X); + MouseStruct.mi.dy = mouse_Y_factor * (fMouse_Y - prev_fMouse_Y); + MouseStruct.mi.mouseData = - 1.0f * mouse_Wheel_factor * (fMouse_Wheel - prev_fMouse_Wheel); + + frame_delay += 1; // Add 1 to the counter + qDebug() << "sendHeadposeToGame(): FTN_RELATIVE x = " << MouseStruct.mi.dx << ", y = " << MouseStruct.mi.dy; + break; + + default: + Mouse_Style = FTN_ABSOLUTE; // Force to a valid value... + break; + } + + // + // Only send Input, when it has changed. + // This releases the Mouse, when tracking is stopped (for a while). + // + if (frame_delay > 10) { + if ((prev_fMouse_X != fMouse_X) || (prev_fMouse_Y != fMouse_Y) || (prev_fMouse_Wheel != fMouse_Wheel)) { + SendInput(1, &MouseStruct, sizeof(MouseStruct)); + } + + prev_fMouse_X = fMouse_X; + prev_fMouse_Y = fMouse_Y; + prev_fMouse_Wheel = fMouse_Wheel; + } +} + +// +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) +{ + + return true; +} + +// +// Return a name, if present the name from the Game, that is connected... +// +void FTNoIR_Protocol::getNameFromGame( char *dest ) +{ + sprintf_s(dest, 99, "Mouse"); + return; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.h b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.h new file mode 100644 index 00000000..b7765b96 --- /dev/null +++ b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE.h @@ -0,0 +1,151 @@ +/******************************************************************************** +* 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) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* 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 . * +* * +* FTNoIR_Protocol_Mouse The Class, that communicates headpose-data by * +* generating Mouse commands. * +* Many games (like FPS's) support Mouse-look features, * +* but no face-tracking. * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_MOUSESERVER_H +#define INCLUDED_MOUSESERVER_H + +//#include +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "ui_FTNoIR_MOUSEcontrols.h" +#include +#include +#include +#include +#include +#include + +#include "winable.h" + +#define MOUSE_AXIS_MIN 0 +#define MOUSE_AXIS_MAX 65535 + +enum FTN_AngleName { + FTN_PITCH = 1, + FTN_YAW = 2, + FTN_ROLL = 3, + FTN_X = 4, + FTN_Y = 5, + FTN_Z = 6 +}; + +enum FTN_MouseStyle { + FTN_ABSOLUTE = 0, + FTN_RELATIVE = 1 +}; + + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Release(); + void Initialize(); + + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... + +private: + HANDLE h; + INPUT MouseStruct; + + FTN_AngleName Mouse_X; // Map one of the 6DOF's to this Mouse direction + FTN_AngleName Mouse_Y; + FTN_AngleName Mouse_Wheel; + FTN_MouseStyle Mouse_Style; // AutoPan, Absolute or Relative? + bool useVirtualDesk; // Extend the mouse-range beyond the standard + float prev_fMouse_X; // The previous value(s) + float mouse_X_factor; // Sensitivity factor + float prev_fMouse_Y; + float mouse_Y_factor; // Sensitivity factor + float prev_fMouse_Wheel; + float mouse_Wheel_factor; // Sensitivity factor + + int frame_delay; // Number of frames to delay SendInput (too fast, too furious?) + + long scale2AnalogLimits( float x, float min_x, float max_x ); + void loadSettings(); + +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class MOUSEControls: public QWidget, Ui::UICMOUSEControls, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit MOUSEControls(); + virtual ~MOUSEControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + }; + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + }; + +private: + Ui::UICMOUSEControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged( int setting ) { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Mouse Look protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/Mouse.ico"); }; +}; + + +#endif//INCLUDED_MOUSESERVER_H +//END diff --git a/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc8.vcproj b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc8.vcproj new file mode 100644 index 00000000..82e93d35 --- /dev/null +++ b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc8.vcproj @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc9.vcproj b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc9.vcproj new file mode 100644 index 00000000..625e88de --- /dev/null +++ b/ftnoir_protocol_mouse/FTNoIR_Protocol_MOUSE_vc9.vcproj @@ -0,0 +1,381 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_mouse/FTNoIR_mousecontrols.ui b/ftnoir_protocol_mouse/FTNoIR_mousecontrols.ui new file mode 100644 index 00000000..4a6cc3b9 --- /dev/null +++ b/ftnoir_protocol_mouse/FTNoIR_mousecontrols.ui @@ -0,0 +1,512 @@ + + + UICMOUSEControls + + + + 0 + 0 + 462 + 299 + + + + MouseLook settings FaceTrackNoIR + + + + :/images/Mouse.ico:/images/Mouse.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + Mouse style: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Map mouse X to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 0 + 0 + + + + Map mouse Y to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 0 + 0 + + + + Map mouse Wheel to: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 80 + 16777215 + + + + Select Number + + + QComboBox::InsertAlphabetically + + + + + + + + 150 + 16777215 + + + + 50 + + + Qt::Horizontal + + + + + + + + 150 + 16777215 + + + + 50 + + + Qt::Horizontal + + + + + + + + 150 + 16777215 + + + + 50 + + + Qt::Horizontal + + + + + + + Sensitivity (10=1x): + + + + + + + 50 + + + + + + + 50 + + + + + + + 50 + + + + + + + + 0 + 0 + + + + Use Virtual Desk: + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + 0 + 20 + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Most games (like First Person Shooters) support 'relative' mouse look. + + + + + + + + + + + Mouse sensitivity can also be influenced via the Windows Mouse settings. + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + + + slideSensX + valueChanged(int) + spinSensX + setValue(int) + + + 334 + 44 + + + 445 + 46 + + + + + slideSensY + valueChanged(int) + spinSensY + setValue(int) + + + 338 + 73 + + + 450 + 70 + + + + + slideSensWheel + valueChanged(int) + spinSensWheel + setValue(int) + + + 334 + 98 + + + 445 + 96 + + + + + spinSensX + valueChanged(int) + slideSensX + setValue(int) + + + 440 + 37 + + + 364 + 41 + + + + + spinSensY + valueChanged(int) + slideSensY + setValue(int) + + + 441 + 69 + + + 347 + 73 + + + + + spinSensWheel + valueChanged(int) + slideSensWheel + setValue(int) + + + 459 + 99 + + + 350 + 99 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_mouse/Protocol.qrc b/ftnoir_protocol_mouse/Protocol.qrc new file mode 100644 index 00000000..0e5e11d9 --- /dev/null +++ b/ftnoir_protocol_mouse/Protocol.qrc @@ -0,0 +1,5 @@ + + + images/Mouse.ico + + diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dialog.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dialog.cpp new file mode 100644 index 00000000..b8d7d7ee --- /dev/null +++ b/ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dialog.cpp @@ -0,0 +1,235 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_MOUSE.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +MOUSEControls::MOUSEControls() : +QWidget() +{ + ui.setupUi( this ); + + // + // Setup the choices + // + ui.cbxSelectMouseStyle->addItem("Absolute"); + ui.cbxSelectMouseStyle->addItem("Relative"); + + ui.cbxSelectMouse_X->addItem("None"); + ui.cbxSelectMouse_X->addItem("Pitch"); + ui.cbxSelectMouse_X->addItem("Yaw"); + ui.cbxSelectMouse_X->addItem("Roll"); + ui.cbxSelectMouse_X->addItem("X"); + ui.cbxSelectMouse_X->addItem("Y"); + ui.cbxSelectMouse_X->addItem("Z"); + + ui.cbxSelectMouse_Y->addItem("None"); + ui.cbxSelectMouse_Y->addItem("Pitch"); + ui.cbxSelectMouse_Y->addItem("Yaw"); + ui.cbxSelectMouse_Y->addItem("Roll"); + ui.cbxSelectMouse_Y->addItem("X"); + ui.cbxSelectMouse_Y->addItem("Y"); + ui.cbxSelectMouse_Y->addItem("Z"); + + ui.cbxSelectMouse_Wheel->addItem("None"); + ui.cbxSelectMouse_Wheel->addItem("Pitch"); + ui.cbxSelectMouse_Wheel->addItem("Yaw"); + ui.cbxSelectMouse_Wheel->addItem("Roll"); + ui.cbxSelectMouse_Wheel->addItem("X"); + ui.cbxSelectMouse_Wheel->addItem("Y"); + ui.cbxSelectMouse_Wheel->addItem("Z"); + + // Connect Qt signals to member-functions + connect(ui.btnOK, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.btnCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.cbxSelectMouse_X, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + connect(ui.cbxSelectMouse_Y, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + connect(ui.cbxSelectMouse_Wheel, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged( int ))); + + connect(ui.spinSensX, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.spinSensY, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.spinSensWheel, SIGNAL(valueChanged(int)), this, SLOT(settingChanged(int))); + + connect(ui.chkUseVirtualDesk, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +MOUSEControls::~MOUSEControls() { + qDebug() << "~MOUSEControls() says: started"; +} + +void MOUSEControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void MOUSEControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void MOUSEControls::doOK() { + save(); + this->close(); +} + +// override show event +void MOUSEControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void MOUSEControls::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 MOUSEControls::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 ( "Mouse" ); + ui.cbxSelectMouseStyle->setCurrentIndex(iniFile.value ( "Style", 1 ).toInt() - 1); + ui.cbxSelectMouse_X->setCurrentIndex(iniFile.value ( "Mouse_X", 1 ).toInt() - 1); + ui.cbxSelectMouse_Y->setCurrentIndex(iniFile.value ( "Mouse_Y", 1 ).toInt() - 1); + ui.cbxSelectMouse_Wheel->setCurrentIndex(iniFile.value ( "Mouse_Wheel", 1 ).toInt() - 1); + + ui.slideSensX->setValue(iniFile.value("SensX", 10).toInt()); + ui.slideSensY->setValue(iniFile.value("SensY", 10).toInt()); + ui.slideSensWheel->setValue(iniFile.value("SensWheel", 10).toInt()); + + ui.chkUseVirtualDesk->setChecked( iniFile.value ( "useVirtualDesk", 0 ).toBool() ); + + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void MOUSEControls::save() { + qDebug() << "save() says: started"; + + 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 ( "Mouse" ); + iniFile.setValue ( "Style", ui.cbxSelectMouseStyle->currentIndex() + 1 ); + iniFile.setValue ( "Mouse_X", ui.cbxSelectMouse_X->currentIndex() + 1 ); + iniFile.setValue ( "Mouse_Y", ui.cbxSelectMouse_Y->currentIndex() + 1 ); + iniFile.setValue ( "Mouse_Wheel", ui.cbxSelectMouse_Wheel->currentIndex() + 1 ); + + iniFile.setValue ( "SensX", ui.slideSensX->value() ); + iniFile.setValue ( "SensY", ui.slideSensY->value() ); + iniFile.setValue ( "SensWheel", ui.slideSensWheel->value() ); + + iniFile.setValue( "useVirtualDesk", ui.chkUseVirtualDesk->isChecked() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new MOUSEControls; +} diff --git a/ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dll.cpp b/ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dll.cpp new file mode 100644 index 00000000..cc6ddc17 --- /dev/null +++ b/ftnoir_protocol_mouse/ftnoir_protocol_MOUSE_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_MOUSE.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_mouse/images/Mouse.ico b/ftnoir_protocol_mouse/images/Mouse.ico new file mode 100644 index 00000000..1151ab2b Binary files /dev/null and b/ftnoir_protocol_mouse/images/Mouse.ico differ diff --git a/ftnoir_protocol_sc/FTNoIR_Protocol_SC.cpp b/ftnoir_protocol_sc/FTNoIR_Protocol_SC.cpp new file mode 100644 index 00000000..7ca38e64 --- /dev/null +++ b/ftnoir_protocol_sc/FTNoIR_Protocol_SC.cpp @@ -0,0 +1,393 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* FTNoIR_Protocol: the Class, that communicates headpose-data * +* to games, using the SimConnect.dll. * +* SimConnect.dll is a so called 'side-by-side' assembly, so it * +* must be treated as such... * +********************************************************************************/ +/* + Modifications (last one on top): + 20110401 - WVR: Moved protocol to a DLL, convenient for installation etc. + 20101224 - WVR: Base class is no longer inheriting QThread. sendHeadposeToGame + is called from run() of Tracker.cpp +*/ +#include "ftnoir_protocol_sc.h" + +importSimConnect_CameraSetRelative6DOF FTNoIR_Protocol::simconnect_set6DOF; +HANDLE FTNoIR_Protocol::hSimConnect = 0; // Handle to SimConnect + +float FTNoIR_Protocol::virtSCPosX = 0.0f; // Headpose +float FTNoIR_Protocol::virtSCPosY = 0.0f; +float FTNoIR_Protocol::virtSCPosZ = 0.0f; + +float FTNoIR_Protocol::virtSCRotX = 0.0f; +float FTNoIR_Protocol::virtSCRotY = 0.0f; +float FTNoIR_Protocol::virtSCRotZ = 0.0f; + +float FTNoIR_Protocol::prevSCPosX = 0.0f; // previous Headpose +float FTNoIR_Protocol::prevSCPosY = 0.0f; +float FTNoIR_Protocol::prevSCPosZ = 0.0f; + +float FTNoIR_Protocol::prevSCRotX = 0.0f; +float FTNoIR_Protocol::prevSCRotY = 0.0f; +float FTNoIR_Protocol::prevSCRotZ = 0.0f; + +/** constructor **/ +FTNoIR_Protocol::FTNoIR_Protocol() +{ + ProgramName = "Microsoft FSX"; + blnSimConnectActive = false; + hSimConnect = 0; + hMainWindow = 0; +} + +/** destructor **/ +FTNoIR_Protocol::~FTNoIR_Protocol() +{ + qDebug() << "~FTNoIR_Protocol says: inside" << FTNoIR_Protocol::hSimConnect; + + if (hSimConnect != 0) { + qDebug() << "~FTNoIR_Protocol says: before simconnect_close"; + if (SUCCEEDED( simconnect_close( FTNoIR_Protocol::hSimConnect ) ) ) { + qDebug() << "~FTNoIR_Protocol says: close SUCCEEDED"; + } + } +// SCClientLib.unload(); Generates crash when tracker is ended... +} + +/** helper to Auto-destruct **/ +void FTNoIR_Protocol::Release() +{ + delete this; +} + +void FTNoIR_Protocol::Initialize() +{ + return; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Protocol::loadSettings() { +// None yet... +} + +// +// Update Headpose in Game. +// +void FTNoIR_Protocol::sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ) { +PDWORD_PTR MsgResult = 0; + + + virtSCRotX = -1.0f * headpose->pitch; // degrees + virtSCRotY = -1.0f * headpose->yaw; + virtSCRotZ = headpose->roll; + + virtSCPosX = headpose->x/100.f; // cm to meters + virtSCPosY = headpose->y/100.f; + virtSCPosZ = -1.0f * headpose->z/100.f; + + // + // It's only useful to send data, if the connection was made. + // + if (!blnSimConnectActive) { + if (SUCCEEDED(simconnect_open(&hSimConnect, "FaceTrackNoIR", NULL, 0, 0, 0))) { + qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: SimConnect active!"; + + //set up the events we want to listen for + HRESULT hr; + + simconnect_subscribetosystemevent(hSimConnect, EVENT_PING, "Frame"); + + hr = simconnect_mapclienteventtosimevent(hSimConnect, EVENT_INIT, ""); + hr = simconnect_addclienteventtonotificationgroup(hSimConnect, GROUP0, EVENT_INIT, false); + hr = simconnect_setnotificationgrouppriority(hSimConnect, GROUP0, SIMCONNECT_GROUP_PRIORITY_HIGHEST); + ////hr = SimConnect_MapInputEventToClientEvent(hSimConnect, INPUT0, "VK_COMMA", EVENT_INIT); + ////hr = SimConnect_SetInputGroupState(hSimConnect, INPUT0, SIMCONNECT_STATE_ON); + + blnSimConnectActive = true; + if (hMainWindow != NULL) { + SendMessageTimeout( (HWND) hMainWindow, RegisterWindowMessageA(FT_PROGRAMID), 0, 0, 0, 2000, MsgResult); + } + } + } + else { + // + // Write the 6DOF-data to FSX +// // +// // Only do this when the data has changed. This way, the HAT-switch can be used when tracking is OFF. +// // +// if ((prevPosX != virtPosX) || (prevPosY != virtPosY) || (prevPosZ != virtPosZ) || +// (prevRotX != virtRotX) || (prevRotY != virtRotY) || (prevRotZ != virtRotZ)) { +//// if (S_OK == simconnect_set6DOF(hSimConnect, virtPosX, virtPosY, virtPosZ, virtRotX, virtRotZ, virtRotY)) { +//// qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; +//// } +// } +// +// prevPosX = virtPosX; +// prevPosY = virtPosY; +// prevPosZ = virtPosZ; +// prevRotX = virtRotX; +// prevRotY = virtRotY; +// prevRotZ = virtRotZ; + + if SUCCEEDED(simconnect_calldispatch(hSimConnect, processNextSimconnectEvent, NULL)) { + qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Dispatching"; + } + else { + qDebug() << "FTNoIR_Protocol::sendHeadposeToGame() says: Error Dispatching!"; + } + } +} + +// +// Returns 'true' if all seems OK. +// +bool FTNoIR_Protocol::checkServerInstallationOK( HANDLE handle ) +{ + QString aFileName; // File Path and Name + + // Code to activate the context for the SimConnect DLL + ACTCTX act = { 0 }; + HANDLE hctx; + ULONG_PTR ulCookie; + + hMainWindow = handle; + + qDebug() << "SCCheckClientDLL says: Starting Function"; + + try { + + act.cbSize = sizeof(act); + act.dwFlags = ACTCTX_FLAG_RESOURCE_NAME_VALID; + + QString manifest(QCoreApplication::applicationDirPath()); +// manifest += "\\FaceTrackNoIR.exe"; + manifest += "\\FTNoIR_Protocol_SC.dll"; + const wchar_t * encodedName = reinterpret_cast(manifest.utf16()); + + act.lpSource = encodedName; + act.lpResourceName = MAKEINTRESOURCE(101); + + hctx = CreateActCtx (&act); + + if (hctx != INVALID_HANDLE_VALUE) { + if (!ActivateActCtx(hctx, &ulCookie)) { + ReleaseActCtx(hctx); + qDebug() << "SCCheckClientDLL says: Error activating SimConnect manifest"; + } + } + else { + qDebug() << "SCCheckClientDLL says: Error INVALID_HANDLE: " << GetLastError(); + return false; + } + + // + // Just try to load the DLL. Let Windows handle the PATH's and such trivialities... + // + aFileName = SC_CLIENT_FILENAME; + + // + // Load the DLL. + // + SCClientLib.setFileName(aFileName); + if (SCClientLib.load() != true) { + qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL"; + return false; + } + + // + // Deactivate the context again: the function-references should stay in-tact... + // + DeactivateActCtx(0, ulCookie); + ReleaseActCtx(hctx); + + } catch(...) { + qDebug() << "SCCheckClientDLL says: Error loading SimConnect DLL"; + return false; + } + + // + // Get the functions from the DLL. + // + simconnect_open = (importSimConnect_Open) SCClientLib.resolve("SimConnect_Open"); + if (simconnect_open == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Open function not found in DLL!"; + return false; + } + simconnect_set6DOF = (importSimConnect_CameraSetRelative6DOF) SCClientLib.resolve("SimConnect_CameraSetRelative6DOF"); + if (simconnect_set6DOF == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CameraSetRelative6DOF function not found in DLL!"; + return false; + } + simconnect_close = (importSimConnect_Close) SCClientLib.resolve("SimConnect_Close"); + if (simconnect_close == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_Close function not found in DLL!"; + return false; + } + + //return true; + + simconnect_calldispatch = (importSimConnect_CallDispatch) SCClientLib.resolve("SimConnect_CallDispatch"); + if (simconnect_calldispatch == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_CallDispatch function not found in DLL!"; + return false; + } + + simconnect_subscribetosystemevent = (importSimConnect_SubscribeToSystemEvent) SCClientLib.resolve("SimConnect_SubscribeToSystemEvent"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SubscribeToSystemEvent function not found in DLL!"; + return false; + } + + simconnect_mapclienteventtosimevent = (importSimConnect_MapClientEventToSimEvent) SCClientLib.resolve("SimConnect_MapClientEventToSimEvent"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_MapClientEventToSimEvent function not found in DLL!"; + return false; + } + + simconnect_addclienteventtonotificationgroup = (importSimConnect_AddClientEventToNotificationGroup) SCClientLib.resolve("SimConnect_AddClientEventToNotificationGroup"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_AddClientEventToNotificationGroup function not found in DLL!"; + return false; + } + + simconnect_setnotificationgrouppriority = (importSimConnect_SetNotificationGroupPriority) SCClientLib.resolve("SimConnect_SetNotificationGroupPriority"); + if (simconnect_subscribetosystemevent == NULL) { + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect_SetNotificationGroupPriority function not found in DLL!"; + return false; + } + + qDebug() << "FTNoIR_Protocol::checkServerInstallationOK() says: SimConnect functions resolved in DLL!"; + + return true; +} + +void CALLBACK FTNoIR_Protocol::processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext) +{ +// HRESULT hr; + + switch(pData->dwID) + { + case SIMCONNECT_RECV_ID_EVENT: + { + SIMCONNECT_RECV_EVENT *evt = (SIMCONNECT_RECV_EVENT*)pData; + + qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: SimConnect active!"; + //switch(evt->uEventID) + //{ + // //case EVENT_CAMERA_RIGHT: + + // // cameraBank = normalize180( cameraBank + 5.0f); + + // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, + // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); + + // // printf("\nCamera Bank = %f", cameraBank); + // // break; + + // //case EVENT_CAMERA_LEFT: + // // + // // cameraBank = normalize180( cameraBank - 5.0f); + + // // hr = SimConnect_CameraSetRelative6DOF(hSimConnect, 0.0f, 0.0f, 0.0f, + // // SIMCONNECT_CAMERA_IGNORE_FIELD,SIMCONNECT_CAMERA_IGNORE_FIELD, cameraBank); + // // + // // printf("\nCamera Bank = %f", cameraBank); + // // break; + + // //default: + // // break; + //} + //break; + } + case SIMCONNECT_RECV_ID_EVENT_FRAME: + { +// qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Frame event!"; + if ((prevSCPosX != virtSCPosX) || (prevSCPosY != virtSCPosY) || (prevSCPosZ != virtSCPosZ) || + (prevSCRotX != virtSCRotX) || (prevSCRotY != virtSCRotY) || (prevSCRotZ != virtSCRotZ)) { + if (S_OK == simconnect_set6DOF(hSimConnect, virtSCPosX, virtSCPosY, virtSCPosZ, virtSCRotX, virtSCRotZ, virtSCRotY)) { + // qDebug() << "FTNoIR_Protocol::run() says: SimConnect data written!"; + } + } + prevSCPosX = virtSCPosX; + prevSCPosY = virtSCPosY; + prevSCPosZ = virtSCPosZ; + prevSCRotX = virtSCRotX; + prevSCRotY = virtSCRotY; + prevSCRotZ = virtSCRotZ; + } + + case SIMCONNECT_RECV_ID_EXCEPTION: + { + SIMCONNECT_RECV_EXCEPTION *except = (SIMCONNECT_RECV_EXCEPTION*)pData; + + switch (except->dwException) + { + case SIMCONNECT_EXCEPTION_ERROR: + printf("\nCamera error"); + break; + + default: + printf("\nException"); + break; + } + break; + } + + case SIMCONNECT_RECV_ID_QUIT: + { + qDebug() << "FTNoIR_Protocol::processNextSimconnectEvent() says: Quit event!"; +// quit = 1; + break; + } + + default: + break; + } +} + +// +// Return a name, if present the name from the Game, that is connected... +// +void FTNoIR_Protocol::getNameFromGame( char *dest ) +{ + sprintf_s(dest, 99, "Microsoft FSX"); + return; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocol - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocol@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocol=_GetProtocol@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolPtr __stdcall GetProtocol() +{ + return new FTNoIR_Protocol; +} diff --git a/ftnoir_protocol_sc/FTNoIR_Protocol_SC.h b/ftnoir_protocol_sc/FTNoIR_Protocol_SC.h new file mode 100644 index 00000000..42eca457 --- /dev/null +++ b/ftnoir_protocol_sc/FTNoIR_Protocol_SC.h @@ -0,0 +1,183 @@ +/******************************************************************************** +* 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) 2010-2011 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +* SCServer SCServer is the Class, that communicates headpose-data * +* to games, using the SimConnect.dll. * +* SimConnect.dll is a so called 'side-by-side' assembly, so it * +* must be treated as such... * +********************************************************************************/ +#pragma once +#ifndef INCLUDED_SCSERVER_H +#define INCLUDED_SCSERVER_H + +// +// Prevent the SimConnect manifest from being merged in the application-manifest +// 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" + +#include "..\ftnoir_protocol_base\ftnoir_protocol_base.h" +#include "ui_FTNoIR_SCcontrols.h" +#include +#include +#include +#include +#include +#include +//#include "math.h" + +typedef HRESULT (WINAPI *importSimConnect_Open)(HANDLE * phSimConnect, LPCSTR szName, HWND hWnd, DWORD UserEventWin32, HANDLE hEventHandle, DWORD ConfigIndex); +typedef HRESULT (WINAPI *importSimConnect_Close)(HANDLE hSimConnect); +typedef HRESULT (WINAPI *importSimConnect_CameraSetRelative6DOF)(HANDLE hSimConnect, float fDeltaX, float fDeltaY, float fDeltaZ, float fPitchDeg, float fBankDeg, float fHeadingDeg); +typedef HRESULT (WINAPI *importSimConnect_CallDispatch)(HANDLE hSimConnect, DispatchProc pfcnDispatch, void * pContext); +typedef HRESULT (WINAPI *importSimConnect_SubscribeToSystemEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * SystemEventName); +typedef HRESULT (WINAPI *importSimConnect_MapClientEventToSimEvent)(HANDLE hSimConnect, SIMCONNECT_CLIENT_EVENT_ID EventID, const char * EventName); +typedef HRESULT (WINAPI *importSimConnect_AddClientEventToNotificationGroup)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, SIMCONNECT_CLIENT_EVENT_ID EventID, BOOL bMaskable); +typedef HRESULT (WINAPI *importSimConnect_SetNotificationGroupPriority)(HANDLE hSimConnect, SIMCONNECT_NOTIFICATION_GROUP_ID GroupID, DWORD uPriority); + +static const char* SC_CLIENT_FILENAME = "SimConnect.dll"; +static const char* FT_PROGRAMID = "FT_ProgramID"; // For message to FaceTrackNoIR main-window. + +enum GROUP_ID +{ + GROUP0=0, +}; + +enum EVENT_ID +{ + EVENT_PING=0, + EVENT_INIT, +}; + +enum INPUT_ID +{ + INPUT0=0, +}; + +class FTNoIR_Protocol : public IProtocol +{ +public: + FTNoIR_Protocol(); + ~FTNoIR_Protocol(); + + void Release(); + void Initialize(); + + bool checkServerInstallationOK( HANDLE handle ); + void sendHeadposeToGame( THeadPoseData *headpose, THeadPoseData *rawheadpose ); + void getNameFromGame( char *dest ); // Take care dest can handle up to 100 chars... + +private: + // Private properties + QString ProgramName; + QLibrary SCClientLib; + + static float virtSCPosX; + static float virtSCPosY; + static float virtSCPosZ; + + static float virtSCRotX; + static float virtSCRotY; + static float virtSCRotZ; + + static float prevSCPosX; + static float prevSCPosY; + static float prevSCPosZ; + + static float prevSCRotX; + static float prevSCRotY; + static float prevSCRotZ; + + bool blnSimConnectActive; + HANDLE hMainWindow; // Save the handle to FaceTrackNoIR main-window + + importSimConnect_Open simconnect_open; // SimConnect function(s) in DLL + importSimConnect_Close simconnect_close; + static importSimConnect_CameraSetRelative6DOF simconnect_set6DOF; + importSimConnect_CallDispatch simconnect_calldispatch; + importSimConnect_SubscribeToSystemEvent simconnect_subscribetosystemevent; + importSimConnect_MapClientEventToSimEvent simconnect_mapclienteventtosimevent; + importSimConnect_AddClientEventToNotificationGroup simconnect_addclienteventtonotificationgroup; + importSimConnect_SetNotificationGroupPriority simconnect_setnotificationgrouppriority; + + static HANDLE hSimConnect; // Handle to SimConnect + static void CALLBACK processNextSimconnectEvent(SIMCONNECT_RECV* pData, DWORD cbData, void *pContext); + void loadSettings(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class SCControls: public QWidget, Ui::UICSCControls, public IProtocolDialog +{ + Q_OBJECT +public: + + explicit SCControls(); + virtual ~SCControls(); + void showEvent ( QShowEvent * event ); + + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerProtocol(IProtocol *protocol) { + theProtocol = (FTNoIR_Protocol *) protocol; // Accept the pointer to the Protocol + }; + void unRegisterProtocol() { + theProtocol = NULL; // Reset the pointer + }; + +private: + Ui::UICSCControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + FTNoIR_Protocol *theProtocol; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Protocol DLL. Functions used to get general info on the Protocol +//******************************************************************************************************* +class FTNoIR_ProtocolDll : public IProtocolDll +{ +public: + FTNoIR_ProtocolDll(); + ~FTNoIR_ProtocolDll(); + + void getFullName(QString *strToBeFilled) { *strToBeFilled = QString("FSX SimConnect"); }; + void getShortName(QString *strToBeFilled) { *strToBeFilled = QString("SimConnect"); }; + void getDescription(QString *strToBeFilled) { *strToBeFilled = QString("Microsoft SimConnect protocol"); }; + + void getIcon(QIcon *icon) { *icon = QIcon(":/images/FSX.ico"); }; +}; + +#endif//INCLUDED_SCSERVER_H +//END diff --git a/ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc8.vcproj b/ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc8.vcproj new file mode 100644 index 00000000..0f3cfdb3 --- /dev/null +++ b/ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc8.vcproj @@ -0,0 +1,377 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc9.vcproj b/ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc9.vcproj new file mode 100644 index 00000000..cd779d2b --- /dev/null +++ b/ftnoir_protocol_sc/FTNoIR_Protocol_SC_vc9.vcproj @@ -0,0 +1,382 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_protocol_sc/FTNoIR_SCcontrols.ui b/ftnoir_protocol_sc/FTNoIR_SCcontrols.ui new file mode 100644 index 00000000..3e7a5062 --- /dev/null +++ b/ftnoir_protocol_sc/FTNoIR_SCcontrols.ui @@ -0,0 +1,162 @@ + + + UICSCControls + + + + 0 + 0 + 346 + 104 + + + + SimConnect settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 0 + 0 + + + + There are no setting necessary for SimConnect + + + Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter + + + false + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_protocol_sc/Protocol.qrc b/ftnoir_protocol_sc/Protocol.qrc new file mode 100644 index 00000000..de6018af --- /dev/null +++ b/ftnoir_protocol_sc/Protocol.qrc @@ -0,0 +1,5 @@ + + + images/FSX.ico + + diff --git a/ftnoir_protocol_sc/SCServer.manifest b/ftnoir_protocol_sc/SCServer.manifest new file mode 100644 index 00000000..19b123ba --- /dev/null +++ b/ftnoir_protocol_sc/SCServer.manifest @@ -0,0 +1,13 @@ + + + + + + + + + + + + + diff --git a/ftnoir_protocol_sc/SimConnect.aps b/ftnoir_protocol_sc/SimConnect.aps new file mode 100644 index 00000000..89c5a65a Binary files /dev/null and b/ftnoir_protocol_sc/SimConnect.aps differ diff --git a/ftnoir_protocol_sc/ftnoir_protocol_SC_dialog.cpp b/ftnoir_protocol_sc/ftnoir_protocol_SC_dialog.cpp new file mode 100644 index 00000000..9047fa61 --- /dev/null +++ b/ftnoir_protocol_sc/ftnoir_protocol_SC_dialog.cpp @@ -0,0 +1,157 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_SC.h" +#include + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +SCControls::SCControls() : +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.cbxSelectPPJoyNumber, SIGNAL(currentIndexChanged(int)), this, SLOT(virtualJoystickSelected( int ))); + + theProtocol = NULL; + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +SCControls::~SCControls() { + qDebug() << "~SCControls() says: started"; +} + +void SCControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void SCControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void SCControls::doOK() { + save(); + this->close(); +} + +// override show event +void SCControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// Cancel clicked on server-dialog +// +void SCControls::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 SCControls::loadSettings() { + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void SCControls::save() { + + settingsDirty = false; +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol-settings dialog object. + +// Export both decorated and undecorated names. +// GetProtocolDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDialog=_GetProtocolDialog@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDialogPtr __stdcall GetProtocolDialog( ) +{ + return new SCControls; +} diff --git a/ftnoir_protocol_sc/ftnoir_protocol_SC_dll.cpp b/ftnoir_protocol_sc/ftnoir_protocol_SC_dll.cpp new file mode 100644 index 00000000..f67f95db --- /dev/null +++ b/ftnoir_protocol_sc/ftnoir_protocol_SC_dll.cpp @@ -0,0 +1,56 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The ProtocolDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_protocol_SC.h" +#include + +FTNoIR_ProtocolDll::FTNoIR_ProtocolDll() { +} + +FTNoIR_ProtocolDll::~FTNoIR_ProtocolDll() +{ + +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Protocol object. + +// Export both decorated and undecorated names. +// GetProtocolDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetProtocolDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetProtocolDll=_GetProtocolDll@0") + +FTNOIR_PROTOCOL_BASE_EXPORT IProtocolDllPtr __stdcall GetProtocolDll() +{ + return new FTNoIR_ProtocolDll; +} diff --git a/ftnoir_protocol_sc/images/FSX.ico b/ftnoir_protocol_sc/images/FSX.ico new file mode 100644 index 00000000..1c71d409 Binary files /dev/null and b/ftnoir_protocol_sc/images/FSX.ico differ diff --git a/ftnoir_tracker_base/ftnoir_tracker_base.h b/ftnoir_tracker_base/ftnoir_tracker_base.h new file mode 100644 index 00000000..396df4d1 --- /dev/null +++ b/ftnoir_tracker_base/ftnoir_tracker_base.h @@ -0,0 +1,128 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* This class implements a tracker-base * +*********************************************************************************/ +/* + Modifications (last one on top): + 20122109 - C14: Replaced Release with virtual destructor + 20120009 - WVR: Removed AutoClosePtr (seemed like it didn't work OK) + 20110415 - WVR: Added overloaded operator - and -= +*/ +#ifndef FTNOIR_TRACKER_BASE_H +#define FTNOIR_TRACKER_BASE_H + +#include "ftnoir_tracker_base_global.h" +#include "ftnoir_tracker_types.h" +#include +#include + +//////////////////////////////////////////////////////////////////////////////// +#ifdef __cplusplus +# define EXTERN_C extern "C" +#else +# define EXTERN_C +#endif // __cplusplus + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct ITracker +{ + virtual ~ITracker() {} + virtual void Initialize( QFrame *videoframe ) = 0; + virtual void StartTracker( HWND parent_window ) = 0; + virtual void StopTracker(bool exit) = 0; + virtual bool GiveHeadPoseData(THeadPoseData *data) = 0; + + virtual bool notifyZeroed() { + return false; + } + virtual void refreshVideo() {} + virtual void notifyCenter() { + return; + } +}; + +typedef ITracker* ITrackerPtr; + +// Factory function that creates instances of the Tracker object. +EXTERN_C +FTNOIR_TRACKER_BASE_EXPORT +ITrackerPtr +__stdcall +GetTracker(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct ITrackerDialog +{ + virtual ~ITrackerDialog() {} + virtual void Initialize(QWidget *parent) = 0; + virtual void registerTracker(ITracker *tracker) = 0; + virtual void unRegisterTracker() = 0; +}; + +typedef ITrackerDialog* ITrackerDialogPtr; + +// Factory function that creates instances of the Tracker object. +EXTERN_C +FTNOIR_TRACKER_BASE_EXPORT +ITrackerDialogPtr +__stdcall +GetTrackerDialog(void); + +//////////////////////////////////////////////////////////////////////////////// +// COM-Like abstract interface. +// This interface doesn't require __declspec(dllexport/dllimport) specifier. +// Method calls are dispatched via virtual table. +// Any C++ compiler can use it. +// Instances are obtained via factory function. +struct ITrackerDll +{ + virtual ~ITrackerDll() {} + virtual void Initialize() = 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; +}; + +typedef ITrackerDll* ITrackerDllPtr; + +// Factory function that creates instances of the Tracker object. +EXTERN_C +FTNOIR_TRACKER_BASE_EXPORT +ITrackerDllPtr +__stdcall +GetTrackerDll(void); + + +#endif // FTNOIR_TRACKER_BASE_H diff --git a/ftnoir_tracker_base/ftnoir_tracker_base_global.h b/ftnoir_tracker_base/ftnoir_tracker_base_global.h new file mode 100644 index 00000000..9f4a6118 --- /dev/null +++ b/ftnoir_tracker_base/ftnoir_tracker_base_global.h @@ -0,0 +1,12 @@ +#ifndef FTNOIR_TRACKER_BASE_GLOBAL_H +#define FTNOIR_TRACKER_BASE_GLOBAL_H + +#include + +#ifdef FTNOIR_TRACKER_BASE_LIB +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_EXPORT +#else +# define FTNOIR_TRACKER_BASE_EXPORT Q_DECL_IMPORT +#endif + +#endif // FTNOIR_TRACKER_BASE_GLOBAL_H diff --git a/ftnoir_tracker_base/ftnoir_tracker_ma_types.h b/ftnoir_tracker_base/ftnoir_tracker_ma_types.h new file mode 100644 index 00000000..bc663056 --- /dev/null +++ b/ftnoir_tracker_base/ftnoir_tracker_ma_types.h @@ -0,0 +1,33 @@ +// +// Definitions for the Shared Memory to send the data to FaceTrackNoIR +// +static const char* MA_MM_DATA = "MA_SharedMem"; +static const char* MA_FACEAPI = "MA_FaceAPI"; +static const char* MA_MUTEX = "MA_Mutex"; + +struct TFaceData { + int DataID; +// smEngineHeadPoseData new_pose; +}; +typedef TFaceData * PFaceData; + +struct SMMemMap { + int command; // Command from FaceTrackNoIR + int status; // Status from faceAPI + TFaceData data; + HANDLE handle; + int state; + int par_val_int; // Value of parameter, indicated by 'command' + int par_val_float; + int initial_filter_level; // Internal faceAPI Filter level + int handshake; +}; +typedef SMMemMap * PSMMemMap; + +enum FTNoIR_Tracker_Command { + FT_MA_START = 10, + FT_MA_STOP = 20, + FT_MA_SHOW_CAM = 30, + FT_MA_SET_PAR_FILTER = 50, + FT_MA_EXIT = 100 +}; diff --git a/ftnoir_tracker_base/ftnoir_tracker_sm_types.h b/ftnoir_tracker_base/ftnoir_tracker_sm_types.h new file mode 100644 index 00000000..a8802e4a --- /dev/null +++ b/ftnoir_tracker_base/ftnoir_tracker_sm_types.h @@ -0,0 +1,35 @@ +// +// Definitions for the Shared Memory to send the data to FaceTrackNoIR +// +static const char* SM_MM_DATA = "SM_SharedMem"; +static const char* SM_FACEAPI = "SM_FaceAPI"; +static const char* SM_MUTEX = "SM_Mutex"; + +#include + +struct TFaceData { + int DataID; + smEngineHeadPoseData new_pose; +}; +typedef TFaceData * PFaceData; + +struct SMMemMap { + int command; // Command from FaceTrackNoIR + int status; // Status from faceAPI + TFaceData data; + HANDLE handle; + int state; + int par_val_int; // Value of parameter, indicated by 'command' + int par_val_float; + int initial_filter_level; // Internal faceAPI Filter level + int handshake; +}; +typedef SMMemMap * PSMMemMap; + +enum FTNoIR_Tracker_Command { + FT_SM_START = 10, + FT_SM_STOP = 20, + FT_SM_SHOW_CAM = 30, + FT_SM_SET_PAR_FILTER = 50, + FT_SM_EXIT = 100 +}; diff --git a/ftnoir_tracker_base/ftnoir_tracker_types.h b/ftnoir_tracker_base/ftnoir_tracker_types.h new file mode 100644 index 00000000..ace7a6e3 --- /dev/null +++ b/ftnoir_tracker_base/ftnoir_tracker_types.h @@ -0,0 +1,51 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of the some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2010 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* This class implements a tracker-base * +*********************************************************************************/ +/* + Modifications (last one on top): + 20120924 - C14: Moved T6DOF to separate file (not pulic interface) + 20110415 - WVR: Added overloaded operator - and -= +*/ +#ifndef FTNOIR_TRACKER_TYPES_H +#define FTNOIR_TRACKER_TYPES_H + +// +// x,y,z position in centimetres, yaw, pitch and roll in degrees... +// +#pragma pack(push, 2) +struct THeadPoseData { + + THeadPoseData() + : x(0.0), y(0.0), z(0.0), yaw(0.0), pitch(0.0), roll(0.0), frame_number(0) {} + + THeadPoseData(double x, double y, double z, + double yaw, double pitch, double roll ) + : x(x), y(y), z(z), yaw(yaw), pitch(pitch), roll(roll), frame_number(0) {} + + double x, y, z, yaw, pitch, roll; + long frame_number; +}; +#pragma pack(pop) + +#endif // FTNOIR_TRACKER_TYPES_H 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..02e95bb4 --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_Tracker_FD.h @@ -0,0 +1,114 @@ +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "face-detect.h" +#include "ui_FTNoIR_FD_controls.h" + +#include +#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 Initialize( QFrame *videoframe ); + void StartTracker( HWND parent_window ); + void StopTracker( bool exit ); + bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good + + void loadSettings(); +// bool setParameterValue(const int index, const float newvalue); + bool notifyZeroed(); + void refreshVideo(); + +private: + bool activep; + //QList> parameterRange; + //QList parameterValueAsFloat; + void TerminateTracker(); + HANDLE hMutex, hMapFile; + struct face_detect_shm* shm; + PROCESS_INFORMATION procInfo; + VideoWidget* ctrl; + QFrame* qframe; +}; + +class TrackerControls: public QWidget, Ui::UICFDClientControls, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + virtual ~TrackerControls(); + void Release(); // Member functions which are accessible from outside the DLL + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) {}; + void unRegisterTracker() {}; + void NotifyZeroing(); + +private: + Ui::UICFDClientControls ui; + void loadSettings(); + void save(); + + bool settingsDirty; + HANDLE hMapFile, hMutex; + struct face_detect_shm* shm; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void doSetRedetectMs(int val); + void doSetCameraId(int val); + void doSetVideoWidget(bool val); +signals: +}; + +//******************************************************************************************************* +// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker +//******************************************************************************************************* +class FTNoIR_TrackerDll : public ITrackerDll +{ +public: + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + + void Initialize(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; +}; diff --git a/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj new file mode 100644 index 00000000..74fa6fec --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc8.vcproj @@ -0,0 +1,379 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj new file mode 100644 index 00000000..a37729e1 --- /dev/null +++ b/ftnoir_tracker_fd/FTNoIR_Tracker_FD_vc9.vcproj @@ -0,0 +1,376 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 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..620fb9fd --- /dev/null +++ b/ftnoir_tracker_fd/ftnoir_tracker_facedetect.cpp @@ -0,0 +1,214 @@ +/* Copyright (c) 2012 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_fd.h" +#include +#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"); + + hMutex = CreateMutex(NULL, false, fd_mutex_name); + hMapFile = CreateFileMapping(INVALID_HANDLE_VALUE, NULL, PAGE_READWRITE, 0, sizeof(struct face_detect_shm), fd_shm_name); + shm = (struct face_detect_shm*) MapViewOfFile(hMapFile, FILE_MAP_READ | FILE_MAP_WRITE, 0, 0, sizeof(struct face_detect_shm)); + memset(shm, 0, sizeof(struct face_detect_shm)); + activep = 0; + procInfo.hProcess = INVALID_HANDLE_VALUE; + ctrl = NULL; + qframe = NULL; +} + +void FTNoIR_Tracker::TerminateTracker() { + if (procInfo.hProcess != INVALID_HANDLE_VALUE) { + shm->settings.quit = 1; + //TerminateProcess(procInfo.hProcess, 42); + CloseHandle(procInfo.hProcess); + CloseHandle(procInfo.hThread); + procInfo.hProcess = INVALID_HANDLE_VALUE; + } +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ + WaitForSingleObject(hMutex, INFINITE); + TerminateTracker(); + UnmapViewOfFile(shm); + //CloseHandle(hMapFile); + ReleaseMutex(hMutex); + //CloseHandle(hMutex); +} + +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) +{ + qDebug("FTNoIR_Tracker::Initialize()"); + WaitForSingleObject(hMutex, INFINITE); + videoframe->setAttribute(Qt::WA_NativeWindow); + videoframe->show(); + ctrl = new VideoWidget(hMutex, shm->pixels, shm); + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(ctrl); + videoframe->setLayout(layout); + ctrl->resize(FD_VIDEO_WIDTH, FD_VIDEO_HEIGHT); + qframe = videoframe; + loadSettings(); + ReleaseMutex(hMutex); +} + +void FTNoIR_Tracker::refreshVideo() { + QWidget* w; + WaitForSingleObject(hMutex, INFINITE); + w = ctrl; + ReleaseMutex(hMutex); + if (w != NULL) + w->update(); +} + +void FTNoIR_Tracker::StartTracker( HWND parent_window ) +{ + WaitForSingleObject(hMutex, INFINITE); + qDebug("* tracker starting"); + activep = true; + ReleaseMutex(hMutex); +} + +void FTNoIR_Tracker::StopTracker( bool exit ) +{ + WaitForSingleObject(hMutex, INFINITE); + qDebug("* tracker stopping"); + activep = false; + if (exit) { + TerminateTracker(); + if (qframe && qframe->layout()) { + delete qframe->layout(); + qframe = NULL; + } + if (ctrl) { + delete ctrl; + ctrl = NULL; + } + } + ReleaseMutex(hMutex); +} + +bool FTNoIR_Tracker::notifyZeroed() { + qDebug("notifying of zero"); + WaitForSingleObject(hMutex, INFINITE); + shm->zerop = 1; + ReleaseMutex(hMutex); + return true; +} + +bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) +{ + WaitForSingleObject(hMutex, INFINITE); + if (procInfo.hProcess == INVALID_HANDLE_VALUE) { + STARTUPINFO si; + SECURITY_ATTRIBUTES sa; + sa.bInheritHandle = 1; + sa.lpSecurityDescriptor = NULL; + sa.nLength = sizeof(SECURITY_ATTRIBUTES); + memset(&si, 0, sizeof(STARTUPINFO)); + si.dwFlags = STARTF_USESHOWWINDOW | STARTF_USESTDHANDLES; + si.cb = sizeof(STARTUPINFO); + si.hStdOutput = NULL; + si.hStdError = NULL; + si.hStdInput = NULL; + if (!CreateProcess(prog_cmdline, NULL, NULL, NULL, true, 0, NULL, NULL, &si, &procInfo)) { + qDebug("Badness! %d", GetLastError()); + } + } + + shm->received = 1; + + if (activep) { + shm->settings.newOutput = 0; + data->x = shm->data[3]; + data->y = shm->data[4]; + data->z = shm->data[5]; + data->yaw = shm->data[0]; + data->pitch = shm->data[1]; + data->roll = shm->data[2]; + ReleaseMutex(hMutex); + return true; + } + ReleaseMutex(hMutex); + return false; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker::loadSettings() { + load_settings(&shm->settings); +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTracker - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTracker@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +{ + return new FTNoIR_Tracker; +} diff --git a/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp new file mode 100644 index 00000000..71b19242 --- /dev/null +++ b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dialog.cpp @@ -0,0 +1,180 @@ +/* Copyright (c) 2012 Stanislaw Halik + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + */ + +#include "ftnoir_tracker_fd.h" +#include +#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))); +} + +void TrackerControls::save() { + save_settings(&shm->settings); + settingsDirty = false; +} + +void TrackerControls::doSetCameraId(int val) { + settingsDirty = true; + WaitForSingleObject(hMutex, INFINITE); + shm->settings.camera_id = val; + ReleaseMutex(hMutex); +} + +void TrackerControls::doSetVideoWidget(bool val) { + settingsDirty = true; + WaitForSingleObject(hMutex, INFINITE); + shm->settings.widgetp = val; + ReleaseMutex(hMutex); +} + +void TrackerControls::doSetRedetectMs(int val) { + settingsDirty = true; + WaitForSingleObject(hMutex, INFINITE); + shm->settings.redetect_ms = val; + ReleaseMutex(hMutex); +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { + UnmapViewOfFile(shm); + //CloseHandle(hMutex); + //CloseHandle(hMapFile); +} + +void TrackerControls::Release() +{ + delete this; +} + +// +// Initialize tracker-client-dialog +// +void TrackerControls::Initialize(QWidget *parent) { + + QPoint offsetpos(200, 200); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void TrackerControls::doOK() { + save(); + this->close(); +} + +// +// Cancel clicked on server-dialog +// +void TrackerControls::doCancel() { + // + // Ask if changed Settings should be saved + // + if (settingsDirty) { + int ret = QMessageBox::question ( this, "Settings have changed", "Do you want to save the settings?", QMessageBox::Save | QMessageBox::Discard | QMessageBox::Cancel, QMessageBox::Discard ); + + switch (ret) { + case QMessageBox::Save: + save(); + this->close(); + break; + case QMessageBox::Discard: + this->close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + this->close(); + } +} + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker-settings dialog object. + +// Export both decorated and undecorated names. +// GetTrackerDialog - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDialog@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) +{ + return new TrackerControls; +} diff --git a/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp new file mode 100644 index 00000000..8e010e3e --- /dev/null +++ b/ftnoir_tracker_fd/ftnoir_tracker_facedetect_dll.cpp @@ -0,0 +1,85 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The TrackerDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_tracker_fd.h" +#include + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "faceDetect V1.0.0"; + trackerShortName = "faceDetect"; + trackerDescription = "Stans' faceDetect V1.0.0"; +} + +FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +{ + +} + +void FTNoIR_TrackerDll::Initialize() +{ + return; +} + +void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + +void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + +void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +void FTNoIR_TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/FaceDetect.ico"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +{ + return new FTNoIR_TrackerDll; +} diff --git a/ftnoir_tracker_fd/images/FaceDetect.ico b/ftnoir_tracker_fd/images/FaceDetect.ico 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_ht/FTNoIR_Tracker_HT_vc8.vcproj b/ftnoir_tracker_ht/FTNoIR_Tracker_HT_vc8.vcproj new file mode 100644 index 00000000..bf9b23c2 --- /dev/null +++ b/ftnoir_tracker_ht/FTNoIR_Tracker_HT_vc8.vcproj @@ -0,0 +1,398 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_ht/Tracker.qrc b/ftnoir_tracker_ht/Tracker.qrc new file mode 100644 index 00000000..9627f700 --- /dev/null +++ b/ftnoir_tracker_ht/Tracker.qrc @@ -0,0 +1,5 @@ + + + images/HT.ico + + diff --git a/ftnoir_tracker_ht/TrackerControls.ui b/ftnoir_tracker_ht/TrackerControls.ui new file mode 100644 index 00000000..0a1bc3ae --- /dev/null +++ b/ftnoir_tracker_ht/TrackerControls.ui @@ -0,0 +1,295 @@ + + + Form + + + Qt::NonModal + + + + 0 + 0 + 500 + 160 + + + + + 0 + 0 + + + + + 500 + 160 + + + + HT tracker settings + + + + + 10 + 10 + 141 + 16 + + + + Horizontal field of view + + + + + + 130 + 10 + 251 + 22 + + + + + + + 35.000000000000000 + + + 180.000000000000000 + + + 69.000000000000000 + + + + + + 10 + 40 + 101 + 16 + + + + Frames per second + + + + + + 130 + 40 + 251 + 22 + + + + + Default + + + + + 30 + + + + + 60 + + + + + 120 + + + + + + + 10 + 70 + 71 + 16 + + + + Camera name + + + + + + 340 + 130 + 75 + 23 + + + + OK + + + + + + 420 + 130 + 75 + 23 + + + + Cancel + + + + + + 390 + 10 + 101 + 81 + + + + Enable axes + + + + + 10 + 20 + 70 + 17 + + + + RX + + + + + + 10 + 40 + 70 + 17 + + + + RY + + + + + + 10 + 60 + 70 + 17 + + + + RZ + + + + + + 60 + 20 + 70 + 17 + + + + TX + + + + + + 60 + 40 + 70 + 17 + + + + TY + + + + + + 60 + 60 + 70 + 17 + + + + TZ + + + + + + + 130 + 70 + 251 + 22 + + + + + + + 10 + 100 + 61 + 16 + + + + Resolution + + + + + + 130 + 100 + 251 + 22 + + + + + 640x480 + + + + + 320x240 + + + + + 320x200 + + + + + Default (not recommended!) + + + + + + + diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp new file mode 100644 index 00000000..336ede2d --- /dev/null +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.cpp @@ -0,0 +1,422 @@ +#include "stdafx.h" +#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "headtracker-ftnoir.h" +#include "ftnoir_tracker_ht.h" +#include "ftnoir_tracker_ht_dll.h" +#include "ui_trackercontrols.h" +#include "../facetracknoir/global-settings.h" + +#define WIDGET_WIDTH 250 +#define WIDGET_HEIGHT 188 + +#if defined(_WIN32) || defined(__WIN32) +#include +#else +#include +#endif + +// delicious copypasta +static QList get_camera_names(void) { + QList ret; +#if defined(_WIN32) || defined(__WIN32) + // Create the System Device Enumerator. + HRESULT hr; + ICreateDevEnum *pSysDevEnum = NULL; + hr = CoCreateInstance(CLSID_SystemDeviceEnum, NULL, CLSCTX_INPROC_SERVER, IID_ICreateDevEnum, (void **)&pSysDevEnum); + if (FAILED(hr)) + { + return ret; + } + // Obtain a class enumerator for the video compressor category. + IEnumMoniker *pEnumCat = NULL; + hr = pSysDevEnum->CreateClassEnumerator(CLSID_VideoInputDeviceCategory, &pEnumCat, 0); + + if (hr == S_OK) { + // Enumerate the monikers. + IMoniker *pMoniker = NULL; + ULONG cFetched; + while (pEnumCat->Next(1, &pMoniker, &cFetched) == S_OK) { + IPropertyBag *pPropBag; + hr = pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void **)&pPropBag); + if (SUCCEEDED(hr)) { + // To retrieve the filter's friendly name, do the following: + VARIANT varName; + VariantInit(&varName); + hr = pPropBag->Read(L"FriendlyName", &varName, 0); + if (SUCCEEDED(hr)) + { + // Display the name in your UI somehow. + QString str((QChar*)varName.bstrVal, wcslen(varName.bstrVal)); + ret.append(str); + } + VariantClear(&varName); + + ////// To create an instance of the filter, do the following: + ////IBaseFilter *pFilter; + ////hr = pMoniker->BindToObject(NULL, NULL, IID_IBaseFilter, + //// (void**)&pFilter); + // Now add the filter to the graph. + //Remember to release pFilter later. + pPropBag->Release(); + } + pMoniker->Release(); + } + pEnumCat->Release(); + } + pSysDevEnum->Release(); +#else + for (int i = 0; i < 16; i++) { + char buf[128]; + sprintf(buf, "/dev/video%d", i); + if (access(buf, R_OK | W_OK) == 0) { + ret.append(buf); + } else { + break; + } + } +#endif + return ret; +} + +typedef struct { + int width; + int height; +} resolution_tuple; + +static resolution_tuple resolution_choices[] = { + { 0, 0 }, + { 640, 480 }, + { 320, 240 }, + { 320, 200 }, + { 0, 0 } +}; + +static void load_settings(ht_config_t* config, Tracker* tracker) +{ + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + + iniFile.beginGroup( "HT-Tracker" ); + config->classification_delay = 4000; + config->field_of_view = iniFile.value("fov", 69).toFloat(); + config->pyrlk_pyramids = 3; + config->pyrlk_win_size_w = config->pyrlk_win_size_h = 21; + config->max_keypoints = 250; + config->keypoint_quality = 12; + config->keypoint_distance = 2.3f; + config->keypoint_3distance = 6; + //config->force_width = 640; + //config->force_height = 480; + config->force_fps = iniFile.value("fps", 0).toInt(); + config->camera_index = iniFile.value("camera-index", -1).toInt(); + config->ransac_num_iters = 100; + config->ransac_max_reprojection_error = 6.5f; + config->ransac_max_inlier_error = 6.5f; + config->ransac_max_mean_error = 4.0f; + config->ransac_abs_max_mean_error = 7.0f; + config->debug = 0; + config->ransac_min_features = 0.75f; + int res = iniFile.value("resolution", 0).toInt(); + if (res < 0 || res >= (int)(sizeof(*resolution_choices) / sizeof(resolution_tuple))) + res = 0; + resolution_tuple r = resolution_choices[res]; + config->force_width = r.width; + config->force_height = r.height; + if (tracker) + { + tracker->enableRX = iniFile.value("enable-rx", true).toBool(); + tracker->enableRY = iniFile.value("enable-ry", true).toBool(); + tracker->enableRZ = iniFile.value("enable-rz", true).toBool(); + tracker->enableTX = iniFile.value("enable-tx", true).toBool(); + tracker->enableTY = iniFile.value("enable-ty", true).toBool(); + tracker->enableTZ = iniFile.value("enable-tz", true).toBool(); + } + iniFile.endGroup(); +} + +Tracker::Tracker() : lck_shm(HT_SHM_NAME, HT_MUTEX_NAME, sizeof(ht_shm_t)), fresh(false) +{ + videoWidget = NULL; + layout = NULL; + enableRX = enableRY = enableRZ = enableTX = enableTY = enableTZ = true; + shm = (ht_shm_t*) lck_shm.mem; + shm->terminate = 0; + load_settings(&shm->config, this); + shm->result.filled = false; +} + +Tracker::~Tracker() +{ + subprocess.kill(); + if (shm) + shm->terminate = true; + if (layout) + delete layout; + if (videoWidget) + delete videoWidget; +} + +void Tracker::StartTracker(QFrame* videoframe) +{ + videoframe->setAttribute(Qt::WA_NativeWindow); + videoframe->show(); + videoWidget = new VideoWidget(videoframe); + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(videoWidget); + if (videoframe->layout()) + delete videoframe->layout(); + videoframe->setLayout(layout); + videoWidget->resize(WIDGET_WIDTH, WIDGET_HEIGHT); + videoWidget->show(); + this->layout = layout; + load_settings(&shm->config, this); + shm->frame.channels = shm->frame.width = shm->frame.height = 0; + shm->pause = shm->terminate = shm->running = false; + shm->timer = 0; + subprocess.setWorkingDirectory(QCoreApplication::applicationDirPath() + "/tracker-ht"); +#if defined(_WIN32) || defined(__WIN32) + subprocess.start("\"" + QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir" + "\""); +#else + subprocess.start(QCoreApplication::applicationDirPath() + "/tracker-ht/headtracker-ftnoir"); +#endif + connect(&timer, SIGNAL(timeout()), this, SLOT(paint_widget())); + timer.start(15); +} + +void Tracker::paint_widget() { + if (fresh) { + fresh = false; + videoWidget->update(); + } +} + +bool Tracker::GiveHeadPoseData(THeadPoseData* data) +{ + bool ret = false; + + lck_shm.lock(); + shm->timer = 0; + if (shm->frame.width > 0) + { + videoWidget->updateImage(shm->frame.frame, shm->frame.width, shm->frame.height); + //memcpy(foo, shm->frame.frame, shm->frame.width * shm->frame.height * 3); + fresh = true; + } + if (shm->result.filled) { + if (enableRX) + data->yaw = shm->result.rotx; + if (enableRY) + data->pitch = shm->result.roty; + if (enableRZ) + data->roll = shm->result.rotz; + if (enableTX) + data->x = shm->result.tx; + if (enableTY) + data->y = shm->result.ty; + if (enableTZ) + data->z = shm->result.tz; + ret = true; + } + lck_shm.unlock(); + + return ret; +} + +//----------------------------------------------------------------------------- +void TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = "HT 0.7"; +} + +void TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = "HT"; +} + +void TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = ""; +} + +void TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/ht.png"); +} + + +//----------------------------------------------------------------------------- +//#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT Metadata* CALLING_CONVENTION GetMetadata() +{ + return new TrackerDll; +} + +//#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetConstructor() +{ + return (ITracker*) new Tracker; +} + +//////////////////////////////////////////////////////////////////////////////// +// 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") + +extern "C" FTNOIR_TRACKER_BASE_EXPORT void* CALLING_CONVENTION GetDialog( ) +{ + return (ITrackerDialog*) new TrackerControls; +} + +TrackerControls::TrackerControls() +{ + ui.setupUi(this); + loadSettings(); + connect(ui.cameraName, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraFPS, SIGNAL(currentIndexChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.cameraFOV, SIGNAL(valueChanged(double)), this, SLOT(settingChanged(double))); + connect(ui.rx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ry, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.rz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tx, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.ty, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.tz, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.buttonCancel, SIGNAL(clicked()), this, SLOT(doCancel())); + connect(ui.buttonOK, SIGNAL(clicked()), this, SLOT(doOK())); + settingsDirty = false; +} + +TrackerControls::~TrackerControls() +{ +} + +void TrackerControls::showEvent(QShowEvent *event) +{ +} + +void TrackerControls::Initialize(QWidget* parent) +{ + show(); +} + +void TrackerControls::loadSettings() +{ + ui.cameraName->clear(); + QList names = get_camera_names(); + names.prepend("Any available"); + ui.cameraName->addItems(names); + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + iniFile.beginGroup( "HT-Tracker" ); + ui.cameraName->setCurrentIndex(iniFile.value("camera-index", -1).toInt() + 1); + ui.cameraFOV->setValue(iniFile.value("fov", 69).toFloat()); + int fps; + switch (iniFile.value("fps", 0).toInt()) + { + default: + case 0: + fps = 0; + break; + case 30: + fps = 1; + break; + case 60: + fps = 2; + break; + case 120: + fps = 3; + break; + } + ui.cameraFPS->setCurrentIndex(fps); + ui.rx->setCheckState(iniFile.value("enable-rx", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.ry->setCheckState(iniFile.value("enable-ry", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.rz->setCheckState(iniFile.value("enable-rz", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.tx->setCheckState(iniFile.value("enable-tx", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.ty->setCheckState(iniFile.value("enable-ty", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.tz->setCheckState(iniFile.value("enable-tz", true).toBool() ? Qt::Checked : Qt::Unchecked); + ui.resolution->setCurrentIndex(iniFile.value("resolution", 0).toInt()); + iniFile.endGroup(); + settingsDirty = false; +} + +void TrackerControls::save() +{ + QSettings settings("Abbequerque Inc.", "FaceTrackNoIR"); + QString currentFile = settings.value( "SettingsFile", QCoreApplication::applicationDirPath() + "/Settings/default.ini" ).toString(); + QSettings iniFile( currentFile, QSettings::IniFormat ); + + iniFile.beginGroup( "HT-Tracker" ); + iniFile.setValue("fov", ui.cameraFOV->value()); + int fps; + switch (ui.cameraFPS->currentIndex()) + { + case 0: + default: + fps = 0; + break; + case 1: + fps = 30; + break; + case 2: + fps = 60; + break; + case 3: + fps = 120; + break; + } + iniFile.setValue("fps", fps); + iniFile.setValue("camera-index", ui.cameraName->currentIndex() - 1); + iniFile.setValue("enable-rx", ui.rx->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-ry", ui.ry->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-rz", ui.rz->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-tx", ui.tx->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-ty", ui.ty->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("enable-tz", ui.tz->checkState() != Qt::Unchecked ? true : false); + iniFile.setValue("resolution", ui.resolution->currentIndex()); + iniFile.endGroup(); + settingsDirty = false; +} + +void TrackerControls::doOK() +{ + save(); + this->close(); +} + +void TrackerControls::doCancel() +{ + 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(); + } +} diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht.h b/ftnoir_tracker_ht/ftnoir_tracker_ht.h new file mode 100644 index 00000000..1a449dca --- /dev/null +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht.h @@ -0,0 +1,80 @@ +/* Copyright (c) 2013 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. + */ + +#ifndef FTNOIR_TRACKER_HT_H +#define FTNOIR_TRACKER_HT_H + +#include "stdafx.h" +#include "../ftnoir_tracker_base/ftnoir_tracker_base.h" +#include "headtracker-ftnoir.h" +#include "ui_trackercontrols.h" +#include "video_widget.h" +#include "../compat/compat.h" +#include +#include + +class Tracker : public QObject, public ITracker +{ + Q_OBJECT +public: + Tracker(); + ~Tracker(); + void StartTracker(QFrame* frame); + bool GiveHeadPoseData(THeadPoseData *data); + bool enableTX, enableTY, enableTZ, enableRX, enableRY, enableRZ; + ht_shm_t* shm; + bool NeedsTimeToFinish() { + return true; + } + void WaitForExit() { + if (shm) { + shm->terminate = true; + subprocess.waitForFinished(5000); + } + subprocess.kill(); + } +private: + QTimer timer; + PortableLockedShm lck_shm; + QProcess subprocess; + VideoWidget* videoWidget; + QHBoxLayout* layout; + volatile bool fresh; +private slots: + void paint_widget(); +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class TrackerControls : public QWidget, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + virtual ~TrackerControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) {}; + void unRegisterTracker() {}; + +private: + Ui::Form ui; + void loadSettings(); + void save(); + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; + void settingChanged(double) { settingsDirty = true; }; +}; + +#endif + diff --git a/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h new file mode 100644 index 00000000..f3bfd381 --- /dev/null +++ b/ftnoir_tracker_ht/ftnoir_tracker_ht_dll.h @@ -0,0 +1,20 @@ +/* Copyright (c) 2013 Stanis³aw 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_base/ftnoir_tracker_base.h" +#include "../facetracknoir/global-settings.h" + +//----------------------------------------------------------------------------- +class TrackerDll : public Metadata +{ + // ITrackerDll interface + void Initialize() {} + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); +}; diff --git a/ftnoir_tracker_ht/headtracker-ftnoir.h b/ftnoir_tracker_ht/headtracker-ftnoir.h new file mode 100644 index 00000000..48510997 --- /dev/null +++ b/ftnoir_tracker_ht/headtracker-ftnoir.h @@ -0,0 +1,24 @@ +#pragma once +#include +#include +#include "ht-api.h" + +#define HT_SHM_NAME "ftnoir-tracker-ht-shm" +#define HT_MUTEX_NAME "ftnoir-tracker-ht-mutex" + +#define HT_MAX_VIDEO_WIDTH 2048 +#define HT_MAX_VIDEO_HEIGHT 1536 +#define HT_MAX_VIDEO_CHANNELS 3 + +typedef struct { + int width, height, channels; + unsigned char frame[HT_MAX_VIDEO_WIDTH * HT_MAX_VIDEO_HEIGHT * HT_MAX_VIDEO_CHANNELS]; +} ht_video_t; + +typedef struct { + ht_video_t frame; + ht_config_t config; + ht_result_t result; + volatile int timer; + volatile bool pause, terminate, running; +} ht_shm_t; diff --git a/ftnoir_tracker_ht/ht-api.h b/ftnoir_tracker_ht/ht-api.h new file mode 100644 index 00000000..ac8d45cf --- /dev/null +++ b/ftnoir_tracker_ht/ht-api.h @@ -0,0 +1,85 @@ +#pragma once +#ifndef HT_API +#ifndef __cplusplus +# define HT_EXTERN +#else +# define HT_EXTERN extern "C" +#endif +# if defined(_WIN32) && !defined(MINGW) +# define HT_API(t) HT_EXTERN __declspec(dllexport) t __stdcall +# else +# define HT_API(t) HT_EXTERN t +# endif +#endif +#if !defined(_WIN32) && !defined(_isnan) +# define _isnan isnan +#endif +#include +struct ht_context; +typedef struct ht_context headtracker_t; + +typedef struct ht_config { + float field_of_view; + float classification_delay; + int pyrlk_pyramids; + int pyrlk_win_size_w; + int pyrlk_win_size_h; + float ransac_max_inlier_error; + float ransac_max_reprojection_error; + int max_keypoints; + int keypoint_quality; + float keypoint_distance; + float keypoint_3distance; + int force_width; + int force_height; + int force_fps; + int camera_index; + bool debug; + int ransac_num_iters; + float ransac_min_features; + float ransac_max_mean_error; + float ransac_abs_max_mean_error; +} ht_config_t; + +typedef struct { + double rotx, roty, rotz; + double tx, ty, tz; + bool filled; +} ht_result_t; + +typedef enum { + cfg_type_float = 0, + cfg_type_int = 1, + cfg_type_bool = 2, + cfg_type_double = 3 +} ht_cfg_type_t; + +typedef union +{ + double d; + float f; + int i; +} ht_cfg_value_t; + +typedef struct { + const char* name; + int offset; + ht_cfg_type_t type; + ht_cfg_value_t default_value; + ht_cfg_value_t min; + ht_cfg_value_t max; + const char* docstring; +} ht_reflection_t; + +typedef struct { + int rows, cols, channels; + unsigned char* data; +} ht_frame_t; + +HT_API(headtracker_t*) ht_make_context(const ht_config_t* config, const char* filename); +HT_API(void) ht_load_config(FILE* stream, ht_config_t* cfg); +HT_API(void) ht_free_context(headtracker_t* ctx); +HT_API(void) ht_get_bgr_frame(headtracker_t* ctx, ht_frame_t* ret); +HT_API(void) ht_make_config(ht_config_t* cfg); +HT_API(bool) ht_cycle(headtracker_t* ctx, ht_result_t* euler); +HT_API(void) ht_reset(headtracker_t* ctx); diff --git a/ftnoir_tracker_ht/images/HT.ico b/ftnoir_tracker_ht/images/HT.ico new file mode 100644 index 00000000..7555ce25 Binary files /dev/null and b/ftnoir_tracker_ht/images/HT.ico differ diff --git a/ftnoir_tracker_ht/stdafx.h b/ftnoir_tracker_ht/stdafx.h new file mode 100644 index 00000000..0e532c9f --- /dev/null +++ b/ftnoir_tracker_ht/stdafx.h @@ -0,0 +1,14 @@ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include diff --git a/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui new file mode 100644 index 00000000..0174df23 --- /dev/null +++ b/ftnoir_tracker_pt/FTNoIR_PT_Controls.ui @@ -0,0 +1,1764 @@ + + + UICPTClientControls + + + Qt::ApplicationModal + + + + 0 + 0 + 405 + 489 + + + + + 0 + 0 + + + + PointTracker Settings + + + + :/Resources/icon.ico:/Resources/icon.ico + + + Qt::LeftToRight + + + false + + + + QLayout::SetFixedSize + + + + + + 0 + 0 + + + + + 0 + 0 + + + + + + + 0 + + + + General + + + + + + Tracker Thread + + + + + + + + + + + Dynamic Pose Resolution + + + + + + + Sleep time + + + sleep_spin + + + + + + + + + Time the tracker thread sleeps after each processed frame + + + + + + 9999 + + + + + + + ms + + + + + + + + + Auto-reset time + + + reset_spin + + + + + + + + + Time until automatic reset of tracker's internal state when no valid tracking result is found + + + 9999 + + + + + + + ms + + + + + + + + + Whether to update the content of the VideoWidget + + + Show VideoWidget + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + false + + + Reset the tracker's internal state + + + Reset + + + + + + + + + + + + + 0 + 85 + + + + Enable Axis + + + + + + + + Roll: + + + chkEnableRoll + + + + + + + Pitch: + + + chkEnablePitch + + + + + + + Yaw: + + + chkEnableYaw + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + chkEnableX + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + chkEnableY + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + chkEnableZ + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + Status + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Camera Info: + + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + + + + + + + Extracted Points: + + + + + + + + 50 + 0 + + + + + + + + + + + + + + + + + Camera + + + + + + Camera Settings + + + + + + + + + + Index + + + camindex_spin + + + + + + + Capture device index + + + + + + + FPS + + + fps_spin + + + + + + + Desired capture framerate + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + + Resolution + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + Desired capture width + + + 2000 + + + 10 + + + + + + + x + + + + + + + Desired capture height + + + 2000 + + + 10 + + + + + + + + + + + (Focal length)/(Sensor width) + + + f_dspin + + + + + + + The camera's focal length devided by its sensor width + + + 2 + + + 0.100000000000000 + + + + + + + + + + + + + + + Camera Pitch (upwards = positive) + + + campitch_spin + + + + + + + Qt::DefaultContextMenu + + + The angle the camera is facing upwards + + + -99 + + + + + + + deg + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + + + + Point Extraction + + + + + + + + Threshold + + + threshold_slider + + + + + + + Intensity threshold for point extraction + + + 255 + + + 127 + + + Qt::Horizontal + + + + + + + + + + + Min Diameter + + + mindiam_spin + + + + + + + Minimum point diameter + + + + + + + px + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Max Diameter + + + maxdiam_spin + + + + + + + Maximum point diameter + + + + + + + px + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + Status + + + + + + QFormLayout::AllNonFixedFieldsGrow + + + + + Camera Info: + + + + + + + + 0 + 0 + + + + + 120 + 0 + + + + + + + + + + + Extracted Points: + + + + + + + + 50 + 0 + + + + + + + + + + + + + + + + + Model + + + + + + QTabWidget::Rounded + + + 2 + + + false + + + false + + + false + + + + Clip + + + + + + Model Dimensions (mm) + + + + + + + 0 + 0 + + + + + 150 + 170 + + + + + + 30 + 30 + 71 + 111 + + + + + + + :/Resources/clip_side.png + + + + + + 100 + 50 + 46 + 22 + + + + 999 + + + + + + 60 + 10 + 46 + 22 + + + + 999 + + + + + + 100 + 90 + 46 + 22 + + + + 999 + + + + + + 10 + 10 + 46 + 13 + + + + Side + + + + + + 40 + 140 + 46 + 22 + + + + 999 + + + + + + 70 + 70 + 16 + 16 + + + + R + + + + + + + + + 0 + 0 + + + + + 100 + 140 + + + + + + 10 + 10 + 46 + 13 + + + + Front + + + + + + 40 + 30 + 21 + 111 + + + + + + + :/Resources/clip_front.png + + + + + + 60 + 70 + 16 + 16 + + + + R + + + + + + + + + + + + Cap + + + + + + Model Dimensions (mm) + + + + + + + 140 + 130 + + + + + + 20 + 50 + 111 + 81 + + + + + + + :/Resources/cap_side.png + + + + + + 30 + 80 + 46 + 22 + + + + 999 + + + + + + 130 + 50 + 16 + 16 + + + + R + + + + + + 10 + 10 + 46 + 13 + + + + Side + + + + + + 50 + 40 + 46 + 22 + + + + 999 + + + + + + + + + 0 + 0 + + + + + 100 + 130 + + + + + + 10 + 10 + 46 + 13 + + + + Front + + + + + + 30 + 50 + 16 + 16 + + + + R + + + + + + 10 + 50 + 81 + 81 + + + + + + + :/Resources/cap_front.png + + + + + + 50 + 30 + 46 + 22 + + + + 999 + + + + + + + + + + + + Custom + + + + + + Model Dimensions (mm) + + + + + + <html><head/><body><p>Location of the two remaining model points<br/>with respect to the reference point in default pose</p></body></html> + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + -999 + + + 999 + + + + + + + y: + + + + + + + -999 + + + 999 + + + + + + + z: + + + + + + + M1: + + + + + + + -999 + + + 999 + + + + + + + x: + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + -999 + + + 999 + + + + + + + x: + + + + + + + z: + + + + + + + -999 + + + 999 + + + + + + + y: + + + + + + + M2: + + + + + + + + + + -999 + + + 999 + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + Qt::Vertical + + + + 20 + 20 + + + + + + + + + + + + + + + Model Position (mm) + + + + + + <html><head/><body><p>Translation from head center to model reference point<br/> in default pose</p></body></html> + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + + + + -999 + + + 999 + + + + + + + x: + + + + + + + y: + + + + + + + z: + + + + + + + -999 + + + 999 + + + + + + + -999 + + + 999 + + + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + false + + + Calibrate + + + true + + + + + + + Qt::Horizontal + + + + 20 + 20 + + + + + + + + + + + + + + About + + + + + 30 + 30 + 161 + 111 + + + + <html><head/><body><p><span style=" font-weight:600;">FTNoIR PointTracker Plugin<br/>Version 1.0</span></p><p><span style=" font-weight:600;">by Patrick Ruoff</span></p><p><a href="http://ftnoirpt.sourceforge.net/"><span style=" font-weight:600; text-decoration: underline; color:#0000ff;">Manual (external)</span></a></p></body></html> + + + true + + + + + + 200 + 30 + 141 + 141 + + + + + + + :/Resources/Logo_IR.png + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Ok + + + + + + + Cancel + + + + + + + + + tabWidget + sleep_spin + reset_spin + chkEnableRoll + chkEnablePitch + chkEnableYaw + chkEnableX + chkEnableY + chkEnableZ + camindex_spin + res_x_spin + res_y_spin + fps_spin + f_dspin + campitch_spin + threshold_slider + mindiam_spin + maxdiam_spin + model_tabs + clip_tlength_spin + clip_theight_spin + clip_bheight_spin + clip_blength_spin + cap_length_spin + cap_height_spin + cap_width_spin + m1x_spin + m1y_spin + m1z_spin + m2x_spin + m2y_spin + m2z_spin + tx_spin + ty_spin + tz_spin + tcalib_button + ok_button + cancel_button + + + + + + + dynpose_check + toggled(bool) + reset_spin + setEnabled(bool) + + + 285 + 105 + + + 139 + 111 + + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_pt/FTNoIR_Tracker_PT.rc b/ftnoir_tracker_pt/FTNoIR_Tracker_PT.rc new file mode 100644 index 00000000..11c5d52f --- /dev/null +++ b/ftnoir_tracker_pt/FTNoIR_Tracker_PT.rc @@ -0,0 +1,61 @@ +// Microsoft Visual C++ generated resource script. +// +#include "resource.h" + +#define APSTUDIO_READONLY_SYMBOLS +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 2 resource. +// +#include "afxres.h" + +///////////////////////////////////////////////////////////////////////////// +#undef APSTUDIO_READONLY_SYMBOLS + +///////////////////////////////////////////////////////////////////////////// +// English (U.S.) resources + +#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU) +LANGUAGE 9, 1 +#pragma code_page(1252) + +#ifdef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// TEXTINCLUDE +// + +1 TEXTINCLUDE +BEGIN + "resource.h\0" +END + +2 TEXTINCLUDE +BEGIN + "#include ""afxres.h""\r\n" + "\0" +END + +3 TEXTINCLUDE +BEGIN + "\r\n" + "\0" +END + +#endif // APSTUDIO_INVOKED + +#endif // English (U.S.) resources +///////////////////////////////////////////////////////////////////////////// + + + +#ifndef APSTUDIO_INVOKED +///////////////////////////////////////////////////////////////////////////// +// +// Generated from the TEXTINCLUDE 3 resource. +// + + +///////////////////////////////////////////////////////////////////////////// +#endif // not APSTUDIO_INVOKED + diff --git a/ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc8.vcproj b/ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc8.vcproj new file mode 100644 index 00000000..5b70b459 --- /dev/null +++ b/ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc8.vcproj @@ -0,0 +1,559 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc9.vcproj b/ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc9.vcproj new file mode 100644 index 00000000..95f5ac62 --- /dev/null +++ b/ftnoir_tracker_pt/FTNoIR_Tracker_PT_vc9.vcproj @@ -0,0 +1,524 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_pt/Resources/Logo_IR.png b/ftnoir_tracker_pt/Resources/Logo_IR.png new file mode 100644 index 00000000..95032a25 Binary files /dev/null and b/ftnoir_tracker_pt/Resources/Logo_IR.png differ diff --git a/ftnoir_tracker_pt/Resources/cap_front.png b/ftnoir_tracker_pt/Resources/cap_front.png new file mode 100644 index 00000000..14207a67 Binary files /dev/null and b/ftnoir_tracker_pt/Resources/cap_front.png differ diff --git a/ftnoir_tracker_pt/Resources/cap_side.png b/ftnoir_tracker_pt/Resources/cap_side.png new file mode 100644 index 00000000..5ad4ee65 Binary files /dev/null and b/ftnoir_tracker_pt/Resources/cap_side.png differ diff --git a/ftnoir_tracker_pt/Resources/clip_front.png b/ftnoir_tracker_pt/Resources/clip_front.png new file mode 100644 index 00000000..04880138 Binary files /dev/null and b/ftnoir_tracker_pt/Resources/clip_front.png differ diff --git a/ftnoir_tracker_pt/Resources/clip_side.png b/ftnoir_tracker_pt/Resources/clip_side.png new file mode 100644 index 00000000..72667ac7 Binary files /dev/null and b/ftnoir_tracker_pt/Resources/clip_side.png differ diff --git a/ftnoir_tracker_pt/Resources/icon.ico b/ftnoir_tracker_pt/Resources/icon.ico new file mode 100644 index 00000000..c4b2aedc Binary files /dev/null and b/ftnoir_tracker_pt/Resources/icon.ico differ diff --git a/ftnoir_tracker_pt/camera.cpp b/ftnoir_tracker_pt/camera.cpp new file mode 100644 index 00000000..fc11c738 --- /dev/null +++ b/ftnoir_tracker_pt/camera.cpp @@ -0,0 +1,226 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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 "camera.h" +#include + +using namespace cv; + +// ---------------------------------------------------------------------------- +void Camera::set_index(int index) +{ + if (desired_index != index) + { + desired_index = index; + _set_index(); + + // reset fps + dt_valid = 0; + dt_mean = 0; + active_index = index; + } +} + +void Camera::set_f(float f) +{ + if (cam_desired.f != f) + { + cam_desired.f = f; + _set_f(); + } +} +void Camera::set_fps(int fps) +{ + if (cam_desired.fps != fps) + { + cam_desired.fps = fps; + _set_fps(); + } +} + +void Camera::set_res(int x_res, int y_res) +{ + if (cam_desired.res_x != x_res || cam_desired.res_y != y_res) + { + cam_desired.res_x = x_res; + cam_desired.res_y = y_res; + _set_res(); + } +} + +bool Camera::get_frame(float dt, cv::Mat* frame) +{ + bool new_frame = _get_frame(frame); + // measure fps of valid frames + const float dt_smoothing_const = 0.9; + dt_valid += dt; + if (new_frame) + { + dt_mean = dt_smoothing_const * dt_mean + (1.0 - dt_smoothing_const) * dt_valid; + cam_info.fps = 1.0 / dt_mean; + dt_valid = 0; + } + return new_frame; +} + +// ---------------------------------------------------------------------------- +/* +void CVCamera::start() +{ + cap = cvCreateCameraCapture(desired_index); + // extract camera info + if (cap) + { + active = true; + active_index = desired_index; + cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH); + cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT); + } +} + +void CVCamera::stop() +{ + if (cap) cvReleaseCapture(&cap); + active = false; +} + +bool CVCamera::_get_frame(Mat* frame) +{ + if (cap && cvGrabFrame(cap) != 0) + { + // retrieve frame + IplImage* _img = cvRetrieveFrame(cap, 0); + if(_img) + { + if(_img->origin == IPL_ORIGIN_TL) + *frame = Mat(_img); + else + { + Mat temp(_img); + flip(temp, *frame, 0); + } + return true; + } + } + return false; +} + +void CVCamera::_set_index() +{ + if (active) restart(); +} + +void CVCamera::_set_f() +{ + cam_info.f = cam_desired.f; +} + +void CVCamera::_set_fps() +{ + if (cap) cvSetCaptureProperty(cap, CV_CAP_PROP_FPS, cam_desired.fps); +} + +void CVCamera::_set_res() +{ + if (cap) + { + cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH, cam_desired.res_x); + cvSetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT, cam_desired.res_y); + cam_info.res_x = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_WIDTH); + cam_info.res_y = cvGetCaptureProperty(cap, CV_CAP_PROP_FRAME_HEIGHT); + } +} +*/ + +// ---------------------------------------------------------------------------- +VICamera::VICamera() : frame_buffer(NULL) +{ + VI.listDevices(); +} + +void VICamera::start() +{ + if (desired_index >= 0) + { + + + if (cam_desired.res_x == 0 || cam_desired.res_y == 0) + VI.setupDevice(desired_index); + else + VI.setupDevice(desired_index, cam_desired.res_x, cam_desired.res_y); + + active = true; + active_index = desired_index; + + cam_info.res_x = VI.getWidth(active_index); + cam_info.res_y = VI.getHeight(active_index); + new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3); + // If matrix is not continuous we have to copy manually via frame_buffer + if (!new_frame.isContinuous()) { + unsigned int size = VI.getSize(active_index); + frame_buffer = new unsigned char[size]; + } + } +} + +void VICamera::stop() +{ + if (active) + { + VI.stopDevice(active_index); + } + if (frame_buffer) + { + delete[] frame_buffer; + frame_buffer = NULL; + } + active = false; +} + +bool VICamera::_get_frame(Mat* frame) +{ + if (active && VI.isFrameNew(active_index)) + { + if (new_frame.isContinuous()) + { + VI.getPixels(active_index, new_frame.data, false, true); + } + else + { + // If matrix is not continuous we have to copy manually via frame_buffer + VI.getPixels(active_index, frame_buffer, false, true); + new_frame = cv::Mat(cam_info.res_y, cam_info.res_x, CV_8UC3, frame_buffer).clone(); + } + *frame = new_frame; + return true; + } + return false; +} + +void VICamera::_set_index() +{ + if (active) restart(); +} + +void VICamera::_set_f() +{ + cam_info.f = cam_desired.f; +} + +void VICamera::_set_fps() +{ + bool was_active = active; + if (active) stop(); + VI.setIdealFramerate(desired_index, cam_desired.fps); + if (was_active) start(); +} + +void VICamera::_set_res() +{ + if (active) restart(); +} + diff --git a/ftnoir_tracker_pt/camera.h b/ftnoir_tracker_pt/camera.h new file mode 100644 index 00000000..cd1f0842 --- /dev/null +++ b/ftnoir_tracker_pt/camera.h @@ -0,0 +1,116 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef CAMERA_H +#define CAMERA_H + +#include +#include "videoInput/videoInput.h" + +// ---------------------------------------------------------------------------- +struct CamInfo +{ + CamInfo() : res_x(0), res_y(0), fps(0), f(1) {} + + int res_x; + int res_y; + int fps; + float f; // (focal length) / (sensor width) +}; + +// ---------------------------------------------------------------------------- +// base class for cameras +class Camera +{ +public: + Camera() : dt_valid(0), dt_mean(0), desired_index(0), active_index(-1), active(false) {} + virtual ~Camera() {} + + // start/stop capturing + virtual void start() = 0; + virtual void stop() = 0; + void restart() { stop(); start(); } + + void set_index(int index); + void set_f(float f); + void set_fps(int fps); + void set_res(int x_res, int y_res); + + // gets a frame from the camera, dt: time since last call in seconds + bool get_frame(float dt, cv::Mat* frame); + + // WARNING: returned references are valid as long as object + const CamInfo& get_info() const { return cam_info; } + const CamInfo& get_desired() const { return cam_desired; } + +protected: + // get a frame from the camera + virtual bool _get_frame(cv::Mat* frame) = 0; + + // update the camera + virtual void _set_index() = 0; + virtual void _set_f() = 0; + virtual void _set_fps() = 0; + virtual void _set_res() = 0; + + bool active; + int desired_index; + int active_index; + CamInfo cam_info; + CamInfo cam_desired; + float dt_valid; + float dt_mean; +}; + + +// ---------------------------------------------------------------------------- +// OpenCV camera +/* +class CVCamera : public Camera +{ +public: + CVCamera() : cap(NULL) {} + ~CVCamera() { stop(); } + + void start(); + void stop(); + +protected: + bool _get_frame(cv::Mat* frame); + void _set_index(); + void _set_f(); + void _set_fps(); + void _set_res(); + + CvCapture* cap; +}; +*/ + +// ---------------------------------------------------------------------------- +// videoInput camera +class VICamera : public Camera +{ +public: + VICamera(); + ~VICamera() { stop(); } + + void start(); + void stop(); + +protected: + bool _get_frame(cv::Mat* frame); + void _set_index(); + void _set_f(); + void _set_fps(); + void _set_res(); + + videoInput VI; + cv::Mat new_frame; + unsigned char* frame_buffer; +}; + +#endif //CAMERA_H diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp new file mode 100644 index 00000000..5b77da69 --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.cpp @@ -0,0 +1,257 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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_pt.h" +#include +#include +#include +#include +#include + +using namespace std; +using namespace cv; +using namespace boost; + +//#define PT_PERF_LOG //log performance + +//----------------------------------------------------------------------------- +Tracker::Tracker() + : frame_count(0), commands(0), video_widget(NULL), tracking_valid(false) +{ + qDebug()<<"Tracker::Tracker"; + TrackerSettings settings; + settings.load_ini(); + apply(settings); + camera.start(); + start(); +} + +Tracker::~Tracker() +{ + qDebug()<<"Tracker::~Tracker"; + set_command(ABORT); + wait(); + if (video_widget) delete video_widget; +} + +void Tracker::set_command(Command command) +{ + QMutexLocker lock(&mutex); + commands |= command; +} + +void Tracker::reset_command(Command command) +{ + QMutexLocker lock(&mutex); + commands &= ~command; +} + +void Tracker::run() +{ + qDebug()<<"Tracker:: Thread started"; + +#ifdef PT_PERF_LOG + QFile log_file(QCoreApplication::applicationDirPath() + "/PointTrackerPerformance.txt"); + if (!log_file.open(QIODevice::WriteOnly | QIODevice::Text)) return; + QTextStream log_stream(&log_file); +#endif + + time.start(); + float dt; + bool new_frame; + forever + { + { + QMutexLocker lock(&mutex); + + if (commands & ABORT) break; + if (commands & PAUSE) continue; + commands = 0; + + dt = time.elapsed() / 1000.0; + time.restart(); + + new_frame = camera.get_frame(dt, &frame); + if (new_frame && !frame.empty()) + { + const std::vector& points = point_extractor.extract_points(frame, dt, draw_frame); + tracking_valid = point_tracker.track(points, camera.get_info().f, dt); + frame_count++; + } +#ifdef PT_PERF_LOG + log_stream<<"dt: "<(new PointModel(settings.M01, settings.M02)); + point_tracker.dynamic_pose_resolution = settings.dyn_pose_res; + sleep_time = settings.sleep_time; + point_tracker.dt_reset = settings.reset_time / 1000.0; + draw_frame = settings.video_widget; + cam_pitch = settings.cam_pitch; + + bEnableRoll = settings.bEnableRoll; + bEnablePitch = settings.bEnablePitch; + bEnableYaw = settings.bEnableYaw; + bEnableX = settings.bEnableX; + bEnableY = settings.bEnableY; + bEnableZ = settings.bEnableZ; + + t_MH = settings.t_MH; + qDebug()<<"Tracker::apply ends"; +} + +void Tracker::reset() +{ + QMutexLocker lock(&mutex); + point_tracker.reset(); +} + +void Tracker::center() +{ + point_tracker.reset(); // we also do a reset here since there is no reset shortkey yet + QMutexLocker lock(&mutex); + FrameTrafo X_CM_0 = point_tracker.get_pose(); + FrameTrafo X_MH(Matx33f::eye(), t_MH); + X_CH_0 = X_CM_0 * X_MH; +} + +//----------------------------------------------------------------------------- +// ITracker interface +void Tracker::Initialize(QFrame *videoframe) +{ + const int VIDEO_FRAME_WIDTH = 252; + const int VIDEO_FRAME_HEIGHT = 189; + + qDebug("Tracker::Initialize"); + // setup video frame + videoframe->setAttribute(Qt::WA_NativeWindow); + videoframe->show(); + video_widget = new VideoWidget(videoframe); + QHBoxLayout* layout = new QHBoxLayout(); + layout->setContentsMargins(0, 0, 0, 0); + layout->addWidget(video_widget); + if (videoframe->layout()) delete videoframe->layout(); + videoframe->setLayout(layout); + video_widget->resize(VIDEO_FRAME_WIDTH, VIDEO_FRAME_HEIGHT); +} + +void Tracker::refreshVideo() +{ + if (video_widget) + { + Mat frame_copy; + shared_ptr< vector > points; + { + QMutexLocker lock(&mutex); + if (!draw_frame || frame.empty()) return; + + // copy the frame and points from the tracker thread + frame_copy = frame.clone(); + points = shared_ptr< vector >(new vector(point_extractor.get_points())); + } + + video_widget->update(frame_copy, points); + } +} + +void Tracker::StartTracker(HWND parent_window) +{ + reset_command(PAUSE); +} + +void Tracker::StopTracker(bool exit) +{ + set_command(PAUSE); +} + +bool Tracker::GiveHeadPoseData(THeadPoseData *data) +{ + const float rad2deg = 180.0/3.14159265; + const float deg2rad = 1.0/rad2deg; + { + QMutexLocker lock(&mutex); + + if (!tracking_valid) return false; + + FrameTrafo X_CM = point_tracker.get_pose(); + FrameTrafo X_MH(Matx33f::eye(), t_MH); + FrameTrafo X_CH = X_CM * X_MH; + + Matx33f R = X_CH.R * X_CH_0.R.t(); + Vec3f t = X_CH.t - X_CH_0.t; + + // correct for camera pitch + Matx33f R_CP( 1, 0, 0, + 0, cos(deg2rad*cam_pitch), sin(deg2rad*cam_pitch), + 0, -sin(deg2rad*cam_pitch), cos(deg2rad*cam_pitch)); + R = R_CP * R * R_CP.t(); + t = R_CP * t; + + // get translation(s) + if (bEnableX) { + data->x = t[0] / 10.0; // convert to cm + } + if (bEnableY) { + data->y = t[1] / 10.0; + } + if (bEnableZ) { + data->z = t[2] / 10.0; + } + + // translate rotation matrix from opengl (G) to roll-pitch-yaw (R) frame + // -z -> x, y -> z, x -> -y + Matx33f R_RG( 0, 0,-1, + -1, 0, 0, + 0, 1, 0); + R = R_RG * R * R_RG.t(); + + // extract rotation angles + float alpha, beta, gamma; + //beta = atan2( -R(2,0), sqrt(R(0,0)*R(0,0) + R(1,0)*R(1,0)) ); + beta = atan2( -R(2,0), sqrt(R(2,1)*R(2,1) + R(2,2)*R(2,2)) ); + alpha = atan2( R(1,0), R(0,0)); + gamma = atan2( R(2,1), R(2,2)); + + if (bEnableYaw) { + data->yaw = rad2deg * alpha; + } + if (bEnablePitch) { + data->pitch = rad2deg * beta; + } + if (bEnableRoll) { + data->roll = rad2deg * gamma; + } + } + return true; +} + +//----------------------------------------------------------------------------- +#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +{ + return new Tracker; +} \ No newline at end of file diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.h b/ftnoir_tracker_pt/ftnoir_tracker_pt.h new file mode 100644 index 00000000..2533a39b --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.h @@ -0,0 +1,86 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef FTNOIR_TRACKER_PT_H +#define FTNOIR_TRACKER_PT_H + +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "ftnoir_tracker_pt_settings.h" +#include "camera.h" +#include "point_extractor.h" +#include "point_tracker.h" +#include "video_widget.h" +#include "timer.h" + +#include +#include +#include +#include + +//----------------------------------------------------------------------------- +class Tracker : public ITracker, QThread +{ +public: + Tracker(); + ~Tracker(); + + // ITracker interface + void Initialize(QFrame *videoframe); + void StartTracker(HWND parent_window); + void StopTracker(bool exit); + bool GiveHeadPoseData(THeadPoseData *data); + + void refreshVideo(); + + void apply(const TrackerSettings& settings); + void center(); + void reset(); // reset the trackers internal state variables + void run(); + + void get_pose(FrameTrafo* X_CM) { QMutexLocker lock(&mutex); *X_CM = point_tracker.get_pose(); } + int get_n_points() { QMutexLocker lock(&mutex); return point_extractor.get_points().size(); } + void get_cam_info(CamInfo* info) { QMutexLocker lock(&mutex); *info = camera.get_info(); } + +protected: + FrameTrafo X_CH_0; // for centering + + QMutex mutex; + cv::Mat frame; // the output frame for display + + enum Command { + ABORT = 1<<0, + PAUSE = 1<<1 + }; + void set_command(Command command); + void reset_command(Command command); + int commands; + + VICamera camera; + PointExtractor point_extractor; + PointTracker point_tracker; + bool tracking_valid; + + cv::Vec3f t_MH; + int cam_pitch; + + bool draw_frame; + int sleep_time; + + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + + long frame_count; + + VideoWidget* video_widget; + Timer time; +}; + +#endif // FTNOIR_TRACKER_PT_H diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc b/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc new file mode 100644 index 00000000..eb1fba2c --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt.qrc @@ -0,0 +1,10 @@ + + + Resources/icon.ico + Resources/cap_front.png + Resources/cap_side.png + Resources/clip_front.png + Resources/clip_side.png + Resources/Logo_IR.png + + diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp new file mode 100644 index 00000000..a1531dd7 --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.cpp @@ -0,0 +1,336 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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_pt_dialog.h" + +#include +#include + +//----------------------------------------------------------------------------- +TrackerDialog::TrackerDialog() + : settings_dirty(false), tracker(NULL), timer(this), trans_calib_running(false) +{ + qDebug()<<"TrackerDialog::TrackerDialog"; + setAttribute(Qt::WA_DeleteOnClose, false); + + ui.setupUi( this ); + + settings.load_ini(); + dialog_settings.load_ini(); + + // initialize ui values + ui.videowidget_check->setChecked(settings.video_widget); + ui.dynpose_check->setChecked(settings.dyn_pose_res); + ui.sleep_spin->setValue(settings.sleep_time); + ui.reset_spin->setValue(settings.reset_time); + ui.camindex_spin->setValue(settings.cam_index); + ui.f_dspin->setValue(settings.cam_f); + ui.res_x_spin->setValue(settings.cam_res_x); + ui.res_y_spin->setValue(settings.cam_res_y); + ui.fps_spin->setValue(settings.cam_fps); + ui.campitch_spin->setValue(settings.cam_pitch); + ui.threshold_slider->setValue(settings.threshold); + + ui.chkEnableRoll->setChecked(settings.bEnableRoll); + ui.chkEnablePitch->setChecked(settings.bEnablePitch); + ui.chkEnableYaw->setChecked(settings.bEnableYaw); + ui.chkEnableX->setChecked(settings.bEnableX); + ui.chkEnableY->setChecked(settings.bEnableY); + ui.chkEnableZ->setChecked(settings.bEnableZ); + + ui.mindiam_spin->setValue(settings.min_point_size); + ui.maxdiam_spin->setValue(settings.max_point_size); + ui.model_tabs->setCurrentIndex(dialog_settings.active_model_panel); + ui.clip_bheight_spin->setValue(dialog_settings.clip_by); + ui.clip_blength_spin->setValue(dialog_settings.clip_bz); + ui.clip_theight_spin->setValue(dialog_settings.clip_ty); + ui.clip_tlength_spin->setValue(dialog_settings.clip_tz); + ui.cap_width_spin->setValue(dialog_settings.cap_x); + ui.cap_height_spin->setValue(dialog_settings.cap_y); + ui.cap_length_spin->setValue(dialog_settings.cap_z); + ui.m1x_spin->setValue(dialog_settings.M01x); + ui.m1y_spin->setValue(dialog_settings.M01y); + ui.m1z_spin->setValue(dialog_settings.M01z); + ui.m2x_spin->setValue(dialog_settings.M02x); + ui.m2y_spin->setValue(dialog_settings.M02y); + ui.m2z_spin->setValue(dialog_settings.M02z); + ui.tx_spin->setValue(settings.t_MH[0]); + ui.ty_spin->setValue(settings.t_MH[1]); + ui.tz_spin->setValue(settings.t_MH[2]); + + // connect Qt signals and slots + connect( ui.videowidget_check,SIGNAL(toggled(bool)), this,SLOT(set_video_widget(bool)) ); + connect( ui.dynpose_check,SIGNAL(toggled(bool)), this,SLOT(set_dyn_pose_res(bool)) ); + connect( ui.sleep_spin,SIGNAL(valueChanged(int)), this,SLOT(set_sleep_time(int)) ); + connect( ui.reset_spin,SIGNAL(valueChanged(int)), this,SLOT(set_reset_time(int)) ); + connect( ui.camindex_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_index(int)) ); + connect( ui.f_dspin,SIGNAL(valueChanged(double)), this,SLOT(set_cam_f(double)) ); + connect( ui.res_x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_x(int)) ); + connect( ui.res_y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_res_y(int)) ); + connect( ui.fps_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_fps(int)) ); + connect( ui.campitch_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cam_pitch(int)) ); + connect( ui.threshold_slider,SIGNAL(sliderMoved(int)), this,SLOT(set_threshold(int)) ); + + connect( ui.chkEnableRoll,SIGNAL(toggled(bool)), this,SLOT(set_ena_roll(bool)) ); + connect( ui.chkEnablePitch,SIGNAL(toggled(bool)), this,SLOT(set_ena_pitch(bool)) ); + connect( ui.chkEnableYaw,SIGNAL(toggled(bool)), this,SLOT(set_ena_yaw(bool)) ); + connect( ui.chkEnableX,SIGNAL(toggled(bool)), this,SLOT(set_ena_x(bool)) ); + connect( ui.chkEnableY,SIGNAL(toggled(bool)), this,SLOT(set_ena_y(bool)) ); + connect( ui.chkEnableZ,SIGNAL(toggled(bool)), this,SLOT(set_ena_z(bool)) ); + + connect( ui.mindiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_min_point_size(int)) ); + connect( ui.maxdiam_spin,SIGNAL(valueChanged(int)), this,SLOT(set_max_point_size(int)) ); + connect( ui.model_tabs,SIGNAL(currentChanged(int)), this,SLOT(set_model(int)) ); + connect( ui.clip_theight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_height(int)) ); + connect( ui.clip_tlength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_t_length(int)) ); + connect( ui.clip_bheight_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_height(int)) ); + connect( ui.clip_blength_spin,SIGNAL(valueChanged(int)), this,SLOT(set_clip_b_length(int)) ); + connect( ui.cap_width_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_width(int)) ); + connect( ui.cap_height_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_height(int)) ); + connect( ui.cap_length_spin,SIGNAL(valueChanged(int)), this,SLOT(set_cap_length(int)) ); + connect( ui.m1x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1x(int)) ); + connect( ui.m1y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1y(int)) ); + connect( ui.m1z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m1z(int)) ); + connect( ui.m2x_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2x(int)) ); + connect( ui.m2y_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2y(int)) ); + connect( ui.m2z_spin,SIGNAL(valueChanged(int)), this,SLOT(set_m2z(int)) ); + connect( ui.tx_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tx(int)) ); + connect( ui.ty_spin,SIGNAL(valueChanged(int)), this,SLOT(set_ty(int)) ); + connect( ui.tz_spin,SIGNAL(valueChanged(int)), this,SLOT(set_tz(int)) ); + + connect( ui.tcalib_button,SIGNAL(toggled(bool)), this,SLOT(startstop_trans_calib(bool)) ); + + connect(ui.reset_button, SIGNAL(clicked()), this, SLOT(doReset())); + //connect(ui.center_button, SIGNAL(clicked()), this, SLOT(doCenter())); + + connect(ui.ok_button, SIGNAL(clicked()), this, SLOT(doOK())); + connect(ui.cancel_button, SIGNAL(clicked()), this, SLOT(doCancel())); + + connect(&timer,SIGNAL(timeout()), this,SLOT(poll_tracker_info())); + timer.start(100); +} + +TrackerDialog::~TrackerDialog() +{ + qDebug()<<"TrackerDialog::~TrackerDialog"; +} + +void TrackerDialog::set_clip() +{ + settings.M01[0] = 0; + settings.M01[1] = dialog_settings.clip_ty; + settings.M01[2] = -dialog_settings.clip_tz; + settings.M02[0] = 0; + settings.M02[1] = -dialog_settings.clip_by; + settings.M02[2] = -dialog_settings.clip_bz; + + settings_changed(); +} + +void TrackerDialog::set_cap() +{ + settings.M01[0] = -dialog_settings.cap_x; + settings.M01[1] = -dialog_settings.cap_y; + settings.M01[2] = -dialog_settings.cap_z; + settings.M02[0] = dialog_settings.cap_x; + settings.M02[1] = -dialog_settings.cap_y; + settings.M02[2] = -dialog_settings.cap_z; + + settings_changed(); +} + +void TrackerDialog::set_custom() +{ + settings.M01[0] = dialog_settings.M01x; + settings.M01[1] = dialog_settings.M01y; + settings.M01[2] = dialog_settings.M01z; + settings.M02[0] = dialog_settings.M02x; + settings.M02[1] = dialog_settings.M02y; + settings.M02[2] = dialog_settings.M02z; + + settings_changed(); +} + +void TrackerDialog::set_model(int val) +{ + dialog_settings.active_model_panel = val; + + switch (val) { + + case TrackerDialogSettings::MODEL_CLIP: + set_clip(); + break; + + case TrackerDialogSettings::MODEL_CAP: + set_cap(); + break; + + case TrackerDialogSettings::MODEL_CUSTOM: + set_custom(); + break; + + default: + break; + } +} + +void TrackerDialog::startstop_trans_calib(bool start) +{ + if (start) + { + qDebug()<<"TrackerDialog:: Starting translation calibration"; + trans_calib.reset(); + trans_calib_running = true; + } + else + { + qDebug()<<"TrackerDialog:: Stoppping translation calibration"; + trans_calib_running = false; + settings.t_MH = trans_calib.get_estimate(); + settings_changed(); + } +} + +void TrackerDialog::trans_calib_step() +{ + if (tracker) + { + FrameTrafo X_CM; + tracker->get_pose(&X_CM); + trans_calib.update(X_CM.R, X_CM.t); + cv::Vec3f t_MH = trans_calib.get_estimate(); + //qDebug()<<"TrackerDialog:: Current translation estimate: "<setValue(t_MH[0]); + ui.ty_spin->setValue(t_MH[1]); + ui.tz_spin->setValue(t_MH[2]); + } +} + +void TrackerDialog::settings_changed() +{ + settings_dirty = true; + if (tracker) tracker->apply(settings); +} + +void TrackerDialog::doCenter() +{ + if (tracker) tracker->center(); +} + +void TrackerDialog::doReset() +{ + if (tracker) tracker->reset(); +} + +void TrackerDialog::doOK() +{ + settings.save_ini(); + dialog_settings.save_ini(); + close(); +} + +void TrackerDialog::doCancel() +{ + if (settings_dirty) { + 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: + settings.save_ini(); + dialog_settings.save_ini(); + close(); + break; + case QMessageBox::Discard: + close(); + break; + case QMessageBox::Cancel: + // Cancel was clicked + break; + default: + // should never be reached + break; + } + } + else { + close(); + } +} + +void TrackerDialog::poll_tracker_info() +{ + if (tracker) + { + QString to_print; + + // display caminfo + CamInfo info; + tracker->get_cam_info(&info); + to_print = QString::number(info.res_x)+"x"+QString::number(info.res_y)+" @ "+QString::number(info.fps)+" FPS"; + ui.caminfo_label->setText(to_print); + ui.caminfo_label_2->setText(to_print); + + // display pointinfo + int n_points = tracker->get_n_points(); + to_print = QString::number(n_points); + if (n_points == 3) + to_print += " OK!"; + else + to_print += " BAD!"; + ui.pointinfo_label->setText(to_print); + ui.pointinfo_label_2->setText(to_print); + + // update calibration + if (trans_calib_running) trans_calib_step(); + } + else + { + QString to_print = "Tracker offline"; + ui.caminfo_label->setText(to_print); + ui.caminfo_label_2->setText(to_print); + ui.pointinfo_label->setText(to_print); + ui.pointinfo_label_2->setText(to_print); + } +} + + +//----------------------------------------------------------------------------- +// ITrackerDialog interface +void TrackerDialog::Initialize(QWidget *parent) +{ + QPoint offsetpos(200, 200); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +void TrackerDialog::registerTracker(ITracker *t) +{ + qDebug()<<"TrackerDialog:: Tracker registered"; + tracker = static_cast(t); + if (isVisible() && settings_dirty) tracker->apply(settings); + ui.tcalib_button->setEnabled(true); + //ui.center_button->setEnabled(true); + ui.reset_button->setEnabled(true); +} + +void TrackerDialog::unRegisterTracker() +{ + qDebug()<<"TrackerDialog:: Tracker un-registered"; + tracker = NULL; + ui.tcalib_button->setEnabled(false); + //ui.center_button->setEnabled(false); + ui.reset_button->setEnabled(false); +} + +//----------------------------------------------------------------------------- +#pragma comment(linker, "/export:GetTrackerDialog=_GetTrackerDialog@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDialogPtr __stdcall GetTrackerDialog( ) +{ + return new TrackerDialog; +} \ No newline at end of file diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h new file mode 100644 index 00000000..0f836dfe --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dialog.h @@ -0,0 +1,102 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef FTNOIR_TRACKER_PT_DIALOG_H +#define FTNOIR_TRACKER_PT_DIALOG_H + +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "ftnoir_tracker_pt_settings.h" +#include "ftnoir_tracker_pt.h" +#include "ui_FTNoIR_PT_Controls.h" +#include "trans_calib.h" + +#include + +//----------------------------------------------------------------------------- +class TrackerDialog : public QWidget, Ui::UICPTClientControls, public ITrackerDialog +{ + Q_OBJECT +public: + TrackerDialog(); + ~TrackerDialog(); + + // ITrackerDialog interface + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker); + void unRegisterTracker(); + + void trans_calib_step(); + +protected slots: + // ugly qt stuff + void set_video_widget(bool val) { settings.video_widget = val; settings_changed(); } + void set_dyn_pose_res(bool val) { settings.dyn_pose_res = val; settings_changed(); } + void set_sleep_time(int val) { settings.sleep_time = val; settings_changed(); } + void set_reset_time(int val) { settings.reset_time = val; settings_changed(); } + void set_cam_index(int val) { settings.cam_index = val; settings_changed(); } + void set_cam_f(double val) { settings.cam_f = val; settings_changed(); } + void set_cam_res_x(int val) { settings.cam_res_x = val; settings_changed(); } + void set_cam_res_y(int val) { settings.cam_res_y = val; settings_changed(); } + void set_cam_fps(int val) { settings.cam_fps = val; settings_changed(); } + void set_cam_pitch(int val) { settings.cam_pitch = val; settings_changed(); } + void set_min_point_size(int val) { settings.min_point_size = val; settings_changed(); } + void set_max_point_size(int val) { settings.max_point_size = val; settings_changed(); } + void set_threshold(int val) { settings.threshold = val; settings_changed(); } + void set_ena_roll(bool val) { settings.bEnableRoll = val; settings_changed(); } + void set_ena_pitch(bool val) { settings.bEnablePitch = val; settings_changed(); } + void set_ena_yaw(bool val) { settings.bEnableYaw = val; settings_changed(); } + void set_ena_x(bool val) { settings.bEnableX = val; settings_changed(); } + void set_ena_y(bool val) { settings.bEnableY = val; settings_changed(); } + void set_ena_z(bool val) { settings.bEnableZ = val; settings_changed(); } + + void set_clip_t_height(int val) { dialog_settings.clip_ty = val; set_clip(); } + void set_clip_t_length(int val) { dialog_settings.clip_tz = val; set_clip(); } + void set_clip_b_height(int val) { dialog_settings.clip_by = val; set_clip(); } + void set_clip_b_length(int val) { dialog_settings.clip_bz = val; set_clip(); } + void set_cap_width(int val) { dialog_settings.cap_x = val; set_cap(); } + void set_cap_height(int val) { dialog_settings.cap_y = val; set_cap(); } + void set_cap_length(int val) { dialog_settings.cap_z = val; set_cap(); } + void set_m1x(int val) { dialog_settings.M01x = val; set_custom(); } + void set_m1y(int val) { dialog_settings.M01y = val; set_custom(); } + void set_m1z(int val) { dialog_settings.M01z = val; set_custom(); } + void set_m2x(int val) { dialog_settings.M02x = val; set_custom(); } + void set_m2y(int val) { dialog_settings.M02y = val; set_custom(); } + void set_m2z(int val) { dialog_settings.M02z = val; set_custom(); } + void set_tx(int val) { settings.t_MH[0] = val; settings_changed(); } + void set_ty(int val) { settings.t_MH[1] = val; settings_changed(); } + void set_tz(int val) { settings.t_MH[2] = val; settings_changed(); } + void set_model(int model_id); + + void doCenter(); + void doReset(); + + void doOK(); + void doCancel(); + + void startstop_trans_calib(bool start); + + void poll_tracker_info(); + +protected: + void set_clip(); + void set_cap(); + void set_custom(); + + void settings_changed(); + + TrackerSettings settings; + TrackerDialogSettings dialog_settings; + bool settings_dirty; + + Tracker* tracker; + TranslationCalibrator trans_calib; + bool trans_calib_running; + QTimer timer; + Ui::UICPTClientControls ui; +}; + +#endif //FTNOIR_TRACKER_PT_DIALOG_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp new file mode 100644 index 00000000..7f58d77d --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.cpp @@ -0,0 +1,40 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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_pt_dll.h" + +#include + +//----------------------------------------------------------------------------- +void TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = "PointTracker 1.0"; +} + +void TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = "PointTracker"; +} + +void TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = "Tracks a 3-point model with know geometry like Freetrack / TrackIR"; +} + +void TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/Resources/icon.ico"); +} + + +//----------------------------------------------------------------------------- +#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +{ + return new TrackerDll; +} diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h new file mode 100644 index 00000000..15ad63aa --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_dll.h @@ -0,0 +1,19 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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_base\ftnoir_tracker_base.h" + +//----------------------------------------------------------------------------- +class TrackerDll : public ITrackerDll +{ + // ITrackerDll interface + void Initialize() {} + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); +}; \ No newline at end of file diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp new file mode 100644 index 00000000..40d1bc4f --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.cpp @@ -0,0 +1,150 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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_pt.h" +#include +#include + +//----------------------------------------------------------------------------- +void TrackerSettings::load_ini() +{ + qDebug("TrackerSettings::load_ini()"); + + 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( "PointTracker" ); + + cam_index = iniFile.value("CameraId", 0).toInt(); + cam_f = iniFile.value("CameraF", 1).toFloat(); + cam_res_x = iniFile.value("CameraResX", 640).toInt(); + cam_res_y = iniFile.value("CameraResY", 480).toInt(); + cam_fps = iniFile.value("CameraFPS", 30).toInt(); + cam_pitch = iniFile.value("CameraPitch", 0).toInt(); + threshold = iniFile.value("PointExtractThreshold", 128).toInt(); + min_point_size = iniFile.value("PointExtractMinSize", 2).toInt(); + max_point_size = iniFile.value("PointExtractMaxSize", 50).toInt(); + M01[0] = iniFile.value("PointModelM01x", 0).toFloat(); + M01[1] = iniFile.value("PointModelM01y", 40).toFloat(); + M01[2] = iniFile.value("PointModelM01z", -30).toFloat(); + M02[0] = iniFile.value("PointModelM02x", 0).toFloat(); + M02[1] = iniFile.value("PointModelM02y", -70).toFloat(); + M02[2] = iniFile.value("PointModelM02z", -80).toFloat(); + t_MH[0] = iniFile.value("tMHx", 0).toFloat(); + t_MH[1] = iniFile.value("tMHy", 0).toFloat(); + t_MH[2] = iniFile.value("tMHz", 0).toFloat(); + dyn_pose_res = iniFile.value("DynamicPoseResolution", true).toBool(); + video_widget = iniFile.value("VideoWidget", true).toBool(); + sleep_time = iniFile.value("SleepTime", 10).toInt(); + reset_time = iniFile.value("ResetTime", 1000).toInt(); + + bEnableRoll = iniFile.value( "EnableRoll", 1 ).toBool(); + bEnablePitch = iniFile.value( "EnablePitch", 1 ).toBool(); + bEnableYaw = iniFile.value( "EnableYaw", 1 ).toBool(); + bEnableX = iniFile.value( "EnableX", 1 ).toBool(); + bEnableY = iniFile.value( "EnableY", 1 ).toBool(); + bEnableZ = iniFile.value( "EnableZ", 1 ).toBool(); + + iniFile.endGroup(); +} + +void TrackerSettings::save_ini() const +{ + qDebug("TrackerSettings::save_ini()"); + + 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 ( "PointTracker" ); + + iniFile.setValue("CameraId", cam_index); + iniFile.setValue("CameraF", cam_f); + iniFile.setValue("CameraResX", cam_res_x); + iniFile.setValue("CameraResY", cam_res_y); + iniFile.setValue("CameraFPS", cam_fps); + iniFile.setValue("CameraPitch", cam_pitch); + iniFile.setValue("PointExtractThreshold", threshold); + iniFile.setValue("PointExtractMinSize", min_point_size); + iniFile.setValue("PointExtractMaxSize", max_point_size); + iniFile.setValue("PointModelM01x", M01[0]); + iniFile.setValue("PointModelM01y", M01[1]); + iniFile.setValue("PointModelM01z", M01[2]); + iniFile.setValue("PointModelM02x", M02[0]); + iniFile.setValue("PointModelM02y", M02[1]); + iniFile.setValue("PointModelM02z", M02[2]); + iniFile.setValue("tMHx", t_MH[0]); + iniFile.setValue("tMHy", t_MH[1]); + iniFile.setValue("tMHz", t_MH[2]); + iniFile.setValue("DynamicPoseResolution", dyn_pose_res); + iniFile.setValue("VideoWidget", video_widget); + iniFile.setValue("SleepTime", sleep_time); + iniFile.setValue("ResetTime", reset_time); + + iniFile.setValue( "EnableRoll", bEnableRoll ); + iniFile.setValue( "EnablePitch", bEnablePitch ); + iniFile.setValue( "EnableYaw", bEnableYaw ); + iniFile.setValue( "EnableX", bEnableX ); + iniFile.setValue( "EnableY", bEnableY ); + iniFile.setValue( "EnableZ", bEnableZ ); + + iniFile.endGroup(); +} + +//----------------------------------------------------------------------------- +void TrackerDialogSettings::load_ini() +{ + qDebug("TrackerDialogSettings::load_ini()"); + + 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( "PointTrackerDialog" ); + + active_model_panel = iniFile.value("ActiveModelPanel", MODEL_CLIP).toInt(); + M01x = iniFile.value("CustomM01x", 0).toInt(); + M01y = iniFile.value("CustomM01y", 40).toInt(); + M01z = iniFile.value("CustomM01z", -30).toInt(); + M02x = iniFile.value("CustomM02x", 0).toInt(); + M02y = iniFile.value("CustomM02y", -70).toInt(); + M02z = iniFile.value("CustomM02z", -80).toInt(); + clip_ty = iniFile.value("ClipTopHeight", 40).toInt(); + clip_tz = iniFile.value("ClipTopLength", 30).toInt(); + clip_by = iniFile.value("ClipBottomHeight", 70).toInt(); + clip_bz = iniFile.value("ClipBottomLength", 80).toInt(); + cap_x = iniFile.value("CapHalfWidth", 40).toInt(); + cap_y = iniFile.value("CapHeight", 60).toInt(); + cap_z = iniFile.value("CapLength", 100).toInt(); +} + +void TrackerDialogSettings::save_ini() const +{ + qDebug("TrackerDialogSettings::save_ini()"); + + 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 ( "PointTrackerDialog" ); + + iniFile.setValue("ActiveModelPanel", active_model_panel); + iniFile.setValue("CustomM01x", M01x); + iniFile.setValue("CustomM01y", M01y); + iniFile.setValue("CustomM01z", M01z); + iniFile.setValue("CustomM02x", M02x); + iniFile.setValue("CustomM02y", M02y); + iniFile.setValue("CustomM02z", M02z); + iniFile.setValue("ClipTopHeight", clip_ty); + iniFile.setValue("ClipTopLength", clip_tz); + iniFile.setValue("ClipBottomHeight", clip_by); + iniFile.setValue("ClipBottomLength", clip_bz); + iniFile.setValue("CapHalfWidth", cap_x); + iniFile.setValue("CapHeight", cap_y); + iniFile.setValue("CapLength", cap_z); +} \ No newline at end of file diff --git a/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h new file mode 100644 index 00000000..88162c86 --- /dev/null +++ b/ftnoir_tracker_pt/ftnoir_tracker_pt_settings.h @@ -0,0 +1,84 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef FTNOIR_TRACKER_PT_SETTINGS_H +#define FTNOIR_TRACKER_PT_SETTINGS_H + +#include +#include "point_tracker.h" + + +//----------------------------------------------------------------------------- +struct TrackerSettings +{ + // camera + int cam_index; + float cam_f; + int cam_res_x; + int cam_res_y; + int cam_fps; + int cam_pitch; + + // point extraction + int threshold; + int min_point_size; + int max_point_size; + + // point tracking + cv::Vec3f M01; + cv::Vec3f M02; + bool dyn_pose_res; + + // head to model translation + cv::Vec3f t_MH; + + int sleep_time; // in ms + int reset_time; // in ms + bool video_widget; + + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; + + void load_ini(); + void save_ini() const; +}; + + +//----------------------------------------------------------------------------- +struct TrackerDialogSettings +{ + enum + { + MODEL_CLIP, + MODEL_CAP, + MODEL_CUSTOM + }; + int active_model_panel; + + int M01x; + int M01y; + int M01z; + int M02x; + int M02y; + int M02z; + int clip_ty; + int clip_tz; + int clip_by; + int clip_bz; + int cap_x; + int cap_y; + int cap_z; + + void load_ini(); + void save_ini() const; +}; + +#endif //FTNOIR_TRACKER_PT_SETTINGS_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/point_extractor.cpp b/ftnoir_tracker_pt/point_extractor.cpp new file mode 100644 index 00000000..4aa1a658 --- /dev/null +++ b/ftnoir_tracker_pt/point_extractor.cpp @@ -0,0 +1,97 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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 "point_extractor.h" +#include + +using namespace cv; +using namespace std; + +// ---------------------------------------------------------------------------- +const vector& PointExtractor::extract_points(Mat frame, float dt, bool draw_output) +{ + /* + // sensitivity test for tracker + static int n = 0; + if (points.size() == 3) + { + for (int i=0; i<3; ++i) + { + points[i][0] -= 1e-4*sin(n/100.0); + points[i][1] -= 1e-4*cos(n/100.0); + } + ++n; + return points; + } + */ + + // convert to grayscale + Mat frame_bw; + cvtColor(frame, frame_bw, CV_RGB2GRAY); + + // convert to binary + threshold(frame_bw, frame_bw, threshold_val, 255, THRESH_BINARY); + //erode(frame_bw, frame_bw, Mat(), Point(-1,-1), min_size); //destroys information -> bad for subpixel accurarcy + + // find connected components... + // extract blobs with floodfill + struct BlobInfo + { + BlobInfo() : m00(0), m10(0), m01(0) {} + long m00; + long m10; + long m01; + }; + vector blobs; + int blob_count = 1; + + for (int y=0; y < frame_bw.rows; y++) { + for (int x=0; x < frame_bw.cols; x++) { + if (frame_bw.at(y,x) != 255) continue; + Rect rect; + floodFill(frame_bw, Point(x,y), Scalar(blob_count), &rect, Scalar(0), Scalar(0), 4); + BlobInfo blob; + for (int i=rect.y; i < (rect.y+rect.height); i++) { + for (int j=rect.x; j < (rect.x+rect.width); j++) { + if (frame_bw.at(i,j) != blob_count) continue; + blob.m00++; + blob.m01+=i; + blob.m10+=j; + } + } + blobs.push_back(blob); + blob_count++; + if (blob_count >= 255) break; + } + if (blob_count >= 255) break; + } + + // extract points + Vec2f c; + points.clear(); + float m00_min = 3.14*min_size*min_size; + float m00_max = 3.14*max_size*max_size; + for (vector::iterator iter = blobs.begin(); + iter!= blobs.end(); + ++iter) + { + const BlobInfo& m = *iter; + if (m.m00 < m00_min || m.m00 > m00_max) continue; + // convert to centered camera coordinate system with y axis upwards + c[0] = (m.m10/float(m.m00) - frame.cols/2)/frame.cols; + c[1] = -(m.m01/float(m.m00) - frame.rows/2)/frame.cols; + points.push_back(c); + } + + // draw output image + if (draw_output) + { + frame.setTo(Scalar(255,0,0), frame_bw); + } + + return points; +} diff --git a/ftnoir_tracker_pt/point_extractor.h b/ftnoir_tracker_pt/point_extractor.h new file mode 100644 index 00000000..b142d2bb --- /dev/null +++ b/ftnoir_tracker_pt/point_extractor.h @@ -0,0 +1,31 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef POINTEXTRACTOR_H +#define POINTEXTRACTOR_H + +#include + +// ---------------------------------------------------------------------------- +// Extracts points from an opencv image +class PointExtractor +{ +public: + // extracts points from frame and draws some processing info into frame, if draw_output is set + // dt: time since last call in seconds + // WARNING: returned reference is valid as long as object + const std::vector& extract_points(cv::Mat frame, float dt, bool draw_output); + const std::vector& get_points() { return points; } + + int threshold_val; + int min_size, max_size; + +protected: + std::vector points; +}; + +#endif //POINTEXTRACTOR_H diff --git a/ftnoir_tracker_pt/point_tracker.cpp b/ftnoir_tracker_pt/point_tracker.cpp new file mode 100644 index 00000000..d617de19 --- /dev/null +++ b/ftnoir_tracker_pt/point_tracker.cpp @@ -0,0 +1,352 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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 "point_tracker.h" + +#include +#include +#include + +#include + +using namespace cv; +using namespace boost; +using namespace std; + +const float PI = 3.14159265358979323846f; + +// ---------------------------------------------------------------------------- +static void get_row(const Matx33f& m, int i, Vec3f& v) +{ + v[0] = m(i,0); + v[1] = m(i,1); + v[2] = m(i,2); +} + +static void set_row(Matx33f& m, int i, const Vec3f& v) +{ + m(i,0) = v[0]; + m(i,1) = v[1]; + m(i,2) = v[2]; +} + +// ---------------------------------------------------------------------------- +PointModel::PointModel(Vec3f M01, Vec3f M02) + : M01(M01), M02(M02) +{ + // calculate u + u = M01.cross(M02); + u /= norm(u); + + // calculate projection matrix on M01,M02 plane + float s11 = M01.dot(M01); + float s12 = M01.dot(M02); + float s22 = M02.dot(M02); + P = 1.0/(s11*s22-s12*s12) * Matx22f(s22, -s12, + -s12, s11); + + // calculate d and d_order for simple freetrack-like point correspondence + vector points; + points.push_back(Vec2f(0,0)); + points.push_back(Vec2f(M01[0], M01[1])); + points.push_back(Vec2f(M02[0], M02[1])); + // fit line to orthographically projected points + // ERROR: yields wrong results with colinear points?! + /* + Vec4f line; + fitLine(points, line, CV_DIST_L2, 0, 0.01, 0.01); + d[0] = line[0]; d[1] = line[1]; + */ + // TODO: fix this + d = Vec2f(M01[0]-M02[0], M01[1]-M02[1]); + + // sort model points + get_d_order(points, d_order); +} + +void PointModel::get_d_order(const std::vector& points, int d_order[]) const +{ + // get sort indices with respect to d scalar product + vector< pair > d_vals; + for (int i = 0; i(d.dot(points[i]), i)); + + struct + { + bool operator()(const pair& a, const pair& b) { return a.first < b.first; } + } comp; + sort(d_vals.begin(), d_vals.end(), comp); + + for (int i = 0; i& points, float f, float dt) +{ + if (!dynamic_pose_resolution) init_phase = true; + + dt_valid += dt; + // if there was no valid tracking result for too long, do a reset + if (dt_valid > dt_reset) + { + //qDebug()<<"dt_valid "< dt_reset "<& points, float f) +{ + if (init_phase) { + // We do a simple freetrack-like sorting in the init phase... + // sort points + int point_d_order[PointModel::N_POINTS]; + point_model->get_d_order(points, point_d_order); + + // set correspondences + for (int i=0; id_order[i]] = points[point_d_order[i]]; + } + } + else { + // ... otherwise we look at the distance to the projection of the expected model points + // project model points under current pose + p_exp[0] = project(Vec3f(0,0,0), f); + p_exp[1] = project(point_model->M01, f); + p_exp[2] = project(point_model->M02, f); + + // set correspondences by minimum distance to projected model point + bool point_taken[PointModel::N_POINTS]; + for (int i=0; iM01)/Z0; + epsilon_2 = k.dot(point_model->M02)/Z0; + + // vector of scalar products and + Vec2f I0_M0i(p[1][0]*(1.0 + epsilon_1) - p[0][0], + p[2][0]*(1.0 + epsilon_2) - p[0][0]); + Vec2f J0_M0i(p[1][1]*(1.0 + epsilon_1) - p[0][1], + p[2][1]*(1.0 + epsilon_2) - p[0][1]); + + // construct projection of I, J onto M0i plane: I0 and J0 + I0_coeff = point_model->P * I0_M0i; + J0_coeff = point_model->P * J0_M0i; + I0 = I0_coeff[0]*point_model->M01 + I0_coeff[1]*point_model->M02; + J0 = J0_coeff[0]*point_model->M01 + J0_coeff[1]*point_model->M02; + + // calculate u component of I, J + float II0 = I0.dot(I0); + float IJ0 = I0.dot(J0); + float JJ0 = J0.dot(J0); + float rho, theta; + if (JJ0 == II0) { + rho = sqrt(abs(2*IJ0)); + theta = -PI/4; + if (IJ0<0) theta *= -1; + } + else { + rho = sqrt(sqrt( (JJ0-II0)*(JJ0-II0) + 4*IJ0*IJ0 )); + theta = atan( -2*IJ0 / (JJ0-II0) ); + if (JJ0 - II0 < 0) theta += PI; + theta /= 2; + } + + // construct the two solutions + I_1 = I0 + rho*cos(theta)*point_model->u; + I_2 = I0 - rho*cos(theta)*point_model->u; + + J_1 = J0 + rho*sin(theta)*point_model->u; + J_2 = J0 - rho*sin(theta)*point_model->u; + + float norm_const = 1.0/norm(I_1); // all have the same norm + + // create rotation matrices + I_1 *= norm_const; J_1 *= norm_const; + I_2 *= norm_const; J_2 *= norm_const; + + set_row(R_1, 0, I_1); + set_row(R_1, 1, J_1); + set_row(R_1, 2, I_1.cross(J_1)); + + set_row(R_2, 0, I_2); + set_row(R_2, 1, J_2); + set_row(R_2, 2, I_2.cross(J_2)); + + // the single translation solution + Z0 = norm_const * f; + + // pick the rotation solution closer to the expected one + // in simple metric d(A,B) = || I - A * B^T || + float R_1_deviation = norm(Matx33f::eye() - R_expected * R_1.t()); + float R_2_deviation = norm(Matx33f::eye() - R_expected * R_2.t()); + + if (R_1_deviation < R_2_deviation) + R_current = &R_1; + else + R_current = &R_2; + + get_row(*R_current, 2, k); + + // check for convergence condition + if (abs(epsilon_1 - old_epsilon_1) + abs(epsilon_2 - old_epsilon_2) < EPS_THRESHOLD) + break; + old_epsilon_1 = epsilon_1; + old_epsilon_2 = epsilon_2; + } + + // apply results + X_CM.R = *R_current; + X_CM.t[0] = p[0][0] * Z0/f; + X_CM.t[1] = p[0][1] * Z0/f; + X_CM.t[2] = Z0; + + return i; + + //Rodrigues(X_CM.R, r); + //qDebug()<<"iter: "< +#include +#include + +// ---------------------------------------------------------------------------- +// Afine frame trafo +class FrameTrafo +{ +public: + FrameTrafo() : R(cv::Matx33f::eye()), t(0,0,0) {} + FrameTrafo(const cv::Matx33f& R, const cv::Vec3f& t) : R(R),t(t) {} + + cv::Matx33f R; + cv::Vec3f t; +}; + +inline FrameTrafo operator*(const FrameTrafo& X, const FrameTrafo& Y) +{ + return FrameTrafo(X.R*Y.R, X.R*Y.t + X.t); +} + +inline cv::Vec3f operator*(const FrameTrafo& X, const cv::Vec3f& v) +{ + return X.R*v + X.t; +} + +// ---------------------------------------------------------------------------- +// Describes a 3-point model +// nomenclature as in +// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] +class PointModel +{ + friend class PointTracker; +public: + static const int N_POINTS = 3; + + PointModel(cv::Vec3f M01, cv::Vec3f M02); + + const cv::Vec3f& get_M01() const { return M01; }; + const cv::Vec3f& get_M02() const { return M02; }; + +protected: + cv::Vec3f M01; // M01 in model frame + cv::Vec3f M02; // M02 in model frame + + cv::Vec3f u; // unit vector perpendicular to M01,M02-plane + + cv::Matx22f P; + + cv::Vec2f d; // discrimant vector for point correspondence + int d_order[3]; // sorting of projected model points with respect to d scalar product + + void get_d_order(const std::vector& points, int d_order[]) const; +}; + +// ---------------------------------------------------------------------------- +// Tracks a 3-point model +// implementing the POSIT algorithm for coplanar points as presented in +// [Denis Oberkampf, Daniel F. DeMenthon, Larry S. Davis: "Iterative Pose Estimation Using Coplanar Feature Points"] +class PointTracker +{ +public: + PointTracker(); + + // track the pose using the set of normalized point coordinates (x pos in range -0.5:0.5) + // f : (focal length)/(sensor width) + // dt : time since last call + bool track(const std::vector& points, float f, float dt); + boost::shared_ptr point_model; + + bool dynamic_pose_resolution; + float dt_reset; + + FrameTrafo get_pose() const { return X_CM; } + void reset(); + +protected: + inline cv::Vec2f project(const cv::Vec3f& v_M, float f) + { + cv::Vec3f v_C = X_CM * v_M; + return cv::Vec2f(f*v_C[0]/v_C[2], f*v_C[1]/v_C[2]); + } + + bool find_correspondences(const std::vector& points, float f); + + cv::Vec2f p[PointModel::N_POINTS]; // the points in model order + cv::Vec2f p_exp[PointModel::N_POINTS]; // the expected point positions + + void predict(float dt); + void update_velocities(float dt); + void reset_velocities(); + + + int POSIT(float f); // The POSIT algorithm, returns the number of iterations + + bool init_phase; + float dt_valid; // time since last valid tracking result + cv::Vec3f v_t; // velocities + cv::Vec3f v_r; + FrameTrafo X_CM; // trafo from model to camera + FrameTrafo X_CM_old; +}; + +#endif //POINTTRACKER_H diff --git a/ftnoir_tracker_pt/resource.h b/ftnoir_tracker_pt/resource.h new file mode 100644 index 00000000..c14e94ad --- /dev/null +++ b/ftnoir_tracker_pt/resource.h @@ -0,0 +1,14 @@ +//{{NO_DEPENDENCIES}} +// Microsoft Visual C++ generated include file. +// Used by FTNoIR_Tracker_PT.rc + +// Next default values for new objects +// +#ifdef APSTUDIO_INVOKED +#ifndef APSTUDIO_READONLY_SYMBOLS +#define _APS_NEXT_RESOURCE_VALUE 101 +#define _APS_NEXT_COMMAND_VALUE 40001 +#define _APS_NEXT_CONTROL_VALUE 1001 +#define _APS_NEXT_SYMED_VALUE 101 +#endif +#endif diff --git a/ftnoir_tracker_pt/timer.cpp b/ftnoir_tracker_pt/timer.cpp new file mode 100644 index 00000000..363b5b09 --- /dev/null +++ b/ftnoir_tracker_pt/timer.cpp @@ -0,0 +1,66 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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 "timer.h" + +#include + +// ---------------------------------------------------------------------------- +Timer::Timer() +: startTime(0), endTime(0), running(false) +{ +#ifdef WIN32 + QueryPerformanceFrequency(&frequency); + startCount.QuadPart = 0; + endCount.QuadPart = 0; +#else + startCount.tv_sec = startCount.tv_usec = 0; + endCount.tv_sec = endCount.tv_usec = 0; +#endif +} + + +void Timer::start() +{ +#ifdef WIN32 + QueryPerformanceCounter(&startCount); +#else + gettimeofday(&startCount, NULL); +#endif + running = true; +} + + +void Timer::stop() +{ +#ifdef WIN32 + QueryPerformanceCounter(&endCount); +#else + gettimeofday(&endCount, NULL); +#endif + running = false; +} + + +double Timer::elapsed() +{ +#ifdef WIN32 + if (running) + QueryPerformanceCounter(&endCount); + + startTime = startCount.QuadPart * (1e3 / frequency.QuadPart); + endTime = endCount.QuadPart * (1e3 / frequency.QuadPart); +#else + if(!stopped) + gettimeofday(&endCount, NULL); + + startTime = (startCount.tv_sec * 1e3) + startCount.tv_usec; + endTime = (endCount.tv_sec * 1e3) + endCount.tv_usec; +#endif + + return endTime - startTime; +} \ No newline at end of file diff --git a/ftnoir_tracker_pt/timer.h b/ftnoir_tracker_pt/timer.h new file mode 100644 index 00000000..2aaf725a --- /dev/null +++ b/ftnoir_tracker_pt/timer.h @@ -0,0 +1,44 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef PT_TIMER_H +#define PT_TIMER_H + +#ifdef WIN32 // Windows system specific +#include +#else // Unix based system specific +#include +#endif + +// ---------------------------------------------------------------------------- +// high resolution timer based on http://www.songho.ca/misc/timer/timer.html +class Timer +{ +public: + Timer(); + + void start(); + void stop(); + void restart() { start(); } // for Qt compatibility + double elapsed(); // get elapsed time in ms + +protected: + double startTime; // starting time in ms + double endTime; // ending time in ms + bool running; + +#ifdef WIN32 + LARGE_INTEGER frequency; // ticks per second + LARGE_INTEGER startCount; + LARGE_INTEGER endCount; +#else + timeval startCount; + timeval endCount; +#endif +}; + +#endif //PT_TIMER_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/trans_calib.cpp b/ftnoir_tracker_pt/trans_calib.cpp new file mode 100644 index 00000000..9b75a1b6 --- /dev/null +++ b/ftnoir_tracker_pt/trans_calib.cpp @@ -0,0 +1,44 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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 "trans_calib.h" + +using namespace cv; + +//----------------------------------------------------------------------------- +TranslationCalibrator::TranslationCalibrator() +{ + reset(); +} + +void TranslationCalibrator::reset() +{ + P = Matx66f::zeros(); + y = Vec6f(0,0,0, 0,0,0); +} + +void TranslationCalibrator::update(const Matx33f& R_CM_k, const Vec3f& t_CM_k) +{ + Matx H_k_T = Matx::zeros(); + for (int i=0; i<3; ++i) { + for (int j=0; j<3; ++j) { + H_k_T(i,j) = R_CM_k(j,i); + } + } + for (int i=0; i<3; ++i) + { + H_k_T(3+i,i) = 1.0; + } + P += H_k_T * H_k_T.t(); + y += H_k_T * t_CM_k; +} + +Vec3f TranslationCalibrator::get_estimate() +{ + Vec6f x = P.inv() * y; + return Vec3f(-x[0], -x[1], -x[2]); +} \ No newline at end of file diff --git a/ftnoir_tracker_pt/trans_calib.h b/ftnoir_tracker_pt/trans_calib.h new file mode 100644 index 00000000..4024d011 --- /dev/null +++ b/ftnoir_tracker_pt/trans_calib.h @@ -0,0 +1,39 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef TRANSCALIB_H +#define TRANSCALIB_H + +#include + +//----------------------------------------------------------------------------- +// calibrates the translation from head to model = t_MH +// by recursive least squares / +// kalman filter in information form with identity noise covariance +// measurement equation when head position = t_CH is fixed: +// (R_CM_k , Id)*(-t_MH, t_CH) = t_CM_k + +class TranslationCalibrator +{ +public: + TranslationCalibrator(); + + // reset the calibration process + void reset(); + + // update the current estimate + void update(const cv::Matx33f& R_CM_k, const cv::Vec3f& t_CM_k); + + // get the current estimate for t_MH + cv::Vec3f get_estimate(); + +protected: + cv::Matx66f P; // normalized precision matrix = inverse covariance + cv::Vec6f y; // P*(-t_MH, t_CH) +}; + +#endif //TRANSCALIB_H \ No newline at end of file diff --git a/ftnoir_tracker_pt/videoInput/videoInput.h b/ftnoir_tracker_pt/videoInput/videoInput.h new file mode 100644 index 00000000..4244902c --- /dev/null +++ b/ftnoir_tracker_pt/videoInput/videoInput.h @@ -0,0 +1,385 @@ +#ifndef _VIDEOINPUT +#define _VIDEOINPUT + +//THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +//IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +//FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +//AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +//LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +//OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +//THE SOFTWARE. + +////////////////////////////////////////////////////////// +//Written by Theodore Watson - theo.watson@gmail.com // +//Do whatever you want with this code but if you find // +//a bug or make an improvement I would love to know! // +// // +//Warning This code is experimental // +//use at your own risk :) // +////////////////////////////////////////////////////////// +///////////////////////////////////////////////////////// +/* Shoutouts + +Thanks to: + + Dillip Kumar Kara for crossbar code. + Zachary Lieberman for getting me into this stuff + and for being so generous with time and code. + The guys at Potion Design for helping me with VC++ + Josh Fisher for being a serious C++ nerd :) + Golan Levin for helping me debug the strangest + and slowest bug in the world! + + And all the people using this library who send in + bugs, suggestions and improvements who keep me working on + the next version - yeah thanks a lot ;) + +*/ +///////////////////////////////////////////////////////// + + + +#include +#include +#include +#include +#include + +//this is for TryEnterCriticalSection +#ifndef _WIN32_WINNT + # define _WIN32_WINNT 0x400 +#endif +#include + + +//Example Usage +/* + //create a videoInput object + videoInput VI; + + //Prints out a list of available devices and returns num of devices found + int numDevices = VI.listDevices(); + + int device1 = 0; //this could be any deviceID that shows up in listDevices + int device2 = 1; //this could be any deviceID that shows up in listDevices + + //if you want to capture at a different frame rate (default is 30) + //specify it here, you are not guaranteed to get this fps though. + //VI.setIdealFramerate(dev, 60); + + //setup the first device - there are a number of options: + + VI.setupDevice(device1); //setup the first device with the default settings + //VI.setupDevice(device1, VI_COMPOSITE); //or setup device with specific connection type + //VI.setupDevice(device1, 320, 240); //or setup device with specified video size + //VI.setupDevice(device1, 320, 240, VI_COMPOSITE); //or setup device with video size and connection type + + //VI.setFormat(device1, VI_NTSC_M); //if your card doesn't remember what format it should be + //call this with the appropriate format listed above + //NOTE: must be called after setupDevice! + + //optionally setup a second (or third, fourth ...) device - same options as above + VI.setupDevice(device2); + + //As requested width and height can not always be accomodated + //make sure to check the size once the device is setup + + int width = VI.getWidth(device1); + int height = VI.getHeight(device1); + int size = VI.getSize(device1); + + unsigned char * yourBuffer1 = new unsigned char[size]; + unsigned char * yourBuffer2 = new unsigned char[size]; + + //to get the data from the device first check if the data is new + if(VI.isFrameNew(device1)){ + VI.getPixels(device1, yourBuffer1, false, false); //fills pixels as a BGR (for openCV) unsigned char array - no flipping + VI.getPixels(device1, yourBuffer2, true, true); //fills pixels as a RGB (for openGL) unsigned char array - flipping! + } + + //same applies to device2 etc + + //to get a settings dialog for the device + VI.showSettingsWindow(device1); + + + //Shut down devices properly + VI.stopDevice(device1); + VI.stopDevice(device2); +*/ + + +////////////////////////////////////// VARS AND DEFS ////////////////////////////////// + + +//STUFF YOU CAN CHANGE + +//change for verbose debug info +static bool verbose = true; + +//if you need VI to use multi threaded com +//#define VI_COM_MULTI_THREADED + +//STUFF YOU DON'T CHANGE + +//videoInput defines +#define VI_VERSION 0.1995 +#define VI_MAX_CAMERAS 20 +#define VI_NUM_TYPES 18 //DON'T TOUCH +#define VI_NUM_FORMATS 18 //DON'T TOUCH + +//defines for setPhyCon - tuner is not as well supported as composite and s-video +#define VI_COMPOSITE 0 +#define VI_S_VIDEO 1 +#define VI_TUNER 2 +#define VI_USB 3 +#define VI_1394 4 + +//defines for formats +#define VI_NTSC_M 0 +#define VI_PAL_B 1 +#define VI_PAL_D 2 +#define VI_PAL_G 3 +#define VI_PAL_H 4 +#define VI_PAL_I 5 +#define VI_PAL_M 6 +#define VI_PAL_N 7 +#define VI_PAL_NC 8 +#define VI_SECAM_B 9 +#define VI_SECAM_D 10 +#define VI_SECAM_G 11 +#define VI_SECAM_H 12 +#define VI_SECAM_K 13 +#define VI_SECAM_K1 14 +#define VI_SECAM_L 15 +#define VI_NTSC_M_J 16 +#define VI_NTSC_433 17 + + +//allows us to directShow classes here with the includes in the cpp +struct ICaptureGraphBuilder2; +struct IGraphBuilder; +struct IBaseFilter; +struct IAMCrossbar; +struct IMediaControl; +struct ISampleGrabber; +struct IMediaEventEx; +struct IAMStreamConfig; +struct _AMMediaType; +class SampleGrabberCallback; +typedef _AMMediaType AM_MEDIA_TYPE; + +//keeps track of how many instances of VI are being used +//don't touch +static int comInitCount = 0; + + +//////////////////////////////////////// VIDEO DEVICE /////////////////////////////////// + +class videoDevice{ + + + public: + + videoDevice(); + void setSize(int w, int h); + void NukeDownstream(IBaseFilter *pBF); + void destroyGraph(); + ~videoDevice(); + + int videoSize; + int width; + int height; + int tryWidth; + int tryHeight; + + ICaptureGraphBuilder2 *pCaptureGraph; // Capture graph builder object + IGraphBuilder *pGraph; // Graph builder object + IMediaControl *pControl; // Media control object + IBaseFilter *pVideoInputFilter; // Video Capture filter + IBaseFilter *pGrabberF; + IBaseFilter * pDestFilter; + IAMStreamConfig *streamConf; + ISampleGrabber * pGrabber; // Grabs frame + AM_MEDIA_TYPE * pAmMediaType; + + IMediaEventEx * pMediaEvent; + + GUID videoType; + long formatType; + + SampleGrabberCallback * sgCallback; + + bool tryDiffSize; + bool useCrossbar; + bool readyToCapture; + bool sizeSet; + bool setupStarted; + bool specificFormat; + bool autoReconnect; + int nFramesForReconnect; + unsigned long nFramesRunning; + int connection; + int storeConn; + int myID; + long requestedFrameTime; //ie fps + + char nDeviceName[255]; + WCHAR wDeviceName[255]; + + unsigned char * pixels; + char * pBuffer; + +}; + + + + +////////////////////////////////////// VIDEO INPUT ///////////////////////////////////// + + + +class videoInput{ + + public: + videoInput(); + ~videoInput(); + + //turns off console messages - default is to print messages + static void setVerbose(bool _verbose); + + //Functions in rough order they should be used. + static int listDevices(bool silent = false); + + //needs to be called after listDevices - otherwise returns NULL + static char * getDeviceName(int deviceID); + + //choose to use callback based capture - or single threaded + void setUseCallback(bool useCallback); + + //call before setupDevice + //directshow will try and get the closest possible framerate to what is requested + void setIdealFramerate(int deviceID, int idealFramerate); + + //some devices will stop delivering frames after a while - this method gives you the option to try and reconnect + //to a device if videoInput detects that a device has stopped delivering frames. + //you MUST CALL isFrameNew every app loop for this to have any effect + void setAutoReconnectOnFreeze(int deviceNumber, bool doReconnect, int numMissedFramesBeforeReconnect); + + //Choose one of these four to setup your device + bool setupDevice(int deviceID); + bool setupDevice(int deviceID, int w, int h); + + //These two are only for capture cards + //USB and Firewire cameras souldn't specify connection + bool setupDevice(int deviceID, int connection); + bool setupDevice(int deviceID, int w, int h, int connection); + + //If you need to you can set your NTSC/PAL/SECAM + //preference here. if it is available it will be used. + //see #defines above for available formats - eg VI_NTSC_M or VI_PAL_B + //should be called after setupDevice + //can be called multiple times + bool setFormat(int deviceNumber, int format); + + //Tells you when a new frame has arrived - you should call this if you have specified setAutoReconnectOnFreeze to true + bool isFrameNew(int deviceID); + + bool isDeviceSetup(int deviceID); + + //Returns the pixels - flipRedAndBlue toggles RGB/BGR flipping - and you can flip the image too + unsigned char * getPixels(int deviceID, bool flipRedAndBlue = true, bool flipImage = false); + + //Or pass in a buffer for getPixels to fill returns true if successful. + bool getPixels(int id, unsigned char * pixels, bool flipRedAndBlue = true, bool flipImage = false); + + //Launches a pop up settings window + //For some reason in GLUT you have to call it twice each time. + void showSettingsWindow(int deviceID); + + //Manual control over settings thanks..... + //These are experimental for now. + bool setVideoSettingFilter(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); + bool setVideoSettingFilterPct(int deviceID, long Property, float pctValue, long Flags = NULL); + bool getVideoSettingFilter(int deviceID, long Property, long &min, long &max, long &SteppingDelta, long ¤tValue, long &flags, long &defaultValue); + + bool setVideoSettingCamera(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); + bool setVideoSettingCameraPct(int deviceID, long Property, float pctValue, long Flags = NULL); + bool getVideoSettingCamera(int deviceID, long Property, long &min, long &max, long &SteppingDelta, long ¤tValue, long &flags, long &defaultValue); + + //bool setVideoSettingCam(int deviceID, long Property, long lValue, long Flags = NULL, bool useDefaultValue = false); + + //get width, height and number of pixels + int getWidth(int deviceID); + int getHeight(int deviceID); + int getSize(int deviceID); + + //completely stops and frees a device + void stopDevice(int deviceID); + + //as above but then sets it up with same settings + bool restartDevice(int deviceID); + + //number of devices available + int devicesFound; + + long propBrightness; + long propContrast; + long propHue; + long propSaturation; + long propSharpness; + long propGamma; + long propColorEnable; + long propWhiteBalance; + long propBacklightCompensation; + long propGain; + + long propPan; + long propTilt; + long propRoll; + long propZoom; + long propExposure; + long propIris; + long propFocus; + + + private: + void setPhyCon(int deviceID, int conn); + void setAttemptCaptureSize(int deviceID, int w, int h); + bool setup(int deviceID); + void processPixels(unsigned char * src, unsigned char * dst, int width, int height, bool bRGB, bool bFlip); + int start(int deviceID, videoDevice * VD); + int getDeviceCount(); + void getMediaSubtypeAsString(GUID type, char * typeAsString); + + HRESULT getDevice(IBaseFilter **pSrcFilter, int deviceID, WCHAR * wDeviceName, char * nDeviceName); + static HRESULT ShowFilterPropertyPages(IBaseFilter *pFilter); + HRESULT SaveGraphFile(IGraphBuilder *pGraph, WCHAR *wszPath); + HRESULT routeCrossbar(ICaptureGraphBuilder2 **ppBuild, IBaseFilter **pVidInFilter, int conType, GUID captureMode); + + //don't touch + static bool comInit(); + static bool comUnInit(); + + int connection; + int callbackSetCount; + bool bCallback; + + GUID CAPTURE_MODE; + + //Extra video subtypes + GUID MEDIASUBTYPE_Y800; + GUID MEDIASUBTYPE_Y8; + GUID MEDIASUBTYPE_GREY; + + videoDevice * VDList[VI_MAX_CAMERAS]; + GUID mediaSubtypes[VI_NUM_TYPES]; + long formatTypes[VI_NUM_FORMATS]; + + static void __cdecl basicThread(void * objPtr); + + static char deviceNames[VI_MAX_CAMERAS][255]; + +}; + + #endif diff --git a/ftnoir_tracker_pt/videoInput/videoInput_vc8.lib b/ftnoir_tracker_pt/videoInput/videoInput_vc8.lib new file mode 100644 index 00000000..15ca9cf3 Binary files /dev/null and b/ftnoir_tracker_pt/videoInput/videoInput_vc8.lib differ diff --git a/ftnoir_tracker_pt/videoInput/videoInput_vc9.lib b/ftnoir_tracker_pt/videoInput/videoInput_vc9.lib new file mode 100644 index 00000000..32637cc9 Binary files /dev/null and b/ftnoir_tracker_pt/videoInput/videoInput_vc9.lib differ diff --git a/ftnoir_tracker_pt/video_widget.cpp b/ftnoir_tracker_pt/video_widget.cpp new file mode 100644 index 00000000..c2b41da1 --- /dev/null +++ b/ftnoir_tracker_pt/video_widget.cpp @@ -0,0 +1,98 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + * + * 20130312, WVR: Add 7 lines to resizeGL after resize_frame. This should lower CPU-load. + */ + +#include "video_widget.h" + +#include + +using namespace cv; +using namespace std; +using namespace boost; + +// ---------------------------------------------------------------------------- +void VideoWidget::initializeGL() +{ + glClearColor(0.0, 0.0, 0.0, 0.0); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void VideoWidget::resizeGL(int w, int h) +{ + // setup 1 to 1 projection + glViewport(0, 0, w, h); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + glOrtho(0, w, 0, h, -1, 1); + resize_frame(); + glDisable(GL_DEPTH_TEST); + glBegin(GL_QUADS); + glVertex2f(0,0); + glVertex2f(1,0); + glVertex2f(1,1); + glVertex2f(0,1); + glEnd(); +} + +void VideoWidget::paintGL() +{ + glClear(GL_COLOR_BUFFER_BIT); + if (!resized_qframe.isNull()) + { + glDrawPixels(resized_qframe.width(), resized_qframe.height(), GL_RGBA, GL_UNSIGNED_BYTE, resized_qframe.bits()); + + const int crosshair_radius = 10; + const int crosshair_thickness = 1; + + glColor3f(1.0, 0.0, 0.0); + glLineWidth(crosshair_thickness); + int x,y; + for (vector::iterator iter = points->begin(); + iter != points->end(); + ++iter) + { + x = (*iter)[0] * resized_qframe.width() + resized_qframe.width()/2.0 + 0.5; + y = (*iter)[1] * resized_qframe.width() + resized_qframe.height()/2.0 + 0.5; + + glBegin(GL_LINES); + glVertex2i(x-crosshair_radius, y); + glVertex2i(x+crosshair_radius, y); + glEnd(); + glBegin(GL_LINES); + glVertex2i(x, y-crosshair_radius); + glVertex2i(x, y+crosshair_radius); + glEnd(); + } + } + glFlush(); +} + + +void VideoWidget::resize_frame() +{ + if (!qframe.isNull()) + resized_qframe = qframe.scaled(this->size(), Qt::KeepAspectRatio); +} + + +void VideoWidget::update(Mat frame, shared_ptr< vector > points) +{ + this->frame = frame; + this->points = points; + + // convert to QImage + if (frame.channels() == 3) + qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_RGB888).rgbSwapped(); + else if (frame.channels() == 1) + qframe = QImage((const unsigned char*)(frame.data), frame.cols, frame.rows, frame.step, QImage::Format_Indexed8); + qframe = QGLWidget::convertToGLFormat(qframe); + + resize_frame(); + updateGL(); +} diff --git a/ftnoir_tracker_pt/video_widget.h b/ftnoir_tracker_pt/video_widget.h new file mode 100644 index 00000000..f49fef18 --- /dev/null +++ b/ftnoir_tracker_pt/video_widget.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2012 Patrick Ruoff + * + * 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. + */ + +#ifndef VIDEOWIDGET_H +#define VIDEOWIDGET_H + +#include +#include +#include +#include + +// ---------------------------------------------------------------------------- +class VideoWidget : public QGLWidget +{ + Q_OBJECT + +public: + VideoWidget(QWidget *parent) : QGLWidget(parent) {} + + void initializeGL(); + void resizeGL(int w, int h); + void paintGL(); + + void update(cv::Mat frame, boost::shared_ptr< std::vector > points); + +private: + void resize_frame(); + + cv::Mat frame; + QImage qframe; + QImage resized_qframe; + + boost::shared_ptr< std::vector > points; +}; + +#endif // VIDEOWIDGET_H diff --git a/ftnoir_tracker_sm/FTNoIR_SM_Controls.ui b/ftnoir_tracker_sm/FTNoIR_SM_Controls.ui new file mode 100644 index 00000000..93befd19 --- /dev/null +++ b/ftnoir_tracker_sm/FTNoIR_SM_Controls.ui @@ -0,0 +1,405 @@ + + + UICSMClientControls + + + + 0 + 0 + 388 + 313 + + + + faceAPI tracker settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + + 100 + 0 + + + + wait... + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Camera + + + + + + + Start + + + + + + + Stop + + + + + + + Engine state: + + + + + + + Internal filtering: + + + + + + + + + + + + + 0 + 140 + + + + Enable Axis + + + + + 10 + 20 + 55 + 110 + + + + + + + Roll: + + + + + + + Pitch: + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + X: + + + + + + + Y: + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 100 + 16777215 + + + + Save + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 70 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_sm/FTNoIR_Tracker_SM.h b/ftnoir_tracker_sm/FTNoIR_Tracker_SM.h new file mode 100644 index 00000000..b7aed1d0 --- /dev/null +++ b/ftnoir_tracker_sm/FTNoIR_Tracker_SM.h @@ -0,0 +1,157 @@ +/******************************************************************************** +* 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" + +#include +#include +#include +#include "Windows.h" +#include "math.h" + +using namespace std; + +class FTNoIR_Tracker : public ITracker +{ +public: + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); + + void Initialize( QFrame *videoframe ); + void StartTracker( HWND parent_window ); + void StopTracker( bool exit ); + bool GiveHeadPoseData(THeadPoseData *data); // Returns true if confidence is good + + void loadSettings(); + bool SMCreateMapping(); + +private: + // + // global variables + // + HANDLE hSMMemMap; + SMMemMap *pMemData; + HANDLE hSMMutex; + QProcess *faceAPI; + +// int numTracker; + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; +}; + +// Widget that has controls for SMoIR protocol client-settings. +class TrackerControls: public QWidget, Ui::UICSMClientControls, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + virtual ~TrackerControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) { + theTracker = (FTNoIR_Tracker *) tracker; // Accept the pointer to the Tracker + }; + void unRegisterTracker() { + theTracker = NULL; // Reset the pointer + }; + +private: + Ui::UICSMClientControls ui; + void loadSettings(); + bool SMCreateMapping(); + void doCommand( int command ); + void doCommand( int command, int value ); + + /** helper **/ + bool settingsDirty; + int prev_state; // Previous engine state + + // + // global variables + // + HANDLE hSMMemMap; + SMMemMap *pMemData; + HANDLE hSMMutex; + smEngineHandle *engine_handle; + QTimer *timUpdateSettings; // Timer to display current settings + + FTNoIR_Tracker *theTracker; + +private slots: + void doOK(); + void doCancel(); + void save(); + void settingChanged() { settingsDirty = true; }; + void doTimUpdate(); + void showSettings( int newState ); + void doStartEngine(){ + doCommand(FT_SM_START); + } + void doStopEngine(){ + doCommand(FT_SM_STOP); + } + void doShowCam(){ + doCommand(FT_SM_SHOW_CAM); + } + void doSetFilter(int value){ + doCommand(FT_SM_SET_PAR_FILTER, value); + } + void settingChanged(int dummy) { + settingsDirty = true; + }; + +signals: + void stateChanged(int newState); + +}; + +//******************************************************************************************************* +// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker +//******************************************************************************************************* +class FTNoIR_TrackerDll : public ITrackerDll +{ +public: + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + + void Initialize(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; +}; diff --git a/ftnoir_tracker_sm/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user b/ftnoir_tracker_sm/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user new file mode 100644 index 00000000..12f78238 --- /dev/null +++ b/ftnoir_tracker_sm/FTNoIR_Tracker_SM.vcproj.VRIEND200810.Wim.user @@ -0,0 +1,65 @@ + + + + + + + + + + + diff --git a/ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc8.vcproj b/ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc8.vcproj new file mode 100644 index 00000000..2efa6022 --- /dev/null +++ b/ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc8.vcproj @@ -0,0 +1,413 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc9.vcproj b/ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc9.vcproj new file mode 100644 index 00000000..8fbfae89 --- /dev/null +++ b/ftnoir_tracker_sm/FTNoIR_Tracker_SM_vc9.vcproj @@ -0,0 +1,405 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_sm/Tracker.qrc b/ftnoir_tracker_sm/Tracker.qrc new file mode 100644 index 00000000..b76ff1b2 --- /dev/null +++ b/ftnoir_tracker_sm/Tracker.qrc @@ -0,0 +1,5 @@ + + + images/SeeingMachines.ico + + diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp new file mode 100644 index 00000000..624e35a0 --- /dev/null +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi.cpp @@ -0,0 +1,254 @@ +/******************************************************************************** +* 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 + +FTNoIR_Tracker::FTNoIR_Tracker() +{ +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ + qDebug() << "~FTNoIR_Tracker says: cleaning up"; + + if ( pMemData != NULL ) { + UnmapViewOfFile ( pMemData ); + } + + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; + + CloseHandle( hSMMutex ); + CloseHandle( hSMMemMap ); + hSMMemMap = 0; +} + +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) +{ + qDebug() << "FTNoIR_Tracker::Initialize says: Starting "; + + if (SMCreateMapping()) { + qDebug() << "FTNoIR_Tracker::Initialize Mapping created."; + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); + } + + loadSettings(); + + if ( pMemData != NULL ) { + pMemData->command = 0; // Reset any and all commands + if (videoframe != NULL) { + pMemData->handle = videoframe->winId(); // Handle of Videoframe widget + } + else { + pMemData->handle = NULL; // reset Handle of Videoframe widget + } + } + + // + // Start FTNoIR_FaceAPI_EXE.exe. The exe contains all faceAPI-stuff and is non-Qt... + // + QString program = "FTNoIR_FaceAPI_EXE.exe"; + faceAPI = new QProcess(0); + faceAPI->start(program); + + // Show the video widget + qDebug() << "FTNoIR_Tracker::Initialize says: videoframe = " << videoframe; + + if (videoframe != NULL) { + videoframe->show(); + } + return; +} + +void FTNoIR_Tracker::StartTracker( HWND parent_window ) +{ + if ( pMemData != NULL ) { + pMemData->command = FT_SM_START; // Start command + } + return; +} + +void FTNoIR_Tracker::StopTracker( bool exit ) +{ + + qDebug() << "FTNoIR_Tracker::StopTracker says: Starting "; + // stops the faceapi engine + if ( pMemData != NULL ) { +// if (exit == true) { + pMemData->command = (exit) ? FT_SM_EXIT : FT_SM_STOP; // Issue 'stop' command + //} + //else { + // pMemData->command = FT_SM_STOP; // Issue 'stop' command + //} + } + return; +} + +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::GiveHeadPoseData says: Retrieving data."; + + // + // Copy the measurements to FaceTrackNoIR. + // + if (bEnableX) { + data->x = pMemData->data.new_pose.head_pos.x * 100.0f; // From meters to centimeters + } + if (bEnableY) { + data->y = pMemData->data.new_pose.head_pos.y * 100.0f; + } + if (bEnableZ) { + data->z = pMemData->data.new_pose.head_pos.z * 100.0f; + } + if (bEnableYaw) { + data->yaw = pMemData->data.new_pose.head_rot.y_rads * 57.295781f; // From rads to degrees + } + if (bEnablePitch) { + data->pitch = pMemData->data.new_pose.head_rot.x_rads * 57.295781f; + } + if (bEnableRoll) { + data->roll = pMemData->data.new_pose.head_rot.z_rads * 57.295781f; + } + + // + // Reset the handshake, to let faceAPI know we're still here! + // + pMemData->handshake = 0; + + ReleaseMutex(hSMMutex); + return ( pMemData->data.new_pose.confidence > 0 ); + } + return false; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker::loadSettings() { + + 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::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "SMTracker" ); + if (pMemData) { + pMemData->initial_filter_level = iniFile.value ( "FilterLevel", 1 ).toInt(); + } + + bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); + bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); + bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); + bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); + bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); + bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); + + iniFile.endGroup (); +} + +// +// Create a memory-mapping to the faceAPI data. +// It contains the tracking data, a command-code from FaceTrackNoIR +// +// +bool FTNoIR_Tracker::SMCreateMapping() +{ + qDebug() << "FTNoIR_Tracker::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() << "FTNoIR_Tracker::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() << "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::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::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; +} + + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTracker - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTracker@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +{ + return new FTNoIR_Tracker; +} diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp new file mode 100644 index 00000000..5c422402 --- /dev/null +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dialog.cpp @@ -0,0 +1,346 @@ +/******************************************************************************** +* 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 + +//******************************************************************************************************* +// faceAPI Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +TrackerControls::TrackerControls() : +QWidget() +{ + ui.setupUi( this ); + + theTracker = NULL; + prev_state = -1; + + // 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())); + connect(ui.btnSave, SIGNAL(clicked()), this, SLOT(save())); + + 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() << "TrackerControls::Initialize Mapping created."; + } + else { + QMessageBox::warning(0,"FaceTrackNoIR Error","Memory mapping not created!",QMessageBox::Ok,QMessageBox::NoButton); + } + + //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 ))); + + connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { + qDebug() << "~TrackerControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void TrackerControls::Initialize(QWidget *parent) { + + QPoint offsetpos(200, 200); + if (parent) { + this->move(parent->pos() + offsetpos); + } + + // Load the settings from the current .INI-file + loadSettings(); + + show(); +} + +// +// OK clicked on server-dialog +// +void TrackerControls::doOK() { + save(); + this->close(); +} + +// override show event +void TrackerControls::showEvent ( QShowEvent * event ) { + prev_state = -1; + loadSettings(); +} + +// +// 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 ); + + 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 TrackerControls::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()); + + ui.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); + ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); + ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); + ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); + ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); + ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); + + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void TrackerControls::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.setValue ( "EnableRoll", ui.chkEnableRoll->isChecked() ); + iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); + iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); + iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); + iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); + iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); + + iniFile.endGroup (); + + // + // If the Tracker is active, let it load the new Settings. + // + if (theTracker) { + theTracker->loadSettings(); + } + + settingsDirty = false; +} + +// +// Create a memory-mapping to the faceAPI data. +// It contains the tracking data, a command-code from FaceTrackNoIR +// +// +bool TrackerControls::SMCreateMapping() +{ + qDebug() << "TrackerControls::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() << "TrackerControls::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() << "TrackerControls::FTCreateMapping says: FileMapping Created again..." << hSMMemMap; + pMemData = (SMMemMap *) MapViewOfFile(hSMMemMap, FILE_MAP_ALL_ACCESS, 0, 0, sizeof(TFaceData)); + if (pMemData != NULL) { + qDebug() << "TrackerControls::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() << "TrackerControls::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 TrackerControls::doTimUpdate() +{ + int state = pMemData->state; + if ( state != prev_state) { + emit stateChanged(state); + prev_state = state; + } +} + +// +// Show the current engine-settings etc. +// +void TrackerControls::showSettings( int newState ) +{ + qDebug() << "TrackerControls::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 TrackerControls::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 TrackerControls::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 ITrackerDialogPtr __stdcall GetTrackerDialog( ) +{ + return new TrackerControls; +} diff --git a/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp new file mode 100644 index 00000000..5f01568f --- /dev/null +++ b/ftnoir_tracker_sm/ftnoir_tracker_faceapi_dll.cpp @@ -0,0 +1,85 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The TrackerDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_tracker_sm.h" +#include + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "faceAPI V3.2.6"; + trackerShortName = "faceAPI"; + trackerDescription = "SeeingMachines faceAPI V3.2.6"; +} + +FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +{ + +} + +void FTNoIR_TrackerDll::Initialize() +{ + return; +} + +void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + +void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + +void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +void FTNoIR_TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/SeeingMachines.ico"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +{ + return new FTNoIR_TrackerDll; +} diff --git a/ftnoir_tracker_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_FTNClientControls.ui b/ftnoir_tracker_udp/FTNoIR_FTNClientControls.ui new file mode 100644 index 00000000..7ac6c0f4 --- /dev/null +++ b/ftnoir_tracker_udp/FTNoIR_FTNClientControls.ui @@ -0,0 +1,381 @@ + + + UICFTNClientControls + + + + 0 + 0 + 411 + 210 + + + + FTNoIR tracker settings FaceTrackNoIR + + + + images/FaceTrackNoIR.icoimages/FaceTrackNoIR.ico + + + Qt::LeftToRight + + + false + + + + + + + + Port-number + + + + + + + 5550 + + + 10000 + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + 0 + 85 + + + + Enable Axis + + + + + 10 + 20 + 143 + 60 + + + + + + + Roll: + + + + + + + Pitch: + + + + + + + Yaw: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + X: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Y: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Z: + + + + + + + + 20 + 16777215 + + + + Qt::LeftToRight + + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Minimum + + + + 40 + 20 + + + + + + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + + + + Enter the port-number for the remote PC. + + + true + + + + + + + Remember: you may have to change firewall-settings too! + + + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + QLayout::SetDefaultConstraint + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + OK + + + + + + + + 0 + 0 + + + + + 100 + 0 + + + + + 100 + 16777215 + + + + Cancel + + + + + + + + + Qt::Horizontal + + + QSizePolicy::Fixed + + + + 10 + 20 + + + + + + + + + + spinPortNumber + btnOK + btnCancel + + + + + startEngineClicked() + stopEngineClicked() + cameraSettingsClicked() + + diff --git a/ftnoir_tracker_udp/FTNoIR_Tracker_UDP.h b/ftnoir_tracker_udp/FTNoIR_Tracker_UDP.h new file mode 100644 index 00000000..94645c84 --- /dev/null +++ b/ftnoir_tracker_udp/FTNoIR_Tracker_UDP.h @@ -0,0 +1,99 @@ +#include "..\ftnoir_tracker_base\ftnoir_tracker_base.h" +#include "ui_FTNoIR_FTNClientcontrols.h" +#include +#include +#include +#include +#include "Windows.h" +#include "math.h" + +class FTNoIR_Tracker : public ITracker, QThread +{ +public: + FTNoIR_Tracker(); + ~FTNoIR_Tracker(); + + void Initialize( QFrame *videoframe ); + void StartTracker( HWND parent_window ); + void StopTracker( bool exit ); + bool GiveHeadPoseData(THeadPoseData *data); + void loadSettings(); + +protected: + void run(); // qthread override run method + +private: + // Handles to neatly terminate thread... + HANDLE m_StopThread; + HANDLE m_WaitThread; + + // UDP socket-variables + QUdpSocket *inSocket; // Receive from ... + QUdpSocket *outSocket; // Send to ... + QHostAddress destIP; // Destination IP-address + int destPort; // Destination port-number + QHostAddress srcIP; // Source IP-address + int srcPort; // Source port-number + + THeadPoseData newHeadPose; // Structure with new headpose + + float portAddress; // Port-number + bool bEnableRoll; + bool bEnablePitch; + bool bEnableYaw; + bool bEnableX; + bool bEnableY; + bool bEnableZ; +}; + +// Widget that has controls for FTNoIR protocol client-settings. +class TrackerControls: public QWidget, Ui::UICFTNClientControls, public ITrackerDialog +{ + Q_OBJECT +public: + + explicit TrackerControls(); + virtual ~TrackerControls(); + void showEvent ( QShowEvent * event ); + + void Initialize(QWidget *parent); + void registerTracker(ITracker *tracker) {}; + void unRegisterTracker() {}; + +private: + Ui::UICFTNClientControls ui; + void loadSettings(); + void save(); + + /** helper **/ + bool settingsDirty; + +private slots: + void doOK(); + void doCancel(); + void settingChanged() { settingsDirty = true; }; + void settingChanged(int) { settingsDirty = true; }; +}; + +//******************************************************************************************************* +// FaceTrackNoIR Tracker DLL. Functions used to get general info on the Tracker +//******************************************************************************************************* +class FTNoIR_TrackerDll : public ITrackerDll +{ +public: + FTNoIR_TrackerDll(); + ~FTNoIR_TrackerDll(); + + void Initialize(); + + void getFullName(QString *strToBeFilled); + void getShortName(QString *strToBeFilled); + void getDescription(QString *strToBeFilled); + void getIcon(QIcon *icon); + +private: + QString trackerFullName; // Trackers' name and description + QString trackerShortName; + QString trackerDescription; +}; + diff --git a/ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc8.vcproj b/ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc8.vcproj new file mode 100644 index 00000000..d855e3c2 --- /dev/null +++ b/ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc8.vcproj @@ -0,0 +1,338 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc9.vcproj b/ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc9.vcproj new file mode 100644 index 00000000..fa465ec9 --- /dev/null +++ b/ftnoir_tracker_udp/FTNoIR_Tracker_UDP_vc9.vcproj @@ -0,0 +1,335 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp new file mode 100644 index 00000000..102c85bd --- /dev/null +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp.cpp @@ -0,0 +1,217 @@ +/******************************************************************************** +* 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_udp.h" + +FTNoIR_Tracker::FTNoIR_Tracker() +{ + inSocket = 0; + outSocket = 0; + + // Create events + m_StopThread = CreateEvent(0, TRUE, FALSE, 0); + m_WaitThread = CreateEvent(0, TRUE, FALSE, 0); + + bEnableRoll = true; + bEnablePitch = true; + bEnableYaw = true; + bEnableX = true; + bEnableY = true; + bEnableZ = true; + portAddress = 5551; + + newHeadPose.x = 0.0f; + newHeadPose.y = 0.0f; + newHeadPose.z = 0.0f; + newHeadPose.yaw = 0.0f; + newHeadPose.pitch = 0.0f; + newHeadPose.roll = 0.0f; +} + +FTNoIR_Tracker::~FTNoIR_Tracker() +{ + // Trigger thread to stop + ::SetEvent(m_StopThread); + + // Wait until thread finished + if (isRunning()) { + ::WaitForSingleObject(m_WaitThread, INFINITE); + } + + // Close handles + ::CloseHandle(m_StopThread); + ::CloseHandle(m_WaitThread); + + if (inSocket) { + inSocket->close(); + delete inSocket; + } + + if (outSocket) { + outSocket->close(); + delete outSocket; + } +} + +/** QThread run @override **/ +void FTNoIR_Tracker::run() { + +int no_bytes; +QHostAddress sender; +quint16 senderPort; + + // + // Read the data that was received. + // + forever { + + // Check event for stop thread + if(::WaitForSingleObject(m_StopThread, 0) == WAIT_OBJECT_0) + { + // Set event + ::SetEvent(m_WaitThread); + qDebug() << "FTNoIR_Tracker::run() terminated run()"; + return; + } + + if (inSocket != 0) { + while (inSocket->hasPendingDatagrams()) { + + QByteArray datagram; + datagram.resize(inSocket->pendingDatagramSize()); + + inSocket->readDatagram( (char * ) &newHeadPose, sizeof(newHeadPose), &sender, &senderPort); + } + } + else { + qDebug() << "FTNoIR_Tracker::run() insocket not ready: exit run()"; + return; + } + + //for lower cpu load + usleep(10000); +// yieldCurrentThread(); + } +} + +void FTNoIR_Tracker::Initialize( QFrame *videoframe ) +{ + 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::run()) + // + if (inSocket == 0) { + qDebug() << "FTNoIR_Tracker::Initialize() creating insocket"; + inSocket = new QUdpSocket(); + // Connect the inSocket to the port, to receive messages + + if (!inSocket->bind(QHostAddress::Any, (int) portAddress, QUdpSocket::ShareAddress | QUdpSocket::ReuseAddressHint)) { + QMessageBox::warning(0,"FaceTrackNoIR Error", "Unable to bind UDP-port",QMessageBox::Ok,QMessageBox::NoButton); + delete inSocket; + inSocket = 0; + } + } + + return; +} + +void FTNoIR_Tracker::StartTracker( HWND parent_window ) +{ + start( QThread::TimeCriticalPriority ); + return; +} + +void FTNoIR_Tracker::StopTracker( bool exit ) +{ + // + // OK, the thread is not stopped, doing this. That might be dangerous anyway... + // + if (exit || !exit) return; + return; +} + +bool FTNoIR_Tracker::GiveHeadPoseData(THeadPoseData *data) +{ + if (bEnableX) { + data->x = newHeadPose.x; + } + if (bEnableX) { + data->y = newHeadPose.y; + } + if (bEnableX) { + data->z = newHeadPose.z; + } + if (bEnableX) { + data->yaw = newHeadPose.yaw; + } + if (bEnableX) { + data->pitch = newHeadPose.pitch; + } + if (bEnableX) { + data->roll = newHeadPose.roll; + } + return true; +} + +// +// Load the current Settings from the currently 'active' INI-file. +// +void FTNoIR_Tracker::loadSettings() { + + 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::loadSettings says: iniFile = " << currentFile; + + iniFile.beginGroup ( "FTNClient" ); + bEnableRoll = iniFile.value ( "EnableRoll", 1 ).toBool(); + bEnablePitch = iniFile.value ( "EnablePitch", 1 ).toBool(); + bEnableYaw = iniFile.value ( "EnableYaw", 1 ).toBool(); + bEnableX = iniFile.value ( "EnableX", 1 ).toBool(); + bEnableY = iniFile.value ( "EnableY", 1 ).toBool(); + bEnableZ = iniFile.value ( "EnableZ", 1 ).toBool(); + portAddress = (float) iniFile.value ( "PortNumber", 5550 ).toInt(); + iniFile.endGroup (); +} + + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTracker - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTracker@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTracker=_GetTracker@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerPtr __stdcall GetTracker() +{ + return new FTNoIR_Tracker; +} diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp new file mode 100644 index 00000000..b489822a --- /dev/null +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dialog.cpp @@ -0,0 +1,181 @@ +/******************************************************************************** +* 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_udp.h" + +//******************************************************************************************************* +// FaceTrackNoIR Client Settings-dialog. +//******************************************************************************************************* + +// +// Constructor for server-settings-dialog +// +TrackerControls::TrackerControls() : +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.spinPortNumber, SIGNAL(valueChanged(int)), this, SLOT(settingChanged())); + + connect(ui.chkEnableRoll, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnablePitch, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableYaw, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableX, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableY, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + connect(ui.chkEnableZ, SIGNAL(stateChanged(int)), this, SLOT(settingChanged(int))); + + // Load the settings from the current .INI-file + loadSettings(); +} + +// +// Destructor for server-dialog +// +TrackerControls::~TrackerControls() { + qDebug() << "~TrackerControls() says: started"; +} + +// +// Initialize tracker-client-dialog +// +void TrackerControls::Initialize(QWidget *parent) { + + QPoint offsetpos(100, 100); + if (parent) { + this->move(parent->pos() + offsetpos); + } + show(); +} + +// +// OK clicked on server-dialog +// +void TrackerControls::doOK() { + save(); + this->close(); +} + +// override show event +void TrackerControls::showEvent ( QShowEvent * event ) { + loadSettings(); +} + +// +// 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 ); + + 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 TrackerControls::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.chkEnableRoll->setChecked(iniFile.value ( "EnableRoll", 1 ).toBool()); + ui.chkEnablePitch->setChecked(iniFile.value ( "EnablePitch", 1 ).toBool()); + ui.chkEnableYaw->setChecked(iniFile.value ( "EnableYaw", 1 ).toBool()); + ui.chkEnableX->setChecked(iniFile.value ( "EnableX", 1 ).toBool()); + ui.chkEnableY->setChecked(iniFile.value ( "EnableY", 1 ).toBool()); + ui.chkEnableZ->setChecked(iniFile.value ( "EnableZ", 1 ).toBool()); + + ui.spinPortNumber->setValue( iniFile.value ( "PortNumber", 5550 ).toInt() ); + iniFile.endGroup (); + + settingsDirty = false; +} + +// +// Save the current Settings to the currently 'active' INI-file. +// +void TrackerControls::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 ( "EnableRoll", ui.chkEnableRoll->isChecked() ); + iniFile.setValue ( "EnablePitch", ui.chkEnablePitch->isChecked() ); + iniFile.setValue ( "EnableYaw", ui.chkEnableYaw->isChecked() ); + iniFile.setValue ( "EnableX", ui.chkEnableX->isChecked() ); + iniFile.setValue ( "EnableY", ui.chkEnableY->isChecked() ); + iniFile.setValue ( "EnableZ", ui.chkEnableZ->isChecked() ); + 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 ITrackerDialogPtr __stdcall GetTrackerDialog( ) +{ + return new TrackerControls; +} diff --git a/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp new file mode 100644 index 00000000..a086a888 --- /dev/null +++ b/ftnoir_tracker_udp/ftnoir_tracker_udp_dll.cpp @@ -0,0 +1,85 @@ +/******************************************************************************** +* FaceTrackNoIR This program is a private project of some enthusiastic * +* gamers from Holland, who don't like to pay much for * +* head-tracking. * +* * +* Copyright (C) 2012 Wim Vriend (Developing) * +* Ron Hendriks (Researching and Testing) * +* * +* Homepage * +* * +* This program is free software; you can redistribute it and/or modify it * +* under the terms of the GNU General Public License as published by the * +* Free Software Foundation; either version 3 of the License, or (at your * +* option) any later version. * +* * +* This program is distributed in the hope that it will be useful, but * +* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY * +* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for * +* more details. * +* * +* You should have received a copy of the GNU General Public License along * +* with this program; if not, see . * +* * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: The Dialog class was used to get general info on the DLL. This + had a big disadvantage: the complete dialog was loaded, just to get + some data and then it was deleted again (without ever showing the dialog). + The TrackerDll class solves this. + The functions to get the name(s) and icon were removed from the two other classes. +*/ +#include "ftnoir_tracker_udp.h" +#include + +FTNoIR_TrackerDll::FTNoIR_TrackerDll() { + //populate the description strings + trackerFullName = "FaceTrackNoIR UDP"; + trackerShortName = "UDP"; + trackerDescription = "FaceTrackNoIR UDP"; +} + +FTNoIR_TrackerDll::~FTNoIR_TrackerDll() +{ + +} + +void FTNoIR_TrackerDll::Initialize() +{ + return; +} + +void FTNoIR_TrackerDll::getFullName(QString *strToBeFilled) +{ + *strToBeFilled = trackerFullName; +}; + +void FTNoIR_TrackerDll::getShortName(QString *strToBeFilled) +{ + *strToBeFilled = trackerShortName; +}; + +void FTNoIR_TrackerDll::getDescription(QString *strToBeFilled) +{ + *strToBeFilled = trackerDescription; +}; + +void FTNoIR_TrackerDll::getIcon(QIcon *icon) +{ + *icon = QIcon(":/images/FaceTrackNoIR.ico"); +}; + +//////////////////////////////////////////////////////////////////////////////// +// Factory function that creates instances if the Tracker object. + +// Export both decorated and undecorated names. +// GetTrackerDll - Undecorated name, which can be easily used with GetProcAddress +// Win32 API function. +// _GetTrackerDll@0 - Common name decoration for __stdcall functions in C language. +#pragma comment(linker, "/export:GetTrackerDll=_GetTrackerDll@0") + +FTNOIR_TRACKER_BASE_EXPORT ITrackerDllPtr __stdcall GetTrackerDll() +{ + return new FTNoIR_TrackerDll; +} diff --git a/list of compatible games.xls b/list of compatible games.xls new file mode 100644 index 00000000..bdc55e62 Binary files /dev/null and b/list of compatible games.xls differ diff --git a/list of compatible webcams.xls b/list of compatible webcams.xls new file mode 100644 index 00000000..a057ef43 Binary files /dev/null and b/list of compatible webcams.xls differ diff --git a/qfunctionconfigurator/Prerequisites for using widget in Qt Designer.png b/qfunctionconfigurator/Prerequisites for using widget in Qt Designer.png new file mode 100644 index 00000000..6e4d8903 Binary files /dev/null and b/qfunctionconfigurator/Prerequisites for using widget in Qt Designer.png differ diff --git a/qfunctionconfigurator/QFunctionConfigurator.sln b/qfunctionconfigurator/QFunctionConfigurator.sln new file mode 100644 index 00000000..91b827df --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 9.00 +# Visual Studio 2005 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QFunctionConfigurator", "QFunctionConfigurator\QFunctionConfigurator.vcproj", "{2527B683-7EFC-4D51-B25A-843668649C54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.ActiveCfg = Debug|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.Build.0 = Debug|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.ActiveCfg = Release|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.cpp b/qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.cpp new file mode 100644 index 00000000..243564d1 Binary files /dev/null and b/qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.cpp differ diff --git a/qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.h b/qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.h new file mode 100644 index 00000000..8dc9cf98 Binary files /dev/null and b/qfunctionconfigurator/QFunctionConfigurator/FunctionConfig.h differ diff --git a/qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj b/qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj new file mode 100644 index 00000000..29a06271 --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator.vcproj @@ -0,0 +1,355 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj b/qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj new file mode 100644 index 00000000..940a6198 --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/QFunctionConfigurator_vc9.vcproj @@ -0,0 +1,354 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/qfunctionconfigurator/QFunctionConfigurator/postbuild.bat b/qfunctionconfigurator/QFunctionConfigurator/postbuild.bat new file mode 100644 index 00000000..3fe2e3ca --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/postbuild.bat @@ -0,0 +1,30 @@ +@echo off +rem Copies required DLL files into output folder. + +setlocal +set COPY=xcopy /D /S /C /I /H /R /Y +set FILTER=find /v "File(s) copied" + +echo parameters %1 en %2 en %3 en %4 + +set API_BIN=%1 +set OUTDIR=%2 +set CONFIG=%3 +set FTN_BIN=%4 + +if %CONFIG%==Debug (goto Debug) +if %CONFIG%==Release (goto Release) + +echo Unknown build configuration %CONFIG% +exit /b -1 + +:Debug +%COPY% %API_BIN%\*.* %OUTDIR%\ | %FILTER% +%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% +exit /b 0 + +:Release +%COPY% %API_BIN%\*.* %OUTDIR%\ | %FILTER% +%COPY% %API_BIN%\*.dll %FTN_BIN%\ | %FILTER% +exit /b 0 + diff --git a/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp new file mode 100644 index 00000000..fe2ad49d --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.cpp @@ -0,0 +1,721 @@ +/******************************************************************************** +* 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 . * +* * +* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * +* FaceTrackNoIR. * +* * +* All credits for this nice piece of code should go to Stanislaw. * +* * +* Copyright (c) 2011-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. * +********************************************************************************/ +/* + Modifications (last one on top): + 20120830 - WVR: Changed functionality a bit. Now only draw the handles, when the function is drawn. + Only check mouseMoves, when they occur 'in range'. Redraw the curve, when a resize occurs. + Somehow, the curve was not drawn correctly, when this was not done (all points were too high). + After a 'Reset' this would disappear... + 20120828 - WVR: Removed bSkipText, which was used to not show a number below each vertical gridline. +*/ +#include "qfunctionconfigurator.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#include + +QFunctionConfigurator::~QFunctionConfigurator() +{ + WaitForSingleObject(_mutex, INFINITE); + CloseHandle(_mutex); + delete btnReset; +} + +static const int pointSize = 5; + +QFunctionConfigurator::QFunctionConfigurator(QWidget *parent) + : QWidget(parent) +{ + + // + // Defaults, for when the widget has no values different from the domXML() + // + MaxInput = 50; // Maximum input limit + MaxOutput = 180; // Maximum output limit + pPerEGU_Output = 1; // Number of pixels, per EGU + pPerEGU_Input = 4; // Number of pixels, per EGU + gDistEGU_Input = 5; // Distance of gridlines + gDistEGU_Output = 10; // Distance of gridlines + + + // Change compared to BezierConfigurator: X = horizontal (input), Y = vertical (output) + // This will require the Curve-Dialog to be higher (which was the reason it was reversed in the first place..) + range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); + + setMouseTracking(true); + moving = NULL; // Pointer to the curve-point, that's being moved + movingPoint = 1; // Index of that same point + + // + // Add a Reset-button + // + btnReset = new QPushButton(QString("Reset"), this); + connect(btnReset, SIGNAL(clicked()), this, SLOT(resetCurve())); + + // + // Variables for FunctionConfig + // + _config = 0; + _points = QList(); + _draw_points = QList(); + _mutex = CreateMutex(NULL, false, NULL); + _draw_background = true; + _draw_function = true; + +// qDebug() << "QFunctionConfigurator::QFunctionConfigurator object created."; + +} + +// +// Attach an existing FunctionConfig to the Widget. +// +void QFunctionConfigurator::setConfig(FunctionConfig* config, QString settingsFile) { +QPointF currentPoint; +QPointF drawPoint; +qreal x; + + WaitForSingleObject(_mutex, INFINITE); + _config = config; + _points = config->getPoints(); + strSettingsFile = settingsFile; // Remember for Reset() + + qDebug() << "QFunctionConfigurator::setConfig" << config->getTitle(); + setCaption(config->getTitle()); + + // + // Get the Function Points, one for each pixel in the horizontal range. + // If the curve does not change, there is no need to run this code every time (it slows down drawing). + // + _draw_points.clear(); + for (int j = 0; j < MaxInput * pPerEGU_Input; j++) { + // + // Weird: not casting to float causes C++ to round the number... + // + x = (float) j / (float) pPerEGU_Input; + currentPoint.setX ( x ); + currentPoint.setY (_config->getValue( x )); + drawPoint = graphicalizePoint(currentPoint, "setConfig"); + if (withinRect(drawPoint, range)) { + _draw_points.append(drawPoint); +// qDebug() << "QFunctionConfigurator::setConfig _draw_Point to add = " << drawPoint; + } + } + + ReleaseMutex(_mutex); + _draw_function = true; + this->update(); +} + +// +// Load the FunctionConfig (points) from the INI-file. +// +void QFunctionConfigurator::loadSettings(QString settingsFile) { + + QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) + strSettingsFile = settingsFile; // Remember for Reset() + qDebug() << "QFunctionConfigurator::loadSettings = " << settingsFile; + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + _config->loadSettings(iniFile); + setConfig(_config, settingsFile); + } + ReleaseMutex(_mutex); +} + +// +// Save the FunctionConfig (points) to the INI-file. +// +void QFunctionConfigurator::saveSettings(QString settingsFile) { + QSettings iniFile( settingsFile, QSettings::IniFormat ); // Application settings (in INI-file) + strSettingsFile = settingsFile; // Remember for Reset() + qDebug() << "QFunctionConfigurator::saveSettings = " << settingsFile; + + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + _config->saveSettings(iniFile); + } + ReleaseMutex(_mutex); +} + +// +// Draw the Background for the graph, the gridlines and the gridpoints. +// The static objects are drawn on a Pixmap, so it does not have to be repeated every paintEvent. Hope this speeds things up... +// +void QFunctionConfigurator::drawBackground(const QRectF &fullRect) +{ +int i; +QRect scale; + + qDebug() << "QFunctionConfigurator::drawBackground."; + + _background = QPixmap(fullRect.width(), fullRect.height()); + QPainter painter(&_background); + + painter.save(); + painter.setRenderHint(QPainter::Antialiasing); + painter.fillRect(fullRect, colBackground); + QColor bg_color(112, 154, 209); + painter.fillRect(range, bg_color); + + QFont font("ComicSans", 4); + font.setPointSize(8); + painter.setFont(font); + + QPen pen(QColor(55, 104, 170, 127), 1, Qt::SolidLine); + + // + // Draw the Caption + // + if (_config) { + strCaption = _config->getTitle(); + } + + scale.setCoords(range.left(), 0, range.right(), 20); + painter.drawText(scale, Qt::AlignCenter, strCaption); + + // + // Draw the horizontal grid + // + for (i = range.bottom() - gDistEGU_Output * pPerEGU_Output; i >= range.top(); i -= gDistEGU_Output * pPerEGU_Output) { + drawLine(&painter, QPointF(40, i), QPointF(range.right(), i), pen); + scale.setCoords(0, i - 5, range.left() - 5, i + 5); + painter.drawText(scale, Qt::AlignRight, tr("%1").arg(((range.bottom() - i))/pPerEGU_Output)); + } + + // + // Draw the vertical guidelines + // + for (i = range.left(); i <= range.right(); i += gDistEGU_Input * pPerEGU_Input) { + drawLine(&painter, QPointF(i, range.top()), QPointF(i, range.bottom()), pen); + scale.setCoords(i - 10, range.bottom() + 2, i + 10, range.bottom() + 15); + painter.drawText(scale, Qt::AlignCenter, tr("%1").arg(abs(((range.left() - i))/pPerEGU_Input))); + } + + scale.setCoords(range.left(), range.bottom() + 20, range.right(), range.bottom() + 35); + painter.drawText(scale, Qt::AlignRight, strInputEGU); + + // + // Draw the EGU of the vertical axis (vertically!) + // + font.setPointSize(10); + painter.translate(range.topLeft().x() - 35, range.topLeft().y()); + painter.rotate(90); + painter.drawText(0,0,strOutputEGU ); + + // + // Draw the two axis + // + pen.setWidth(2); + pen.setColor( Qt::black ); + drawLine(&painter, range.topLeft() - QPointF(2,0), range.bottomLeft() - QPointF(2,0), pen); + drawLine(&painter, range.bottomLeft(), range.bottomRight(), pen); + + painter.restore(); +} + + +// +// Draw the Function for the graph, on a Pixmap. +// +void QFunctionConfigurator::drawFunction(const QRectF &fullRect) +{ + if (!_config) + return; +int i; +QPointF prevPoint; +QPointF currentPoint; + + // + // Use the background picture to draw on. + // ToDo: find out how to add Pixmaps, without getting it all green... + // + _function = QPixmap(_background); + QPainter painter(&_function); + + painter.save(); + painter.setRenderHint(QPainter::Antialiasing, false); + + // + // Draw the handles for the Points + // + for (i = 0; i < _points.size(); i++) { + currentPoint = graphicalizePoint( _points[i], "drawFunction handles" ); // Get the next point and convert it to Widget measures + drawPoint(&painter, currentPoint, QColor(200, 200, 210, 120)); + lastPoint = currentPoint; // Remember which point is the rightmost in the graph +//qDebug() << "QFunctionConfigurator::paintEvent, drawing handle for " << currentPoint; + } + + + QPen pen(colBezier, 2, Qt::SolidLine); + + prevPoint = graphicalizePoint( QPointF(0,0), "drawFunction lines" ); // Start at the Axis + double max = maxInputEGU(); + QPointF prev = graphicalizePoint(QPointF(0, 0)); + double step = 1 / (double) pixPerEGU_Input(); + for (double i = 0; i < max; i += step) { + double val = _config->getValue(i); + QPointF cur = graphicalizePoint(QPointF(i, val)); + drawLine(&painter, prev, cur, pen); + prev = cur; + } + painter.restore(); +} + +// +// The Widget paints the surface every x msecs. +// +void QFunctionConfigurator::paintEvent(QPaintEvent *e) +{ +QPointF prevPoint; +QPointF currentPoint; +QPointF actualPos; +int i; + +// qDebug() << "QFunctionConfigurator::paintEvent."; + + QPainter p(this); + p.setRenderHint(QPainter::Antialiasing); + p.setClipRect(e->rect()); + + if (_draw_background) { + drawBackground(e->rect()); // Draw the static parts on a Pixmap + p.drawPixmap(0, 0, _background); // Paint the background + _draw_background = false; + + btnReset->move(e->rect().left(), e->rect().bottom() - btnReset->height() - 2); + } + + if (_draw_function) { + drawFunction(e->rect()); // Draw the Function on a Pixmap + _draw_function = false; + } + p.drawPixmap(0, 0, _function); // Always draw the background and the function + + QPen pen(Qt::white, 1, Qt::SolidLine); + + // + // Draw the Points, that make up the Curve + // + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + + // + // When moving, also draw a sketched version of the Function. + // + if (moving) { + prevPoint = graphicalizePoint( QPointF(0,0), "paintEvent moving" ); // Start at the Axis + for (i = 0; i < _points.size(); i++) { + currentPoint = graphicalizePoint( _points[i], "paintEvent moving" ); // Get the next point and convert it to Widget measures + drawLine(&p, prevPoint, currentPoint, pen); + prevPoint = currentPoint; +// qDebug() << "QFunctionConfigurator::paintEvent, drawing while moving " << currentPoint; + } + + // + // When moving, also draw a few help-lines, so positioning the point gets easier. + // + pen.setWidth(1); + pen.setColor( Qt::white ); + pen.setStyle( Qt::DashLine ); + actualPos = graphicalizePoint(*moving, "paintEvent moving help line(s)"); + drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); + drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); + } + + // + // If the Tracker is active, the 'Last Point' it requested is recorded. + // Show that point on the graph, with some lines to assist. + // This new feature is very handy for tweaking the curves! + // + if (_config->getLastPoint( currentPoint )) { + +// qDebug() << "QFunctionConfigurator::paintEvent, drawing tracked Point " << currentPoint; + + actualPos = graphicalizePoint( currentPoint, "paintEvent tracking" ); + drawPoint(&p, actualPos, QColor(255, 0, 0, 120)); + + pen.setWidth(1); + pen.setColor( Qt::black ); + pen.setStyle( Qt::SolidLine ); + drawLine(&p, QPoint(range.left(), actualPos.y()), QPoint(actualPos.x(), actualPos.y()), pen); + drawLine(&p, QPoint(actualPos.x(), actualPos.y()), QPoint(actualPos.x(), range.bottom()), pen); + } + + } + ReleaseMutex(_mutex); + + // + // Draw the delimiters + // + pen.setWidth(1); + pen.setColor( Qt::white ); + pen.setStyle( Qt::SolidLine ); + drawLine(&p, QPoint(lastPoint.x(), range.top()), QPoint(lastPoint.x(), range.bottom()), pen); + drawLine(&p, QPoint(range.left(), lastPoint.y()), QPoint(range.right(), lastPoint.y()), pen); + + QTimer::singleShot(250, this, SLOT(update())); +} + +// +// Draw the handle, to move the Bezier-curve. +// +void QFunctionConfigurator::drawPoint(QPainter *painter, const QPointF &pos, QColor colBG ) +{ + painter->save(); + painter->setPen(QColor(50, 100, 120, 200)); + painter->setBrush( colBG ); + painter->drawEllipse(QRectF(pos.x() - pointSize, + pos.y() - pointSize, + pointSize*2, pointSize*2)); + painter->restore(); +} + +void QFunctionConfigurator::drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen) +{ + painter->save(); + painter->setPen(pen); + painter->setBrush(Qt::NoBrush); + painter->drawLine(start, end); + painter->restore(); +} + +// +// If the mousebutton is pressed, check if it is inside one of the Points. +// If so: start moving that Point, until mouse release. +// +void QFunctionConfigurator::mousePressEvent(QMouseEvent *e) +{ + // + // First: check the left mouse-button + // + if (e->button() == Qt::LeftButton) { + + // + // Check to see if the cursor is touching one of the points. + // + bool bTouchingPoint = false; + movingPoint = -1; + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + + for (int i = 0; i < _points.size(); i++) { + if ( markContains( graphicalizePoint( _points[i], "mousePressEvent markContains" ), e->pos() ) ) { + bTouchingPoint = true; + moving = &_points[i]; + movingPoint = i; + } + } + + // + // If the Left Mouse-button was clicked without touching a Point, add a new Point + // + if (!bTouchingPoint) { + if (withinRect(e->pos(), range)) { + _config->addPoint(normalizePoint(e->pos())); + setConfig(_config, strSettingsFile); + moving = NULL; + emit CurveChanged( true ); + } + } + } + ReleaseMutex(_mutex); + } + + // + // Then: check the right mouse-button + // + if (e->button() == Qt::RightButton) { + + // + // Check to see if the cursor is touching one of the points. + // + moving = NULL; + movingPoint = -1; + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + + for (int i = 0; i < _points.size(); i++) { + if ( markContains( graphicalizePoint( _points[i], "mousePressEvent RightButton" ), e->pos() ) ) { + movingPoint = i; + } + } + + // + // If the Right Mouse-button was clicked while touching a Point, remove the Point + // + if (movingPoint >= 0) { + _config->removePoint(movingPoint); + setConfig(_config, strSettingsFile); + movingPoint = -1; + emit CurveChanged( true ); + } + } + ReleaseMutex(_mutex); + } + +} + +// +// If the mouse if moving, make sure the Bezier moves along. +// Of course, only when a Point is selected... +// +void QFunctionConfigurator::mouseMoveEvent(QMouseEvent *e) +{ + + if (moving) { + + setCursor(Qt::ClosedHandCursor); + + // + // Change the currently moving Point. + // + *moving = normalizePoint(e->pos()); + update(); + } + else { + + // + // Check to see if the cursor is touching one of the points. + // + bool bTouchingPoint = false; + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + + for (int i = 0; i < _points.size(); i++) { + if ( markContains( graphicalizePoint( _points[i], "mouseMoveEvent" ), e->pos() ) ) { + bTouchingPoint = true; + } + } + } + ReleaseMutex(_mutex); + + if ( bTouchingPoint ) { + setCursor(Qt::OpenHandCursor); + } + else { + setCursor(Qt::ArrowCursor); + } + + } +} + +void QFunctionConfigurator::mouseReleaseEvent(QMouseEvent *e) +{ + //qDebug()<<"releasing"; + if (moving > 0) { + emit CurveChanged( true ); + + // + // Update the Point in the _config + // + WaitForSingleObject(_mutex, INFINITE); + if (_config) { + _config->movePoint(movingPoint, normalizePoint(e->pos())); + setConfig(_config, strSettingsFile); + } + ReleaseMutex(_mutex); + + } + setCursor(Qt::ArrowCursor); + moving = NULL; + movingPoint = 0; +} + +// +// Determine if the mousebutton was pressed within the range of the Point. +// +bool QFunctionConfigurator::markContains(const QPointF &pos, const QPointF &coord) const +{ + QRectF rect(pos.x() - pointSize, + pos.y() - pointSize, + pointSize*2, pointSize*2); + QPainterPath path; + path.addEllipse(rect); + return path.contains(coord); +} + +bool QFunctionConfigurator::withinRect( const QPointF &coord, const QRectF &rect ) const +{ + QPainterPath path; + path.addRect(rect); + return path.contains(coord); +} + +// +// Convert the Point in the graph, to the real-life Point. +// +QPointF QFunctionConfigurator::normalizePoint(QPointF point) const +{ + QPointF norm; + + norm.setX( (point.x() - range.left()) / pPerEGU_Input ); + norm.setY( (range.bottom() - point.y()) / pPerEGU_Output ); + + if (norm.x() > maxInputEGU()) + norm.setX(maxInputEGU()); + else if (norm.x() < 0) + norm.setX(0); + if (norm.y() > maxOutputEGU()) + norm.setY(maxOutputEGU()); + else if (norm.y() < 0) + norm.setY(0); + + return norm; +} + +// +// Convert the real-life Point into the graphical Point. +// +QPointF QFunctionConfigurator::graphicalizePoint(QPointF point, QString source) const +{ +QPointF graph; + + graph.setX( range.left() + (fabs(point.x()) * pPerEGU_Input) ); + graph.setY( range.bottom() - (fabs(point.y()) * pPerEGU_Output) ); + +// qDebug() << "QFunctionConfigurator::graphicalizePoint source = " << source << ", point = " << point << ", graph = " << graph; + + return graph; +} + +void QFunctionConfigurator::setmaxInputEGU(int value) +{ + MaxInput = value; + setMinimumWidth(MaxInput * pPerEGU_Input + 55); +// resetCurve(); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); +} +void QFunctionConfigurator::setmaxOutputEGU(int value) +{ + MaxOutput = value; + setMinimumHeight(MaxOutput * pPerEGU_Output + 60); +// resetCurve(); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); +} + +// +// To make configuration more visibly attractive, the number of pixels 'per EGU' can be defined. +// +void QFunctionConfigurator::setpixPerEGU_Input(int value) +{ + pPerEGU_Input = value; + setMinimumWidth(MaxInput * pPerEGU_Input + 55); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); +} + +// +// To make configuration more visibly attractive, the number of pixels 'per EGU' can be defined. +// +void QFunctionConfigurator::setpixPerEGU_Output(int value) +{ + pPerEGU_Output = value; + setMinimumHeight(MaxOutput * pPerEGU_Output + 60); + resize( MaxInput * pPerEGU_Input + 55, MaxOutput * pPerEGU_Output + 60 ); +} + +// +// Define the distance of the grid 'in EGU' points. +// +void QFunctionConfigurator::setgridDistEGU_Input(int value) +{ + gDistEGU_Input = value; + _draw_background = true; + _draw_function = true; + repaint(); +} + +// +// Define the distance of the grid 'in EGU' points. +// +void QFunctionConfigurator::setgridDistEGU_Output(int value) +{ + gDistEGU_Output = value; + _draw_background = true; + _draw_function = true; + repaint(); +} + +void QFunctionConfigurator::setColorBezier(QColor color) +{ + colBezier = color; + update(); +} +void QFunctionConfigurator::setColorBackground(QColor color) +{ + colBackground = color; + update(); +} + +void QFunctionConfigurator::setInputEGU(QString egu) +{ + strInputEGU = egu; + update(); +} +void QFunctionConfigurator::setOutputEGU(QString egu) +{ + strOutputEGU = egu; + update(); +} +void QFunctionConfigurator::setCaption(QString cap) +{ + strCaption = cap; + update(); +} + +void QFunctionConfigurator::resizeEvent(QResizeEvent *e) +{ + QSize s = e->size(); + range = QRectF(40, 20, MaxInput * pPerEGU_Input, MaxOutput * pPerEGU_Output); + + qDebug() << "QFunctionConfigurator::resizeEvent, name = " << strCaption << ",range = " << range; + + if (_config) { + setConfig(_config, strSettingsFile); + } + _draw_background = true; + _draw_function = true; + repaint(); +} diff --git a/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.h b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.h new file mode 100644 index 00000000..c467bc92 --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfigurator.h @@ -0,0 +1,206 @@ +/******************************************************************************** +* 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 . * +* * +* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * +* FaceTrackNoIR. * +* * +* All credits for this nice piece of code should go to Stanislaw. * +* * +* Copyright (c) 2011-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. * +********************************************************************************/ +#ifndef QFUNCTIONCONFIGURATOR_H +#define QFUNCTIONCONFIGURATOR_H + +#include +#include +#include +#include "FunctionConfig.h" + +// +// The FunctionConfigurator Widget is used to display and configure a function (curve). +// The Function is used by FaceTrackNoIR to 'translate' the actual head-pose to the virtual headpose. Every axis is configured by a separate Function. +// +// The Function is coded in a separate Class and can exists, without the Widget. When the widget is displayed (therefore 'created'), the Function can be attached to the +// Widget and the Widget used to change the Function. +// +class QDESIGNER_WIDGET_EXPORT QFunctionConfigurator : public QWidget +{ + Q_OBJECT + Q_PROPERTY(int maxInputEGU READ maxInputEGU WRITE setmaxInputEGU); + Q_PROPERTY(int maxOutputEGU READ maxOutputEGU WRITE setmaxOutputEGU); + Q_PROPERTY(int pixPerEGU_Input READ pixPerEGU_Input WRITE setpixPerEGU_Input); + Q_PROPERTY(int pixPerEGU_Output READ pixPerEGU_Output WRITE setpixPerEGU_Output); + Q_PROPERTY(int gridDistEGU_Input READ gridDistEGU_Input WRITE setgridDistEGU_Input); + Q_PROPERTY(int gridDistEGU_Output READ gridDistEGU_Output WRITE setgridDistEGU_Output); + + Q_PROPERTY(QColor colorBezier READ colorBezier WRITE setColorBezier); + Q_PROPERTY(QColor colorBackground READ colorBackground WRITE setColorBackground); + Q_PROPERTY(QString stringInputEGU READ stringInputEGU WRITE setInputEGU); + Q_PROPERTY(QString stringOutputEGU READ stringOutputEGU WRITE setOutputEGU); + Q_PROPERTY(QString stringCaption READ stringCaption WRITE setCaption); + + // Return the current value to Designer + int maxInputEGU() const + { + return MaxInput; + } + int maxOutputEGU() const + { + return MaxOutput; + } + int pixPerEGU_Input() const + { + return pPerEGU_Input; + } + int pixPerEGU_Output() const + { + return pPerEGU_Output; + } + int gridDistEGU_Input() const + { + return gDistEGU_Input; + } + int gridDistEGU_Output() const + { + return gDistEGU_Output; + } + + // Return the current color to Designer + QColor colorBezier() const + { + return colBezier; + } + // Return the current color to Designer + QColor colorBackground() const + { + return colBackground; + } + // Return the current string to Designer + QString stringInputEGU() const + { + return strInputEGU; + } + // Return the current string to Designer + QString stringOutputEGU() const + { + return strOutputEGU; + } + // Return the current string to Designer + QString stringCaption() const + { + return strCaption; + } + +public: + QFunctionConfigurator(QWidget *parent = 0); + ~QFunctionConfigurator(); + FunctionConfig* config(); + + void setConfig(FunctionConfig* config, QString settingsFile); // Connect the FunctionConfig to the Widget. + void loadSettings(QString settingsFile); // Load the FunctionConfig (points) from the INI-file + void saveSettings(QString settingsFile); // Save the FunctionConfig (points) to the INI-file + +signals: + void CurveChanged(bool); + +public slots: + void setmaxInputEGU(int); + void setmaxOutputEGU(int); + void setpixPerEGU_Input(int); + void setpixPerEGU_Output(int); + void setgridDistEGU_Input(int); + void setgridDistEGU_Output(int); + + void setColorBezier(QColor); + void setColorBackground(QColor); + void setInputEGU(QString); + void setOutputEGU(QString); + void setCaption(QString); + + void resetCurve() { + qDebug() << "QFunctionConfigurator::resetCurve = " << strSettingsFile; + loadSettings( strSettingsFile ); + } + +protected slots: + void paintEvent(QPaintEvent *e); + void mousePressEvent(QMouseEvent *e); + void mouseMoveEvent(QMouseEvent *e); + void mouseReleaseEvent(QMouseEvent *e); + +protected: + void drawBackground(const QRectF &rect); + void drawFunction(const QRectF &rect); + void drawPoint(QPainter *painter, const QPointF &pt, QColor colBG ); + void drawLine(QPainter *painter, const QPointF &start, const QPointF &end, QPen pen); + bool markContains(const QPointF &pt, const QPointF &coord) const; +// bool withinRange( const QPointF &coord ) const; + bool withinRect( const QPointF &coord, const QRectF &rect ) const; + +protected: + virtual void resizeEvent(QResizeEvent *); + +private: + QRectF range; // The actual rectangle for the Bezier-curve + QPointF lastPoint; // The right-most point of the Function + QPointF normalizePoint (QPointF point) const; // Convert the graphical Point to a real-life Point + QPointF graphicalizePoint (QPointF point, QString source = "") const; // Convert the Point to a graphical Point + + QPointF *moving; + int movingPoint; + + int MaxInput; // Maximum input limit + int MaxOutput; // Maximum output limit + int pPerEGU_Input; // Number of pixels, per EGU of Input + int pPerEGU_Output; // Number of pixels, per EGU of Output + int gDistEGU_Input; // Distance of the grid, in EGU of Input + int gDistEGU_Output; // Distance of the grid, in EGU of Output + + QColor colBezier; // Color of Bezier curve + QColor colBackground; // Color of widget background + QString strInputEGU; // Engineering Units input (vertical axis) + QString strOutputEGU; // Engineering Units output (horizontal axis) + QString strCaption; // Caption of the graph + QString strSettingsFile; // Name of last read INI-file + QPushButton *btnReset; // Reset Curve + + bool _draw_background; // Flag to determine if the background should be (re-)drawn on the QPixmap + QPixmap _background; // Image of the static parts (axis, lines, etc.) + bool _draw_function; // Flag to determine if the function should be (re-)drawn on the QPixmap + QPixmap _function; // Image of the function (static unless edited by the user) + + // + // Properties of the CurveConfigurator Widget + // + QString _title; // Title do display in Widget and to load Settings + FunctionConfig* _config; + QList _points; // Function-points + QList _draw_points; // Curve-points needed for drawing + HANDLE _mutex; +}; + +#endif // QFUNCTIONCONFIGURATOR_H diff --git a/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp new file mode 100644 index 00000000..44e9f831 --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.cpp @@ -0,0 +1,146 @@ +/******************************************************************************** +* 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 . * +* * +* The FunctionConfigurator was made by Stanislaw Halik, and adapted to * +* FaceTrackNoIR. * +* * +* All credits for this nice piece of code should go to Stanislaw. * +* * +* Copyright (c) 2011-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 "qfunctionconfigurator.h" + +#include +#include "qfunctionconfiguratorplugin.h" + + +QFunctionConfiguratorPlugin::QFunctionConfiguratorPlugin(QObject *parent) + : QObject(parent) +{ + initialized = false; +} + +void QFunctionConfiguratorPlugin::initialize(QDesignerFormEditorInterface */*core*/) +{ + if (initialized) + return; + + initialized = true; +} + +bool QFunctionConfiguratorPlugin::isInitialized() const +{ + return initialized; +} + +QWidget *QFunctionConfiguratorPlugin::createWidget(QWidget *parent) +{ + return new QFunctionConfigurator(parent); +} + +QString QFunctionConfiguratorPlugin::name() const +{ + return "QFunctionConfigurator"; +} + +QString QFunctionConfiguratorPlugin::group() const +{ + return "My Plugins"; +} + +QIcon QFunctionConfiguratorPlugin::icon() const +{ + return QIcon(); +} + +QString QFunctionConfiguratorPlugin::toolTip() const +{ + return QString(); +} + +QString QFunctionConfiguratorPlugin::whatsThis() const +{ + return QString(); +} + +bool QFunctionConfiguratorPlugin::isContainer() const +{ + return false; +} + +QString QFunctionConfiguratorPlugin::domXml() const +{ + return "\n" + " \n" + " \n" + " 0\n" + " 0\n" + " 161\n" + " 220\n" + " \n" + " \n" + " \n" + " \n" + " 255\n" + " 170\n" + " 0\n" + " \n" + " \n" + " \n" + " \n" + " 192\n" + " 192\n" + " 192\n" + " \n" + " \n" + " \n" + " Input Yaw (degr.)\n" + " \n" + " \n" + " Output Yaw (degr.)\n" + " \n" + " \n" + " 50\n" + " \n" + " \n" + " 180\n" + " \n" + " \n" + " 2\n" + " \n" + " \n" + " 1\n" + " \n" + "\n"; +} + +QString QFunctionConfiguratorPlugin::includeFile() const +{ + return "qfunctionconfigurator.h"; +} + +Q_EXPORT_PLUGIN2(qfunctionconfigurator, QFunctionConfiguratorPlugin) diff --git a/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h new file mode 100644 index 00000000..31bf0b2e --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator/qfunctionconfiguratorplugin.h @@ -0,0 +1,30 @@ +#ifndef QFUNCTIONCONFIGURATORPLUGIN_H +#define QFUNCTIONCONFIGURATORPLUGIN_H + +#include + +class QFunctionConfiguratorPlugin : public QObject, public QDesignerCustomWidgetInterface +{ + Q_OBJECT + Q_INTERFACES(QDesignerCustomWidgetInterface) + +public: + QFunctionConfiguratorPlugin(QObject *parent = 0); + + bool isContainer() const; + bool isInitialized() const; + QIcon icon() const; + QString domXml() const; + QString group() const; + QString includeFile() const; + QString name() const; + QString toolTip() const; + QString whatsThis() const; + QWidget *createWidget(QWidget *parent); + void initialize(QDesignerFormEditorInterface *core); + +private: + bool initialized; +}; + +#endif // QFUNCTIONCONFIGURATORPLUGIN_H diff --git a/qfunctionconfigurator/QFunctionConfigurator_vc9.sln b/qfunctionconfigurator/QFunctionConfigurator_vc9.sln new file mode 100644 index 00000000..3e82962f --- /dev/null +++ b/qfunctionconfigurator/QFunctionConfigurator_vc9.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "QFunctionConfigurator", "QFunctionConfigurator\QFunctionConfigurator_vc9.vcproj", "{2527B683-7EFC-4D51-B25A-843668649C54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.ActiveCfg = Debug|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Debug|Win32.Build.0 = Debug|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.ActiveCfg = Release|Win32 + {2527B683-7EFC-4D51-B25A-843668649C54}.Release|Win32.Build.0 = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/readme.txt b/readme.txt new file mode 100644 index 00000000..18d3babb --- /dev/null +++ b/readme.txt @@ -0,0 +1,48 @@ +This project was derived from the 'Sweetspotter' project. + + +If you want to work with the source code you should use the Microsoft Visual Studio 2005 and the Qt 4.6.x or better source code. (http://qt.nokia.com/downloads) Also it's useful to install the Qt Visual Studio Add-In. + +The integration of Qt (LGPL) in Visual Studio must be done manually. See the PDF's in the documentation folder for specific instructions. + +Here are some remarks, which were not mentioned in the PDF's, but have to be followed: +Remark 1: instead of just running "configure" you should run +"configure -debug-and-release -no-qt3support -no-webkit -platform win32-msvc2005". + +Remark 2: in the Qt folders (\src\script\tmp\moc\debug_shared\, src\script\tmp\moc\release_shared\ +and src\3rdparty\webkit\WebCore\tmp\moc can be a file called: mocinclude.tmp. Remove these, because "nmake" will fail if you don't. + + +You need also: +- FaceApi www.faceapi.com + +You need to setup the folders to the binaries and include files in the Visual Studio IDE. + + Tools > Options > Projects and Solutions > VC++ Directories + +Example in the standard way: + + Executable Files: + + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\API\bin + + Include Files: + + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\API\include + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\C++\include + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\Qt\include + C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Win32\api\inc + C:\Qt\4.6.2\include + + Library Files: + + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\Qt\lib + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\Wrappers\C++\lib + C:\Program Files (x86)\SeeingMachines\FaceTrackingAPI_NC 3.1\API\bin + C:\Program Files (x86)\FMOD SoundSystem\FMOD Programmers API Win32\api\lib + C:\Qt\4.6.2\lib + + +Best regards, + +Wim Vriend. -- cgit v1.2.3