2013年9月28日土曜日

How to set color and depth resolution of Xtion

This post is my memorandum.

// Create Depth stream
openni::VideoMode depth_mode;
depth_mode.setResolution( 320, 240 );
depth_mode.setFps( 30 );
depth_mode.setPixelFormat(openni::PIXEL_FORMAT_DEPTH_1_MM );

rc = depth.create(device, openni::SENSOR_DEPTH);
if (rc == openni::STATUS_OK){
rc = depth.setVideoMode(depth_mode);
rc = depth.start();
if (rc != openni::STATUS_OK){
printf("SimpleViewer: Couldn't start depth stream:\n%s\n",
openni::OpenNI::getExtendedError());
depth.destroy();
}
} else {
printf("SimpleViewer: Couldn't find depth stream:\n%s\n",
openni::OpenNI::getExtendedError());
}

// Create RBG Stream
openni::VideoMode color_mode;
color_mode.setResolution(  320, 240 );
color_mode.setFps( 30 );
color_mode.setPixelFormat(openni::PIXEL_FORMAT_RGB888 );

rc = color.create(device, openni::SENSOR_COLOR);
if (rc == openni::STATUS_OK) {

rc = color.setVideoMode(color_mode);
rc = color.start();
if (rc != openni::STATUS_OK) {
printf("SimpleViewer: Couldn't start color stream:\n%s\n",
openni::OpenNI::getExtendedError());
color.destroy();
}
} else {
printf("SimpleViewer: Couldn't find color stream:\n%s\n",
openni::OpenNI::getExtendedError());
}

0 件のコメント:

コメントを投稿