void captureSingleFrame(int) { int num = findUniqueFileName(); XnChar csImageFileName[XN_FILE_MAX_PATH]; XnChar csDepthFileName[XN_FILE_MAX_PATH]; XnChar csIRFileName[XN_FILE_MAX_PATH]; getImageFileName(num, csImageFileName); getDepthFileName(num, csDepthFileName); getIRFileName(num, csIRFileName); const ImageMetaData* pImageMD = getImageMetaData(); if (pImageMD != NULL) { xnOSSaveFile(csImageFileName, pImageMD->Data(), pImageMD->DataSize()); } const IRMetaData* pIRMD = getIRMetaData(); if (pIRMD != NULL) { xnOSSaveFile(csIRFileName, pIRMD->Data(), pIRMD->DataSize()); } const DepthMetaData* pDepthMD = getDepthMetaData(); if (pDepthMD != NULL) { xnOSSaveFile(csDepthFileName, pDepthMD->Data(), pDepthMD->DataSize()); } g_Capture.nCapturedFrameUniqueID = num + 1; // displayMessage("Frames saved with ID %d", num); printf("Frames saved with ID %d\n", num); }
void captureSingleFrame(int) { int num = findUniqueFileName(); XnChar csColorFileName[XN_FILE_MAX_PATH]; XnChar csDepthFileName[XN_FILE_MAX_PATH]; XnChar csIRFileName[XN_FILE_MAX_PATH]; getColorFileName(num, csColorFileName); getDepthFileName(num, csDepthFileName); getIRFileName(num, csIRFileName); openni::VideoFrameRef& colorFrame = getColorFrame(); if (colorFrame.isValid()) { xnOSSaveFile(csColorFileName, colorFrame.getData(), colorFrame.getDataSize()); } openni::VideoFrameRef& depthFrame = getDepthFrame(); if (depthFrame.isValid()) { xnOSSaveFile(csDepthFileName, depthFrame.getData(), depthFrame.getDataSize()); } openni::VideoFrameRef& irFrame = getIRFrame(); if (irFrame.isValid()) { xnOSSaveFile(csIRFileName, irFrame.getData(), irFrame.getDataSize()); } g_Capture.nCapturedFrameUniqueID = num + 1; displayMessage("Frames saved with ID %d", num); }
XnStatus XnDeviceSensorProtocolDumpLastRawFrameImpl(XnDevicePrivateData* pDevicePrivateData, const XnChar* strType, const XnChar* strFileName) { XnStatus nRetVal = XN_STATUS_OK; const XnChar* strName; nRetVal = XnDeviceSensorProtocolFindStreamOfType(pDevicePrivateData, strType, &strName); XN_IS_STATUS_OK(nRetVal); XnUInt64 nMaxDataSize; nRetVal = pDevicePrivateData->pSensor->GetProperty(strName, XN_STREAM_PROPERTY_REQUIRED_DATA_SIZE, &nMaxDataSize); XN_IS_STATUS_OK(nRetVal); XnDynamicSizeBuffer dsb; dsb.nMaxSize = (XnUInt32)nMaxDataSize; dsb.pData = xnOSMallocAligned((XnUInt32)nMaxDataSize, XN_DEFAULT_MEM_ALIGN); XN_VALIDATE_ALLOC_PTR(dsb.pData); nRetVal = pDevicePrivateData->pSensor->GetProperty(strName, XN_STREAM_PROPERTY_LAST_RAW_FRAME, XN_PACK_GENERAL_BUFFER(dsb)); if (nRetVal != XN_STATUS_OK) { xnOSFreeAligned(dsb.pData); return (nRetVal); } xnOSSaveFile(strFileName, dsb.pData, dsb.nDataSize); xnOSFreeAligned(dsb.pData); return (XN_STATUS_OK); }
XnStatus XnDeviceSensorProtocolDumpLastRawFrameImpl(XnDevicePrivateData* pDevicePrivateData, const XnChar* strType, const XnChar* strFileName) { XnStatus nRetVal = XN_STATUS_OK; const XnChar* strName; nRetVal = XnDeviceSensorProtocolFindStreamOfType(pDevicePrivateData, strType, &strName); XN_IS_STATUS_OK(nRetVal); XnUInt64 nMaxDataSize; nRetVal = pDevicePrivateData->pSensor->GetProperty(strName, XN_STREAM_PROPERTY_REQUIRED_DATA_SIZE, &nMaxDataSize); XN_IS_STATUS_OK(nRetVal); XnDynamicSizeBuffer dsb; dsb.nMaxSize = (XnUInt32)nMaxDataSize; dsb.pData = xnOSMallocAligned((XnUInt32)nMaxDataSize, XN_DEFAULT_MEM_ALIGN); XN_VALIDATE_ALLOC_PTR(dsb.pData); nRetVal = pDevicePrivateData->pSensor->GetProperty(strName, XN_STREAM_PROPERTY_LAST_RAW_FRAME, XN_PACK_GENERAL_BUFFER(dsb)); if (nRetVal != XN_STATUS_OK) { xnOSFreeAligned(dsb.pData); return (nRetVal); } // The real depth size is half of what's being reported because of special depth+shift memory packing format. if (strType == XN_STREAM_TYPE_DEPTH) { dsb.nDataSize /= 2; } xnOSSaveFile(strFileName, dsb.pData, dsb.nDataSize); xnOSFreeAligned(dsb.pData); return (XN_STATUS_OK); }