How to align color and depth frames using C API? #12320
-
Hello, I'm trying to read color and depth frames and align them to the color frame, but using C bindings. All I could find related to aligning was If anyone could explain how to implement a very simple align example like the C++ one I would be very grateful. Also, I would like to know how to do this with Rust as well, as our project is using Rust Thank you |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments
-
Hi @junyoung-lee-1201 There is a C-language example of alignment with rs2_create_align() at the link below under the heading Using C API. https://dev.intelrealsense.com/docs/projection-in-intel-realsense-sdk-20#frame-alignment There is lttle information available regarding using RealSense with Rust, though the RealSense Rust wrapper realsense_sys apparently also uses the C rs2_create_align instruction to perform alignment. https://docs.rs/realsense-sys/latest/realsense_sys/ https://docs.rs/realsense-sys/latest/realsense_sys/fn.rs2_create_align.html |
Beta Was this translation helpful? Give feedback.
-
I ended up downgrading realsense-rust crate to 0.5.1. Here's how to align a composite frame. let frames = pipeline.wait(None).unwrap().unwrap();
let mut align = Align::create(StreamKind::Color).unwrap();
let frames = align
.process(frames)
.unwrap()
.try_extend_to::<Composite>()
.unwrap()
.unwrap();
// These two frames should be aligned.
let color_frame = frames.color_frame().unwrap().unwrap();
let depth_frame = frames.depth_frame().unwrap().unwrap(); |
Beta Was this translation helpful? Give feedback.
-
It's great to hear that you achieved a solution. Thanks so much for sharing your code! |
Beta Was this translation helpful? Give feedback.
Hi @junyoung-lee-1201 There is a C-language example of alignment with rs2_create_align() at the link below under the heading Using C API.
https://dev.intelrealsense.com/docs/projection-in-intel-realsense-sdk-20#frame-alignment
There is lttle information available regarding using RealSense with Rust, though the RealSense Rust wrapper realsense_sys apparently also uses the C rs2_create_align instruction to perform alignment.
https://docs.rs/realsense-sys/latest/realsense_sys/
https://docs.rs/realsense-sys/latest/realsense_sys/fn.rs2_create_align.html