Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Applying a preset in pyrealsense2 #2577

Closed
dibya-pati opened this issue Oct 22, 2018 · 6 comments
Closed

Applying a preset in pyrealsense2 #2577

dibya-pati opened this issue Oct 22, 2018 · 6 comments
Assignees

Comments

@dibya-pati
Copy link

dibya-pati commented Oct 22, 2018

Required Info
Camera Model D415
Firmware Version 05.09.13.00
Operating System & Version Win 10
Platform PC
SDK Version 05.09.13.00
Language python

Issue Description

I'm trying to apply a high accuracy preset while capturing depth using SDK, couldnt find any example for python. Would appreciate any lead

@RealSense-Customer-Engineering
Copy link
Collaborator

[Realsense Customer Engineering Team Comment]
Hi @dibya-pati,

Try below code to see how it works:

pipe_profile = pipeline.start(config)

depth_sensor = pipe_profile.get_device().first_depth_sensor()

preset_range = depth_sensor.get_option_range(rs.option.visual_preset)
_#print('preset range:'+str(preset_range))_
**for** i **in** range(int(preset_range.max)):
 visulpreset = depth_sensor.get_option_value_description(rs.option.visual_preset,i)
 print(**'%02d: %s'**%(i,visulpreset))
 **if** visulpreset == **"High Accuracy"**:
 depth_sensor.set_option(rs.option.visual_preset, i)

@dibya-pati
Copy link
Author

[Realsense Customer Engineering Team Comment]
Hi @dibya-pati,

Try below code to see how it works:

pipe_profile = pipeline.start(config)

depth_sensor = pipe_profile.get_device().first_depth_sensor()

preset_range = depth_sensor.get_option_range(rs.option.visual_preset)
_#print('preset range:'+str(preset_range))_
**for** i **in** range(int(preset_range.max)):
 visulpreset = depth_sensor.get_option_value_description(rs.option.visual_preset,i)
 print(**'%02d: %s'**%(i,visulpreset))
 **if** visulpreset == **"High Accuracy"**:
 depth_sensor.set_option(rs.option.visual_preset, i)

Thanks, this works

@lxop
Copy link

lxop commented Nov 28, 2022

Hi @RealSense-Customer-Engineering ,

Is there any intention to expose the preset symbols in the Python wrapper directly so that we can do something more like

depth_sensor.set_option(rs.option.visual_preset, rs.rs400_visual_preset.high_accuracy)

rather than looping through descriptions looking for a label just to set a preset? Or is this looping approach intended to be the way to apply a preset with the Python wrapper?

It seems like it would simply require one line in c_files.cpp to do this - is it being avoided intentionally? I'm happy to open a PR if that's all it requires.

Thank you,
Alex

@MartyG-RealSense
Copy link
Collaborator

Hi @dibya-pati You should be able to set the preset with a simple number value if you know which number relates to which preset on your particular camera (the 400 Series and L515 models have different presets). A Python example of this simplified code would be:

depth_sensor.set_option(rs.option.visual_preset , 3)

On 400 Series cameras, presets start at '0' and correspond to the order in which presets are listed in the RealSense Viewer. So if you open the Viewer's preset list and count 0, 1, 2, 3, then '3' would be the fourth preset in the list, which is 'High Accuracy'.

image

@lxop
Copy link

lxop commented Nov 29, 2022

Hi @MartyG-RealSense ,

Thanks for your reply; I understand that I can use a plain number like this, however it would be valuable to have these values exposed symbolically in the library, so I'm just wondering if they have been omitted intentionally or just haven't been done yet.

Thanks,
Alex

@YouJiacheng
Copy link

It seems that preset_range.max is inclusive, i.e. range(int(preset_range.min), int(preset_range.max) + 1, int(preset_range.step)).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

6 participants