From f41f404de607b4f8f5aa270e36ae7c43baf63862 Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Wed, 3 Feb 2016 23:40:48 +0100 Subject: tracker/rs: added camera preview, removed separate process and TCP socket the RS implementation still resides in a different DLL as it has to be compiled separately by MSVC compiler. --- .../rs_impl/bin/opentrack-tracker-rs-impl.dll | Bin 0 -> 72704 bytes .../rs_impl/bin/opentrack-tracker-rs-impl.exe | Bin 93696 -> 0 bytes .../rs_impl/bin/opentrack-tracker-rs-impl.lib | Bin 0 -> 2882 bytes tracker-rs/rs_impl/build.bat | 3 +- tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp | 75 ++++++++++++++++++--- tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h | 1 + 6 files changed, 69 insertions(+), 10 deletions(-) create mode 100644 tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll delete mode 100644 tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.exe create mode 100644 tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib (limited to 'tracker-rs/rs_impl') diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll new file mode 100644 index 00000000..9e75d4e3 Binary files /dev/null and b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll differ diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.exe b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.exe deleted file mode 100644 index e00ed69c..00000000 Binary files a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.exe and /dev/null differ diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib new file mode 100644 index 00000000..772cd340 Binary files /dev/null and b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib differ diff --git a/tracker-rs/rs_impl/build.bat b/tracker-rs/rs_impl/build.bat index 3a44fed5..799630b2 100644 --- a/tracker-rs/rs_impl/build.bat +++ b/tracker-rs/rs_impl/build.bat @@ -3,4 +3,5 @@ IF DEFINED %VS120COMNTOOLS%] ( ) ELSE ( cd "%VS140COMNTOOLS%\..\..\VC" ) -vcvarsall x64 && cd %~dp0 && CL /nologo /Ox /DUNICODE /D_UNICODE /MT /I"%RSSDK_DIR%\opensource\include" ftnoir_tracker_rs_impl.cpp udp_sender.cpp "%RSSDK_DIR%\opensource\src\libpxc\libpxc.cpp" /link ADVAPI32.LIB Ws2_32.lib /SUBSYSTEM:CONSOLE /OUT:bin\opentrack-tracker-rs-impl.exe \ No newline at end of file + +vcvarsall x86 && cd %~dp0 && CL /nologo /Ox /DUNICODE /D_UNICODE /DEXPORT_RS_IMPL /MT /I"%RSSDK_DIR%\opensource\include" ftnoir_tracker_rs_impl.cpp "%RSSDK_DIR%\opensource\src\libpxc\libpxc.cpp" /link ADVAPI32.LIB /DLL /OUT:bin\opentrack-tracker-rs-impl.dll \ No newline at end of file diff --git a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp index c1ba5c75..75499c71 100644 --- a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp +++ b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp @@ -8,11 +8,18 @@ #include "ftnoir_tracker_rs_impl.h" #include #include +#include + +const size_t kPreviewStreamWidth = 640; +const size_t kPreviewStreamHeight = 480; PXCSenseManager* g_senseManager = NULL; PXCFaceData* g_faceData = NULL; +void* g_previewImage = NULL; + +CRITICAL_SECTION g_criticalSection; -pxcStatus rs_tracker_set_configuration(PXCFaceModule *faceModule){ +pxcStatus set_face_module_configuration(PXCFaceModule *faceModule){ pxcStatus retStatus; PXCFaceConfiguration *faceConfig = NULL; @@ -43,7 +50,37 @@ pxcStatus rs_tracker_set_configuration(PXCFaceModule *faceModule){ return PXC_STATUS_NO_ERROR; } +pxcStatus retrieve_preview_from_frame(){ + pxcStatus retStatus = PXC_STATUS_NO_ERROR; + PXCCapture::Sample* sample = g_senseManager->QuerySample(); + PXCImage::ImageInfo info = sample->depth->QueryInfo(); + + if(info.width>kPreviewStreamWidth || info.height>kPreviewStreamHeight) + return PXC_STATUS_PARAM_UNSUPPORTED; + + PXCImage::ImageData depthData; + 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; idepth->ReleaseAccess(&depthData); + } + + return retStatus; +} + int rs_tracker_impl_start(){ + InitializeCriticalSection(&g_criticalSection); + g_previewImage = malloc(kPreviewStreamWidth*kPreviewStreamHeight); + memset(g_previewImage, 0, kPreviewStreamWidth*kPreviewStreamHeight); + pxcStatus retStatus; PXCFaceModule *faceModule = NULL; @@ -65,7 +102,7 @@ int rs_tracker_impl_start(){ return PXC_STATUS_HANDLE_INVALID; } - retStatus = rs_tracker_set_configuration(faceModule); + retStatus = set_face_module_configuration(faceModule); if (retStatus != PXC_STATUS_NO_ERROR){ rs_tracker_impl_end(); return PXC_STATUS_HANDLE_INVALID; @@ -86,7 +123,18 @@ int rs_tracker_impl_start(){ return PXC_STATUS_NO_ERROR; } -int rs_tracker_impl_update_pose(double *data){ +int rs_tracker_impl_get_preview(void* previewImageOut, int width, int height){ + if(width!=kPreviewStreamWidth || height!=kPreviewStreamHeight || g_previewImage == NULL) + return -1;//TODO: improve errors communication. + + EnterCriticalSection(&g_criticalSection); + memcpy(previewImageOut, g_previewImage, kPreviewStreamWidth*kPreviewStreamHeight); + LeaveCriticalSection(&g_criticalSection); + + return PXC_STATUS_HANDLE_INVALID; +} + +int rs_tracker_impl_update_pose(double *data){//TODO: add bool preview activated. pxcStatus retStatus; PXCFaceData::PoseEulerAngles angles; PXCFaceData::HeadPosition headPosition; @@ -95,9 +143,11 @@ int rs_tracker_impl_update_pose(double *data){ bool poseAnglesAvailable = false; bool headPositionAvailable = false; - if (g_senseManager != NULL && g_faceData != NULL + if (g_senseManager != NULL && g_faceData != NULL && g_previewImage != NULL && (retStatus = g_senseManager->AcquireFrame(true, 16)) == PXC_STATUS_NO_ERROR){ - + + retrieve_preview_from_frame(); + retStatus = g_faceData->Update(); if (retStatus != PXC_STATUS_NO_ERROR){ rs_tracker_impl_end(); @@ -105,8 +155,8 @@ int rs_tracker_impl_update_pose(double *data){ } pxcI32 numberOfDetectedFaces = g_faceData->QueryNumberOfDetectedFaces(); - for (pxcI32 i = 0; i < numberOfDetectedFaces; ++i) { - face = g_faceData->QueryFaceByIndex(0); + for(int i=0; iQueryFaceByIndex(i); if (face == NULL) continue; pose = face->QueryPose(); @@ -128,13 +178,15 @@ int rs_tracker_impl_update_pose(double *data){ //yaw, pitch, roll: degrees data[3] = -angles.yaw; data[4] = angles.pitch; - data[5] = -angles.roll; + data[5] = angles.roll; + + break; } g_senseManager->ReleaseFrame(); } - return retStatus; + return retStatus; } int rs_tracker_impl_end(){ @@ -147,5 +199,10 @@ int rs_tracker_impl_end(){ g_senseManager->Release(); g_senseManager = NULL; } + + DeleteCriticalSection(&g_criticalSection); + + free(g_previewImage); + return PXC_STATUS_NO_ERROR; } diff --git a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h index 0e4073d0..a4c03ce8 100644 --- a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h +++ b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.h @@ -15,5 +15,6 @@ extern "C" { RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_start(); RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_update_pose(double *pose); + RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_get_preview(void* data, int width, int height); RSTRACKERIMPL_VISIBILITY int rs_tracker_impl_end(); } -- cgit v1.2.3 From 652bdad279f7769523d3c6faa609448028907256 Mon Sep 17 00:00:00 2001 From: Xavier Hallade Date: Thu, 11 Feb 2016 16:50:09 +0100 Subject: tracker/rs: updated runtime to 2016 R1. --- tracker-rs/CMakeLists.txt | 2 +- tracker-rs/ftnoir_tracker_rs.cpp | 4 ++-- tracker-rs/ftnoir_tracker_rs_controls.ui | 10 +++++----- tracker-rs/ftnoir_tracker_rs_worker.cpp | 9 +++++---- .../intel_rs_sdk_runtime_websetup_7.0.23.8048.exe | Bin 1203240 -> 0 bytes .../intel_rs_sdk_runtime_websetup_8.0.24.6528.exe | Bin 0 -> 1226096 bytes .../rs_impl/bin/opentrack-tracker-rs-impl.dll | Bin 72704 -> 72704 bytes .../rs_impl/bin/opentrack-tracker-rs-impl.lib | Bin 2882 -> 2882 bytes 8 files changed, 13 insertions(+), 12 deletions(-) delete mode 100644 tracker-rs/redist/intel_rs_sdk_runtime_websetup_7.0.23.8048.exe create mode 100644 tracker-rs/redist/intel_rs_sdk_runtime_websetup_8.0.24.6528.exe (limited to 'tracker-rs/rs_impl') diff --git a/tracker-rs/CMakeLists.txt b/tracker-rs/CMakeLists.txt index 76ffd191..9219aafd 100644 --- a/tracker-rs/CMakeLists.txt +++ b/tracker-rs/CMakeLists.txt @@ -2,5 +2,5 @@ if(WIN32) opentrack_boilerplate(opentrack-tracker-rs) target_link_libraries(opentrack-tracker-rs "${CMAKE_SOURCE_DIR}/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib") install(FILES "${CMAKE_SOURCE_DIR}/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll" DESTINATION . ${opentrack-perms}) - install(FILES "${CMAKE_SOURCE_DIR}/tracker-rs/redist/intel_rs_sdk_runtime_websetup_7.0.23.8048.exe" DESTINATION ./contrib/ ${opentrack-perms}) + install(FILES "${CMAKE_SOURCE_DIR}/tracker-rs/redist/intel_rs_sdk_runtime_websetup_8.0.24.6528.exe" DESTINATION ./contrib/ ${opentrack-perms}) endif() diff --git a/tracker-rs/ftnoir_tracker_rs.cpp b/tracker-rs/ftnoir_tracker_rs.cpp index 7bb47256..d8d12210 100644 --- a/tracker-rs/ftnoir_tracker_rs.cpp +++ b/tracker-rs/ftnoir_tracker_rs.cpp @@ -72,7 +72,7 @@ void RSTracker::handleTrackingEnded(int exitCode){ bool RSTracker::startSdkInstallationProcess() { - bool pStarted = QProcess::startDetached("contrib\\intel_rs_sdk_runtime_websetup_7.0.23.8048.exe --finstall=core,face3d --fnone=all"); + bool pStarted = QProcess::startDetached("contrib\\intel_rs_sdk_runtime_websetup_8.0.24.6528.exe --finstall=core,face3d --fnone=all"); if(!pStarted){ QMessageBox::warning(0, "Intel® RealSense™ Runtime Installation", "Installation process failed to start.", QMessageBox::Ok); } @@ -88,7 +88,7 @@ void RSTracker::showRealSenseErrorMessageBox(int exitCode) msgBox.setInformativeText("Couldn't initialize RealSense tracking. Please install SDK Runtime R5."); } else { - msgBox.setInformativeText("Status code: " + QString::number(exitCode) + ".\n\nNote that you need the latest camera drivers and the SDK runtime R5 to be installed."); + msgBox.setInformativeText("Status code: " + QString::number(exitCode) + ".\n\nNote that you need the latest camera drivers and the SDK runtime 2016 R1 to be installed."); } QPushButton* triggerSdkInstallation = msgBox.addButton("Install Runtime", QMessageBox::ActionRole); diff --git a/tracker-rs/ftnoir_tracker_rs_controls.ui b/tracker-rs/ftnoir_tracker_rs_controls.ui index 023e14d3..30d06956 100644 --- a/tracker-rs/ftnoir_tracker_rs_controls.ui +++ b/tracker-rs/ftnoir_tracker_rs_controls.ui @@ -9,8 +9,8 @@ 0 0 - 378 - 193 + 484 + 244 @@ -36,15 +36,15 @@ The application will activate your camera for face tracking by the Intel® RealSense™ SDK. By design, the application has no direct access to any camera images. -In order to use this tracker, you need a PC equipped with -an Intel® RealSense™ R200 camera and the RealSense™ SDK R5 runtime. +In order to use this tracker, you need a PC equipped with an Intel® RealSense™ +F200 or SR300 camera and the RealSense™ SDK 2016 R1 runtime. - Install SDK Runtime R5 + Install Runtime diff --git a/tracker-rs/ftnoir_tracker_rs_worker.cpp b/tracker-rs/ftnoir_tracker_rs_worker.cpp index c387b731..213f13ff 100644 --- a/tracker-rs/ftnoir_tracker_rs_worker.cpp +++ b/tracker-rs/ftnoir_tracker_rs_worker.cpp @@ -29,13 +29,14 @@ void RSTrackerWorkerThread::run(){ while(!isInterruptionRequested()){ retValue = rs_tracker_impl_update_pose(pose); - if(retValue!=0 && retValue!=-303){ // -303 is only a timeout. + if(retValue == 0){ // success + QMutexLocker lock(&mMutex); + memcpy(mPose, pose, sizeof(pose)); + } + else if(retValue != -303){ // pose update failed. -303 is OK as it's only a timeout. emit trackingHasFinished(retValue); break; } - - QMutexLocker lock(&mMutex); - memcpy(mPose, pose, sizeof(pose)); } rs_tracker_impl_end(); diff --git a/tracker-rs/redist/intel_rs_sdk_runtime_websetup_7.0.23.8048.exe b/tracker-rs/redist/intel_rs_sdk_runtime_websetup_7.0.23.8048.exe deleted file mode 100644 index 2e2b365c..00000000 Binary files a/tracker-rs/redist/intel_rs_sdk_runtime_websetup_7.0.23.8048.exe and /dev/null differ diff --git a/tracker-rs/redist/intel_rs_sdk_runtime_websetup_8.0.24.6528.exe b/tracker-rs/redist/intel_rs_sdk_runtime_websetup_8.0.24.6528.exe new file mode 100644 index 00000000..5b3704ed Binary files /dev/null and b/tracker-rs/redist/intel_rs_sdk_runtime_websetup_8.0.24.6528.exe differ diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll index 9e75d4e3..d6e0a261 100644 Binary files a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll and b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll differ diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib index 772cd340..47743c50 100644 Binary files a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib and b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib differ -- cgit v1.2.3