Software Archive
Read-only legacy content
17061 Discussions

saving RGB and depth images

ajinkya_A_
Beginner
517 Views

As in the documentation I have used 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?

Thanks in advance

0 Kudos
3 Replies
samontab
Valued Contributor II
517 Views

Have a look at the Clip Editor example

0 Kudos
ajinkya_A_
Beginner
517 Views

@Samontab 

Yes, but I didn't understand how to connect that with camera_viewer.cpp . Is there any other way to achieve my goals? 

0 Kudos
samontab
Valued Contributor II
517 Views

Well, you have the bytes of the image in memory so you could use a 3rd party library for saving it.

At the lowest level this could be for example libjpeg, or libpng.

If you are planning to process the images as well, you could use OpenCV which has those libraries and more already built-in.

0 Kudos
Reply