Visual Servoing Platform version 3.7.0
Loading...
Searching...
No Matches
vpKinect Class Reference

#include <vpKinect.h>

Inheritance diagram for vpKinect:

Public Types

enum  vpDMResolution { DMAP_LOW_RES , DMAP_MEDIUM_RES }

Public Member Functions

 vpKinect (freenect_context *ctx, int index)
virtual ~vpKinect ()
void start (vpKinect::vpDMResolution res=DMAP_LOW_RES)
void stop ()
bool getDepthMap (vpImage< float > &map)
bool getDepthMap (vpImage< float > &map, vpImage< unsigned char > &Imap)
bool getRGB (vpImage< vpRGBa > &IRGB)
void getIRCamParameters (vpCameraParameters &cam) const
void getRGBCamParameters (vpCameraParameters &cam) const
void setIRCamParameters (const vpCameraParameters &cam)
void setRGBCamParameters (const vpCameraParameters &cam)
void warpRGBFrame (const vpImage< vpRGBa > &Irgb, const vpImage< float > &Idepth, vpImage< vpRGBa > &IrgbWarped)

Detailed Description

Driver for the Kinect-1 device.

To be enabled this class requires libfreenect 3rd party. Installation instructions are provided here https://visp.inria.fr/3rd_freenect.

The following example shows how to use this class to acquire data (depth map and color image) from a Kinect.

#include <visp3/core/vpImage.h>
#include <visp3/sensor/vpKinect.h>
#ifdef ENABLE_VISP_NAMESPACE
using namespace VISP_NAMESPACE_NAME;
#endif
int main() {
#ifdef VISP_HAVE_LIBFREENECT_AND_DEPENDENCIES
// Init Kinect device
#ifdef VISP_HAVE_LIBFREENECT_OLD
// This is the way to initialize Freenect with an old version of libfreenect
// package under ubuntu lucid 10.04
Freenect::Freenect<vpKinect> freenect;
vpKinect * kinect = &freenect.createDevice(0);
#else
Freenect::Freenect freenect;
vpKinect * kinect = &freenect.createDevice<vpKinect>(0);
#endif
kinect->start(); // Start acquisition thread
// Set tilt angle
float angle = -5;
kinect->setTiltDegrees(angle);
vpImage<vpRGBa> Irgb(480,640);
vpImage<float> dmap(480,640);
// Acquisition loop
for (int i=0; i<100; i++)
{
kinect->getDepthMap(dmap,I);
kinect->getRGB(Irgb);
}
kinect->stop(); // Stop acquisition thread
#endif
return 0;
}
Definition of the vpImage class member functions.
Definition vpImage.h:131
void stop()
Definition vpKinect.cpp:110
bool getDepthMap(vpImage< float > &map)
Definition vpKinect.cpp:165
void start(vpKinect::vpDMResolution res=DMAP_LOW_RES)
Definition vpKinect.cpp:70
vpKinect(freenect_context *ctx, int index)
Definition vpKinect.cpp:50
bool getRGB(vpImage< vpRGBa > &IRGB)
Definition vpKinect.cpp:223
Examples
kinectAcquisition.cpp, and servoViper850FourPointsKinect.cpp.

Definition at line 109 of file vpKinect.h.

Member Enumeration Documentation

◆ vpDMResolution

Depth map resolution.

Enumerator
DMAP_LOW_RES 

Depth map has a resolution of 320 by 240.

DMAP_MEDIUM_RES 

Depth map has a resolution of 640 by 480.

Definition at line 124 of file vpKinect.h.

Constructor & Destructor Documentation

◆ vpKinect()

BEGIN_VISP_NAMESPACE vpKinect::vpKinect ( freenect_context * ctx,
int index )

Default constructor.

Those are the parameters found for our Kinect device. Note that they can differ from one device to another.

Definition at line 50 of file vpKinect.cpp.

References DMAP_LOW_RES.

◆ ~vpKinect()

vpKinect::~vpKinect ( )
virtual

Destructor.

Definition at line 68 of file vpKinect.cpp.

Member Function Documentation

◆ getDepthMap() [1/2]

bool vpKinect::getDepthMap ( vpImage< float > & map)

Get metric depth map (float).

Examples
kinectAcquisition.cpp.

Definition at line 165 of file vpKinect.cpp.

◆ getDepthMap() [2/2]

bool vpKinect::getDepthMap ( vpImage< float > & map,
vpImage< unsigned char > & Imap )

Get metric depth map (float) and corresponding image.

Definition at line 178 of file vpKinect.cpp.

References DMAP_LOW_RES, vpImage< Type >::getHeight(), and vpERROR_TRACE.

◆ getIRCamParameters()

void vpKinect::getIRCamParameters ( vpCameraParameters & cam) const
inline

Definition at line 140 of file vpKinect.h.

◆ getRGB()

bool vpKinect::getRGB ( vpImage< vpRGBa > & I_RGB)

Get RGB image

Examples
kinectAcquisition.cpp, and servoViper850FourPointsKinect.cpp.

Definition at line 223 of file vpKinect.cpp.

◆ getRGBCamParameters()

void vpKinect::getRGBCamParameters ( vpCameraParameters & cam) const
inline

Definition at line 141 of file vpKinect.h.

◆ setIRCamParameters()

void vpKinect::setIRCamParameters ( const vpCameraParameters & cam)
inline

Definition at line 142 of file vpKinect.h.

◆ setRGBCamParameters()

void vpKinect::setRGBCamParameters ( const vpCameraParameters & cam)
inline

Definition at line 143 of file vpKinect.h.

◆ start()

void vpKinect::start ( vpKinect::vpDMResolution res = DMAP_LOW_RES)

Calibration parameters are the parameters found for our Kinect device. Note that they can differ from one device to another.

Examples
kinectAcquisition.cpp, and servoViper850FourPointsKinect.cpp.

Definition at line 70 of file vpKinect.cpp.

References DMAP_LOW_RES, vpXmlParserCamera::parse(), and vpCameraParameters::perspectiveProjWithDistortion.

◆ stop()

void vpKinect::stop ( )
Examples
kinectAcquisition.cpp, and servoViper850FourPointsKinect.cpp.

Definition at line 110 of file vpKinect.cpp.

◆ warpRGBFrame()

void vpKinect::warpRGBFrame ( const vpImage< vpRGBa > & Irgb,
const vpImage< float > & Idepth,
vpImage< vpRGBa > & IrgbWarped )

Warp the RGB frame to the depth camera frame. The size of the resulting IrgbWarped frame is the same as the size of the depth map Idepth

Compute metric coordinates in the ir camera Frame :

Change frame :

compute pixel coordinates of the corresponding point in the depth image

Fill warped image value

Examples
kinectAcquisition.cpp.

Definition at line 237 of file vpKinect.cpp.

References vpMeterPixelConversion::convertPoint(), vpPixelMeterConversion::convertPoint(), vpImage< Type >::getHeight(), vpImage< Type >::getWidth(), vpImage< Type >::resize(), and vpERROR_TRACE.