GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — code/Chapter9_FluidInteractionUsingKinect/KinectController.h at master · whwayne/code Expand file tree/ Copy pathKinectController.hMore file actions executable file ·124 lines (113 loc) · 5.29 KB / Copy pathKinectController.hFile metadata and controlsexecutable file ·124 lines (113 loc) · 5.29 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 /***************************************************************************** * Ch9 of the book "Mastering OpenCV with Practical Computer Vision Projects" * Copyright Packt Publishing 2012. * http://www.packtpub.com/cool-projects-with-opencv/book * http://code.google.com/p/fluidwall/ *****************************************************************************/ /** * @file KinectController.h * @author Naureen Mahmood * @copyright 2011 Austin Hines, Naureen Mahmood, and Texas A&M Dept. of Visualization * @version 1.0.1 * * This file is part of Fluid Wall. You can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * Fluid Wall is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with Fluid Wall. If not, see <http://www.gnu.org/licenses/>. * * Version History: * 1.0.0 * - Initial Release */ #ifndef KINECT_CONTROLLER_H #define KINECT_CONTROLLER_H //OpenNI includes #include <XnOpenNI.h> #include <XnCppWrapper.h> //OpenCV includes #include <cv.h> #include <cxcore.h> #include <highgui.h> #include <iostream> #define HEIGHT XN_VGA_Y_RES #define WIDTH XN_VGA_X_RES #define SAMPLE_XML_PATH "Data/SamplesConfig.xml" #define CHECK_RC(nRetVal, what) \ if (nRetVal != XN_STATUS_OK) \ { \ printf("%s failed: %s\n", what, xnGetStatusString(nRetVal));\ return xnRetVal; \ } #define MAX_USERS 6 #define MAX_DEPTH 3000 #define ITERATIONS_BEFORE_RESET 10000 using namespace std; using namespace cv; //! KinectController Class /*! KinectController Class initializes and runs all the modules for controlling the kinect camera devices. */ class KinectController { public: /* * (Default) Constructor with initialization list. * @param _maxDepth initialize depth threshold for Kinect depth data stream(less than 6000) * @param _maxUsers initialize maximum users to be detected (between 1-6) * @param _depthMatrix initialize an empty cvMatrix to store the kinect depth-map * @param _usersMatrix initialize an empty cvMatrix to store the kinect userID-map */ /*! Constructor with initialization lists */ KinectController () : _maxDepth( MAX_DEPTH ), _maxUsers( MAX_USERS ), _depthMatrix( Mat::zeros(480,640,CV_8UC1) ), _usersMatrix( Mat::zeros(480,640,CV_8UC1) ) { init(); } /*! Destructor */ ~KinectController() { kinectCleanupExit(); } /*! Initialize all KinectController variables & modules */ XnStatus init(); /*! Depth & User Tracking Modules */ XnStatus update(); /*! Update the XnOpenNI Depth & User tracking data for each frame of video captured */ XnStatus reset(); /*! Set Depth Threshold */ void setDepth(int depthDelta); /*! Get depth matrix for current video frame */ void getDepthMat(Mat &depth) { _depthMatrix.copyTo(depth); } /*! Get matrix of tracked users for current video frame */ void getUsersMat(Mat &users) { _usersMatrix.copyTo(users); } /*! Get maximum number of users to be tracked */ int getMaxUsers() { return _maxUsers; } private: // OPENNI DEPTH & USER TRACKING VARIABLES xn::Context xnContext; /*! context object that creates depth and user data nodes */ xn::DepthGenerator xnDepthGenerator; /*! captures and returns depth values at each frame */ xn::UserGenerator xnUserGenerator; /*! captures and returns user detection data at each frame */ xn::SceneMetaData xnSceneMD; /*! scene metadata: gives access to IDs of detected users at each pixel of a captured frame */ xn::DepthMetaData xnDepthMD; /*! depth metadata: gives access to depth data at each pixel of a captured frame */ XnStatus xnRetVal; /*! used to check the status of each call to an XNOpenNI function */ int _maxUsers; /*! users to detect */ int _maxDepth; /*! depth threshold for how far the Kinect should capture */ int _maxIterate; /*! iterations to run before reset */ int _iterationCount; /*! running iterations so far (goes up to maxIterate then resets to 0) */ Mat _depthMatrix; /*! image-sized matrix containing the depth values at each pixel */ Mat _usersMatrix; /*! image-sized matrix containing the userID's of detected people at /*! each pixel (or 0 if no detected user at that pixel) */ /*! Initialize XnOpenNI depth control & user tracking modules */ XnStatus initDepthControl(); /*! Destroy & shutdown XnOpenNI depth control & user tracking modules */ void stopDepthControl() { xnContext.Shutdown(); } /*! Run Shutdown functions for Depth control */ void kinectCleanupExit(); }; #endif |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |