How to obtain a white balance value in a Frame metadata of D405
Hello
I'm trying to extract the color temperature for white balance from the D405. It appears to be stored in the frame metadata. Even when I specify the color stream using the code below, the color temperature doesn't seem to be included, but I don't know how to specify the color sensor instead.
import pyrealsense2 as rs
import time
ctx = rs.context()
devices = ctx.query_devices()
dev = devices[0]
# sensor = dev.first_color_sensor()
sensor = dev.first_depth_sensor()
sensor.set_option(rs.option.enable_auto_white_balance, 1)
pipeline = rs.pipeline()
config = rs.config()
config.enable_stream(rs.stream.color)
config.enable_stream(rs.stream.depth)
pipeline.start(config)
for i in range(20):
frames = pipeline.wait_for_frames()
frm = frames.get_depth_frame()
frmc = frames.get_color_frame()
metac = None
if frmc.supports_frame_metadata(rs.frame_metadata_value.white_balance):
metac = frmc.get_frame_metadata(rs.frame_metadata_value.white_balance)
print(f"frame#={fn} actual_frame={metaf} actual_exposure={metae} actual_col_temp={metac}")
time.sleep(1.0) # 反映待ち
pipeline.stop()
-
Hi Taku Osada The D405 camera model does not have a dedicated RGB color sensor and obtains its RGB from the depth sensor. So when accessing color stream settings, the above approach you have used of accessing the depth sensor is the correct one.
Is the color white-balance metadata provided if you comment out the if frmc.supports_frame_metadata line, please?
-
Thank you for your comment.
When I comment out the "if frmc.supports_frame_metadata" line, on next line,
it put out RuntimeError: Color frame does not support metadata "White Balance".
Although, I want to use D405 on Ubuntu 24.04 (Raspberry pi 4),
when I use RealsenseViewer on windows, color temperature is appeared in frame-metadata overlay.
-
On a Linux-based operating system, support for some types of metadata parameters known as 'hardware metadata' needs to be enabled when installing the SDK.
If librealsense is installed with the force_libuvc= true or the force_rsusb_backend=true flag included in the CMake build instruction then hardware metadata support is included in the SDK build. If these parameters are not included then a patch script needs to be applied to the kernel.
The most reliable way to achieve a successful installation of librealsense on Raspberry Pi is to build with CMake with -DFORCE_LIBUVC=TRUE included in the CMake build command. Do you use this parameter when installing on Pi, please?
On Windows, metadata support is enabled much more easily by clicking a button on a pop-up message in the top corner of the RealSense Viewer window that appears when the Viewer is launched.
-
Hi Taku Osada Do you require further assistance with this case, please? Thanks!
-
I tried force_rsusb_backend=true mode, actually I use following cmake options
cmake .. -DBUILD_PYTHON_BINDINGS=true \
-DPYTHON_EXECUTABLE=$(which python3) \
-DFORCE_RSUSB_BACKEND=true \
-DBUILD_EXAMPLES=false \
-DBUILD_GRAPHICAL_EXAMPLES=false \
-DBUILD_TOOLS=falseAnd I can read the actual_exposure value from depth frame. And I can set color temperature in the a manual white balance mode, but I can't read it neither auto nor manual white balance mode.I understood the limitation about frame meta-data on D405 camera. I think I could get the enough information I want to get. Thank you for your advice.
Please sign in to leave a comment.
Comments
6 comments