Software Archive
Read-only legacy content
17061 Discussions

Saving color and depth frames

varsha_h_
Beginner
1,346 Views

Hey all, I'm working on Intel RealSense SDK (R2). I want to save the image from Camera_viewer. I have worked till saving the frame to specific buffers and retrieving from the same. I want to know how to save those frames/images to a specified location/folder. 

Here's my code:

    PXCImage *colorIm, *depthIm;
    for (int i=0; i<MAX_FRAMES; i++) {

        // This function blocks until all streams are ready (depth and color)
        // if false streams will be unaligned
        if (psm->AcquireFrame(true)<PXC_STATUS_NO_ERROR) break; 

        // retrieve all available image samples
        PXCCapture::Sample *sample = psm->QuerySample();

        // retrieve the image or frame by type from the sample
        colorIm = sample->color;
        depthIm = sample->depth;

        // render the frame
        if (!renderColor->RenderFrame(colorIm)) break;
        if (!renderDepth->RenderFrame(depthIm)) break;

        // release or unlock the current frame to fetch the next frame
        psm->ReleaseFrame();
    }

I'm able to retrieve the frames/images successfully, but I want to save those files for further use. So I want to know how to save those files in a folder.

Thanks in advance

0 Kudos
4 Replies
Dan_Middleton
Employee
1,346 Views

The CaptureManager has a SetFileName method that will let you record to a file.  There's an example in the SDK documentation you might find helpful:

void RecordORPlayback(pxcCHAR *file, bool 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);

 

   // 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

       ...

 
       // Go fetching the next sample

       sm->ReleaseFrame();

   }

 

   // close down

   sm->Release();

}

0 Kudos
varsha_h_
Beginner
1,346 Views

Thank you so much. 

0 Kudos
varsha_h_
Beginner
1,346 Views

@Dan

As you have suggested I have tried the same using a function. But I'm not able to record the frames to a specified folder. I have attached the file, please correct me if I'm wrong

 

0 Kudos
Lesly_Z_
Beginner
1,346 Views

hey!

how can I apply the same for librealsense?

I am trying to use:

RS_STREAM_COLOR_ALIGNED_TO_DEPTH

for getting something similar to the example in cpp-align

thanks

0 Kudos
Reply