librealsense icon indicating copy to clipboard operation
librealsense copied to clipboard

Accessing infrared stream

Open Jason420Git opened this issue 9 years ago • 5 comments

Required Info
Camera Model D400
Firmware Version
Operating System & Version
Kernel Version (Linux Only)

Hi,

I am following the API guide but having issue getting Infrared stream. The method: rs2::device::get() does not take any parameters which is unlike the example. Instead there are just get_depth and get_color.

Jason420Git avatar Oct 19 '17 11:10 Jason420Git

Hi,

rs2::device::get() returns a std::shared_ptr<rs2_device> to the underlying device used inside the library. You can't use this pointer for anything in your application other than passing it to the C API, which we don't recommend mixing with the C++ API.

Are you following this guide: "API How To"?

Please try the suggested code in the API How To guide (found in our Wiki) and let us know if you managed to get what you need.

zivsha avatar Oct 20 '17 05:10 zivsha

I am following this yes. But there is not an example of how to get a frame from the infrared stream. And the example which I presume i could follow, is no longer applicable.

rs2::frame depth_frame = frames.get(RS2_STREAM_INFRARED);

Is what I presumed I could do (as per the example using depth) but it does no longer exist. The method for getting depth frames is now frame.get_depth_frame(), but there is no call for infrared frames.

Jason420Git avatar Oct 21 '17 11:10 Jason420Git

rs2::frameset provides several ways of getting a specific frame from it.

  1. Iterating over it and querying the type of stream per frame.
rs2::frameset frames = pipe.wait_for_frames();
for(auto&& f : frames)
{
    if(f.get_profile().stream_type() == RS2_STREAM_INFRARED)
    {
        \\f is an infrared frame
    }
}
  1. Using the rs2::frameset::first(rs_stream s) method: https://github.com/IntelRealSense/librealsense/blob/67cdafef0c79554cd0c482d188f76feffd1bd9e2/include/librealsense2/hpp/rs_frame.hpp#L483 For example:
rs2::frameset frames = pipe.wait_for_frames();
rs2::frame ir_frame = frames.first(RS2_STREAM_INFRARED);

I will make sure we add this usages to our documentation and/or example code (if it is indeed missing)

zivsha avatar Oct 21 '17 19:10 zivsha

Thank you. The .first is what I was missing.

Jason420Git avatar Oct 23 '17 16:10 Jason420Git

FYI, the Wiki contains an example for this use case: wait-for-coherent-set-of-frames

zivsha avatar Oct 24 '17 08:10 zivsha