1 | initial version |
It depends on the format you were using. You can read video (AVI) files using theVideoCapture
class , or a series of images with the imread
function.
The problem with depth data is that depth data ranges from 800 to 4000 (millimeters), which is outside the 8 bit (0-255) range. So the AVI file cannot store the real depth data, so only some image formats (TIFF and PNG) can be used to store these values (note: you have to use CV_LOAD_IMAGE_ANYDEPTH
in the imread
function).
So I suggest to store the captured data as a series of images: the color as JPG (PNG or TIFF), the depth as 16 bit TIFF: color1.jpg,color2.jpg,...,depth1.tif,depth2.tif,...
Here is the code to read them
Mat depth,color;
int count=10; //number of depth images
char s[20];
for(int i=0;i<count;i++)
{
sprintf(s,"depth%d.tif",i);
depth=imread(s,CV_LOAD_IMAGE_ANYDEPTH);
sprintf(s,"color%d.jpg",i);
color=imread(s);
//process the images...
}
2 | No.2 Revision |
It depends on the format you were using. You can read video (AVI) files using theVideoCapture
class , or a series of images with the imread
function.
The problem with depth data the Kinect sensor is that depth data ranges from 800 to 4000 (millimeters), which is outside the 8 bit (0-255) range. So the AVI file cannot store the real depth data, so only some image formats (TIFF and PNG) can be used to store these values (note: you have to use CV_LOAD_IMAGE_ANYDEPTH
in the imread
function).
So I suggest to store the captured data as a series of images: the color as JPG (PNG or TIFF), the depth as 16 bit TIFF: color1.jpg,color2.jpg,...,depth1.tif,depth2.tif,...
Here is the code to read them
Mat depth,color;
int count=10; //number of depth images
char s[20];
for(int i=0;i<count;i++)
{
sprintf(s,"depth%d.tif",i);
depth=imread(s,CV_LOAD_IMAGE_ANYDEPTH);
sprintf(s,"color%d.jpg",i);
color=imread(s);
//process the images...
}