diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-28 10:39:40 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2016-08-28 10:40:14 +0200 |
commit | b6c1c5ec8768eae71f3492a4e5c92cac65cee5a1 (patch) | |
tree | 61ee5d7825d407b2648424bc110f9fc18af25420 /tracker-rs/rs_impl | |
parent | dacec3441a491c132443b9c8bb066ca514cb3335 (diff) |
tracker/rs: connect rs_impl to build
Pinging @ph0b.
Diffstat (limited to 'tracker-rs/rs_impl')
-rw-r--r-- | tracker-rs/rs_impl/CMakeLists.txt | 6 | ||||
-rw-r--r-- | tracker-rs/rs_impl/attic/bin/amd64/.gitignore (renamed from tracker-rs/rs_impl/bin/amd64/.gitignore) | 0 | ||||
-rw-r--r-- | tracker-rs/rs_impl/attic/bin/ia32/.gitignore (renamed from tracker-rs/rs_impl/bin/ia32/.gitignore) | 0 | ||||
-rw-r--r-- | tracker-rs/rs_impl/attic/build.bat | 29 | ||||
-rw-r--r-- | tracker-rs/rs_impl/attic/build_common.bat | 21 | ||||
-rw-r--r-- | tracker-rs/rs_impl/attic/udp_sender.cpp (renamed from tracker-rs/rs_impl/udp_sender.cpp) | 0 | ||||
-rw-r--r-- | tracker-rs/rs_impl/bin/amd64/rs-impl.lib | bin | 19184 -> 0 bytes | |||
-rw-r--r-- | tracker-rs/rs_impl/bin/ia32/rs-impl.lib | bin | 12906 -> 0 bytes | |||
-rw-r--r-- | tracker-rs/rs_impl/build.bat | 2 | ||||
-rw-r--r-- | tracker-rs/rs_impl/build_common.bat | 11 | ||||
-rw-r--r-- | tracker-rs/rs_impl/build_wrapped.bat | 21 | ||||
-rw-r--r-- | tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp | 317 |
12 files changed, 214 insertions, 193 deletions
diff --git a/tracker-rs/rs_impl/CMakeLists.txt b/tracker-rs/rs_impl/CMakeLists.txt new file mode 100644 index 00000000..10a71537 --- /dev/null +++ b/tracker-rs/rs_impl/CMakeLists.txt @@ -0,0 +1,6 @@ +if(WIN32) + opentrack_boilerplate(opentrack-tracker-rs-impl STATIC NO-QT SOURCES "${SDK_REALSENSE}/opensource/src/libpxc/libpxc.cpp") + target_compile_definitions(opentrack-tracker-rs-impl PRIVATE -DUNICODE -D_UNICODE -DEXPORT_RS_IMPL) + target_include_directories(opentrack-tracker-rs-impl PRIVATE SYSTEM "${SDK_REALSENSE}/include") + target_link_libraries(opentrack-tracker-rs-impl advapi32) +endif() diff --git a/tracker-rs/rs_impl/bin/amd64/.gitignore b/tracker-rs/rs_impl/attic/bin/amd64/.gitignore index 59314700..59314700 100644 --- a/tracker-rs/rs_impl/bin/amd64/.gitignore +++ b/tracker-rs/rs_impl/attic/bin/amd64/.gitignore diff --git a/tracker-rs/rs_impl/bin/ia32/.gitignore b/tracker-rs/rs_impl/attic/bin/ia32/.gitignore index 59314700..59314700 100644 --- a/tracker-rs/rs_impl/bin/ia32/.gitignore +++ b/tracker-rs/rs_impl/attic/bin/ia32/.gitignore diff --git a/tracker-rs/rs_impl/attic/build.bat b/tracker-rs/rs_impl/attic/build.bat new file mode 100644 index 00000000..3d5e8bc0 --- /dev/null +++ b/tracker-rs/rs_impl/attic/build.bat @@ -0,0 +1,29 @@ +@echo off
+
+setlocal
+
+IF DEFINED VS150COMNTOOLS (
+ if exist "%VS150COMNTOOLS%\..\..\VC\vcvarsall.bat" (
+ set vs_dir="%VS150COMNTOOLS%\..\..\VC"
+ set vs_64=amd64
+ ) else (
+ rem it installed vcvarsall.bat here for me for some reason -sh 20160827
+ set vs_dir="%VS150COMNTOOLS%\..\ide\vc"
+ set vs_64=amd64
+ )) else (
+ set vs_dir="%VS140COMNTOOLS%\..\..\VC"
+ set vs_64=amd64
+ )
+
+cd /d "%~dp0"
+if %errorlevel% neq 0 exit /b 1
+
+set rs_objs=ftnoir_tracker_rs_impl.obj libpxc.obj
+
+set rs_subdir=ia32&set vs_var=x86
+call ".\build_common.bat" || exit /b 1
+
+set rs_subdir=amd64&set vs_var=%vs_64%
+call ".\build_common.bat" || exit /b 1
+
+exit /b 0
diff --git a/tracker-rs/rs_impl/attic/build_common.bat b/tracker-rs/rs_impl/attic/build_common.bat new file mode 100644 index 00000000..c37e0ae8 --- /dev/null +++ b/tracker-rs/rs_impl/attic/build_common.bat @@ -0,0 +1,21 @@ +@echo off
+
+setlocal
+
+cd /d .\bin\%rs_subdir% || exit 1
+
+echo --- %rs_subdir%
+
+set rice_ld=/OPT:REF /OPT:ICF=10 /DEBUG /DYNAMICBASE /NXCOMPAT /LTCG
+set rice_lib=
+set rice_cc=/Ox /arch:SSE2 /EHscr /fp:fast /GS- /GF /GR- /Gy /MT /Y- /Zi /W1 /GL /Zi
+set libs=advapi32.lib
+
+if not exist %vs_dir%\vcvarsall.bat exit /b 1
+call %vs_dir%\vcvarsall %vs_var% || exit /b 1
+if ["%libpath%"] == [""] exit /b 1
+
+cl /c /nologo -DEXPORT_RS_IMPL -DUNICODE -D_UNICODE -MT %rice_cc% /I "%RSSDK_DIR%\opensource\include" ..\..\ftnoir_tracker_rs_impl.cpp "%RSSDK_DIR%\opensource\src\libpxc\libpxc.cpp" || exit /b 1
+lib /nologo %rice_lib% %rs_objs% %libs% /OUT:rs-impl.lib || exit /b 1
+
+exit /b 0
diff --git a/tracker-rs/rs_impl/udp_sender.cpp b/tracker-rs/rs_impl/attic/udp_sender.cpp index 095edd8f..095edd8f 100644 --- a/tracker-rs/rs_impl/udp_sender.cpp +++ b/tracker-rs/rs_impl/attic/udp_sender.cpp diff --git a/tracker-rs/rs_impl/bin/amd64/rs-impl.lib b/tracker-rs/rs_impl/bin/amd64/rs-impl.lib Binary files differdeleted file mode 100644 index 755e4dfb..00000000 --- a/tracker-rs/rs_impl/bin/amd64/rs-impl.lib +++ /dev/null diff --git a/tracker-rs/rs_impl/bin/ia32/rs-impl.lib b/tracker-rs/rs_impl/bin/ia32/rs-impl.lib Binary files differdeleted file mode 100644 index ce074cf6..00000000 --- a/tracker-rs/rs_impl/bin/ia32/rs-impl.lib +++ /dev/null diff --git a/tracker-rs/rs_impl/build.bat b/tracker-rs/rs_impl/build.bat deleted file mode 100644 index 612b1371..00000000 --- a/tracker-rs/rs_impl/build.bat +++ /dev/null @@ -1,2 +0,0 @@ -@cmd /c "%~dp0\build_wrapped.bat"
-@pause
\ No newline at end of file diff --git a/tracker-rs/rs_impl/build_common.bat b/tracker-rs/rs_impl/build_common.bat deleted file mode 100644 index 580cb4d8..00000000 --- a/tracker-rs/rs_impl/build_common.bat +++ /dev/null @@ -1,11 +0,0 @@ -@echo off
-
-cd /d .\bin\%rs_subdir%
-if %errorlevel% neq 0 exit 1
-
-echo --- %rs_subdir%
-
-call %vs_dir%\vcvarsall %vs_var% && CL /c /GS- /nologo /Ox /DUNICODE /D_UNICODE /MT /I "%RSSDK_DIR%\opensource\include" ..\..\ftnoir_tracker_rs_impl.cpp "%RSSDK_DIR%\opensource\src\libpxc\libpxc.cpp" && lib /NOLOGO %rs_objs% /OUT:rs-impl.lib
-
-if %errorlevel% neq 0 exit 1
-exit 0
diff --git a/tracker-rs/rs_impl/build_wrapped.bat b/tracker-rs/rs_impl/build_wrapped.bat deleted file mode 100644 index 1e65ef12..00000000 --- a/tracker-rs/rs_impl/build_wrapped.bat +++ /dev/null @@ -1,21 +0,0 @@ -@echo off - -IF DEFINED VS150COMNTOOLS ( - set vs_dir="%VS150COMNTOOLS%\..\..\VC" - set vs_64=x86_amd64 - ) ELSE ( - set vs_dir="%VS140COMNTOOLS%\..\..\VC" - set vs_64=amd64 - ) - - -cd /d "%~dp0" -if %errorlevel% neq 0 exit 1 - -set rs_objs=ftnoir_tracker_rs_impl.obj libpxc.obj - -set rs_subdir=ia32&set vs_var=x86 -cmd /c "call .\build_common.bat" - -set rs_subdir=amd64&set vs_var=%vs_64% -cmd /c "call .\build_common.bat" diff --git a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp index c371e30a..6b3c5351 100644 --- a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp +++ b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp @@ -4,7 +4,6 @@ * 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. * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ - #include "ftnoir_tracker_rs_impl.h" #include <pxcsensemanager.h> #include <pxcfacemodule.h> @@ -21,201 +20,201 @@ void* g_previewImage = NULL; CRITICAL_SECTION g_criticalSection; pxcStatus set_face_module_configuration(PXCFaceModule *faceModule) { - pxcStatus retStatus = PXC_STATUS_NO_ERROR; - PXCFaceConfiguration *faceConfig = NULL; - - if (faceModule == NULL) { - return PXC_STATUS_HANDLE_INVALID; - } - - faceConfig = faceModule->CreateActiveConfiguration(); - if (faceConfig == NULL) { - return PXC_STATUS_HANDLE_INVALID; - } - - faceConfig->pose.isEnabled = true; - faceConfig->pose.maxTrackedFaces = 1; - faceConfig->pose.smoothingLevel = PXCFaceConfiguration::SmoothingLevelType::SMOOTHING_DISABLED; - faceConfig->strategy = PXCFaceConfiguration::STRATEGY_CLOSEST_TO_FARTHEST; - faceConfig->detection.isEnabled = false; - faceConfig->landmarks.isEnabled = false; - faceConfig->DisableAllAlerts(); - faceConfig->SetTrackingMode(PXCFaceConfiguration::FACE_MODE_COLOR_PLUS_DEPTH); - - retStatus = faceConfig->ApplyChanges(); - - faceConfig->Release(); - return retStatus; + pxcStatus retStatus = PXC_STATUS_NO_ERROR; + PXCFaceConfiguration *faceConfig = NULL; + + if (faceModule == NULL) { + return PXC_STATUS_HANDLE_INVALID; + } + + faceConfig = faceModule->CreateActiveConfiguration(); + if (faceConfig == NULL) { + return PXC_STATUS_HANDLE_INVALID; + } + + faceConfig->pose.isEnabled = true; + faceConfig->pose.maxTrackedFaces = 1; + faceConfig->pose.smoothingLevel = PXCFaceConfiguration::SmoothingLevelType::SMOOTHING_DISABLED; + faceConfig->strategy = PXCFaceConfiguration::STRATEGY_CLOSEST_TO_FARTHEST; + faceConfig->detection.isEnabled = false; + faceConfig->landmarks.isEnabled = false; + faceConfig->DisableAllAlerts(); + faceConfig->SetTrackingMode(PXCFaceConfiguration::FACE_MODE_COLOR_PLUS_DEPTH); + + retStatus = faceConfig->ApplyChanges(); + + faceConfig->Release(); + return retStatus; } pxcStatus retrieve_preview_from_frame() { - pxcStatus retStatus = PXC_STATUS_NO_ERROR; - PXCCapture::Sample* sample = NULL; - PXCImage::ImageInfo info; - PXCImage::ImageData depthData; + pxcStatus retStatus = PXC_STATUS_NO_ERROR; + PXCCapture::Sample* sample = NULL; + PXCImage::ImageInfo info; + PXCImage::ImageData depthData; - if (g_senseManager == NULL) { - return PXC_STATUS_HANDLE_INVALID; - } + if (g_senseManager == NULL) { + return PXC_STATUS_HANDLE_INVALID; + } - sample = g_senseManager->QuerySample(); - if (sample == NULL || sample->depth == NULL) { - return PXC_STATUS_DATA_UNAVAILABLE; - } + sample = g_senseManager->QuerySample(); + if (sample == NULL || sample->depth == NULL) { + return PXC_STATUS_DATA_UNAVAILABLE; + } - info = sample->depth->QueryInfo(); - if (info.width > kPreviewStreamWidth || info.height > kPreviewStreamHeight) { - return PXC_STATUS_PARAM_UNSUPPORTED; - } + info = sample->depth->QueryInfo(); + if (info.width > kPreviewStreamWidth || info.height > kPreviewStreamHeight) { + return PXC_STATUS_PARAM_UNSUPPORTED; + } - retStatus = sample->depth->AcquireAccess(PXCImage::Access::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB32, &depthData); - if (retStatus == PXC_STATUS_NO_ERROR) { - EnterCriticalSection(&g_criticalSection); + retStatus = sample->depth->AcquireAccess(PXCImage::Access::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB32, &depthData); + if (retStatus == PXC_STATUS_NO_ERROR) { + EnterCriticalSection(&g_criticalSection); - for (int i = 0; i < info.height; ++i) - for (int j = 0; j < info.width; ++j) - ((unsigned char*)g_previewImage)[i*info.width + j] = ((unsigned char*)depthData.planes[0])[(i + 1) * 4 * info.width - 4 * (j + 1)]; //mirror and convert from RGB32 to Y8. + for (int i = 0; i < info.height; ++i) + for (int j = 0; j < info.width; ++j) + ((unsigned char*)g_previewImage)[i*info.width + j] = ((unsigned char*)depthData.planes[0])[(i + 1) * 4 * info.width - 4 * (j + 1)]; //mirror and convert from RGB32 to Y8. - LeaveCriticalSection(&g_criticalSection); + LeaveCriticalSection(&g_criticalSection); - sample->depth->ReleaseAccess(&depthData); - } + sample->depth->ReleaseAccess(&depthData); + } - return retStatus; + return retStatus; } int rs_tracker_impl_start() { - pxcStatus retStatus = PXC_STATUS_NO_ERROR; - PXCFaceModule *faceModule = NULL; - - InitializeCriticalSection(&g_criticalSection); - g_previewImage = malloc(kPreviewStreamWidth*kPreviewStreamHeight); - memset(g_previewImage, 0, kPreviewStreamWidth*kPreviewStreamHeight); - - g_senseManager = PXCSenseManager::CreateInstance(); - if (g_senseManager == NULL) { - rs_tracker_impl_end(); - return PXC_STATUS_HANDLE_INVALID; - } - - retStatus = g_senseManager->EnableFace(); - if (retStatus != PXC_STATUS_NO_ERROR) { - rs_tracker_impl_end(); - return retStatus; - } - - faceModule = g_senseManager->QueryFace(); - if (faceModule == NULL) { - rs_tracker_impl_end(); - return PXC_STATUS_HANDLE_INVALID; - } - - retStatus = set_face_module_configuration(faceModule); - if (retStatus != PXC_STATUS_NO_ERROR) { - rs_tracker_impl_end(); - return retStatus; - } - - retStatus = g_senseManager->Init(); - if (retStatus != PXC_STATUS_NO_ERROR) { - rs_tracker_impl_end(); - return retStatus; - } - - g_faceData = faceModule->CreateOutput(); - if (g_faceData == NULL) { - rs_tracker_impl_end(); - return PXC_STATUS_HANDLE_INVALID; - } - - return retStatus; + pxcStatus retStatus = PXC_STATUS_NO_ERROR; + PXCFaceModule *faceModule = NULL; + + InitializeCriticalSection(&g_criticalSection); + g_previewImage = malloc(kPreviewStreamWidth*kPreviewStreamHeight); + memset(g_previewImage, 0, kPreviewStreamWidth*kPreviewStreamHeight); + + g_senseManager = PXCSenseManager::CreateInstance(); + if (g_senseManager == NULL) { + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + retStatus = g_senseManager->EnableFace(); + if (retStatus != PXC_STATUS_NO_ERROR) { + rs_tracker_impl_end(); + return retStatus; + } + + faceModule = g_senseManager->QueryFace(); + if (faceModule == NULL) { + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + retStatus = set_face_module_configuration(faceModule); + if (retStatus != PXC_STATUS_NO_ERROR) { + rs_tracker_impl_end(); + return retStatus; + } + + retStatus = g_senseManager->Init(); + if (retStatus != PXC_STATUS_NO_ERROR) { + rs_tracker_impl_end(); + return retStatus; + } + + g_faceData = faceModule->CreateOutput(); + if (g_faceData == NULL) { + rs_tracker_impl_end(); + return PXC_STATUS_HANDLE_INVALID; + } + + return retStatus; } int rs_tracker_impl_get_preview(void* previewImageOut, int width, int height) { - if (width != kPreviewStreamWidth || height != kPreviewStreamHeight) - return PXC_STATUS_PARAM_UNSUPPORTED; + if (width != kPreviewStreamWidth || height != kPreviewStreamHeight) + return PXC_STATUS_PARAM_UNSUPPORTED; - if (g_previewImage == NULL) - return PXC_STATUS_DATA_UNAVAILABLE; + if (g_previewImage == NULL) + return PXC_STATUS_DATA_UNAVAILABLE; - EnterCriticalSection(&g_criticalSection); - if (g_previewImage != NULL) - memcpy(previewImageOut, g_previewImage, kPreviewStreamWidth*kPreviewStreamHeight); - LeaveCriticalSection(&g_criticalSection); + EnterCriticalSection(&g_criticalSection); + if (g_previewImage != NULL) + memcpy(previewImageOut, g_previewImage, kPreviewStreamWidth*kPreviewStreamHeight); + LeaveCriticalSection(&g_criticalSection); - return PXC_STATUS_NO_ERROR; + return PXC_STATUS_NO_ERROR; } int rs_tracker_impl_update_pose(double *data) {//TODO: add bool preview activated. - pxcStatus retStatus = PXC_STATUS_NO_ERROR; - PXCFaceData::PoseEulerAngles angles; - PXCFaceData::HeadPosition headPosition; - PXCFaceData::Face *face = NULL; - PXCFaceData::PoseData *pose = NULL; - bool poseAnglesAvailable = false; - bool headPositionAvailable = false; + pxcStatus retStatus = PXC_STATUS_NO_ERROR; + PXCFaceData::PoseEulerAngles angles; + PXCFaceData::HeadPosition headPosition; + PXCFaceData::Face *face = NULL; + PXCFaceData::PoseData *pose = NULL; + bool poseAnglesAvailable = false; + bool headPositionAvailable = false; - if (g_senseManager != NULL && g_faceData != NULL && g_previewImage != NULL - && (retStatus = g_senseManager->AcquireFrame(true, 30)) == PXC_STATUS_NO_ERROR) { + if (g_senseManager != NULL && g_faceData != NULL && g_previewImage != NULL + && (retStatus = g_senseManager->AcquireFrame(true, 30)) == PXC_STATUS_NO_ERROR) { - retrieve_preview_from_frame(); + retrieve_preview_from_frame(); - retStatus = g_faceData->Update(); - if (retStatus != PXC_STATUS_NO_ERROR) { - rs_tracker_impl_end(); - return retStatus; - } + retStatus = g_faceData->Update(); + if (retStatus != PXC_STATUS_NO_ERROR) { + rs_tracker_impl_end(); + return retStatus; + } - pxcI32 numberOfDetectedFaces = g_faceData->QueryNumberOfDetectedFaces(); - for (int i = 0; i < numberOfDetectedFaces; ++i) { - face = g_faceData->QueryFaceByIndex(i); - if (face == NULL) continue; + pxcI32 numberOfDetectedFaces = g_faceData->QueryNumberOfDetectedFaces(); + for (int i = 0; i < numberOfDetectedFaces; ++i) { + face = g_faceData->QueryFaceByIndex(i); + if (face == NULL) continue; - pose = face->QueryPose(); - if (pose == NULL) continue; + pose = face->QueryPose(); + if (pose == NULL) continue; - poseAnglesAvailable = pose->QueryPoseAngles(&angles); - if (!poseAnglesAvailable) continue; + poseAnglesAvailable = pose->QueryPoseAngles(&angles); + if (!poseAnglesAvailable) continue; - headPositionAvailable = pose->QueryHeadPosition(&headPosition); - if (!headPositionAvailable) continue; + headPositionAvailable = pose->QueryHeadPosition(&headPosition); + if (!headPositionAvailable) continue; - //TODO: use pxcI32 pose->QueryConfidence() ? + //TODO: use pxcI32 pose->QueryConfidence() ? - //x, y, z: cm - data[0] = headPosition.headCenter.x / 10.; - data[1] = headPosition.headCenter.y / 10.; - data[2] = headPosition.headCenter.z / 10.; + //x, y, z: cm + data[0] = headPosition.headCenter.x / 10.; + data[1] = headPosition.headCenter.y / 10.; + data[2] = headPosition.headCenter.z / 10.; - //yaw, pitch, roll: degrees - data[3] = -angles.yaw; - data[4] = angles.pitch; - data[5] = angles.roll; + //yaw, pitch, roll: degrees + data[3] = -angles.yaw; + data[4] = angles.pitch; + data[5] = angles.roll; - break; - } + break; + } - g_senseManager->ReleaseFrame(); - } + g_senseManager->ReleaseFrame(); + } - return retStatus; + return retStatus; } int rs_tracker_impl_end() { - if (g_faceData != NULL) { - g_faceData->Release(); - g_faceData = NULL; - } - - if (g_senseManager != NULL) { - g_senseManager->Release(); - g_senseManager = NULL; - } - - EnterCriticalSection(&g_criticalSection); - free(g_previewImage); - g_previewImage = NULL; - DeleteCriticalSection(&g_criticalSection); - - return PXC_STATUS_NO_ERROR; + if (g_faceData != NULL) { + g_faceData->Release(); + g_faceData = NULL; + } + + if (g_senseManager != NULL) { + g_senseManager->Release(); + g_senseManager = NULL; + } + + EnterCriticalSection(&g_criticalSection); + free(g_previewImage); + g_previewImage = NULL; + DeleteCriticalSection(&g_criticalSection); + + return PXC_STATUS_NO_ERROR; } |