-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
pyRealSense: Load JSON preset and record to file #10184
Comments
Hi @danfleck #8868 (comment) may be a helpful Python json loading reference to compare to your own code. |
Thanks Marty. I'm not having problems reading the JSON file but I tried the different code you linked in to make sure and it didn't make a difference. If I remove the line: Do you have an example that reads a JSON config file and enables recording to a file? That is where the problem is I think. Thanks for your help! |
May I confirm that you are placing the rs_config.enable_record_to_file instruction on the line before the pipe start instruction and not after the pipe start, please? |
Yes. My code looks like this:
|
Does it work if you specify a filename to record to instead of using the filename string. For example:
|
No, I tried it and get the same error. I am using it successfully without loading the JSON presets now, so I think everything is working correctly (no null filename). However, the camera settings aren't great because the JSON file isn't loaded. |
It may be worth exporting a json from the RealSense Viewer and loading the filename into your script. I suggest this because if you are testing with the ShortRangePreset.json file from the 400 Series visual presets page, I have had errors with loading downloaded json links from that page into the RealSense Viewer recently. You could see whether your test json file is okay by attempting to load it into the Viewer with the json load option near the top of the Viewer side-panel (adjacent to the json drop-down selector menu) and see whether it can be loaded into the Viewer successfully. |
Here is a simplified (mostly) example of the problem. If you comment out either
it works. Otherwise, it fails with the error. (Change the extension back to .py) |
Sorry, you don't need my rs_utils import either. Here is a version with that commented out |
I actually can't load any JSON presets into Realsense-viewer actually because of a different problem. I'm on a Mac and all the files are grayed out when using the file chooser from realsense-viewer. I can navigate directories, but I can't load any files because I can't select them. (This is a problem for a different problem report though. The JSON seems to load fine in my code as long as the enable_write_to_file is commented out.) |
Another approach to setting a json would be to load one of the pre-defined RealSense presets that are built into the SDK, such as 'High Accuracy'. These can be loaded using a different method to the procedure that loads a custom-defined json, so this might allow a json and record_to_file to co-exist in your script at the same time. A Python script for this is at #2577 (comment) |
Thanks Marty. That does work I can set it using the other approach with built-in presets. It still seems like a bug though that I can't load the JSON presets file. Were you able to confirm that with the code I posted? I'll try and use the other presets but the short range JSON file seemed to be the best for my application. |
I am not able to test code myself but it is not the first case over the years in which I have seen such conflicts. I would recommend the Medium Density preset for a wide range of applications, as it provides a good balance between accuracy and the amount of detail on the image, whereas High Accuracy tends to over-strip the image of detail and leave it looking sparse. |
Thanks Marty! The only preset names I see are: |
Medium Density is one of the built-in presets. My understanding is that the presets are enumerated in the SDK in the order that they are displayed in the RealSense Viewer's preset list, so as Medium Density is the 6th in the list, it may be '05' Interestingly, the SDK's support for presets in the C# language describes the 'Default' preset (1) as 'ShortRange' instead, so it may be worth trying 'Default' to see whether it provides similar characteristics to ShortRangePreset.json. It also lists Medium Density as being setting 5.
|
Hi @danfleck Do you require further assistance with this case, please? Thanks! |
The workaround you suggested is working for now, but I was hoping someone at Intel could confirm the bug and make a determination if it was something that was actually going to be fixed. I still can't use the JSON file while recording to a file. If it's not going to be fixed though let me know and I can just close it. Thanks for your help! |
In my opinion it is unlikely that this particular issue will be investigated by Intel for the possibility of a bug fix. |
Issue Description
When using pyRealSense to try and load JSON presets and record, I receive an error:
RuntimeError: null pointer passed for argument "dev"
This occurs when trying to load the JSON using code similar to the DeviceManager code. This code:
This issue seems very similar to: #6739 except I'm using python instead of C++.
If I comment out the line:
rs_config.enable_record_to_file(filename)
everything works fine.
If I comment out the
advanced_mode.load_json(json_text)
call above, it also works fine. With both the load_json and the enable_record_to_file the error appears. I'm trying to load ShortRangePreset.json if that helps.The text was updated successfully, but these errors were encountered: