本文整理汇总了C++中XnDeviceStream::GetLastTimestamp方法的典型用法代码示例。如果您正苦于以下问题:C++ XnDeviceStream::GetLastTimestamp方法的具体用法?C++ XnDeviceStream::GetLastTimestamp怎么用?C++ XnDeviceStream::GetLastTimestamp使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XnDeviceStream
的用法示例。
在下文中一共展示了XnDeviceStream::GetLastTimestamp方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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;
}