How to retrieve advanced mode options in C#?
Hello,
I'm using Unity and Realsense D435 to create a green screen-based mixed reality system. I'm at the very first stages of this project and I'm now trying to create a runtime GUI to control the camera.

Everything works fine, but I can't figure out how to get advanced controls.
Here's how I get the sensors and their option list:
private void onStartStreaming(PipelineProfile profile)
{
var sensors = new Dictionary<string, Sensor>();
var sensorOptions = new Dictionary<string, List<IOption>>();
// ...
device = profile.Device;
var sensorsCollection = device.Sensors;
foreach (Sensor s in sensorsCollection)
{
var sensorName = s.Info[CameraInfo.Name];
sensors.Add(sensorName, s);
sensorOptions.Add(sensorName, s.Options.ToList())
{
}
And here's how I access individual options:
foreach (IOption option in sensorOptions[sensorName])
{
string optionName = option.Key.ToString();
string optionDescription = option.Description;
// ...
}
In this way I only get the base option list. How can I get advanced mode options, too?
Thanks,
Francesco
-
Hello F Cucchiara,
Thank you for your interest in the Intel RealSense D435 camera.
Please take a look at NativeMethods.cs file from C# wrapper, at line number 554: https://github.com/IntelRealSense/librealsense/blob/d6f6be84b46190c8c84c95f6ac279d239320fcda/wrappers/csharp/Intel.RealSense/NativeMethods.cs#L554 Here you have Advanced Modes defined in C#.
Thank you and best regards,
Eliza
-
Thanks for the answer, Eliza!
I could take a look at the NativeMethods.cs class and I tried to integrate it in my project. Something is still not clear for me, I'll try to explain it using as axample the rs2_get_slo_penalty_control method:internal static extern void rs2_get_slo_penalty_control(IntPtr dev, IntPtr group, int mode, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(ErrorMarshaler))] out object error);
I found that a valid "dev" pointer value is AdvancedDevice.Handle:
AdvancedDevice advancedDevice = AdvancedDevice.FromDevice(device);
IntPtr devPtr = advancedDevice.Handle;But I couldn't find a way to create the "group" parameter structure, which in the C API is called STSloPenaltyControl:
typedef struct
{
uint32_t sloK1Penalty;
uint32_t sloK2Penalty;
uint32_t sloK1PenaltyMod1;
uint32_t sloK2PenaltyMod1;
uint32_t sloK1PenaltyMod2;
uint32_t sloK2PenaltyMod2;
}STSloPenaltyControl;Am I missing something?
Note: NativeMethods.cs class is marked as internal, so I had to create a new script, copy-and-paste the original file and then remove the "internal" keyword in order to access its methods without Reflections.
Thanks,
Francesco
Please sign in to leave a comment.
Comments
2 comments