IntelRealSense / librealsense

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

ImportError: generic_type: type "option" is already registered! #1874

Closed chencheng1560 closed 6 years ago

chencheng1560 commented 6 years ago
Required Info
Camera Model { R200 / F200 / SR300 / ZR300 / D400 }
Firmware Version (Open RealSense Viewer)
Operating System & Version { Ubuntu 16.04)
Kernel Version (Linux Only) (e.g. 4.4.0.127)
Platform PC
SDK Version { legacy / 2.12 }
Language { python }

Issue Description

I am using python wrapper provided by librealsense to control camera. There are two requirement: 1 take color/depth picture. 2 provide an api interface to control the brightness, contrast of the camera. So I "import pyrealsense2" to take color picture, and "import pybackend2" to control the brightness.

However, if this two modules import in one python file, ERR "ImportError: generic_type: type "option" is already registered!" happened.

May I know how can I solve this problem? Or is there any other method how can I meet the two requirement by python. Thanks

dorodnic commented 6 years ago

Hi @chencheng1560 You can get the same result with pyrealsense2 only, I would strongly advise against using pybackend2.

chencheng1560 commented 6 years ago

Hi @dorodnic Thanks for your suggestion.

I use pyrealsense2 to implement the function to control the brightness.

I paste the code I use here, hope it can help someone who has the same requirement.

# Create a pipeline
pipeline = rs.pipeline()

#Create a config and configure the pipeline to stream
config = rs.config()

# Start streaming
profile = pipeline.start(config)
# Getting the depth sensor's depth scale (see rs-align example for explanation)
dev = profile.get_device()
##pipeline.stop()

for i in range(len(dev.sensors)):
    if dev.sensors[i].is_depth_sensor() == False :
        sens=dev.sensors[i]
        break
print sens.get_option(rs.option.brightness)        
print sens.get_option(rs.option.contrast)        
print sens.get_option(rs.option.gain)        

pipeline.stop()
RealSense-Customer-Engineering commented 6 years ago

[Realsense Customer Engineering Team Comment] Hi @chencheng1560,

Thanks for your code shared. Will close this since your have resolved it. If any more concern, you still can re-open or create another ticket.