예제 #1
0
XnDumpFile* xnDumpFileOpenImpl(const XnChar* strDumpName, XnBool bForce, XnBool bSessionDump, const XnChar* strNameFormat, va_list args)
{
    XnStatus nRetVal = XN_STATUS_OK;

    DumpData& dumpData = DumpData::GetInstance();

    // check if there are writers
    if (dumpData.writers.IsEmpty())
    {
        return NULL;
    }

    if (!bForce)
    {
        if (!xnLogIsDumpMaskEnabled(strDumpName))
        {
            return NULL;
        }
    }

    // format file name
    XnChar strFileName[XN_FILE_MAX_PATH];
    XnUInt32 nChars;
    nRetVal = xnOSStrFormatV(strFileName, XN_FILE_MAX_PATH, &nChars, strNameFormat, args);
    if (nRetVal != XN_STATUS_OK)
    {
        XN_ASSERT(FALSE);
        return NULL;
    }

    // create a handle that will hold all handles to all writers
    XnDumpFile* pFile = XN_NEW(XnDumpFile);

    // try to add writers
    for (XnDumpWriters::Iterator it = dumpData.writers.Begin(); it != dumpData.writers.End(); ++it)
    {
        XnDumpWriterFile writerFile;
        writerFile.pWriter = *it;
        writerFile.hFile = writerFile.pWriter->OpenFile(writerFile.pWriter->pCookie, strDumpName, bSessionDump, strFileName);
        XN_ASSERT(writerFile.hFile.pInternal != NULL);
        if (writerFile.hFile.pInternal != NULL)
        {
            nRetVal = pFile->m_writersFiles.AddLast(writerFile);
            XN_ASSERT(nRetVal == XN_STATUS_OK);
        }
    }

    // check if any writer succeeded
    if (pFile->m_writersFiles.IsEmpty())
    {
        // no file. Release memory
        XN_DELETE(pFile);
        return NULL;
    }

    // return the file pointer
    return pFile;
}
예제 #2
0
XN_C_API void xnDumpInit(XnDump* pDump, const XnChar* csDumpMask, const XnChar* csHeader, const XnChar* csFileNameFormat, ...)
{
    if (pDump->hFile == XN_INVALID_FILE_HANDLE && xnLogIsDumpMaskEnabled(csDumpMask))
    {
        va_list args;
        va_start(args, csFileNameFormat);
        xnDumpCreate(pDump, csHeader, csFileNameFormat, args);
        va_end(args);
    }
}
예제 #3
0
OniStatus LinkOniStream::getProperty(int propertyId, void* data, int* pDataSize)
{
	switch(propertyId)
	{
	case PS_PROPERTY_DUMP_DATA:
		{
			XnChar strDumpName[XN_FILE_MAX_PATH] = "";
			xnLinkGetStreamDumpName(m_streamId, strDumpName, sizeof(strDumpName));
			XnBool bEnabled = xnLogIsDumpMaskEnabled(strDumpName);
			ENSURE_PROP_SIZE(*pDataSize, bool);
			ASSIGN_PROP_VALUE_INT(data, *pDataSize, bEnabled);
		}
		break;
	default:
		return ONI_STATUS_BAD_PARAMETER;
	}

	return ONI_STATUS_OK;
}
예제 #4
0
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;
}