Items with no label
3335 Discussions

Where is the source code for the alignment function in RealSense SDK2.0?

idata
Employee
1,598 Views

Hello,

I am trying to figure out where the source code (C++) is for the alignment function in RealSense SDK2.0 and wonder if someone can give me an advice.

Specifically, I wrote codes for aligning a depth frame to the corresponding color frame as follows:

rs2::frameset frames = pipe.wait_for_frames();

rs2::align align(rs2_stream::RS2_STREAM_COLOR);

rs2::frameset aligned_frames = align.process(frames);

rs2::frame color_frame = frames.get_color_frame();

rs2::frame depth_frame = aligned_frames.get_depth_frame();

I'd like to see source codes for checking how the alignment is accomplished. I found the following codes in "rs_processing.hpp" but I do not see any code for actual calculations for the alignment.

class align

{

public:

.....

}

Also, I've found that "align.cpp" has the "void align_images()" function but I am not sure if this is the same as the alignment function above.

Where can I find the source code for the alignment function?

Regards,

0 Kudos
7 Replies
MartyG
Honored Contributor III
658 Views

There is also a file in the source code called align.h in the src/proc folder.

https://github.com/IntelRealSense/librealsense/blob/093186bfaaf89a3bd140fc943daf46cd5a6eadc3/src/proc/align.h librealsense/align.h at 093186bfaaf89a3bd140fc943daf46cd5a6eadc3 · IntelRealSense/librealsense · GitHub

0 Kudos
idata
Employee
658 Views

Hi MartyG,

Thanks for letting me know align.h

It seems to me that the critical part of alignment is the following code in align.cpp:

frameset process(frameset frame)

{

(*_block)(frame);

rs2::frame f;

_queue.poll_for_frame(&f);

return frameset(f);

}

Nonetheless, from here, I cannot figure out how to get to the source code for actual calculations for the alignment. Is the source code available or hidden?

Regards,

0 Kudos
MartyG
Honored Contributor III
658 Views

SDK 2.0 is fully open source, so it is unlikely there are hidden parts. They may just be very difficult to find. I went through the source code carefully and all roads of the investigation seemed to lead back to rs_processing.hpp, the file you'd already found.

This documentation page has an outline explanation of how Align is processed, and may give you some new leads to follow.

https://unanancyowen.github.io/librealsense2_apireference/classrs2_1_1align.html Intel® RealSense™ Cross Platform API: rs2::align Class Reference

0 Kudos
idata
Employee
658 Views

Thanks MartyG. I sent an email to the guy who created the website about the alignment function.

Best regards,

0 Kudos
MartyG
Honored Contributor III
658 Views

If you mean UnaNancyOwen, their documentation site draws its contents directly from the official documentation and arranges it in a more user-friendly interface. Having said that, UnaNancyOwen is a very skilled developer, having created a set of sample programs for using SDK 2.0 camera functions such as depth and align with OpenCV. So maybe they can give you some useful insight.

0 Kudos
idata
Employee
658 Views

MartyG,

Yes, I meant UnaNancyOwen. He was quick in replying to my email. He said the alignment function is written in align.cpp. I will take a closer look.

In any case, thanks always for giving me helpful advices.

Best Regards,

0 Kudos
MartyG
Honored Contributor III
658 Views

You are very welcome. It's great that UnaNancyOwen replied so fast. Have a great day!

0 Kudos
Reply