Items with no label
3335 Discussions

How to convert cv::Mat to rs2::frame ?

yliu54
Beginner
2,068 Views

hello,

I have already seen this question in this community but didn't get the answer I want.

 

In rs_align, I have converted the rs2:: frame to cv:: Mat for using the joint bilateral filter provided by OpenCV to improve the quality of the depth map. The depth map of the processed mat type that is obtained cannot be used to call remove_background().

So,I just want to know how to convert cv:: Mat to rs2:: frame. If you can help me, I would be very grateful.

Thank you!

0 Kudos
5 Replies
MartyG
Honored Contributor III
954 Views

Intel support team member Eliza has stated on a past reply to this question in September 2018, "The memory in rs2::frame may be reused by librealsense/UVC. Converting from cv::Mat to rs2::frame (copy pixel array to a object of rs2::frame) is not a good idea. Note that when the camera captures images, the uvcvideo driver writes the frame information into the rs2::frame".

0 Kudos
yliu54
Beginner
954 Views

Thank you for your reply!

But in order to use cv::ximgproc:: jointBilateralFilter,I have converted rs2::frame to cv:: mat.I just want to transform the destination filtered depth map(rs:: mat) to rs:: frame for using the remove_background().

0 Kudos
MartyG
Honored Contributor III
954 Views

I do not know how to do such a conversion, unfortunately. Hopefully one of the Intel support team on this forum can provide some advice on this. Good luck!

0 Kudos
yliu54
Beginner
954 Views

Anyway, thank you for your attention!

0 Kudos
idata
Employee
954 Views

Hello Yu523,

 

 

I see your question has been answered here: https://github.com/IntelRealSense/librealsense/issues/2634.

 

 

Regards,

 

Jesus

 

Intel Customer Support
0 Kudos
Reply