Kinect module for Ubri based on OpenNI
C++
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
Config
NITE_Data
cmake
src
.gitignore
CMakeLists.txt
COPYING
README

README

UrbiOpenNIKinect
--------------------------------------------------------------------------------
INFO
--------------------------------------------------------------------------------

Kinect module based on OpenNI for URBI
Copyright (C) 2012  Lukasz Malek
 
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
 
This program 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 General Public License for more details.
  
You should have received a copy of the GNU General Public License
along with this program.  If not, see <http://www.gnu.org/licenses/>.

--------------------------------------------------------------------------------
REQUIREMENTS
--------------------------------------------------------------------------------

1. Download unstable OpenNI and NITE from 
   http://www.openni.org/Downloads/OpenNIModules.aspx 
   tested on:
	- OpenNI-Bin-Dev-Linux-x64-v1.5.2.23
	- NITE-Bin-Dev-Linux-x64-v1.5.2.21
2. Install OpenNI and NITE
3. Download SensorKinect from avin2 github
   https://github.com/avin2/SensorKinect
   The easiest way is to download ZIP archive.
4. Extract SensorKinect archive. Go to extracted direcotry.
   Build sensor according to the information from README.
   Go to Bin dir end extrac SensorKinect... suitable for your system.
5. Install SensorKinect
6. Adjust NITE to work with Kinect
   cp NITE_Data/*.xml [NITE_DIR]/Data/
7. Reboot
8. Make sure that your user has permission to use kinect device
9. Plug Kinect and test it with 
   [OpenNI-DIR]/Samples/Bin/[...]/NIViewer 
   

ALTERNATIVE

Instead of manually building OpenNI on Ubintu one can instal it from pepository
https://launchpad.net/~admo/+archive/openni by typing

sudo apt-add-apt-repository ppa:admo/openni



--------------------------------------------------------------------------------
INSTALATION
--------------------------------------------------------------------------------

This library is prepared to work with the cmake.
Create new directory

mkdir build

then run cmake, ccmake or cmake-gui to configure project

ccmake ../

after configuring project type

make

--------------------------------------------------------------------------------
MODULE FUNCTIONS
--------------------------------------------------------------------------------

# initialization of module with specific components boolean flags
UKinectOpenNI.new(activateImageComponent, activateDepthComponent, activateUserComponent);

UKinectOpenNI.image;        - access to UImage with camera image  
UKinectOpenNI.imageWidth;   - image width
UKinectOpenNI.imageHeight;  - image height
UKinectOpenNI.depth;        - access to UImage with depth map image, unit value in 25 mm 
UKinectOpenNI.depthWidth;   - image width
UKinectOpenNI.depthHeight;  - image height
UKinectOpenNI.numUsers;     - number of detected user
UKinectOpenNI.skeleton;     - access to UImage with depth map image
UKinectOpenNI.jointConfidence; - acces to joint identification confidence level 0-1
UKinectOpenNI.fps;          - module performance Frames Pers Seconds max 30

UKinectOpenNI.motorMove(absolutAngle);  - move motor head to given angle
UKinectOpenNI.setLed(color);  - move motor head to given angle
UKinectOpenNI.getAccelerometer();       - acces gravity vector coordinate XYZ, X - to Kinect rigth, Y - to Kinect botom, Z - to Kinect rear
UKinectOpenNI.refreshData();    - obtain new data from Kinect
UKinectOpenNI.getImage();   - update camera image if posible
UKinectOpenNI.getDepth();   - update depth map image if possible
UKinectOpenNI.getUsers();   - update data about users if possible
UKinectOpenNI.getSkeleton(baseImage);   - draw sceletons on skeleton image based on baseImage, for examle camera image or depth map image

# jointNumber starting from 1 from http://openni.org/Documentation/Reference/_xn_types_8h_ac025301dbcbd9a91e532fa3d8991361d.html#ac025301dbcbd9a91e532fa3d8991361d
UKinectOpenNI.getJointPosition(userID, jointNumber);    - get vector of a joint possition for given user
UKinectOpenNI.getJointImageCoordinate(userID, jointNumber); - get vector of a 2D joint ccordinate in image for given user
UKinectOpenNI.getDepthXY(x,y);  - depth map pixel value
UKinectOpenNI.getDepthMedianFromArea(x1, y1, x2, y2);   - depth map mediana from area 
UKinectOpenNI.matchDepthToImage(trueOrFalse);   - fix calibration depth and image.
UKinectOpenNI.getUsersID(); - obtain the list of tracked user ID list
UKinectOpenNI.getVisibleUsersID( eJoint);  - obtain the list of visible user ID list. User is visible if its torso is visible.  eJoint joint number that identify that user is visible   

--------------------------------------------------------------------------------
NOTES
--------------------------------------------------------------------------------

Example of usage:

urbi -i -m UKinectOpenNI -P 54000

var Global.xyz;
var Global.Kinect=UKinectOpenNI.new(true,true,true);
Kinect.refreshData();
Kinect.getUsers();
Kinect.getImage();
t:loop{
    Kinect.refreshData();
    Kinect.getUsers();
    if (Kinect.numUsers > 0) {
        echo(Kinect.numUsers);
        xyz = Kinect.getJointPosition(1,3);
        echo("x="+xyz[0]+" y="+xyz[1]+" z="+xyz[2]);
    };
    sleep(0.03s);
},

var Global.Kinect=UKinectOpenNI.new(true,true,true);
t:loop{
    Kinect.refreshData();
    Kinect.getImage();
    Kinect.getDepth();
    Kinect.getUsers();
    Kinect.getSkeleton(Kinect.image);
    sleep(0.03s);
},

t:loop{
    Kinect.refreshData();
    Kinect.getImage();
    Kinect.getDepth();
    Kinect.getUsers();
    Kinect.getSkeleton(Kinect.depth);
    sleep(0.03s);
},

t:loop{
    Kinect.refreshData();
    Kinect.getImage();
    Kinect.getDepth();
    Kinect.getUsers();
    Kinect.getSkeleton(Kinect.depth);
    sleep(0.03s);
},


var Global.Kinect=UKinectOpenNI.new(true,true,true);
Kinect.matchDepthToImage(true);

t:loop{
    Kinect.refreshData();
    Kinect.getImage();
    Kinect.getDepth();
    Kinect.getUsers();
    Kinect.getSkeleton(Kinect.image);
    sleep(0.03s);
},