XnStatus ConfigureGenerators(const RecConfiguration& config, xn::Context& context, xn::DepthGenerator& depthGenerator, xn::ImageGenerator& imageGenerator) { XnStatus nRetVal = XN_STATUS_OK; xn::EnumerationErrors errors; // Configure the depth, if needed if (config.bRecordDepth) { nRetVal = context.CreateAnyProductionTree(XN_NODE_TYPE_DEPTH, NULL, depthGenerator, &errors); CHECK_RC_ERR(nRetVal, "Create Depth", errors); nRetVal = depthGenerator.SetMapOutputMode(*config.pDepthMode); CHECK_RC(nRetVal, "Set Mode"); if (config.bMirrorIndicated && depthGenerator.IsCapabilitySupported(XN_CAPABILITY_MIRROR)) { depthGenerator.GetMirrorCap().SetMirror(config.bMirror); } // Set Hole Filter depthGenerator.SetIntProperty("HoleFilter", TRUE); } // Configure the image, if needed if (config.bRecordImage) { nRetVal = context.CreateAnyProductionTree(XN_NODE_TYPE_IMAGE, NULL, imageGenerator, &errors); CHECK_RC_ERR(nRetVal, "Create Image", errors); nRetVal = imageGenerator.SetMapOutputMode(*config.pImageMode); CHECK_RC(nRetVal, "Set Mode"); if (config.bMirrorIndicated && imageGenerator.IsCapabilitySupported(XN_CAPABILITY_MIRROR)) { imageGenerator.GetMirrorCap().SetMirror(config.bMirror); } } // Configuration for when there are both streams if (config.bRecordDepth && config.bRecordImage) { // Registration if (config.bRegister && depthGenerator.IsCapabilitySupported(XN_CAPABILITY_ALTERNATIVE_VIEW_POINT)) { nRetVal = depthGenerator.GetAlternativeViewPointCap().SetViewPoint(imageGenerator); CHECK_RC(nRetVal, "Registration"); } // Frame Sync if (config.bFrameSync && depthGenerator.IsCapabilitySupported(XN_CAPABILITY_FRAME_SYNC)) { if (depthGenerator.GetFrameSyncCap().CanFrameSyncWith(imageGenerator)) { nRetVal = depthGenerator.GetFrameSyncCap().FrameSyncWith(imageGenerator); CHECK_RC(nRetVal, "Frame sync"); } } } return XN_STATUS_OK; }
static void wrapper(void (*cb)(void)) { gboolean rc = FALSE; GError *err = NULL; g_printerr("\n"); hc_url_set(url, HCURL_REFERENCE, next_name("container")); hc_url_set(url, HCURL_PATH, next_name("content")); g_debug("ROUND with [%s] %s", hc_url_get(url, HCURL_HEXID), hc_url_get(url, HCURL_WHOLE)); rc = meta2_remote_container_create(&addr, timeout, &err, hc_url_get_id(url), hc_url_get(url, HCURL_REFERENCE)); CHECK_RC_ERR(rc, err, "CREATE"); if (cb) cb(); }
// Save the current state of the buffer to a file XnStatus Dump() { xn::MockDepthGenerator mockDepth; xn::MockImageGenerator mockImage; xn::EnumerationErrors errors; XnStatus rc; // Create recorder rc = m_context.CreateAnyProductionTree(XN_NODE_TYPE_RECORDER, NULL, m_recorder, &errors); CHECK_RC_ERR(rc, "Create recorder", errors); // Create name of new file time_t rawtime; struct tm *timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); XnChar strFileName[XN_FILE_MAX_PATH]; sprintf(strFileName, "%s/%04d%02d%02d-%02d%02d%02d.oni", m_strDirName, timeinfo->tm_year+1900, timeinfo->tm_mon+1, timeinfo->tm_mday, timeinfo->tm_hour, timeinfo->tm_min, timeinfo->tm_sec); m_recorder.SetDestination(XN_RECORD_MEDIUM_FILE, strFileName); printf("Creating file %s\n", strFileName); // Create mock nodes based on the depth generator, to save depth if (m_bDepth) { // Create mock nodes based on the depth generator, to save depth rc = m_context.CreateMockNodeBasedOn(m_depthGenerator, NULL, mockDepth); CHECK_RC(rc, "Create depth node"); rc = m_recorder.AddNodeToRecording(mockDepth); CHECK_RC(rc, "Add depth node"); } if (m_bImage) { // Create mock nodes based on the image generator, to save image rc = m_context.CreateMockNodeBasedOn(m_imageGenerator, NULL, mockImage); CHECK_RC(rc, "Create image node"); rc = m_recorder.AddNodeToRecording(mockImage); CHECK_RC(rc, "Add image node"); } // Write frames from next index (which will be next to be written, and so the first available) // this is only if a full loop was done, and this frame has meaningful data if (m_nNextWrite < m_nBufferCount) { // Not first loop, right till end for (XnUInt32 i = m_nNextWrite; i < m_nBufferSize; ++i) { if (m_bDepth) { mockDepth.SetData(m_pFrames[i].depthFrame); } if (m_bImage) { mockImage.SetData(m_pFrames[i].imageFrame); } m_recorder.Record(); } } // Write frames from the beginning of the buffer to the last on written for (XnUInt32 i = 0; i < m_nNextWrite; ++i) { if (m_bDepth) { mockDepth.SetData(m_pFrames[i].depthFrame); } if (m_bImage) { mockImage.SetData(m_pFrames[i].imageFrame); } m_recorder.Record(); } // Close recorder m_recorder.Release(); return XN_STATUS_OK; }