Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to save raw data (.bag) with lesser frame rate #3537

Closed
snmathur4 opened this issue Mar 19, 2019 · 10 comments
Closed

How to save raw data (.bag) with lesser frame rate #3537

snmathur4 opened this issue Mar 19, 2019 · 10 comments

Comments

@snmathur4
Copy link

snmathur4 commented Mar 19, 2019


Required Info
Camera Model D400
Operating System & Version Win 10
Platform PC
Language C#

Issue Description

I am saving a .bag using

private Pipeline pipeline = new Pipeline();
var cfg = new Config();
cfg.EnableRecordToFile("C:\temp\My_test111.bag");
var pp = pipeline.Start(cfg);
// rest of code ...
pipeline.Stop();

But my .bag file gets huge (GB) very quickly. I am not interested in so much data. I want to record about 1 minute but maybe only 10 frames per second. Is it possible to specify the frame rate for recording data to bag files? thanks

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Mar 19, 2019

As well as supporting 30 fps on most resolution modes, 6 fps and 15 fps are also supported. So a good compromise may be to configure your stream to run at 15 fps and record the bag file as normal.

When doing the bag recording in the RealSense Viewer program, you can also now set custom save paths so that the file gets saved in a computer location where you have the most spare storage capacity.

@snmathur4
Copy link
Author

Thanks for your reply. I tried your suggestion with this code:

Config cfg = new Config();
cfg.EnableStream(Stream.Depth, 640, 480, framerate: 6);
cfg.EnableStream(Stream.Color, Format.Rgb8, framerate: 30);
cfg.EnableRecordToFile(@"C:\temp\My_test111.bag");
pipeline.Start(cfg);

This code works fine, but when I change the Stream.Color to framerate: 6. I get this exception:
Capture

@snmathur4 snmathur4 reopened this Mar 20, 2019
@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Mar 20, 2019

I think you need to use the code below for your cfg stream configuration lines:

cfg.enable_stream(rs2.stream.depth, 640, 480, rs2.format.z16, 6)
cfg.enable_stream(rs2.stream.color, 640, 480, rs2.format.rgb8, 30)

@snmathur4
Copy link
Author

I am using C# and the naming is little different. Based on this example:
https://github.com/IntelRealSense/librealsense/blob/master/wrappers/csharp/cs-tutorial-2-capture/Window.xaml.cs

I also noticed following works good and created a good .bag file

cfg.enable_stream(rs2.stream.depth, 640, 480, rs.format.z16, 30)

but following creates a corrupt .bag file ("Bag unindexed") when I try to open it

cfg.enable_stream(rs2.stream.depth, 640, 480, rs.format.z16, 30)

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Mar 20, 2019

Yes, sorry, I just realized that the C# format is different. My apologies!

Apparently, the unindexed bag error is related to a problem with how the bag recording is closed.

#2326

Though your code does conform to the suggestion in that discussion to close it with Stop if you are using the pipeline.

@snmathur4
Copy link
Author

Yes! you're right. Just tried and seems like .bag file is created correctly with following. thanks!

pipeline.Stop(); 

But I am still have issues with this:

cfg.EnableStream(Stream.Color, Format.Rgb8, framerate: 6);

6 frame rate works for Stream.Depth but not Stream.Color

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Mar 20, 2019

I found another case where someone had trouble with streaming color at 6 fps. No explanation was provided regarding why that may have been happening for that user though, unfortunately. It looks like it may have been a case where it got closed because the user stopped providing responses.

#2771

Does it work at 15 fps?

@snmathur4
Copy link
Author

Yup! thank you 15 fps worked with 640 x 480.
Strange it doesn't work with 6 fps. I'll read through the post some more.
Thanks for your help!

@MartyG-RealSense
Copy link
Collaborator

Glad I could help!

I just did a test with your configuration in RealSense Viewer (640x480 at 6 fps for depth and color, z16 for depth and rgb8 for color). The most noticeable event was that when a 6 fps color stream was started, a 'no frames received' error briefly flashed up and then the color stream started running normally. This error did not occur at 15 fps and above.

@snmathur4
Copy link
Author

snmathur4 commented Mar 20, 2019

Oh interesting, maybe I'll try to just ignore first few frames or wait couple seconds before retrieving frames. Will see if that helps.

I tried both Color and Depth at 15 fps, and for 1 minute I am getting 1 GB of .bag file. This is acceptable to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants