diff --git a/modules/highgui/include/opencv2/highgui/highgui_c.h b/modules/highgui/include/opencv2/highgui/highgui_c.h index 8ef4680ea3..2ad1fd08d6 100644 --- a/modules/highgui/include/opencv2/highgui/highgui_c.h +++ b/modules/highgui/include/opencv2/highgui/highgui_c.h @@ -360,9 +360,11 @@ enum 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_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 CV_CAP_GSTREAMER_QUEUE_LENGTH = 200, // default is 1 diff --git a/modules/highgui/src/cap_openni.cpp b/modules/highgui/src/cap_openni.cpp index 558d25721b..41dd329dd0 100644 --- a/modules/highgui/src/cap_openni.cpp +++ b/modules/highgui/src/cap_openni.cpp @@ -344,7 +344,28 @@ double CvCapture_OpenNI::getDepthGeneratorProperty( int propIdx ) bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue ) { CV_Assert( depthGenerator.IsValid() ); - CV_Error( CV_StsBadArg, "Depth generator does not support such parameter for setting.\n"); + switch(propIdx) + { + case CV_CAP_PROP_OPENNI_REGISTRATION_ON: + { + CV_Assert( imageGenerator.IsValid() ); + if (!depthGenerator.GetAlternativeViewPointCap ().IsViewPointAs (imageGenerator)) + { + if (depthGenerator.GetAlternativeViewPointCap ().IsViewPointSupported (imageGenerator)) + { + XnStatus status = depthGenerator.GetAlternativeViewPointCap().SetViewPoint (imageGenerator); + if (status != XN_STATUS_OK) + CV_Error( CV_StsError, std::string("turning registration on failed. Reason: ") + xnGetStatusString (status)); + } + else + CV_Error( CV_StsError, "turning registration on failed. Reason: unsupported viewpoint"); + } + } + return true; + break; + default: + CV_Error( CV_StsBadArg, "Depth generator does not support such parameter for setting.\n"); + } return false; }