文章目录
获取当前color sensor支持的参数
# -*- coding: utf-8 -*-
"""
@File : 200109_获取受支持的参数.py
@Time : 2020/1/9 8:59
@Author : Dontla
@Email : [email protected]
@Software: PyCharm
"""
import time
import numpy as np
import pyrealsense2 as rs
import cv2
ctx = rs.context()
pipeline = rs.pipeline(ctx)
cfg = rs.config()
cfg.enable_device('838212073161')
cfg.enable_stream(rs.stream.depth, 640, 360, rs.format.z16, 30)
cfg.enable_stream(rs.stream.color, 640, 360, rs.format.bgr8, 30)
pipeline_profile = pipeline.start(cfg)
# [0]是获取depth_sesor,[1]是获取color_sensor
sensor = pipeline.get_active_profile().get_device().query_sensors()[1]
print(sensor.get_supported_options())
结果:
[option.backlight_compensation, option.brightness, option.contrast, option.exposure, option.gain, option.gamma, option.hue, option.saturation, option.sharpness, option.white_balance, option.enable_auto_exposure, option.enable_auto_white_balance, option.frames_queue_size, option.power_line_frequency, option.auto_exposure_priority, option.global_time_enabled]
获取当前depth sensor支持的参数
代码同上,除下句之外
sensor = pipeline.get_active_profile().get_device().query_sensors()[0]
[option.exposure, option.gain, option.enable_auto_exposure, option.visual_preset, option.laser_power, option.emitter_enabled, option.frames_queue_size, option.asic_temperature, option.error_polling_enabled, option.projector_temperature, option.output_trigger_enabled, option.depth_units, option.stereo_baseline, option.inter_cam_sync_mode, option.emitter_on_off, option.global_time_enabled]
获取color_sensor和depth_sensor各自不同的参数
写了个简单的代码,获取color_sensor和depth_sensor各自不同的参数:
color_frame_options = ['option.backlight_compensation',
'option.brightness',
'option.contrast',
'option.exposure',
'option.gain',
'option.gamma',
'option.hue',
'option.saturation,'
'option.sharpness',
'option.white_balance',
'option.enable_auto_exposure',
'option.enable_auto_white_balance',
'option.frames_queue_size',
'option.power_line_frequency',
'option.auto_exposure_priority',
'option.global_time_enabled']
depth_frame_options = ['option.exposure',
'option.gain', 'option.enable_auto_exposure', 'option.visual_preset', 'option.laser_power',
'option.emitter_enabled', 'option.frames_queue_size', 'option.asic_temperature',
'option.error_polling_enabled', 'option.projector_temperature', 'option.output_trigger_enabled',
'option.depth_units', 'option.stereo_baseline', 'option.inter_cam_sync_mode',
'option.emitter_on_off', 'option.global_time_enabled']
color_different_options = []
depth_different_options = []
for i in color_frame_options:
flag = False
for j in depth_frame_options:
if i == j:
flag = True
break
if not flag:
color_different_options.append(i)
for i in depth_frame_options:
flag = False
for j in color_frame_options:
if i == j:
flag = True
break
if not flag:
depth_different_options.append(i)
print(color_different_options)
print(depth_different_options)
结果:
color_different_options:[‘option.backlight_compensation’, ‘option.brightness’, ‘option.contrast’, ‘option.gamma’, ‘option.hue’, ‘option.saturation,option.sharpness’, ‘option.white_balance’, ‘option.enable_auto_white_balance’, ‘option.power_line_frequency’, ‘option.auto_exposure_priority’]
depth_different_options:[‘option.visual_preset’, ‘option.laser_power’, ‘option.emitter_enabled’, ‘option.asic_temperature’, ‘option.error_polling_enabled’, ‘option.projector_temperature’, ‘option.output_trigger_enabled’, ‘option.depth_units’, ‘option.stereo_baseline’, ‘option.inter_cam_sync_mode’, ‘option.emitter_on_off’]
获取color_sensor和depth_sensor相同的参数
color_frame_options = ['option.backlight_compensation',
'option.brightness',
'option.contrast',
'option.exposure',
'option.gain',
'option.gamma',
'option.hue',
'option.saturation,'
'option.sharpness',
'option.white_balance',
'option.enable_auto_exposure',
'option.enable_auto_white_balance',
'option.frames_queue_size',
'option.power_line_frequency',
'option.auto_exposure_priority',
'option.global_time_enabled']
depth_frame_options = ['option.exposure',
'option.gain', 'option.enable_auto_exposure', 'option.visual_preset', 'option.laser_power',
'option.emitter_enabled', 'option.frames_queue_size', 'option.asic_temperature',
'option.error_polling_enabled', 'option.projector_temperature', 'option.output_trigger_enabled',
'option.depth_units', 'option.stereo_baseline', 'option.inter_cam_sync_mode',
'option.emitter_on_off', 'option.global_time_enabled']
equal_options = []
for i in color_frame_options:
for j in depth_frame_options:
if i == j:
equal_options.append(i)
print('equal_options:{}'.format(equal_options))
# equal_options:['option.exposure', 'option.gain', 'option.enable_auto_exposure', 'option.frames_queue_size', 'option.global_time_enabled']
结果:
equal_options:[‘option.exposure’, ‘option.gain’, ‘option.enable_auto_exposure’, ‘option.frames_queue_size’, ‘option.global_time_enabled’]