IntelRealSense / librealsense

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

Why are my RGB images displaying the wrong colors? #13546

Open wenmingxiaohuo opened 20 hours ago

wenmingxiaohuo commented 20 hours ago
Required Info
Camera Model { R200 / F200 / SR300 / ZR300 / D400 }
Firmware Version (Open RealSense Viewer --> Click info)
Operating System & Version {Win (8.1/10) / Linux (Ubuntu 14/16/17) / MacOS
Kernel Version (Linux Only) (e.g. 4.14.13)
Platform PC/Raspberry Pi/ NVIDIA Jetson / etc..
SDK Version { legacy / 2.<?>.<?> }
Language {C/C#/labview/nodejs/opencv/pcl/python/unity }
Segment {Robot/Smartphone/VR/AR/others }

Issue Description

<Describe your issue / question / feature request / etc..>

matlab

`function RGB_example() % Make Pipeline object to manage streaming

pipe = realsense.pipeline();
% Make Colorizer object to prettify depth output
% colorizer = realsense.colorizer();
% Start streaming on an arbitrary camera with default settings
profile = pipe.start(); %开启设备
device = profile.get_device();
device.hardware_reset();
% Get streaming device's name
dev = profile.get_device();
name = dev.get_info(realsense.camera_info.name);

% Get frames. We discard the first couple to allow
% the camera time to settle
for i = 1:5
    fs = pipe.wait_for_frames();
end

% Stop streaming
pipe.stop(); %关闭设备

% Select depth frame
RGB = fs.get_color_frame();
% Colorize depth frame
% color = colorizer.colorize(RGB);

% Get actual data and convert into a format imshow can use
% (Color data arrives as [R, G, B, R, G, B, ...] vector)
data = RGB.get_data();
% r=(reshape(data(1:3:end,1),RGB.get_width(),RGB.get_height()))';
% g=(reshape(data(2:3:end,1),RGB.get_width(),RGB.get_height()))';
% b=(reshape(data(3:3:end,1),RGB.get_width(),RGB.get_height()))';
% data=cat(3,r,g,b); %'3'表示延第三维度扩展,'1'表示延行扩展,'2'表示延列扩展
img = permute(reshape(data',[3,RGB.get_width(),RGB.get_height()]),[3 2 1]);

% Display image
imshow(img);
title(sprintf("Colorized depth frame from %s", name));

end` image

MartyG-RealSense commented 13 hours ago

Hi @wenmingxiaohuo It looks as though the problem is not with the RGB image's colors but rather that it has very low brightness. A workaround for increasing RGB brightness with RealSense MATLAB wrapper code by disabling auto-exposure and setting a high RGB manual exposure value can be found at https://github.com/IntelRealSense/librealsense/issues/7102#issuecomment-673623848`

If you are using the camera indoors, where the artificial lighting level will likely be consistent through the day, then it should be okay to have auto-exposure disabled and use a fixed exposure value.

If you need auto-exposure to be enabled then you could try directly maximizing the value of the RGB brightness option by replacing the last line of the script at the link above with the following line.

sensors{1}{2}.set_option(realsense.option.brightness,64);

The supported raneg of brightness values is -64 (lowest) to 64 (highest).