IntelRealSense / librealsense

Intel® RealSense™ SDK
https://www.intelrealsense.com/
Apache License 2.0
7.52k stars 4.81k forks source link

[Question] How to Downscale My Recorded Frames to a Different Resolution? #13180

Closed Guan9Wu closed 4 weeks ago

Guan9Wu commented 1 month ago
Required Info
Camera Model D415
Firmware Version 5.16.0.1
Operating System & Version Linux
Kernel Version (Linux Only) 6.9.10-zen1-1-zen
Platform PC
SDK Version 2.55.1

Issue Description

I have recorded a .bag file that includes a stream with a 1280x720 resolution for both color and depth frames. I now require the aligned frames to be at a 640x480 resolution, but the RealSense Viewer does not allow for resolution adjustment of recorded frames. Here's my proposed approach:

Extract the aligned frames at their original 1280x720 resolution. Subsequently, crop them to the desired 640x480 resolution. However, I am uncertain if the depth and color frames obtained through this method would be equivalent to those recorded directly at 640x480 resolution. If there are discrepancies, I would appreciate suggestions for alternative methods.

MartyG-RealSense commented 1 month ago

Hi @Guan9Wu If you are using the RealSense Viewer tool then the 1280x720 frames are already being downsampled. This is because a post-processing filter called the Decimation Filter is enabled by default in the Viewer. When a bag is imported into the Viewer and played back, the Decimation filter is applied to the bag data in real-time.

The default value of the filter is '2', so 1280x720 is downsampled by half to 640x360.

image

However, downsampling the resolution is not the same as cropping it by using a lower resolution directly. Below are images of 1280x720 downsampled to 640x360 (upper image) and 640x480 directly with the Decimation Filter disabled (lower image). You can see a significant reduction in the viewpoint size in the 640x480 image.

1280x720 downsampled

image

640x480 direct

image

It is possible to crop an image in code using a bounding box, though it is a complicated process. A RealSense user at https://github.com/IntelRealSense/librealsense/issues/2016#issuecomment-403804157 approached the problem by using a 'struct' to define minimum and maximum values for X and Y and then getting the point cloud points.

MartyG-RealSense commented 1 month ago

Hi @Guan9Wu Do you require further assistance with this case, please? Thanks!

MartyG-RealSense commented 4 weeks ago

Case closed due to no further comments received.