mirror of
https://thingvellir.net/git/overte
synced 2025-03-27 23:52:03 +01:00
Remove RealSense & MIDI
This commit is contained in:
parent
3854523787
commit
2cea593fbd
12 changed files with 1 additions and 600 deletions
|
@ -1,33 +0,0 @@
|
|||
# Try to find the RSSDK library
|
||||
#
|
||||
# You must provide a RSSDK_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# RSSDK_FOUND - system found RSSDK
|
||||
# RSSDK_INCLUDE_DIRS - the RSSDK include directory
|
||||
# RSSDK_LIBRARIES - Link this to use RSSDK
|
||||
#
|
||||
# Created on 12/7/2014 by Thijs Wenker
|
||||
# Copyright (c) 2014 High Fidelity
|
||||
#
|
||||
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("rssdk")
|
||||
|
||||
find_path(RSSDK_INCLUDE_DIRS pxcbase.h PATH_SUFFIXES include HINTS ${RSSDK_SEARCH_DIRS})
|
||||
|
||||
if (WIN32)
|
||||
find_library(RSSDK_LIBRARY_DEBUG libpxc_d PATH_SUFFIXES lib/Win32 HINTS ${RSSDK_SEARCH_DIRS})
|
||||
find_library(RSSDK_LIBRARY_RELEASE libpxc PATH_SUFFIXES lib/Win32 HINTS ${RSSDK_SEARCH_DIRS})
|
||||
endif ()
|
||||
|
||||
include(SelectLibraryConfigurations)
|
||||
select_library_configurations(RSSDK)
|
||||
|
||||
set(RSSDK_LIBRARIES "${RSSDK_LIBRARY}")
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(RSSDK DEFAULT_MSG RSSDK_INCLUDE_DIRS RSSDK_LIBRARIES)
|
||||
|
||||
mark_as_advanced(RSSDK_INCLUDE_DIRS RSSDK_LIBRARIES RSSDK_SEARCH_DIRS)
|
|
@ -1,30 +0,0 @@
|
|||
#
|
||||
# FindRtMidi.cmake
|
||||
#
|
||||
# Try to find the RtMidi library
|
||||
#
|
||||
# You can provide a RTMIDI_ROOT_DIR which contains lib and include directories
|
||||
#
|
||||
# Once done this will define
|
||||
#
|
||||
# RTMIDI_FOUND - system found RtMidi
|
||||
# RTMIDI_INCLUDE_DIRS - the RtMidi include directory
|
||||
# RTMIDI_LIBRARIES - link to this to use RtMidi
|
||||
#
|
||||
# Created on 6/30/2014 by Stephen Birarda
|
||||
# Copyright 2014 High Fidelity, Inc.
|
||||
#
|
||||
# Distributed under the Apache License, Version 2.0.
|
||||
# See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
#
|
||||
|
||||
include("${MACRO_DIR}/HifiLibrarySearchHints.cmake")
|
||||
hifi_library_search_hints("rtmidi")
|
||||
|
||||
find_path(RTMIDI_INCLUDE_DIRS RtMidi.h PATH_SUFFIXES include HINTS ${RTMIDI_SEARCH_DIRS})
|
||||
find_library(RTMIDI_LIBRARIES NAMES rtmidi PATH_SUFFIXES lib HINTS ${RTMIDI_SEARCH_DIRS})
|
||||
|
||||
include(FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args(RtMidi DEFAULT_MSG RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES)
|
||||
|
||||
mark_as_advanced(RTMIDI_INCLUDE_DIRS RTMIDI_LIBRARIES RTMIDI_SEARCH_DIRS)
|
|
@ -2,7 +2,7 @@ set(TARGET_NAME interface)
|
|||
project(${TARGET_NAME})
|
||||
|
||||
# set a default root dir for each of our optional externals if it was not passed
|
||||
set(OPTIONAL_EXTERNALS "LeapMotion" "RtMidi" "RSSDK")
|
||||
set(OPTIONAL_EXTERNALS "LeapMotion")
|
||||
|
||||
if(WIN32)
|
||||
list(APPEND OPTIONAL_EXTERNALS "3DConnexionClient")
|
||||
|
@ -161,13 +161,6 @@ foreach(EXTERNAL ${OPTIONAL_EXTERNALS})
|
|||
endif ()
|
||||
endforeach()
|
||||
|
||||
# special OS X modifications for RtMidi library
|
||||
if (RTMIDI_FOUND AND NOT DISABLE_RTMIDI AND APPLE)
|
||||
find_library(CoreMIDI CoreMIDI)
|
||||
add_definitions(-D__MACOSX_CORE__)
|
||||
target_link_libraries(${TARGET_NAME} ${CoreMIDI})
|
||||
endif ()
|
||||
|
||||
# include headers for interface and InterfaceConfig.
|
||||
include_directories("${PROJECT_SOURCE_DIR}/src")
|
||||
|
||||
|
|
9
interface/external/rssdk/readme.txt
vendored
9
interface/external/rssdk/readme.txt
vendored
|
@ -1,9 +0,0 @@
|
|||
|
||||
Instructions for adding the Intel Realsense (RSSDK) to Interface
|
||||
Thijs Wenker, December 19, 2014
|
||||
|
||||
This is Windows only for now.
|
||||
|
||||
1. Download the SDK at https://software.intel.com/en-us/intel-realsense-sdk/download
|
||||
|
||||
2. Copy the `lib` and `include` folder inside this directory
|
43
interface/external/rtmidi/readme.txt
vendored
43
interface/external/rtmidi/readme.txt
vendored
|
@ -1,43 +0,0 @@
|
|||
|
||||
Instructions for adding the RtMidi library to Interface
|
||||
Stephen Birarda, June 30, 2014
|
||||
|
||||
1. Download the RtMidi tarball from High Fidelity S3.
|
||||
http://public.highfidelity.io/dependencies/rtmidi-2.1.0.tar.gz
|
||||
|
||||
2. Copy RtMidi.h to externals/rtmidi/include.
|
||||
|
||||
3. Compile the RtMidi library.
|
||||
|
||||
3. Copy either librtmidi.dylib (dynamic) or librtmidi.a (static) to externals/rtmidi/lib
|
||||
|
||||
4. Delete your build directory, run cmake and build, and you should be all set.
|
||||
|
||||
=========================
|
||||
|
||||
RtMidi: realtime MIDI i/o C++ classes<BR>
|
||||
Copyright (c) 2003-2014 Gary P. Scavone
|
||||
|
||||
Permission is hereby granted, free of charge, to any person
|
||||
obtaining a copy of this software and associated documentation files
|
||||
(the "Software"), to deal in the Software without restriction,
|
||||
including without limitation the rights to use, copy, modify, merge,
|
||||
publish, distribute, sublicense, and/or sell copies of the Software,
|
||||
and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
Any person wishing to distribute modifications to the Software is
|
||||
asked to send the modifications to the original developer so that
|
||||
they can be incorporated into the canonical version. This is,
|
||||
however, not a binding provision of this license.
|
||||
|
||||
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.
|
|
@ -110,8 +110,6 @@
|
|||
#include "devices/EyeTracker.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/Leapmotion.h"
|
||||
#include "devices/MIDIManager.h"
|
||||
#include "devices/RealSense.h"
|
||||
#include "DiscoverabilityManager.h"
|
||||
#include "GLCanvas.h"
|
||||
#include "InterfaceActionFactory.h"
|
||||
|
@ -719,12 +717,6 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer) :
|
|||
// set the local loopback interface for local sounds from audio scripts
|
||||
AudioScriptingInterface::getInstance().setLocalAudioInterface(audioIO.data());
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
// setup the MIDIManager
|
||||
MIDIManager& midiManagerInstance = MIDIManager::getInstance();
|
||||
midiManagerInstance.openDefaultPort();
|
||||
#endif
|
||||
|
||||
this->installEventFilter(this);
|
||||
|
||||
// initialize our face trackers after loading the menu settings
|
||||
|
@ -970,7 +962,6 @@ Application::~Application() {
|
|||
nodeThread->wait();
|
||||
|
||||
Leapmotion::destroy();
|
||||
RealSense::destroy();
|
||||
|
||||
#if 0
|
||||
ConnexionClient::getInstance().destroy();
|
||||
|
@ -2519,7 +2510,6 @@ void Application::init() {
|
|||
qCDebug(interfaceapp) << "Loaded settings";
|
||||
|
||||
Leapmotion::init();
|
||||
RealSense::init();
|
||||
|
||||
// fire off an immediate domain-server check in now that settings are loaded
|
||||
DependencyManager::get<NodeList>()->sendDomainServerCheckIn();
|
||||
|
@ -4069,10 +4059,6 @@ void Application::registerScriptEngineWithApplicationServices(ScriptEngine* scri
|
|||
scriptEngine->registerGlobalObject("Scene", DependencyManager::get<SceneScriptingInterface>().data());
|
||||
|
||||
scriptEngine->registerGlobalObject("ScriptDiscoveryService", this->getRunningScriptsWidget());
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
scriptEngine->registerGlobalObject("MIDI", &MIDIManager::getInstance());
|
||||
#endif
|
||||
}
|
||||
|
||||
bool Application::canAcceptURL(const QString& urlString) {
|
||||
|
|
|
@ -29,7 +29,6 @@
|
|||
#include "avatar/AvatarManager.h"
|
||||
#include "devices/DdeFaceTracker.h"
|
||||
#include "devices/Faceshift.h"
|
||||
#include "devices/RealSense.h"
|
||||
#include "input-plugins/SpacemouseManager.h"
|
||||
#include "MainWindow.h"
|
||||
#include "scripting/MenuScriptingInterface.h"
|
||||
|
@ -462,12 +461,6 @@ Menu::Menu() {
|
|||
MenuWrapper* leapOptionsMenu = handOptionsMenu->addMenu("Leap Motion");
|
||||
addCheckableActionToQMenuAndActionHash(leapOptionsMenu, MenuOption::LeapMotionOnHMD, 0, false);
|
||||
|
||||
#ifdef HAVE_RSSDK
|
||||
MenuWrapper* realSenseOptionsMenu = handOptionsMenu->addMenu("RealSense");
|
||||
addActionToQMenuAndActionHash(realSenseOptionsMenu, MenuOption::LoadRSSDKFile, 0,
|
||||
RealSense::getInstance(), SLOT(loadRSSDKFile()));
|
||||
#endif
|
||||
|
||||
MenuWrapper* networkMenu = developerMenu->addMenu("Network");
|
||||
addActionToQMenuAndActionHash(networkMenu, MenuOption::ReloadContent, 0, qApp, SLOT(reloadResourceCaches()));
|
||||
addCheckableActionToQMenuAndActionHash(networkMenu, MenuOption::DisableNackPackets, 0, false,
|
||||
|
|
|
@ -211,7 +211,6 @@ namespace MenuOption {
|
|||
const QString LeapMotionOnHMD = "Leap Motion on HMD";
|
||||
const QString LoadScript = "Open and Run Script File...";
|
||||
const QString LoadScriptURL = "Open and Run Script from URL...";
|
||||
const QString LoadRSSDKFile = "Load .rssdk file";
|
||||
const QString LodTools = "LOD Tools";
|
||||
const QString Login = "Login";
|
||||
const QString Log = "Log";
|
||||
|
|
|
@ -1,73 +0,0 @@
|
|||
//
|
||||
// MIDIManager.cpp
|
||||
//
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-06-30.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include "InterfaceLogging.h"
|
||||
#include "MIDIManager.h"
|
||||
|
||||
MIDIManager& MIDIManager::getInstance() {
|
||||
static MIDIManager sharedInstance;
|
||||
return sharedInstance;
|
||||
}
|
||||
|
||||
void MIDIManager::midiCallback(double deltaTime, std::vector<unsigned char>* message, void* userData) {
|
||||
#ifdef HAVE_RTMIDI
|
||||
|
||||
MIDIEvent callbackEvent;
|
||||
callbackEvent.deltaTime = deltaTime;
|
||||
|
||||
callbackEvent.type = message->at(0);
|
||||
|
||||
if (message->size() > 1) {
|
||||
callbackEvent.data1 = message->at(1);
|
||||
}
|
||||
|
||||
if (message->size() > 2) {
|
||||
callbackEvent.data2 = message->at(2);
|
||||
}
|
||||
|
||||
emit getInstance().midiEvent(callbackEvent);
|
||||
#endif
|
||||
}
|
||||
|
||||
MIDIManager::~MIDIManager() {
|
||||
#ifdef HAVE_RTMIDI
|
||||
delete _midiInput;
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
const int DEFAULT_MIDI_PORT = 0;
|
||||
#endif
|
||||
|
||||
void MIDIManager::openDefaultPort() {
|
||||
#ifdef HAVE_RTMIDI
|
||||
if (!_midiInput) {
|
||||
_midiInput = new RtMidiIn();
|
||||
|
||||
if (_midiInput->getPortCount() > 0) {
|
||||
qCDebug(interfaceapp) << "MIDIManager opening port" << DEFAULT_MIDI_PORT;
|
||||
|
||||
_midiInput->openPort(DEFAULT_MIDI_PORT);
|
||||
|
||||
// don't ignore sysex, timing, or active sensing messages
|
||||
_midiInput->ignoreTypes(false, false, false);
|
||||
|
||||
_midiInput->setCallback(&MIDIManager::midiCallback);
|
||||
} else {
|
||||
qCDebug(interfaceapp) << "MIDIManager openDefaultPort called but there are no ports available.";
|
||||
delete _midiInput;
|
||||
_midiInput = NULL;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
//
|
||||
// MIDIManager.h
|
||||
// interface/src/devices
|
||||
//
|
||||
// Created by Stephen Birarda on 2014-06-30.
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_MIDIManager_h
|
||||
#define hifi_MIDIManager_h
|
||||
|
||||
#include <QtCore/QObject>
|
||||
#include <QtScript/QScriptEngine>
|
||||
|
||||
#include <MIDIEvent.h>
|
||||
|
||||
#ifdef HAVE_RTMIDI
|
||||
#include <RtMidi.h>
|
||||
#endif
|
||||
|
||||
class MIDIManager : public QObject {
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY(unsigned int NoteOn READ NoteOn)
|
||||
Q_PROPERTY(unsigned int NoteOff READ NoteOff)
|
||||
Q_PROPERTY(unsigned int ModWheel READ ModWheel)
|
||||
Q_PROPERTY(unsigned int PitchWheel READ PitchWheel)
|
||||
|
||||
public:
|
||||
static MIDIManager& getInstance();
|
||||
static void midiCallback(double deltaTime, std::vector<unsigned char>* message, void* userData);
|
||||
|
||||
~MIDIManager();
|
||||
|
||||
void openDefaultPort();
|
||||
#ifdef HAVE_RTMIDI
|
||||
bool hasDevice() const { return !!_midiInput; }
|
||||
#endif
|
||||
public slots:
|
||||
unsigned int NoteOn() const { return 144; }
|
||||
unsigned int NoteOff() const { return 128; }
|
||||
unsigned int ModWheel() const { return 176; }
|
||||
unsigned int PitchWheel() const { return 224; }
|
||||
signals:
|
||||
void midiEvent(const MIDIEvent& event);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_RTMIDI
|
||||
RtMidiIn* _midiInput;
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
#endif // hifi_MIDIManager_h
|
||||
|
|
@ -1,259 +0,0 @@
|
|||
//
|
||||
// RealSense.cpp
|
||||
// interface/src/devices
|
||||
//
|
||||
// Created by Thijs Wenker on 12/10/14
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#include "Application.h"
|
||||
#include "RealSense.h"
|
||||
#include "MainWindow.h"
|
||||
#include "Menu.h"
|
||||
#include "SharedUtil.h"
|
||||
|
||||
#ifdef HAVE_RSSDK
|
||||
const int PALMROOT_NUM_JOINTS = 3;
|
||||
const int FINGER_NUM_JOINTS = 4;
|
||||
#endif // HAVE_RSSDK
|
||||
|
||||
const DeviceTracker::Name RealSense::NAME = "RealSense";
|
||||
|
||||
// find the index of a joint from
|
||||
// the side: true = right
|
||||
// the finger & the bone:
|
||||
// finger in [0..4] : bone in [0..3] a finger phalange
|
||||
// [-1] up the hand branch : bone in [0..1] <=> [ hand, forearm]
|
||||
MotionTracker::Index evalRealSenseJointIndex(bool isRightSide, int finger, int bone) {
|
||||
#ifdef HAVE_RSSDK
|
||||
MotionTracker::Index offset = 1 // start after root
|
||||
+ (int(isRightSide) * PXCHandData::NUMBER_OF_JOINTS) // then offset for side
|
||||
+ PALMROOT_NUM_JOINTS; // then add the arm/forearm/hand chain
|
||||
if (finger >= 0) {
|
||||
// from there go down in the correct finger and bone
|
||||
return offset + (finger * FINGER_NUM_JOINTS) + bone;
|
||||
} else {
|
||||
// or go back up for the correct root bone
|
||||
return offset - 1 - bone;
|
||||
}
|
||||
#else
|
||||
return -1;
|
||||
#endif // HAVE_RSSDK
|
||||
}
|
||||
|
||||
// static
|
||||
void RealSense::init() {
|
||||
DeviceTracker* device = DeviceTracker::getDevice(NAME);
|
||||
if (!device) {
|
||||
// create a new RealSense and register it
|
||||
RealSense* realSense = new RealSense();
|
||||
DeviceTracker::registerDevice(NAME, realSense);
|
||||
}
|
||||
}
|
||||
|
||||
// static
|
||||
void RealSense::destroy() {
|
||||
DeviceTracker::destroyDevice(NAME);
|
||||
}
|
||||
|
||||
// static
|
||||
RealSense* RealSense::getInstance() {
|
||||
DeviceTracker* device = DeviceTracker::getDevice(NAME);
|
||||
if (!device) {
|
||||
// create a new RealSense and register it
|
||||
RealSense* realSense = new RealSense();
|
||||
DeviceTracker::registerDevice(NAME, realSense);
|
||||
}
|
||||
return dynamic_cast< RealSense* > (device);
|
||||
}
|
||||
|
||||
RealSense::RealSense() :
|
||||
MotionTracker(),
|
||||
_active(false)
|
||||
{
|
||||
#ifdef HAVE_RSSDK
|
||||
_handData = NULL;
|
||||
_session = PXCSession_Create();
|
||||
initSession(false, NULL);
|
||||
|
||||
// Create the RealSense joint hierarchy
|
||||
std::vector< Semantic > sides;
|
||||
sides.push_back("joint_L_");
|
||||
sides.push_back("joint_R_");
|
||||
|
||||
std::vector< Semantic > rootBones;
|
||||
rootBones.push_back("wrist");
|
||||
rootBones.push_back("hand");
|
||||
|
||||
std::vector< Semantic > fingers;
|
||||
fingers.push_back("thumb");
|
||||
fingers.push_back("index");
|
||||
fingers.push_back("middle");
|
||||
fingers.push_back("ring");
|
||||
fingers.push_back("pinky");
|
||||
|
||||
std::vector< Semantic > fingerBones;
|
||||
fingerBones.push_back("1");
|
||||
fingerBones.push_back("2");
|
||||
fingerBones.push_back("3");
|
||||
fingerBones.push_back("4");
|
||||
|
||||
std::vector< Index > palms;
|
||||
for (unsigned int s = 0; s < sides.size(); s++) {
|
||||
Index rootJoint = 0;
|
||||
for (unsigned int rb = 0; rb < rootBones.size(); rb++) {
|
||||
rootJoint = addJoint(sides[s] + rootBones[rb], rootJoint);
|
||||
}
|
||||
|
||||
// capture the hand index for debug
|
||||
palms.push_back(rootJoint);
|
||||
|
||||
for (unsigned int f = 0; f < fingers.size(); f++) {
|
||||
for (unsigned int b = 0; b < fingerBones.size(); b++) {
|
||||
rootJoint = addJoint(sides[s] + fingers[f] + fingerBones[b], rootJoint);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif // HAVE_RSSDK
|
||||
}
|
||||
|
||||
RealSense::~RealSense() {
|
||||
#ifdef HAVE_RSSDK
|
||||
_manager->Release();
|
||||
#endif // HAVE_RSSDK
|
||||
}
|
||||
|
||||
void RealSense::initSession(bool playback, QString filename) {
|
||||
#ifdef HAVE_RSSDK
|
||||
_active = false;
|
||||
_properlyInitialized = false;
|
||||
if (_handData != NULL) {
|
||||
_handData->Release();
|
||||
_handController->Release();
|
||||
_session->Release();
|
||||
_config->Release();
|
||||
}
|
||||
_manager = _session->CreateSenseManager();
|
||||
if (playback) {
|
||||
_manager->QueryCaptureManager()->SetFileName(filename.toStdWString().c_str(), false);
|
||||
}
|
||||
_manager->QueryCaptureManager()->SetRealtime(!playback);
|
||||
_manager->EnableHand(0);
|
||||
_handController = _manager->QueryHand();
|
||||
|
||||
if (_manager->Init() == PXC_STATUS_NO_ERROR) {
|
||||
_handData = _handController->CreateOutput();
|
||||
|
||||
PXCCapture::Device *device = _manager->QueryCaptureManager()->QueryDevice();
|
||||
PXCCapture::DeviceInfo dinfo;
|
||||
_manager->QueryCaptureManager()->QueryDevice()->QueryDeviceInfo(&dinfo);
|
||||
if (dinfo.model == PXCCapture::DEVICE_MODEL_IVCAM)
|
||||
{
|
||||
device->SetDepthConfidenceThreshold(1);
|
||||
device->SetMirrorMode(PXCCapture::Device::MIRROR_MODE_DISABLED);
|
||||
device->SetIVCAMFilterOption(6);
|
||||
}
|
||||
_properlyInitialized = true;
|
||||
}
|
||||
|
||||
_config = _handController->CreateActiveConfiguration();
|
||||
_config->EnableStabilizer(true);
|
||||
_config->SetTrackingMode(PXCHandData::TRACKING_MODE_FULL_HAND);
|
||||
_config->ApplyChanges();
|
||||
#endif // HAVE_RSSDK
|
||||
}
|
||||
|
||||
#ifdef HAVE_RSSDK
|
||||
glm::quat quatFromPXCPoint4DF32(const PXCPoint4DF32& basis) {
|
||||
return glm::normalize(glm::quat(basis.w, basis.x, basis.y, basis.z) * glm::quat(glm::vec3(0, M_PI, 0)));
|
||||
}
|
||||
|
||||
glm::vec3 vec3FromPXCPoint3DF32(const PXCPoint3DF32& vec) {
|
||||
return glm::vec3(-vec.x, vec.y, -vec.z);
|
||||
}
|
||||
#endif // HAVE_RSSDK
|
||||
|
||||
void RealSense::update() {
|
||||
#ifdef HAVE_RSSDK
|
||||
bool wasActive = _active;
|
||||
_active = _manager->IsConnected() && _properlyInitialized;
|
||||
if (_active || wasActive) {
|
||||
// Go through all the joints and increment their counter since last update.
|
||||
// Increment all counters once after controller first becomes inactive so that each joint reports itself as inactive.
|
||||
// TODO C++11 for (auto jointIt = _jointsArray.begin(); jointIt != _jointsArray.end(); jointIt++) {
|
||||
for (JointTracker::Vector::iterator jointIt = _jointsArray.begin(); jointIt != _jointsArray.end(); jointIt++) {
|
||||
(*jointIt).tickNewFrame();
|
||||
}
|
||||
}
|
||||
|
||||
if (!_active) {
|
||||
return;
|
||||
}
|
||||
|
||||
pxcStatus sts = _manager->AcquireFrame(true);
|
||||
_handData->Update();
|
||||
PXCHandData::JointData nodes[2][PXCHandData::NUMBER_OF_JOINTS] = {};
|
||||
PXCHandData::ExtremityData extremitiesPointsNodes[2][PXCHandData::NUMBER_OF_EXTREMITIES] = {};
|
||||
for (pxcI32 i = 0; i < _handData->QueryNumberOfHands(); i++) {
|
||||
PXCHandData::IHand* handData;
|
||||
if (_handData->QueryHandData(PXCHandData::ACCESS_ORDER_BY_TIME, i, handData) == PXC_STATUS_NO_ERROR) {
|
||||
int rightSide = handData->QueryBodySide() == PXCHandData::BODY_SIDE_RIGHT;
|
||||
PXCHandData::JointData jointData;
|
||||
JointTracker* parentJointTracker = _jointsArray.data();
|
||||
//Iterate Joints
|
||||
int rootBranchIndex = -1;
|
||||
JointTracker* palmJoint = NULL;
|
||||
for (int j = 0; j < PXCHandData::NUMBER_OF_JOINTS; j++) {
|
||||
handData->QueryTrackedJoint((PXCHandData::JointType)j, jointData);
|
||||
nodes[i][j] = jointData;
|
||||
if (j == PXCHandData::JOINT_WRIST) {
|
||||
JointTracker* wrist = editJointTracker(evalRealSenseJointIndex(rightSide, rootBranchIndex, 1)); // 1 is the index of the wrist joint
|
||||
wrist->editAbsFrame().setTranslation(vec3FromPXCPoint3DF32(jointData.positionWorld));
|
||||
wrist->editAbsFrame().setRotation(quatFromPXCPoint4DF32(jointData.globalOrientation));
|
||||
wrist->updateLocFromAbsTransform(parentJointTracker);
|
||||
wrist->activeFrame();
|
||||
parentJointTracker = wrist;
|
||||
continue;
|
||||
} else if (j == PXCHandData::JOINT_CENTER) {
|
||||
palmJoint = editJointTracker(evalRealSenseJointIndex(rightSide, rootBranchIndex, 0)); // 0 is the index of the palm joint
|
||||
palmJoint->editAbsFrame().setTranslation(vec3FromPXCPoint3DF32(jointData.positionWorld));
|
||||
palmJoint->editAbsFrame().setRotation(quatFromPXCPoint4DF32(jointData.globalOrientation));
|
||||
palmJoint->updateLocFromAbsTransform(parentJointTracker);
|
||||
palmJoint->activeFrame();
|
||||
parentJointTracker = palmJoint;
|
||||
continue;
|
||||
}
|
||||
int finger_index = j - PALMROOT_NUM_JOINTS;
|
||||
int finger = finger_index / FINGER_NUM_JOINTS;
|
||||
int finger_bone = finger_index % FINGER_NUM_JOINTS;
|
||||
JointTracker* ljointTracker = editJointTracker(evalRealSenseJointIndex(rightSide, finger, finger_bone));
|
||||
if (jointData.confidence > 0) {
|
||||
ljointTracker->editAbsFrame().setTranslation(vec3FromPXCPoint3DF32(jointData.positionWorld));
|
||||
ljointTracker->editAbsFrame().setRotation(quatFromPXCPoint4DF32(jointData.globalOrientation));
|
||||
ljointTracker->updateLocFromAbsTransform(parentJointTracker);
|
||||
ljointTracker->activeFrame();
|
||||
}
|
||||
if (finger_bone == (FINGER_NUM_JOINTS - 1)) {
|
||||
parentJointTracker = palmJoint;
|
||||
continue;
|
||||
}
|
||||
parentJointTracker = ljointTracker;
|
||||
}
|
||||
}
|
||||
}
|
||||
_manager->ReleaseFrame();
|
||||
#endif // HAVE_RSSDK
|
||||
}
|
||||
|
||||
void RealSense::loadRSSDKFile() {
|
||||
QString locationDir(QStandardPaths::displayName(QStandardPaths::DesktopLocation));
|
||||
QString fileNameString = QFileDialog::getOpenFileName(qApp->getWindow(), tr("Open RSSDK clip"),
|
||||
locationDir,
|
||||
tr("RSSDK Recordings (*.rssdk)"));
|
||||
if (!fileNameString.isEmpty()) {
|
||||
initSession(true, fileNameString);
|
||||
}
|
||||
}
|
|
@ -1,65 +0,0 @@
|
|||
//
|
||||
// RealSense.h
|
||||
// interface/src/devices
|
||||
//
|
||||
// Created by Thijs Wenker on 12/10/14
|
||||
// Copyright 2014 High Fidelity, Inc.
|
||||
//
|
||||
// Distributed under the Apache License, Version 2.0.
|
||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
//
|
||||
|
||||
#ifndef hifi_RealSense_h
|
||||
#define hifi_RealSense_h
|
||||
|
||||
#include <QFileDialog>
|
||||
|
||||
#include "MotionTracker.h"
|
||||
|
||||
#ifdef HAVE_RSSDK
|
||||
#include <pxcsession.h>
|
||||
#include <pxchandmodule.h>
|
||||
#include <pxchandconfiguration.h>
|
||||
#include <pxcsensemanager.h>
|
||||
#include <pxchanddata.h>
|
||||
#endif
|
||||
|
||||
/// Handles interaction with the RealSense skeleton tracking suit.
|
||||
class RealSense : public QObject, public MotionTracker {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
static const Name NAME;
|
||||
|
||||
static void init();
|
||||
static void destroy();
|
||||
|
||||
/// RealSense MotionTracker factory
|
||||
static RealSense* getInstance();
|
||||
|
||||
bool isActive() const { return _active; }
|
||||
|
||||
virtual void update();
|
||||
|
||||
public slots:
|
||||
void loadRSSDKFile();
|
||||
|
||||
protected:
|
||||
RealSense();
|
||||
virtual ~RealSense();
|
||||
|
||||
void initSession(bool playback, QString filename);
|
||||
|
||||
private:
|
||||
#ifdef HAVE_RSSDK
|
||||
PXCSession* _session;
|
||||
PXCSenseManager* _manager;
|
||||
PXCHandModule* _handController;
|
||||
PXCHandData* _handData;
|
||||
PXCHandConfiguration* _config;
|
||||
#endif
|
||||
bool _properlyInitialized;
|
||||
bool _active;
|
||||
};
|
||||
|
||||
#endif // hifi_RealSense_h
|
Loading…
Reference in a new issue