summaryrefslogtreecommitdiffhomepage
path: root/ftnoir_tracker_rs/rs_impl
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-09-30 16:21:41 +0200
committerStanislaw Halik <sthalik@misaki.pl>2015-09-30 16:22:00 +0200
commitac4dc94acc5d1e1d8fd4867730b835e2aa1fcc89 (patch)
tree8ca3dc84958e572e3f890ac3f56dfda670c63f60 /ftnoir_tracker_rs/rs_impl
parent03a164ed74d616e8d5203142ec7e9738c8aae547 (diff)
parenteb7703b4ecea5540a4c4a65faa1ff4c53fe97631 (diff)
Merge branch 'unstable' into trackhat-ui
Sponsored-by: TrackHat * unstable: (112 commits) Revert "accela: try more complex deadzone algorithm" pt: add wiki link for calibration instructions qfc: more gray colors when graph is disabled qfc, mapping: disallow editing and change color when checkbox disabled qfc: don't allow editing when disabled plugin-support: workaround multiple copies of modules accela: change translation gain accela: change rotation gain pt: change extraction code freepie-udp: add license freepie-udp: update accela: try more complex deadzone algorithm accela: add helpful comment accela: revert to more quadratic spline at start also save if save pending when start tracking ui: force saving if saving timer is pending accela: slightly more linear function pose-widget: simplify freepie-udp: nix harmless warning pose-widget: add comment simple-mat: add __restrict for GNU ui: save settings on a timer ui: show a warning if configuration directory can't be used aruco: tune min/max marker size win32-joystick: fix duplicate device name selection logic ui: no need to reset settings on tracking start ui: save profile when combobox text changes, not merely index ui: save current tracker/filter/proto, not last win32-joystick: fix COM failure path win32-joystick: nix unused variable win32-joystick: allow for unique selection of joysticks qfc: also draw line from function start while moving no need to save on tracking start anymore save axis opts, not just spline control points tracker: change centering order again fix typo cmake: don't say "opentrack" twice for osx build ui: really don't switch profiles while refreshing combobox pt: fix type mismatch ui: save prior to switching configs tracker_rs: adjusted tracker's name ui: don't reload settings if config wasn't changed ui: save everything before switching profiles options: return .ini basename easier tracker_rs: more readable icon tracker_rs: prevent potential thread starvation ui: switch to newly-created config ui: decruft ui: also bail on new config if its name is ".ini" ui: auto-refresh config list ui: display up to 20 profiles w/o scrolling ui: create an empty config properly in another code branch udp-tracker: silence harmless warning plugin-support: fix typo plugin-support: set more sane RTLD flags plugin-support: free modules from address space when needed ui: rename symbol to reflect current usage ui: move some slots to private ui, shortcuts: these are slots, actually ui: no need to write anything to new empty config ui: avoid potential memory leak ft: new game support game-data: chomp newlines in extractor ui: append extension in the right place simple-mat: fix arglist SFINAE simple-mat: can use static_cast here nix default empty config. it gets created on its own. ui: these aren't qt slots ui: nix wrong headers ui: remove GNU GPL ui: simplify condition props changed only main, ui: store config files in a predefined directory pt: show extracted points' areas and success count close dialogs on switch to new module ...
Diffstat (limited to 'ftnoir_tracker_rs/rs_impl')
-rw-r--r--ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exebin0 -> 83968 bytes
-rw-r--r--ftnoir_tracker_rs/rs_impl/build.bat2
-rw-r--r--ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp151
-rw-r--r--ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h19
-rw-r--r--ftnoir_tracker_rs/rs_impl/udp_sender.cpp53
5 files changed, 225 insertions, 0 deletions
diff --git a/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe b/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe
new file mode 100644
index 00000000..1e2a57f1
--- /dev/null
+++ b/ftnoir_tracker_rs/rs_impl/bin/opentrack-tracker-rs-impl.exe
Binary files differ
diff --git a/ftnoir_tracker_rs/rs_impl/build.bat b/ftnoir_tracker_rs/rs_impl/build.bat
new file mode 100644
index 00000000..15206431
--- /dev/null
+++ b/ftnoir_tracker_rs/rs_impl/build.bat
@@ -0,0 +1,2 @@
+cd "%VS120COMNTOOLS%\..\..\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
diff --git a/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp
new file mode 100644
index 00000000..c1ba5c75
--- /dev/null
+++ b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.cpp
@@ -0,0 +1,151 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+#include "ftnoir_tracker_rs_impl.h"
+#include <pxcsensemanager.h>
+#include <pxcfaceconfiguration.h>
+
+PXCSenseManager* g_senseManager = NULL;
+PXCFaceData* g_faceData = NULL;
+
+pxcStatus rs_tracker_set_configuration(PXCFaceModule *faceModule){
+ pxcStatus retStatus;
+ 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();
+ if (retStatus != PXC_STATUS_NO_ERROR){
+ faceConfig->Release();
+ return retStatus;
+ }
+
+ faceConfig->Release();
+ return PXC_STATUS_NO_ERROR;
+}
+
+int rs_tracker_impl_start(){
+ pxcStatus retStatus;
+ PXCFaceModule *faceModule = NULL;
+
+ 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 = rs_tracker_set_configuration(faceModule);
+ if (retStatus != PXC_STATUS_NO_ERROR){
+ rs_tracker_impl_end();
+ return PXC_STATUS_HANDLE_INVALID;
+ }
+
+ 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 PXC_STATUS_NO_ERROR;
+}
+
+int rs_tracker_impl_update_pose(double *data){
+ pxcStatus retStatus;
+ 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
+ && (retStatus = g_senseManager->AcquireFrame(true, 16)) == PXC_STATUS_NO_ERROR){
+
+ retStatus = g_faceData->Update();
+ if (retStatus != PXC_STATUS_NO_ERROR){
+ rs_tracker_impl_end();
+ return retStatus;
+ }
+
+ pxcI32 numberOfDetectedFaces = g_faceData->QueryNumberOfDetectedFaces();
+ for (pxcI32 i = 0; i < numberOfDetectedFaces; ++i) {
+ face = g_faceData->QueryFaceByIndex(0);
+ if (face == NULL) continue;
+
+ pose = face->QueryPose();
+ if (pose == NULL) continue;
+
+ poseAnglesAvailable = pose->QueryPoseAngles(&angles);
+ if (!poseAnglesAvailable) continue;
+
+ headPositionAvailable = pose->QueryHeadPosition(&headPosition);
+ if (!headPositionAvailable) continue;
+
+ //TODO: use pxcI32 pose->QueryConfidence(); ? for data[6] or to filter here ?
+
+ //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;
+ }
+
+ g_senseManager->ReleaseFrame();
+ }
+
+ 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;
+ }
+ return PXC_STATUS_NO_ERROR;
+}
diff --git a/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h
new file mode 100644
index 00000000..0e4073d0
--- /dev/null
+++ b/ftnoir_tracker_rs/rs_impl/ftnoir_tracker_rs_impl.h
@@ -0,0 +1,19 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+#pragma once
+#ifdef EXPORT_RS_IMPL
+#define RSTRACKERIMPL_VISIBILITY __declspec( dllexport )
+#else
+#define RSTRACKERIMPL_VISIBILITY
+#endif
+
+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_end();
+}
diff --git a/ftnoir_tracker_rs/rs_impl/udp_sender.cpp b/ftnoir_tracker_rs/rs_impl/udp_sender.cpp
new file mode 100644
index 00000000..095edd8f
--- /dev/null
+++ b/ftnoir_tracker_rs/rs_impl/udp_sender.cpp
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2015, 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.
+ */
+
+#include "ftnoir_tracker_rs_impl.h"
+#include <winsock2.h>
+#include <Ws2tcpip.h>
+#include <commctrl.h>
+#include <cstdlib>
+
+#define UDP_PORT 4242
+
+int main(){
+ double pose[6] = { 0., 0., 0., 0., 0., 0. };
+ struct sockaddr_in socketInfo;
+ SOCKET s = 0;
+ WSADATA wsa;
+
+ int retStatus = rs_tracker_impl_start();
+ if (retStatus != 0){
+ exit(retStatus);
+ }
+
+ if (WSAStartup(MAKEWORD(2, 2), &wsa) != 0) //init winsocketapi
+ exit(EXIT_FAILURE);
+
+ memset(&socketInfo, 0, sizeof(socketInfo));
+ socketInfo.sin_family = AF_INET;
+ socketInfo.sin_port = htons(UDP_PORT);
+ InetPton(AF_INET, L"127.0.0.1", &socketInfo.sin_addr.S_un.S_addr);
+
+ if ((s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) //create UDP socket
+ exit(EXIT_FAILURE);
+
+ for(;;) {
+ retStatus = rs_tracker_impl_update_pose(pose);
+ if(retStatus == 0){ //no error
+ if (sendto(s, (char*)&pose, sizeof(pose), 0, (struct sockaddr *) &socketInfo, sizeof(socketInfo)) == SOCKET_ERROR) //send new data
+ exit(EXIT_FAILURE);
+ }
+
+ if(retStatus != 0 && retStatus != -303)// -303=timeout and 0 are ok, else we've got to stop.
+ break;
+ }
+
+ closesocket(s);
+ WSACleanup();
+
+ return retStatus;
+}