Accessing infrared stream
| 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.
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.
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.
rs2::frameset provides several ways of getting a specific frame from it.
- 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
}
}
- 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)
Thank you. The .first is what I was missing.
FYI, the Wiki contains an example for this use case: wait-for-coherent-set-of-frames