How to use Python to increase exposure and enable transmitters
-
Before opening a new issue, we wanted to provide you with some useful suggestions (Click "Preview" above for a better view):
- Consider checking out SDK examples.
- Have you looked in our documentations?
- Is you question a frequently asked one?
- Try searching our GitHub Issues (open and closed) for a similar issue.
-
All users are welcomed to report bugs, ask questions, suggest or request enhancements and generally feel free to open new issue, even if they haven't followed any of the suggestions above :)
| Required Info | |
|---|---|
| Camera Model | { D435 } |
| Firmware Version | (Open RealSense Viewer --> Click info) |
| Operating System & Version | { Linux (Ubuntu16) |
| Kernel Version (Linux Only) | (e.g. 4.14.13) |
| Platform | PC |
| SDK Version | { legacy / 2.<16>.<1> } |
| Language | {python } |
| Segment | {Robot } |
Issue Description
我现在的程序是使用python编写的,我的程序可以调用realsense D435相机 进行拍照,利用opencv形成照片,我现在的照片发现精度不高 经常取深度值为0米,我现在和Windows的SDK进行对比发现照片不一样,我想着在我程序中添加曝光度和发射器。我自己的编写的程序拍的照片大部分是蓝色。想要到达Windows的SDK形成的照片一样有红黄蓝。 我现在的程序是使用python编写的,我的程序可以调用realsense D435相机 进行拍照,利用opencv形成照片,我现在的照片发现精度不高 经常取深度值为0米,我现在和Windows的SDK进行对比发现照片不一样,我想着在我程序中添加曝光度和发射器。我自己的编写的程序拍的照片大部分是蓝色。想要到达Windows的SDK形成的照片一样有红黄蓝。 My current program is written using python, my program can call the realsense D435 camera to take photos, using OpenCV to form photos, I now find that the accuracy of photos is not high, often take a depth of 0 meters, I now compare with Windows SDK and find that photos are different, I want to add exposure and transmitter in my program. Most of the photos taken by my own program are blue. The SDK images that you want to get to Windows have the same red, yellow and blue color.
Are you able to post some pictures you captured? Or some code segments?
Also, if there are many spots in the depth images with 0 meter depths, you can try using the hole filling filter.
@HippoEug
import pyrealsense2 as rs import numpy as np import cv2 pipeline = rs.pipeline() config = rs.config() config.enable_stream(rs.stream.depth, 1280, 720, rs.format.z16, 30) config.enable_stream(rs.stream.color, 640, 480, rs.format.bgr8, 30) profile = pipeline.start(config) align_to = rs.stream.color align = rs.align(align_to) try: while True:
frames = pipeline.wait_for_frames()
aligned_frames = align.process(frames)
aligned_depth_frame = aligned_frames.get_depth_frame() # aligned_depth_frame is a 640x480 depth image
color_frame = aligned_frames.get_color_frame()
if not aligned_depth_frame or not color_frame:
continue
depth_image = np.asanyarray(aligned_depth_frame.get_data())
depth = depth_image.astype(float)
depth_scale = profile.get_device().first_depth_sensor().get_depth_scale()
depth = depth * depth_scale
print(len(depth))
print(depth[320,240])
color_image = np.asanyarray(color_frame.get_data())
cv2.circle(color_image, (320,240),3,(0,0,255),5)
cv2.putText(color_image, str(depth[320,240])+'m', (330,230), cv2.FONT_HERSHEY_TRIPLEX, 0.5, (0, 0, 255), 1,False)
depth_colormap = cv2.applyColorMap(cv2.convertScaleAbs(depth_image, alpha=0.03), cv2.COLORMAP_JET)
images = np.hstack((color_image, depth_colormap))
cv2.imwrite('/home/zx/Pictures/rgb/rgb' + ".png",color_image)
cv2.imwrite('/home/zx/Pictures/depth/depth'+ ".png", depth_colormap)
cv2.namedWindow('Align Example', cv2.WINDOW_AUTOSIZE)
cv2.imshow('Align Example', images)
cv2.waitKey(1)
finally: pipeline.stop()
[Realsense Customer Engineering Team Comment] @chaojizhangdaxin
If you need more colors just like Windows SDK, please refer to below code snippet in colorizer.cpp. https://github.com/IntelRealSense/librealsense/blob/master/src/proc/colorizer.cpp#L204-L237
About how to set the exposure and emitter status, please refer to below code snippet.
ctx = rs.context() devices = ctx.query_devices() for dev in devices: sensors = dev.query_sensors() for sensor in sensors: if sensor.is_depth_sensor(): exp = sensor.get_option(rs.option.exposure) # Get exposure gn = sensor.get_option(rs.option.gain) # Get gain emit = sensor.get_option(rs.option.emitter_enabled) # Get emitter status sensor.set_option(rs.option.exposure, 8400.0) # Example to set exposure as 8400.0 sensor.set_option(rs.option.gain, 19.0) # Example to set gain as 19.0 sensor.set_option(rs.option.emitter_enabled, 0) # Example to disable emitter
[Realsense Customer Engineering Team Comment] @Chaojizhangdaxin Any other questions about this ticket? Please update. Thanks!
[Realsense Customer Engineering Team Comment] @chaojizhangdaxin Didn't get update yet. Close this ticket. If you still have question, please create a new one or re-open it. Thanks!
Hi !
I want to use also exposure parameters and I got an unexpected error : This option is read-only!
Below my python code :

By the way, do you know others methods to denoise the 3D pointCloud ? I tested with post-process filter, laser power, and build filters as low-pass, median filter and gaussian filter. However, the pointcloud remains noisy as you can see :

The main problem is the differents hole in the depth map and using the spatial.hole filling filter add to much information.. I applied differents filters to reduce high frequencies responsible to noise. I think I have to find the best exposure according to this document written by Anders Grunnet : https://dev.intelrealsense.com/docs/tuning-depth-cameras-for-best-performance
I also had a look on IA for denoise but I prefer not to do that ^^