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# D400 Series Visual Presets #2854

Closed
laolaolulu opened this issue Dec 6, 2018 · 18 comments
Closed

c# D400 Series Visual Presets #2854

laolaolulu opened this issue Dec 6, 2018 · 18 comments
Assignees
Labels

Comments

@laolaolulu
Copy link

.net C # How to load the default JSON file?

{
"aux-param-autoexposure-setpoint": "1536",
"aux-param-colorcorrection1": "0.298828",
"aux-param-colorcorrection10": "0",
"aux-param-colorcorrection11": "0",
"aux-param-colorcorrection12": "0",
"aux-param-colorcorrection2": "0.293945",
"aux-param-colorcorrection3": "0.293945",
"aux-param-colorcorrection4": "0.114258",
"aux-param-colorcorrection5": "0",
"aux-param-colorcorrection6": "0",
"aux-param-colorcorrection7": "0",
"aux-param-colorcorrection8": "0",
"aux-param-colorcorrection9": "0",
"aux-param-depthclampmax": "65536",
"aux-param-depthclampmin": "0",
"aux-param-disparityshift": "50",
"controls-autoexposure-auto": "True",
"controls-autoexposure-manual": "8500",
"controls-color-autoexposure-auto": "True",
"controls-color-autoexposure-manual": "156",
"controls-color-backlight-compensation": "0",
"controls-color-brightness": "0",
"controls-color-contrast": "50",
"controls-color-gain": "64",
"controls-color-gamma": "300",
"controls-color-hue": "0",
"controls-color-power-line-frequency": "3",
"controls-color-saturation": "64",
"controls-color-sharpness": "50",
"controls-color-white-balance-auto": "True",
"controls-color-white-balance-manual": "4600",
"controls-depth-gain": "16",
"controls-laserpower": "360",
"controls-laserstate": "on",
"ignoreSAD": "0",
"param-autoexposure-setpoint": "1536",
"param-censusenablereg-udiameter": "9",
"param-censusenablereg-vdiameter": "9",
"param-censususize": "9",
"param-censusvsize": "9",
"param-depthclampmax": "65536",
"param-depthclampmin": "0",
"param-depthunits": "100",
"param-disableraucolor": "0",
"param-disablesadcolor": "0",
"param-disablesadnormalize": "0",
"param-disablesloleftcolor": "0",
"param-disableslorightcolor": "0",
"param-disparitymode": "0",
"param-disparityshift": "50",
"param-lambdaad": "800",
"param-lambdacensus": "26",
"param-leftrightthreshold": "24",
"param-maxscorethreshb": "2047",
"param-medianthreshold": "500",
"param-minscorethresha": "1",
"param-neighborthresh": "7",
"param-raumine": "1",
"param-rauminn": "1",
"param-rauminnssum": "3",
"param-raumins": "1",
"param-rauminw": "1",
"param-rauminwesum": "3",
"param-regioncolorthresholdb": "0.0499022",
"param-regioncolorthresholdg": "0.0499022",
"param-regioncolorthresholdr": "0.0499022",
"param-regionshrinku": "3",
"param-regionshrinkv": "1",
"param-robbinsmonrodecrement": "10",
"param-robbinsmonroincrement": "10",
"param-rsmdiffthreshold": "4",
"param-rsmrauslodiffthreshold": "1",
"param-rsmremovethreshold": "0.375",
"param-scanlineedgetaub": "72",
"param-scanlineedgetaug": "72",
"param-scanlineedgetaur": "72",
"param-scanlinep1": "60",
"param-scanlinep1onediscon": "105",
"param-scanlinep1twodiscon": "70",
"param-scanlinep2": "342",
"param-scanlinep2onediscon": "190",
"param-scanlinep2twodiscon": "130",
"param-secondpeakdelta": "325",
"param-texturecountthresh": "0",
"param-texturedifferencethresh": "0",
"param-usersm": "1",
"param-zunits": "100",
"stream-depth-format": "Z16",
"stream-fps": "6",
"stream-height": "720",
"stream-width": "1280"
}

@dorodnic dorodnic added the .NET label Dec 6, 2018
@dorodnic
Copy link
Contributor

dorodnic commented Dec 6, 2018

Hi @laolaolulu

var pipeline = new Pipeline();
var profile = pipeline.Start();
var adv = AdvancedDevice.FromDevice(profile.Device);
adv.JsonConfiguration = File.ReadAllText("1.json");

@laolaolulu
Copy link
Author

The exception thrown: "System. AccessViolationException" (in OpenCvSharp. dll) Unhandled exceptions of the "System.AccessViolationException" type occur in OpenCvSharp.dll Attempt to read or write to protected memory. This usually indicates that other memory is corrupted.

tim 20181206181832
tim 20181206181713

@dorodnic
Copy link
Contributor

dorodnic commented Dec 6, 2018

I don't think this is related to the SDK. My best guess is that by switching from explicit Config (the commented out code) to the new code snippet, your app got a different resolution from before, resulting in over/under-flow in OpenCvSharp.dll. Can this be the case?

@laolaolulu
Copy link
Author

The program does nothing else, as long as it executes this (var adv = AdvancedDevice. FromDevice (profile. Device);) the code program exits immediately or throws System. AccessViolationException:" I couldn't find the PDB file of Intel. RealSense. dll.

tim 20181207093421

@laolaolulu
Copy link
Author

I've given up using JSON files. I need to set up Disparity Shift, Laser Power... How should c# be set? Sorry, realsense has too little information about. net.

@dorodnic

@laolaolulu
Copy link
Author

I found something unusual.
tim 20181207105040

@ThunderChild-001
Copy link

Hallo @dorodnic

I also discovered something similar to the above. It seems to be some setting in the json file which is causing an access violation exception randomly within the first 5 seconds of running the camera?

I just tried to load the HighDensityPreset via a Json file I created through the RealSense viewer. Everything runs fine for around 5 seconds and then you get an access violation. It seems to have more chance of happening if I'm dragging a movable button to get pixel values to use in a measurement.

This doesn't happen without the preset loaded. Some setting must be causing instability?

@dorodnic
Copy link
Contributor

Hi @KarlAbson
We will try to reproduce and look into that.

@ThunderChild-001
Copy link

Hi @dorodnic

That would be great! Thanks very much.
Would it help if I sent you the sample project?
It's not quite finished, could do with some improvement but I was going to send you the measuring project in C# anyway.

@RealSense-Customer-Engineering
Copy link
Collaborator

[Realsense Customer Engineering Team Comment]
Hi @KarlAbson, @laolaolulu,

I can reproduce the similar crash issue if a json file loaded.
By the way, which librealsense version do you use?

@ThunderChild-001
Copy link

Hi @RealSense-Customer-Engineering

Great. Thanks for looking into it. I'm using 2.16.5.

@amatabuena
Copy link

amatabuena commented Jan 10, 2019

Hi,

I can also reproduce the same issue. In my case with 2.17.0 librealsense version. When disposing device I also receive a System.AccessViolationException. If I don't dispose it, when I try to load a Json again I receive again a System.AccessViolationException. It looks like Json settings get device corrupted.

If I don't load any Json file, it works fine.

@OlivierHoel
Copy link

Hi all !
I have a similar bug when trying to load presets config stored in a json file in my C# script (running in Unity).
Is there another "manual" way to set parameter values ?
Thanks

@RealSenseCustomerSupport
Copy link
Collaborator


Hi @OlivierHoel,

You can refer to #3088 to set the options in C#.

@OlivierHoel
Copy link

Thanks for the link but apparently the enum values listed in Intel.RealSense.Option only gives you access to the "standard" parameters and not the "advanced" ones (e.g. disparity shift). I couldn't find a way to set the 92 params present in my json config file (exported from the realsense viewer).

@RealSenseCustomerSupport
Copy link
Collaborator


@ogoshen, any info to support the advanced parameters?

@ogoshen
Copy link
Contributor

ogoshen commented Feb 28, 2019

Advanced mode commands API is yet available in C# (STDepthControlGroup, STRsm, etc.)
The various functions (rs2_set_depth_control, rs2_set_rsm...) are present in NativeMethod.cs but not yet exposed through the public API of AdvancedDevice.

A PR would be more than welcome here...

In the meanwhile I can suggest getting the above fixes for AdvancedDevice, and using JSON de/serialization for getting and setting those parameters.

@RealSenseCustomerSupport
Copy link
Collaborator


This is fixed. Please refer to the release note.

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

No branches or pull requests

8 participants