diff --git a/doc/user_guide/ug_highgui.rst b/doc/user_guide/ug_highgui.rst index fcc61b145..59aefb0ad 100644 --- a/doc/user_guide/ug_highgui.rst +++ b/doc/user_guide/ug_highgui.rst @@ -95,7 +95,7 @@ Since two types of sensor's data generators are supported (image generator and d Some depth sensors (for example XtionPRO) do not have image generator. In order to check it you can get ``CV_CAP_OPENNI_PROP_IMAGE_GENERATOR_PRESENT`` property. :: - bool isImageGeneratorPresent = capture.get( CV_CAP_OPENNI_PROP_IMAGE_GENERATOR_PRESENT ) != 0; // or == 1 + bool isImageGeneratorPresent = capture.get( CV_CAP_PROP_OPENNI_IMAGE_GENERATOR_PRESENT ) != 0; // or == 1 Flags specifing the needed generator type must be used in combination with particular generator property. The following properties of cameras available through OpenNI interfaces are supported: diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index d23b0b24d..ce9a96089 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -370,28 +370,28 @@ enum CV_CAP_PROP_GUID =29, CV_CAP_PROP_ISO_SPEED =30, CV_CAP_PROP_MAX_DC1394 =31, - CV_CAP_PROP_IMAGE_GENERATOR_PRESENT = 32, CV_CAP_PROP_AUTOGRAB =1024, // property for highgui class CvCapture_Android only CV_CAP_PROP_SUPPORTED_PREVIEW_SIZES_STRING=1025, // readonly, tricky property, returns cpnst char* indeed CV_CAP_PROP_PREVIEW_FORMAT=1026, // readonly, tricky property, returns cpnst char* indeed + // OpenNI map generators CV_CAP_OPENNI_DEPTH_GENERATOR = 0, CV_CAP_OPENNI_IMAGE_GENERATOR = 1 << 31, CV_CAP_OPENNI_GENERATORS_MASK = 1 << 31, - CV_CAP_OPENNI_PROP_IMAGE_GENERATOR_PRESENT = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_IMAGE_GENERATOR_PRESENT, // Properties of cameras available through OpenNI interfaces - CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100, - CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm - CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm - CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels - CV_CAP_PROP_OPENNI_REGISTRATION_ON = 104, // flag - CV_CAP_PROP_OPENNI_REGISTRATION = CV_CAP_PROP_OPENNI_REGISTRATION_ON, // flag that synchronizes the remapping depth map to image map - // by changing depth generator's view point (if the flag is "on") or - // sets this view point to its normal one (if the flag is "off"). - CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE, - CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE, - CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH, + CV_CAP_PROP_OPENNI_OUTPUT_MODE = 100, + CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH = 101, // in mm + CV_CAP_PROP_OPENNI_BASELINE = 102, // in mm + CV_CAP_PROP_OPENNI_FOCAL_LENGTH = 103, // in pixels + CV_CAP_PROP_OPENNI_REGISTRATION_ON = 104, // flag + CV_CAP_PROP_OPENNI_REGISTRATION = CV_CAP_PROP_OPENNI_REGISTRATION_ON, // flag that synchronizes the remapping depth map to image map + // by changing depth generator's view point (if the flag is "on") or + // sets this view point to its normal one (if the flag is "off"). + CV_CAP_PROP_OPENNI_IMAGE_GENERATOR_PRESENT = 105, + CV_CAP_OPENNI_IMAGE_GENERATOR_OUTPUT_MODE = CV_CAP_OPENNI_IMAGE_GENERATOR + CV_CAP_PROP_OPENNI_OUTPUT_MODE, + CV_CAP_OPENNI_DEPTH_GENERATOR_BASELINE = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_BASELINE, + CV_CAP_OPENNI_DEPTH_GENERATOR_FOCAL_LENGTH = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_FOCAL_LENGTH, CV_CAP_OPENNI_DEPTH_GENERATOR_REGISTRATION_ON = CV_CAP_OPENNI_DEPTH_GENERATOR + CV_CAP_PROP_OPENNI_REGISTRATION_ON, // Properties of cameras available through GStreamer interface diff --git a/modules/highgui/src/cap_openni.cpp b/modules/highgui/src/cap_openni.cpp index 03856b40a..159e03d92 100644 --- a/modules/highgui/src/cap_openni.cpp +++ b/modules/highgui/src/cap_openni.cpp @@ -127,13 +127,13 @@ protected: // OpenNI context xn::Context context; bool m_isOpened; + bool m_isImageGeneratorPresent; // Data generators with its metadata xn::DepthGenerator depthGenerator; xn::DepthMetaData depthMetaData; XnMapOutputMode depthOutputMode; - bool m_isImageGeneratorPresent; xn::ImageGenerator imageGenerator; xn::ImageMetaData imageMetaData; XnMapOutputMode imageOutputMode; @@ -177,6 +177,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) depthOutputMode.nFPS = imageOutputMode.nFPS = 30; m_isOpened = false; + m_isImageGeneratorPresent = false; // Initialize and configure the context. if( context.Init() == XN_STATUS_OK ) @@ -246,13 +247,9 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) return; } - if(Imagelist.IsEmpty()) + if( !Imagelist.IsEmpty() ) { - m_isImageGeneratorPresent = FALSE; - } - else - { - m_isImageGeneratorPresent = TRUE; + m_isImageGeneratorPresent = true; imageGenerator.Create( context ); if( status != XN_STATUS_OK ) { @@ -264,7 +261,7 @@ CvCapture_OpenNI::CvCapture_OpenNI( int index ) // Set map output mode. CV_Assert( depthGenerator.SetMapOutputMode( depthOutputMode ) == XN_STATUS_OK ); // xn::DepthGenerator supports VGA only! (Jan 2011) - CV_Assert( m_isImageGeneratorPresent ? ( imageGenerator.SetMapOutputMode( imageOutputMode ) == XN_STATUS_OK ) : TRUE ); + CV_Assert( m_isImageGeneratorPresent ? ( imageGenerator.SetMapOutputMode( imageOutputMode ) == XN_STATUS_OK ) : true ); // Start generating data. status = context.StartGeneratingAll(); @@ -483,7 +480,7 @@ double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx ) if( !m_isImageGeneratorPresent ) return propValue; - if( propIdx == CV_CAP_PROP_IMAGE_GENERATOR_PRESENT ) + if( propIdx == CV_CAP_PROP_OPENNI_IMAGE_GENERATOR_PRESENT ) propValue = m_isImageGeneratorPresent ? 1. : 0.; else { diff --git a/samples/cpp/openni_capture.cpp b/samples/cpp/openni_capture.cpp index 3836c1660..866f71b8b 100644 --- a/samples/cpp/openni_capture.cpp +++ b/samples/cpp/openni_capture.cpp @@ -208,7 +208,7 @@ int main( int argc, char* argv[] ) "FRAME_HEIGHT " << capture.get( CV_CAP_PROP_FRAME_HEIGHT ) << endl << "FRAME_MAX_DEPTH " << capture.get( CV_CAP_PROP_OPENNI_FRAME_MAX_DEPTH ) << " mm" << endl << "FPS " << capture.get( CV_CAP_PROP_FPS ) << endl; - if( capture.get( CV_CAP_OPENNI_PROP_IMAGE_GENERATOR_PRESENT ) ) + if( capture.get( CV_CAP_PROP_OPENNI_IMAGE_GENERATOR_PRESENT ) ) { cout << "\nImage generator output mode:" << endl <<