Items with no label
3335 Discussions

How to enable/disable emitter through python wrapper pyrealsense2?

NCacc
Beginner
6,207 Views

Hi, I would like to disable the emitter in order to retrieve clean IR data. By far I was only able to find this:

 

https://github.com/IntelRealSense/librealsense/blob/master/wrappers/python/examples/box_dimensioner_multicam/realsense_device_manager.py

 

and several examples in c++ but I still can't find a solution

0 Kudos
6 Replies
MartyG
Honored Contributor III
4,686 Views

I do not know of a Python version of code to toggle the emitter, but there is Python code to control the laser power. As the visibility of the IR pattern reduces as the Laser Power setting is reduced, setting laser power to '0' should have the same effect as turning it off.

 

https://github.com/IntelRealSense/librealsense/issues/1258?language=en_US

0 Kudos
NCacc
Beginner
4,685 Views

thank you, I already saw that post and I managed to modify it to find a workaround for what i needed:

import pyrealsense2 as rs pipeline = rs.pipeline() config = rs.config() pipeline_profile = pipeline.start(config) device = pipeline_profile.get_device() depth_sensor = device.query_sensors()[0] emitter = depth_sensor.get_option(rs.option.emitter_enabled) print("emitter = ", emitter) set_emitter = 0 depth_sensor.set_option(rs.option.emitter_enabled, set_emitter) emitter1 = depth_sensor.get_option(rs.option.emitter_enabled) print("new emitter = ", emitter1)

Hope this can be useful for other users!^^

0 Kudos
Shabnam
Beginner
3,887 Views

Thank you so much.

The script works well for D435i but I get the below error for SR300.

line 8, in <module>
emitter = depth_sensor.get_option(rs.option.emitter_enabled)
RuntimeError: object doesn't support option #18

How can I fix it? Does this script even work for SR300?

0 Kudos
MartyG
Honored Contributor III
4,685 Views

Thanks so much for sharing your script with the community! :)

0 Kudos
GBene1
Novice
4,685 Views

This was a big help, thank you.

So what would be the addition for turning on both IR projectors for a d435?

0 Kudos
MartyG
Honored Contributor III
4,686 Views

The 400 Series USB cameras only have one IR emitter (the IR emitter is not the same as the two IR imager components). The purpose of the emitter is to project a semi-random pattern of dots onto the scene observed by the camera to aid analysis of the depth of surfaces in the scene. If the location is well lit though then the emitter does not need to be enabled, as the cameras can alternatively use ambient light to analyse surface depth instead.

 

In case what you meant to ask was to how to turn on both the left and right IR streams, the link below has a script for doing so. Use the script under the 'Librealsense2' heading.

 

https://github.com/IntelRealSense/librealsense/wiki/API-How-To#start-streaming-left-and-right-infrared-imagers

 

I am off-shift now but if you require further help, please leave a comment below and I will be happy to help when I am back in 7 hours from the time of writing this. Good luck!

0 Kudos
Reply