本文整理汇总了C++中XnDeviceStream::IsNewDataAvailable方法的典型用法代码示例。如果您正苦于以下问题:C++ XnDeviceStream::IsNewDataAvailable方法的具体用法?C++ XnDeviceStream::IsNewDataAvailable怎么用?C++ XnDeviceStream::IsNewDataAvailable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XnDeviceStream
的用法示例。
在下文中一共展示了XnDeviceStream::IsNewDataAvailable方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: IsNewDataAvailable
XnStatus XnDeviceBase::IsNewDataAvailable(const XnChar* StreamName, XnBool* pbNewDataAvailable, XnUInt64* pnTimestamp)
{
XnStatus nRetVal = XN_STATUS_OK;
XN_VALIDATE_INPUT_PTR(StreamName);
XN_VALIDATE_OUTPUT_PTR(pbNewDataAvailable);
*pbNewDataAvailable = FALSE;
if (strcmp(StreamName, XN_PRIMARY_STREAM_ANY) == 0)
{
const XnChar* aStreamNames[100];
XnUInt32 nCount = 100;
nRetVal = GetStreamNames(aStreamNames, &nCount);
XN_IS_STATUS_OK(nRetVal);
for (XnUInt32 i = 0; i < nCount; ++i)
{
// find stream
XnDeviceStream* pStream = NULL;
nRetVal = FindStream(StreamName, &pStream);
XN_IS_STATUS_OK(nRetVal);
if (pStream->IsNewDataAvailable())
{
*pbNewDataAvailable = TRUE;
*pnTimestamp = pStream->GetLastTimestamp();
break;
}
}
}
else
{
// find stream
XnDeviceStream* pStream = NULL;
nRetVal = FindStream(StreamName, &pStream);
XN_IS_STATUS_OK(nRetVal);
if (pStream->IsNewDataAvailable())
{
*pbNewDataAvailable = TRUE;
*pnTimestamp = pStream->GetLastTimestamp();
}
}
return (XN_STATUS_OK);
}
示例2: ReadStream
XnStatus XnDeviceBase::ReadStream(XnStreamData* pStreamOutput)
{
XnStatus nRetVal = XN_STATUS_OK;
XN_VALIDATE_INPUT_PTR(pStreamOutput);
if (m_ReadWriteMode.GetValue() == XN_DEVICE_MODE_WRITE)
{
return XN_STATUS_IO_DEVICE_WRONG_MODE;
}
// take the stream to read
XnDeviceStream* pStream;
nRetVal = FindStream(pStreamOutput->StreamName, &pStream);
XN_IS_STATUS_OK(nRetVal);
// make sure it is open
if (!pStream->IsNewDataAvailable() && !pStream->IsOpen())
{
return XN_STATUS_STREAM_NOT_OPEN;
}
// wait for it to advance
nRetVal = WaitForStream(m_hNewDataEvent, pStream);
XN_IS_STATUS_OK(nRetVal);
// and read
nRetVal = ReadFromStreamImpl(pStream, pStreamOutput);
XN_IS_STATUS_OK(nRetVal);
return (XN_STATUS_OK);
}
示例3: HasSynchedFrameArrived
XnBool XnSensor::HasSynchedFrameArrived(const XnChar* strDepthStream, const XnChar* strImageStream)
{
// find both streams
XnDeviceStream* pDepth;
XnDeviceStream* pImage;
if (XN_STATUS_OK != FindStream(strDepthStream, &pDepth))
return FALSE;
if (XN_STATUS_OK != FindStream(strImageStream, &pImage))
return FALSE;
XnUInt32 nThreshold = XN_SENSOR_FRAME_SYNC_MAX_DIFF;
if (IsHighResTimestamps())
nThreshold *= 1000;
// wait for both to advance, and time difference to be less than threshold
XnInt32 nTimestampDiff = XnInt32(pDepth->GetLastTimestamp() - pImage->GetLastTimestamp());
XnBool bConditionMet = (
pDepth->IsNewDataAvailable() &&
pImage->IsNewDataAvailable() &&
(XnUInt32)abs(nTimestampDiff) <= nThreshold
);
if (xnLogIsDumpMaskEnabled(XN_DUMP_FRAME_SYNC))
{
XnUInt64 nNow;
xnOSGetHighResTimeStamp(&nNow);
xnDumpWriteString(m_FrameSyncDump, "%llu,%u,%llu,%u,%llu,%s\n",
nNow,
pDepth->IsNewDataAvailable(),
pDepth->GetLastTimestamp(),
pImage->IsNewDataAvailable(),
pImage->GetLastTimestamp(),
bConditionMet ? "OK" : "Waiting");
}
return bConditionMet;
}
示例4: HasPrimaryStreamAdvanced
XnBool XnDeviceBase::HasPrimaryStreamAdvanced(XnStreamDataSet* pOutputSet)
{
if (strcmp(m_PrimaryStream.GetValue(), XN_PRIMARY_STREAM_NONE) == 0)
{
// special case of None: condition is always true
return TRUE;
}
const XnChar* astrNames[XN_DEVICE_BASE_MAX_STREAMS_COUNT];
XnUInt32 nArraySize = XN_DEVICE_BASE_MAX_STREAMS_COUNT;
// take a list of streams to check for new data
if (strcmp(m_PrimaryStream.GetValue(), XN_PRIMARY_STREAM_ANY) != 0)
{
// we have a specific stream. Add it to the list
astrNames[0] = m_PrimaryStream.GetValue();
nArraySize = 1;
}
else
{
// special case of ANY. we need to check every one of requested streams
XnStreamData* apStreamOutputs[XN_DEVICE_BASE_MAX_STREAMS_COUNT];
if (XN_STATUS_OK != XnStreamDataSetCopyToArray(pOutputSet, apStreamOutputs, &nArraySize))
{
return FALSE;
}
for (XnUInt32 i = 0; i < nArraySize; ++i)
{
astrNames[i] = apStreamOutputs[i]->StreamName;
}
}
// now check if we have new data
for (XnUInt32 i = 0; i < nArraySize; ++i)
{
XnDeviceStream* pStream = NULL;
if (XN_STATUS_OK == FindStream(astrNames[i], &pStream))
{
if (pStream->IsNewDataAvailable())
return TRUE;
}
}
return FALSE;
}