Search code examples
visual-c++rgbintelsaving-datarealsense

saving RGB and depth images in Intel RealSense


I'm using SetFileName() function to save the RGB and Depth image to the specified file location. But that's not saving anything. The code runs without error, but nothing gets saved.

Here's my code:

void RecordORPlayback(pxcCHAR *file, pxcBool record)
{
// Create a SenseManager instance
 PXCSenseManager *sm=PXCSenseManager::CreateInstance();

 // Set file recording or playback
sm->QueryCaptureManager()->SetFileName(file,record);

// Select the color stream

sm->EnableStream(PXCCapture::STREAM_TYPE_COLOR,640,480,0); 
sm->EnableStream(PXCCapture::STREAM_TYPE_DEPTH,640,480,0);

PXCImage *colorIm, *depthIm;
// Initialize and Record 300 frames

sm->Init(); 

 for (int i=0;i<300;i++) {

   // This function blocks until a color sample is ready
   if (sm->AcquireFrame(true)<PXC_STATUS_NO_ERROR) break; 

   // Retrieve the sample

   PXCCapture::Sample *sample=sm->QuerySample();

   // Work on the image sample->color
    colorIm=sample->color;
    depthIm=sample->depth;

   // Go fetching the next sample
   sm->ReleaseFrame();

 }
 // close down
sm->Release();

}

I have no idea how to save the output. Any suggestions?


Solution

  • the boolean record must be set to true for recording and false for playback. When you don't give it a value it is false by default. Try putting true.