diff options
author | Xavier Hallade <xavier.hallade@intel.com> | 2016-06-01 22:00:13 +0200 |
---|---|---|
committer | Xavier Hallade <xavier.hallade@intel.com> | 2016-06-01 22:00:13 +0200 |
commit | cd6ddb9f572dc9cc0a60b43c1c327709311c072e (patch) | |
tree | 415a5e573a15bd6fa246f9dc90fbbce62c4cdb7e /tracker-rs/rs_impl | |
parent | f906076ef1205387f52c03e8eed4ac2419c6d9a6 (diff) |
tracker-rs: updated to SDK 2016 R2. Added more debug information and safeguards.
Diffstat (limited to 'tracker-rs/rs_impl')
-rw-r--r-- | tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll | bin | 72704 -> 76288 bytes | |||
-rw-r--r-- | tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib | bin | 2882 -> 2882 bytes | |||
-rw-r--r-- | tracker-rs/rs_impl/build.bat | 6 | ||||
-rw-r--r-- | tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp | 135 |
4 files changed, 77 insertions, 64 deletions
diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll Binary files differindex d6e0a261..3f18f212 100644 --- a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll +++ b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.dll diff --git a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib Binary files differindex 47743c50..7e49ed05 100644 --- a/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib +++ b/tracker-rs/rs_impl/bin/opentrack-tracker-rs-impl.lib diff --git a/tracker-rs/rs_impl/build.bat b/tracker-rs/rs_impl/build.bat index 799630b2..89b7647e 100644 --- a/tracker-rs/rs_impl/build.bat +++ b/tracker-rs/rs_impl/build.bat @@ -1,7 +1,7 @@ IF DEFINED %VS120COMNTOOLS%] ( - cd "%VS120COMNTOOLS%\..\..\VC" + chdir /d "%VS120COMNTOOLS%\..\..\VC" ) ELSE ( - cd "%VS140COMNTOOLS%\..\..\VC" + chdir /d "%VS140COMNTOOLS%\..\..\VC" ) -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 +vcvarsall x86 && chdir /d %~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 75499c71..c371e30a 100644 --- a/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp +++ b/tracker-rs/rs_impl/ftnoir_tracker_rs_impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Intel Corporation + * Copyright (c) 2015-2016, Intel Corporation * Author: Xavier Hallade <xavier.hallade@intel.com> * 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. @@ -7,6 +7,7 @@ #include "ftnoir_tracker_rs_impl.h" #include <pxcsensemanager.h> +#include <pxcfacemodule.h> #include <pxcfaceconfiguration.h> #include <windows.h> @@ -19,15 +20,16 @@ void* g_previewImage = NULL; CRITICAL_SECTION g_criticalSection; -pxcStatus set_face_module_configuration(PXCFaceModule *faceModule){ - pxcStatus retStatus; +pxcStatus set_face_module_configuration(PXCFaceModule *faceModule) { + pxcStatus retStatus = PXC_STATUS_NO_ERROR; PXCFaceConfiguration *faceConfig = NULL; - if (faceModule == NULL) + if (faceModule == NULL) { return PXC_STATUS_HANDLE_INVALID; + } faceConfig = faceModule->CreateActiveConfiguration(); - if (faceConfig == NULL){ + if (faceConfig == NULL) { return PXC_STATUS_HANDLE_INVALID; } @@ -41,101 +43,111 @@ pxcStatus set_face_module_configuration(PXCFaceModule *faceModule){ faceConfig->SetTrackingMode(PXCFaceConfiguration::FACE_MODE_COLOR_PLUS_DEPTH); retStatus = faceConfig->ApplyChanges(); - if (retStatus != PXC_STATUS_NO_ERROR){ - faceConfig->Release(); - return retStatus; - } faceConfig->Release(); - return PXC_STATUS_NO_ERROR; + return retStatus; } -pxcStatus retrieve_preview_from_frame(){ +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; - + PXCCapture::Sample* sample = NULL; + PXCImage::ImageInfo info; PXCImage::ImageData depthData; - retStatus = sample->depth->AcquireAccess(PXCImage::Access::ACCESS_READ, PXCImage::PIXEL_FORMAT_RGB32, &depthData); - if(retStatus == PXC_STATUS_NO_ERROR){ + if (g_senseManager == NULL) { + return PXC_STATUS_HANDLE_INVALID; + } + + 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; + } + + 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); - + sample->depth->ReleaseAccess(&depthData); } - + return retStatus; } -int rs_tracker_impl_start(){ +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); - - pxcStatus retStatus; - PXCFaceModule *faceModule = NULL; + memset(g_previewImage, 0, kPreviewStreamWidth*kPreviewStreamHeight); g_senseManager = PXCSenseManager::CreateInstance(); - if (g_senseManager == NULL){ + if (g_senseManager == NULL) { rs_tracker_impl_end(); return PXC_STATUS_HANDLE_INVALID; } retStatus = g_senseManager->EnableFace(); - if (retStatus != PXC_STATUS_NO_ERROR){ + if (retStatus != PXC_STATUS_NO_ERROR) { rs_tracker_impl_end(); return retStatus; } faceModule = g_senseManager->QueryFace(); - if (faceModule == NULL){ + if (faceModule == NULL) { rs_tracker_impl_end(); return PXC_STATUS_HANDLE_INVALID; } retStatus = set_face_module_configuration(faceModule); - if (retStatus != PXC_STATUS_NO_ERROR){ + if (retStatus != PXC_STATUS_NO_ERROR) { rs_tracker_impl_end(); - return PXC_STATUS_HANDLE_INVALID; + return retStatus; } retStatus = g_senseManager->Init(); - if (retStatus != PXC_STATUS_NO_ERROR){ + if (retStatus != PXC_STATUS_NO_ERROR) { rs_tracker_impl_end(); return retStatus; } g_faceData = faceModule->CreateOutput(); - if (g_faceData == NULL){ + if (g_faceData == NULL) { rs_tracker_impl_end(); return PXC_STATUS_HANDLE_INVALID; } - return PXC_STATUS_NO_ERROR; + return retStatus; } -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. +int rs_tracker_impl_get_preview(void* previewImageOut, int width, int height) { + if (width != kPreviewStreamWidth || height != kPreviewStreamHeight) + return PXC_STATUS_PARAM_UNSUPPORTED; + + if (g_previewImage == NULL) + return PXC_STATUS_DATA_UNAVAILABLE; EnterCriticalSection(&g_criticalSection); - memcpy(previewImageOut, g_previewImage, kPreviewStreamWidth*kPreviewStreamHeight); + if (g_previewImage != NULL) + memcpy(previewImageOut, g_previewImage, kPreviewStreamWidth*kPreviewStreamHeight); LeaveCriticalSection(&g_criticalSection); - return PXC_STATUS_HANDLE_INVALID; + return PXC_STATUS_NO_ERROR; } -int rs_tracker_impl_update_pose(double *data){//TODO: add bool preview activated. - pxcStatus retStatus; +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; @@ -144,18 +156,18 @@ int rs_tracker_impl_update_pose(double *data){//TODO: add bool preview activated bool headPositionAvailable = false; if (g_senseManager != NULL && g_faceData != NULL && g_previewImage != NULL - && (retStatus = g_senseManager->AcquireFrame(true, 16)) == PXC_STATUS_NO_ERROR){ - + && (retStatus = g_senseManager->AcquireFrame(true, 30)) == PXC_STATUS_NO_ERROR) { + retrieve_preview_from_frame(); - + retStatus = g_faceData->Update(); - if (retStatus != PXC_STATUS_NO_ERROR){ + if (retStatus != PXC_STATUS_NO_ERROR) { rs_tracker_impl_end(); return retStatus; } pxcI32 numberOfDetectedFaces = g_faceData->QueryNumberOfDetectedFaces(); - for(int i=0; i<numberOfDetectedFaces; ++i) { + for (int i = 0; i < numberOfDetectedFaces; ++i) { face = g_faceData->QueryFaceByIndex(i); if (face == NULL) continue; @@ -168,7 +180,7 @@ int rs_tracker_impl_update_pose(double *data){//TODO: add bool preview activated headPositionAvailable = pose->QueryHeadPosition(&headPosition); if (!headPositionAvailable) continue; - //TODO: use pxcI32 pose->QueryConfidence(); ? for data[6] or to filter here ? + //TODO: use pxcI32 pose->QueryConfidence() ? //x, y, z: cm data[0] = headPosition.headCenter.x / 10.; @@ -179,30 +191,31 @@ int rs_tracker_impl_update_pose(double *data){//TODO: add bool preview activated data[3] = -angles.yaw; data[4] = angles.pitch; data[5] = angles.roll; - + break; } g_senseManager->ReleaseFrame(); } - return retStatus; + return retStatus; } -int rs_tracker_impl_end(){ - if (g_faceData != NULL){ +int rs_tracker_impl_end() { + if (g_faceData != NULL) { g_faceData->Release(); g_faceData = NULL; } - if (g_senseManager != NULL){ + if (g_senseManager != NULL) { g_senseManager->Release(); g_senseManager = NULL; } - - DeleteCriticalSection(&g_criticalSection); - + + EnterCriticalSection(&g_criticalSection); free(g_previewImage); - + g_previewImage = NULL; + DeleteCriticalSection(&g_criticalSection); + return PXC_STATUS_NO_ERROR; } |