The color data stream reads failed. The program will stay at “readframe”
Some Simple code
int main( int argc, char** argv )
{
bool end_while = false;
OpenNI::initialize();
Device devAnyDevice;
devAnyDevice.open(ANY_DEVICE );
VideoStream streamColor;
streamColor.create( devAnyDevice, SENSOR_COLOR );
VideoMode mModeColor;
mModeColor.setResolution( 640, 480 );
mModeColor.setFps( 30 );
mModeColor.setPixelFormat( (PIXEL_FORMAT_RGB888 );//
streamColor.setVideoMode( mModeColor);
streamColor.start();
namedWindow( "Color Image", CV_WINDOW_AUTOSIZE );
VideoFrameRef frameColor;
while( !end_while)
{
streamColor.readFrame( &frameColor );
const cv::Mat mImageRGB(frameColor.getHeight(), frameColor.getWidth(), CV_8UC3, (void*)frameColor.getData());
cv::Mat cImageBGR;
cv::cvtColor( mImageRGB, cImageBGR, CV_RGB2BGR );
cv::imshow( "Color Image", cImageBGR )
char key = (char)cv::waitKey(1);
switch (key)
{
case 'q':
case 'Q':
case 27:
//std::cout << "Exit key hit" << std::endl;
end_while = true;
break;
}
}
streamColor.destroy();
devAnyDevice.close();
openni::OpenNI::shutdown();
return 0;
}