本文整理汇总了C++中xn::ImageGenerator::IsValid方法的典型用法代码示例。如果您正苦于以下问题:C++ ImageGenerator::IsValid方法的具体用法?C++ ImageGenerator::IsValid怎么用?C++ ImageGenerator::IsValid使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xn::ImageGenerator
的用法示例。
在下文中一共展示了ImageGenerator::IsValid方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: setCommonProperty
bool CvCapture_OpenNI::setCommonProperty( int propIdx, double propValue )
{
bool isSet = false;
switch( propIdx )
{
// There is a set of properties that correspond to depth generator by default
// (is they are pass without particular generator flag).
case CV_CAP_PROP_OPENNI_REGISTRATION:
isSet = setDepthGeneratorProperty( propIdx, propValue );
break;
case CV_CAP_PROP_OPENNI_APPROX_FRAME_SYNC :
if( propValue && depthGenerator.IsValid() && imageGenerator.IsValid() )
{
// start synchronization
if( approxSyncGrabber.empty() )
{
approxSyncGrabber = new ApproximateSyncGrabber( context, depthGenerator, imageGenerator, maxBufferSize, isCircleBuffer, maxTimeDuration );
}
else
{
approxSyncGrabber->finish();
// update params
approxSyncGrabber->setMaxBufferSize(maxBufferSize);
approxSyncGrabber->setIsCircleBuffer(isCircleBuffer);
approxSyncGrabber->setMaxTimeDuration(maxTimeDuration);
}
approxSyncGrabber->start();
}
else if( !propValue && !approxSyncGrabber.empty() )
{
// finish synchronization
approxSyncGrabber->finish();
}
break;
case CV_CAP_PROP_OPENNI_MAX_BUFFER_SIZE :
maxBufferSize = cvRound(propValue);
if( !approxSyncGrabber.empty() )
approxSyncGrabber->setMaxBufferSize(maxBufferSize);
break;
case CV_CAP_PROP_OPENNI_CIRCLE_BUFFER :
if( !approxSyncGrabber.empty() )
approxSyncGrabber->setIsCircleBuffer(isCircleBuffer);
break;
case CV_CAP_PROP_OPENNI_MAX_TIME_DURATION :
maxTimeDuration = cvRound(propValue);
if( !approxSyncGrabber.empty() )
approxSyncGrabber->setMaxTimeDuration(maxTimeDuration);
break;
default:
{
std::stringstream ss;
ss << "Such parameter (propIdx=" << propIdx << ") isn't supported for setting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
}
return isSet;
}
示例2: grabFrame
bool CvCapture_OpenNI::grabFrame()
{
if( !isOpened() )
return false;
bool isGrabbed = false;
if( !approxSyncGrabber.empty() && approxSyncGrabber->isRun() )
{
isGrabbed = approxSyncGrabber->grab( depthMetaData, imageMetaData );
}
else
{
XnStatus status = context.WaitAndUpdateAll();
if( status != XN_STATUS_OK )
return false;
if( depthGenerator.IsValid() )
depthGenerator.GetMetaData( depthMetaData );
if( imageGenerator.IsValid() )
imageGenerator.GetMetaData( imageMetaData );
isGrabbed = true;
}
return isGrabbed;
}
示例3: setImageGeneratorProperty
bool CvCapture_OpenNI::setImageGeneratorProperty( int propIdx, double propValue )
{
bool isSet = false;
if( !imageGenerator.IsValid() )
return isSet;
switch( propIdx )
{
case CV_CAP_PROP_OPENNI_OUTPUT_MODE :
{
XnMapOutputMode mode;
switch( cvRound(propValue) )
{
case CV_CAP_OPENNI_VGA_30HZ :
mode.nXRes = XN_VGA_X_RES;
mode.nYRes = XN_VGA_Y_RES;
mode.nFPS = 30;
break;
case CV_CAP_OPENNI_SXGA_15HZ :
mode.nXRes = XN_SXGA_X_RES;
mode.nYRes = XN_SXGA_Y_RES;
mode.nFPS = 15;
break;
case CV_CAP_OPENNI_SXGA_30HZ :
mode.nXRes = XN_SXGA_X_RES;
mode.nYRes = XN_SXGA_Y_RES;
mode.nFPS = 30;
break;
case CV_CAP_OPENNI_QVGA_30HZ :
mode.nXRes = XN_QVGA_X_RES;
mode.nYRes = XN_QVGA_Y_RES;
mode.nFPS = 30;
break;
case CV_CAP_OPENNI_QVGA_60HZ :
mode.nXRes = XN_QVGA_X_RES;
mode.nYRes = XN_QVGA_Y_RES;
mode.nFPS = 60;
break;
default :
CV_Error( CV_StsBadArg, "Unsupported image generator output mode.\n");
}
XnStatus status = imageGenerator.SetMapOutputMode( mode );
if( status != XN_STATUS_OK )
std::cerr << "CvCapture_OpenNI::setImageGeneratorProperty : " << xnGetStatusString(status) << std::endl;
else
isSet = true;
break;
}
default:
{
std::stringstream ss;
ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
}
return isSet;
}
示例4: getImageGeneratorProperty
double CvCapture_OpenNI::getImageGeneratorProperty( int propIdx )
{
double propValue = 0.;
if( !imageGenerator.IsValid() )
return propValue;
XnMapOutputMode mode;
switch( propIdx )
{
case CV_CAP_PROP_OPENNI_GENERATOR_PRESENT :
CV_DbgAssert( imageGenerator.IsValid() );
propValue = 1.;
break;
case CV_CAP_PROP_FRAME_WIDTH :
if( imageGenerator.GetMapOutputMode(mode) == XN_STATUS_OK )
propValue = mode.nXRes;
break;
case CV_CAP_PROP_FRAME_HEIGHT :
if( imageGenerator.GetMapOutputMode(mode) == XN_STATUS_OK )
propValue = mode.nYRes;
break;
case CV_CAP_PROP_FPS :
if( imageGenerator.GetMapOutputMode(mode) == XN_STATUS_OK )
propValue = mode.nFPS;
break;
case CV_CAP_PROP_POS_MSEC :
propValue = imageGenerator.GetTimestamp();
break;
case CV_CAP_PROP_POS_FRAMES :
propValue = imageGenerator.GetFrameID();
break;
default :
{
std::stringstream ss;
ss << "Image generator does not support such parameter (propIdx=" << propIdx << ") for getting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
}
return propValue;
}
示例5: setDepthGeneratorProperty
bool CvCapture_OpenNI::setDepthGeneratorProperty( int propIdx, double propValue )
{
bool isSet = false;
CV_Assert( depthGenerator.IsValid() );
switch( propIdx )
{
case CV_CAP_PROP_OPENNI_REGISTRATION:
{
if( propValue != 0.0 ) // "on"
{
// if there isn't image generator (i.e. ASUS XtionPro doesn't have it)
// then the property isn't avaliable
if( imageGenerator.IsValid() )
{
if( !depthGenerator.GetAlternativeViewPointCap().IsViewPointAs(imageGenerator) )
{
if( depthGenerator.GetAlternativeViewPointCap().IsViewPointSupported(imageGenerator) )
{
XnStatus status = depthGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator);
if( status != XN_STATUS_OK )
std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : " << xnGetStatusString(status) << std::endl;
else
isSet = true;
}
else
std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : Unsupported viewpoint." << std::endl;
}
else
isSet = true;
}
}
else // "off"
{
XnStatus status = depthGenerator.GetAlternativeViewPointCap().ResetViewPoint();
if( status != XN_STATUS_OK )
std::cerr << "CvCapture_OpenNI::setDepthGeneratorProperty : " << xnGetStatusString(status) << std::endl;
else
isSet = true;
}
}
break;
default:
{
std::stringstream ss;
ss << "Depth generator does not support such parameter (propIdx=" << propIdx << ") for setting.\n";
CV_Error( CV_StsBadArg, ss.str().c_str() );
}
}
return isSet;
}
示例6: changeRegistration
void changeRegistration(int nValue)
{
if (!g_DepthGenerator.IsValid() || !g_DepthGenerator.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT))
{
return;
}
if(!nValue)
{
g_DepthGenerator.GetAlternativeViewPointCap().ResetViewPoint();
}
else if (g_ImageGenerator.IsValid())
{
g_DepthGenerator.GetAlternativeViewPointCap().SetViewPoint(g_ImageGenerator);
}
}