bool OpenNI2CameraImpl::pollOne( OpenNI2Camera::FrameView& frame, int timeoutMS ) { frame.colorUpdated = false; frame.depthUpdated = false; frame.infraredUpdated = false; VideoStream* streams[] = { &m_colorStream, &m_depthStream, &m_infraredStream }; int readyIndex = -1; // Initialized to fail. Status rc = OpenNI::waitForAnyStream( streams, 3, &readyIndex, timeoutMS ); if( rc == STATUS_OK ) { if( readyIndex == 0 ) // color { return copyColor( frame ); } else if( readyIndex == 1 ) // depth { return copyDepth( frame ); } else if( readyIndex == 2 ) // infrared { return copyInfrared( frame ); } } return false; }
bool OpenNI2CameraImpl::pollDepth( OpenNI2Camera::FrameView& frame, int timeoutMS ) { if( !m_depthStream.isValid() ) { return false; } VideoStream* streams[] = { &m_depthStream }; int readyIndex = -1; // Initialized to fail. Status rc = OpenNI::waitForAnyStream( streams, 1, &readyIndex, timeoutMS ); if( rc == STATUS_OK && readyIndex == 0 ) { return copyDepth( frame ); } return false; }
bool OpenNICamera::nextFrame( size_t /*timeout*/ ) { XnStatus status = XN_STATUS_OK; status = _imageGen.WaitAndUpdateData(); //status = _context.WaitAndUpdateAll(); if( status != XN_STATUS_OK ){ throw CVTException( "Error in WaitAndUpdateData for img" ); } else { copyImage(); } status = _depthGen.WaitAndUpdateData(); if( status != XN_STATUS_OK ){ throw CVTException( "Error in WaitAndUpdateData for depth" ); } else { copyDepth(); } return true; }