IntelRealSense / librealsense

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

Failed to run enable_device from_file #13474

Closed zerostarter1998 closed 3 weeks ago

zerostarter1998 commented 3 weeks ago

I was trying to load local config settings which are saved from DQT I wrote follow python code:

pipeline = rs.pipeline()
config = rs.config()
config.enable_device_from_file("../model/camerasettings.json")
pipeline = rs.pipeline()
pipeline.start(config)

Then i got:

RuntimeError: Failed to resolve request. Request to enable_device_from_file("../model/camerasettings.json") was invalid, Reason: Failed to create ros reader: Error opening file: ../model/camerasettings.json

MartyG-RealSense commented 3 weeks ago

Hi @zerostarter1998 json camera configuration files are usually exported from the realsense-viewer tool instead of the Depth Quality Tool (DQT). I am not aware of any RealSense users that have previously used a json exported from the DQT. Would it be possible to repeat your settings in realsense-viewer and export a json from there, please?

You can also test your script's json import by downloading an official RealSense SDK json from the table at the link below.

https://dev.intelrealsense.com/docs/d400-series-visual-presets#preset-table

zerostarter1998 commented 3 weeks ago

Thank you for your reply. I exported a json from realsense-viewer repeating the same settings. I checked the files and found the same content, so the problem is not on that. I downloaded a json from the mentioned link and tried to load it, leading to the same result. Anyway the problem is unsolved and for the record the code is running in Windows 11 system.

MartyG-RealSense commented 3 weeks ago

The problem may be that the config.enable_device_from_file() instruction is used for importing .bag files (recordings of camera data) and not json camera configuration files. For importing json files, the instruction json.load is used. https://github.com/IntelRealSense/librealsense/issues/6075#issuecomment-600087038 has an example of a Python script for importing a json with a specific filename.

The link below has another Python script that demonstrates use of json.load.

https://stackoverflow.com/questions/53520301/how-to-load-json-file-to-realsense-d435-camera-using-c-and-intel-api/53633791#53633791