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

C# .NET Problem loading json files #5117

Closed
ThunderChild-001 opened this issue Oct 24, 2019 · 8 comments
Closed

C# .NET Problem loading json files #5117

ThunderChild-001 opened this issue Oct 24, 2019 · 8 comments

Comments

@ThunderChild-001
Copy link

Required Info
Camera Model { D400 }
Firmware Version 05.11.15.00
Operating System & Version {Win 10
SDK Version { 2.29 }
Language {C# }

Issue Description

On loading a json file a System.Exception occurs. This appears to be the case both for json files downloaded and those created through Realsense viewer.

The full error is:

hr returned: HResult 0x8007001f: "A device connected to the system does not work."
rs2_load_json(dev:07BDB9F8, json_content:11B39ED0, content_size:3595)'

Issues with loading json files in .Net were reported back in Dec 2018 in #2854.
This job was closed as fixed?

Is a simple way of changing the advanced settings available in .Net yet? This is really needed.

Many thanks,
Karl

@ThunderChild-001
Copy link
Author

The code being used is as follows:

var adv = AdvancedDevice.FromDevice(pp.Device);
string path = System.IO.Directory.GetCurrentDirectory();
string full = System.IO.Path.Combine(path, "default.json");
adv.JsonConfiguration = System.IO.File.ReadAllText(full);

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Oct 24, 2019

The C# wrapper still does not have access to the Advanced Mode instructions, as far as I know.

A C# code example for loading a json file can be found here:

#2854 (comment)

In the case of this example, the filename '1.json' refers to the "Default" visual preset json. Substitute in your own json file-name if you are using your own choice of json other than Default.

The easiest way to create your own json file is to define settings in the RealSense Viewer and then export them as a json using an icon on the toolbar at the top of the Viewer's options side-panel.

@ThunderChild-001
Copy link
Author

I would like a response from Intel regarding this. The problem of loading these files was reported over a year ago. Accessing the advanced features of the camera is necessary for professional applications.

@MartyG-RealSense
Copy link
Collaborator

MartyG-RealSense commented Oct 24, 2019

I had some recollection of this subject being discussed earlier this year on the Intel Support forum and dug out the link. An Intel RealSense support team member advised accessing Advanced Mode in C# via a C# wrapper script called NativeMethods.cs

https://support.intelrealsense.com/hc/en-us/community/posts/360033065534-How-to-retrieve-advanced-mode-options-in-C-

@ThunderChild-001
Copy link
Author

I would rather investigate and fix the problem with the above code than search for a workaround at the moment. It could well be that the workaround suffers from the same problem. The following code should work:

var adv = AdvancedDevice.FromDevice(pp.Device);
string path = System.IO.Directory.GetCurrentDirectory();
string full = System.IO.Path.Combine(path, "HighResHighDensityPreset.json");
adv.JsonConfiguration = System.IO.File.ReadAllText(full);

Indeed I tried this in one of the sample projects and it works there. In my project however I get the following error message:

System.Exception: 'hr returned: HResult 0x8007001f: "A device connected to the system does not work." rs2_load_json(dev:084AA598, json_content:1101ABC0, content_size:3595)'

My project is naturally more complex as I need to be able to start / stop capture without memory leaks as well as analyse images etc. It carries things out in much the same way however in the same order. Understanding the above error message, why, where and how it happens would help.

@RealSenseCustomerSupport
Copy link
Collaborator


Hi @KarlAbson,

A simple C# app with json file loading has no the issue. Do you have any librealsense log there when you run your app with this loading exception issue?
Will also further discuss internally to have a simple way to configure the advanced parameters directly in C#.

@ThunderChild-001
Copy link
Author

Hi @RealSenseCustomerSupport,

Thanks for the reply. I managed to fix this. The problem was related to the following case:
C# Wrapper - samples crash on launch

Simply there are a number of issues with the C# wrapper. The dlls are named wrong. He cannot find the realsense2.dll as it is now called realsense2d.dll. Also the C# projects are set to AnyPC by default. There are no mention of these things in the read me so it took time to identify the problem.

@MartyG-RealSense
Copy link
Collaborator

Adding a note that I am now the Intel RealSense team member handling this case.

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

4 participants