- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
i saw the code example of IntelRealSense/librealsense/examples/save-to-disk/rs-save-to-disk.cpp from github.
link is https://github.com/IntelRealSense/librealsense/blob/master/examples/save-to-disk/rs-save-to-disk.cpp#L34
line 34 for (auto&& frame : pipe.wait_for_frames())
why code like this rather "auto frame = pipe.wait_for_frames()"
and line 37 if (auto vf = frame.as<rs2::video_frame>())
rather "auto vf = frame.get_depth_frame()"
is any better to code this way?
Link Copied
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
is it in order to minimize the memory cost?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
The link below explains why wait_for_frames is used and the alternatives to it.
https://github.com/IntelRealSense/librealsense/issues/2422#issuecomment-423254709
Using 'video' frame is an appropriate choice when only saving data as a simple PNG, and not a file format with embedded depth matrix information such as .raw. or .bin
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks for reply, it 's really helpful.
But what really disturb me is why it use A reference " auto &&" to define frame, is it a better(tidy) wrriting than using " = " to define an argument(the way we usually do)?and why?
then using "as" methond to change the class of frame. on the contrary, I may use "get_depth_frame" function straightly if my purpose is to get a depth image.
Perhaps it belongs to a c++ question boundary, but i would appriciate it if you give me some suggestions.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My understanding is that "auto &&" makes it a 'universal reference' that can be bound to anything.
When programming Librealsense, my advice is to use example programs as a base reference and then adjust the code to your own style if you believe that your own method of structuring code is more suitable. Librealsense is open-source exactly so users can mold it to their needs and preferences.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
My opinion is maybe it's a memory saving way to code like this. Anyway, thanks you very much.

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page