From 6a6c51f80ec919cc84e66a00559e1bc04f746ca5 Mon Sep 17 00:00:00 2001 From: Mark Peng Date: Thu, 1 Aug 2013 15:04:58 -0700 Subject: [PATCH] Add skeleton tracking toggle in options menu in interface. --- interface/src/Application.cpp | 1 + interface/src/Webcam.cpp | 4 ++-- interface/src/Webcam.h | 7 +++++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 7fc9bd7ac8..0de45b3dcf 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -1728,6 +1728,7 @@ void Application::initMenu() { _testPing->setChecked(true); (_fullScreenMode = optionsMenu->addAction("Fullscreen", this, SLOT(setFullscreen(bool)), Qt::Key_F))->setCheckable(true); optionsMenu->addAction("Webcam", &_webcam, SLOT(setEnabled(bool)))->setCheckable(true); + optionsMenu->addAction("Toggle Skeleton Tracking", &_webcam, SLOT(toggleSkeletonTracking(bool)))->setCheckable(true); optionsMenu->addAction("Go Home", this, SLOT(goHome())); QMenu* renderMenu = menuBar->addMenu("Render"); diff --git a/interface/src/Webcam.cpp b/interface/src/Webcam.cpp index d4fa015ba0..921f4f427b 100644 --- a/interface/src/Webcam.cpp +++ b/interface/src/Webcam.cpp @@ -32,7 +32,7 @@ int jointVectorMetaType = qRegisterMetaType("JointVector"); int matMetaType = qRegisterMetaType("cv::Mat"); int rotatedRectMetaType = qRegisterMetaType("cv::RotatedRect"); -Webcam::Webcam() : _enabled(false), _active(false), _colorTextureID(0), _depthTextureID(0) { +Webcam::Webcam() : _enabled(false), _active(false), _colorTextureID(0), _depthTextureID(0), _skeletonTrackingOn(false) { // the grabber simply runs as fast as possible _grabber = new FrameGrabber(); _grabber->moveToThread(&_grabberThread); @@ -194,7 +194,7 @@ void Webcam::setFrame(const Mat& color, int format, const Mat& depth, float mean // store our face rect and joints, update our frame count for fps computation _faceRect = faceRect; - _joints = joints; + if (_skeletonTrackingOn) _joints = joints; _frameCount++; const int MAX_FPS = 60; diff --git a/interface/src/Webcam.h b/interface/src/Webcam.h index 3910bb4a19..7e27fba189 100644 --- a/interface/src/Webcam.h +++ b/interface/src/Webcam.h @@ -45,7 +45,7 @@ public: ~Webcam(); bool isActive() const { return _active; } - + GLuint getColorTextureID() const { return _colorTextureID; } GLuint getDepthTextureID() const { return _depthTextureID; } const cv::Size2f& getTextureSize() const { return _textureSize; } @@ -57,13 +57,14 @@ public: const JointVector& getEstimatedJoints() const { return _estimatedJoints; } void reset(); - void renderPreview(int screenWidth, int screenHeight); + void renderPreview(int screenWidth, int screenHeight); public slots: void setEnabled(bool enabled); void setFrame(const cv::Mat& color, int format, const cv::Mat& depth, float meanFaceDepth, const cv::RotatedRect& faceRect, const JointVector& joints); + void toggleSkeletonTracking(bool toggle) { _skeletonTrackingOn = toggle; }; private: @@ -88,6 +89,8 @@ private: glm::vec3 _estimatedPosition; glm::vec3 _estimatedRotation; JointVector _estimatedJoints; + + bool _skeletonTrackingOn; }; class FrameGrabber : public QObject {