diff --git a/wrappers/csharp/CMakeLists.txt b/wrappers/csharp/CMakeLists.txt index 2a20dd7d2f..21ebc80839 100644 --- a/wrappers/csharp/CMakeLists.txt +++ b/wrappers/csharp/CMakeLists.txt @@ -5,9 +5,10 @@ include(CSharpUtilities) set(CMAKE_CSharp_FLAGS "/langversion:6") add_subdirectory(Intel.RealSense) -add_subdirectory(cs-tutorial-1-depth) -add_subdirectory(cs-tutorial-2-capture) -add_subdirectory(cs-tutorial-3-processing) -add_subdirectory(cs-tutorial-4-software-dev) -add_subdirectory(cs-tutorial-5-pose) -add_subdirectory(cs-tutorial-8-D400-on-chip-calibration) \ No newline at end of file +add_subdirectory(tutorial/depth) +add_subdirectory(tutorial/capture) +add_subdirectory(tutorial/processing) +add_subdirectory(tutorial/software-dev) +add_subdirectory(tutorial/pose) +add_subdirectory(tutorial/d400-occ) +add_subdirectory(tutorial/load-json) diff --git a/wrappers/csharp/Intel.RealSense/Devices/CMakeLists.txt b/wrappers/csharp/Intel.RealSense/Devices/CMakeLists.txt index 03ad837e23..90c866039b 100644 --- a/wrappers/csharp/Intel.RealSense/Devices/CMakeLists.txt +++ b/wrappers/csharp/Intel.RealSense/Devices/CMakeLists.txt @@ -1,6 +1,7 @@ target_sources(${LRS_DOTNET_TARGET} PRIVATE "${CMAKE_CURRENT_LIST_DIR}/AdvancedDevice.cs" + "${CMAKE_CURRENT_LIST_DIR}/SerializableDevice.cs" "${CMAKE_CURRENT_LIST_DIR}/AutoCalibratedDevice.cs" "${CMAKE_CURRENT_LIST_DIR}/CalibratedDevice.cs" "${CMAKE_CURRENT_LIST_DIR}/DebugDevice.cs" diff --git a/wrappers/csharp/Intel.RealSense/Devices/SerializableDevice.cs b/wrappers/csharp/Intel.RealSense/Devices/SerializableDevice.cs new file mode 100644 index 0000000000..91ad7e2766 --- /dev/null +++ b/wrappers/csharp/Intel.RealSense/Devices/SerializableDevice.cs @@ -0,0 +1,47 @@ +// License: Apache 2.0. See LICENSE file in root directory. +// Copyright(c) 2017 Intel Corporation. All Rights Reserved. + +namespace Intel.RealSense +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Runtime.InteropServices; + + + public class SerializableDevice : Device + { + internal SerializableDevice(IntPtr dev) + : base(dev) + { } + + public static SerializableDevice FromDevice(Device dev) + { + return Device.Create(dev.Handle); + } + + /// + /// Gets or sets JSON and applies advanced-mode controls + /// + /// Serialize JSON content + public string JsonConfiguration + { + get + { + object error; + IntPtr buffer = NativeMethods.rs2_serialize_json(Handle, out error); + int size = NativeMethods.rs2_get_raw_data_size(buffer, out error); + IntPtr data = NativeMethods.rs2_get_raw_data(buffer, out error); + var str = Marshal.PtrToStringAnsi(data, size); + NativeMethods.rs2_delete_raw_data(buffer); + return str; + } + + set + { + object error; + NativeMethods.rs2_load_json(Handle, value, (uint)value.Length, out error); + } + } + } +} diff --git a/wrappers/csharp/cs-tutorial-2-capture/CMakeLists.txt b/wrappers/csharp/tutorial/capture/CMakeLists.txt similarity index 100% rename from wrappers/csharp/cs-tutorial-2-capture/CMakeLists.txt rename to wrappers/csharp/tutorial/capture/CMakeLists.txt diff --git a/wrappers/csharp/cs-tutorial-2-capture/Program.cs b/wrappers/csharp/tutorial/capture/Program.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-2-capture/Program.cs rename to wrappers/csharp/tutorial/capture/Program.cs diff --git a/wrappers/csharp/cs-tutorial-2-capture/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/capture/Properties/AssemblyInfo.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-2-capture/Properties/AssemblyInfo.cs rename to wrappers/csharp/tutorial/capture/Properties/AssemblyInfo.cs diff --git a/wrappers/csharp/cs-tutorial-2-capture/Window.xaml b/wrappers/csharp/tutorial/capture/Window.xaml similarity index 100% rename from wrappers/csharp/cs-tutorial-2-capture/Window.xaml rename to wrappers/csharp/tutorial/capture/Window.xaml diff --git a/wrappers/csharp/cs-tutorial-2-capture/Window.xaml.cs b/wrappers/csharp/tutorial/capture/Window.xaml.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-2-capture/Window.xaml.cs rename to wrappers/csharp/tutorial/capture/Window.xaml.cs diff --git a/wrappers/csharp/cs-tutorial-2-capture/app.config b/wrappers/csharp/tutorial/capture/app.config similarity index 100% rename from wrappers/csharp/cs-tutorial-2-capture/app.config rename to wrappers/csharp/tutorial/capture/app.config diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/CMakeLists.txt b/wrappers/csharp/tutorial/d400-occ/CMakeLists.txt similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/CMakeLists.txt rename to wrappers/csharp/tutorial/d400-occ/CMakeLists.txt diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/ExampleAutocalibrateDevice.cs b/wrappers/csharp/tutorial/d400-occ/ExampleAutocalibrateDevice.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/ExampleAutocalibrateDevice.cs rename to wrappers/csharp/tutorial/d400-occ/ExampleAutocalibrateDevice.cs diff --git a/wrappers/csharp/cs-tutorial-4-software-dev/Program.cs b/wrappers/csharp/tutorial/d400-occ/Program.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-4-software-dev/Program.cs rename to wrappers/csharp/tutorial/d400-occ/Program.cs diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/d400-occ/Properties/AssemblyInfo.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Properties/AssemblyInfo.cs rename to wrappers/csharp/tutorial/d400-occ/Properties/AssemblyInfo.cs diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Window.xaml b/wrappers/csharp/tutorial/d400-occ/Window.xaml similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Window.xaml rename to wrappers/csharp/tutorial/d400-occ/Window.xaml diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Window.xaml.cs b/wrappers/csharp/tutorial/d400-occ/Window.xaml.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Window.xaml.cs rename to wrappers/csharp/tutorial/d400-occ/Window.xaml.cs diff --git a/wrappers/csharp/cs-tutorial-3-processing/app.config b/wrappers/csharp/tutorial/d400-occ/app.config similarity index 100% rename from wrappers/csharp/cs-tutorial-3-processing/app.config rename to wrappers/csharp/tutorial/d400-occ/app.config diff --git a/wrappers/csharp/cs-tutorial-1-depth/CMakeLists.txt b/wrappers/csharp/tutorial/depth/CMakeLists.txt similarity index 100% rename from wrappers/csharp/cs-tutorial-1-depth/CMakeLists.txt rename to wrappers/csharp/tutorial/depth/CMakeLists.txt diff --git a/wrappers/csharp/cs-tutorial-1-depth/Program.cs b/wrappers/csharp/tutorial/depth/Program.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-1-depth/Program.cs rename to wrappers/csharp/tutorial/depth/Program.cs diff --git a/wrappers/csharp/cs-tutorial-1-depth/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/depth/Properties/AssemblyInfo.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-1-depth/Properties/AssemblyInfo.cs rename to wrappers/csharp/tutorial/depth/Properties/AssemblyInfo.cs diff --git a/wrappers/csharp/cs-tutorial-1-depth/app.config b/wrappers/csharp/tutorial/depth/app.config similarity index 100% rename from wrappers/csharp/cs-tutorial-1-depth/app.config rename to wrappers/csharp/tutorial/depth/app.config diff --git a/wrappers/csharp/tutorial/load-json/ADP_TestLoadSettingsJson.cs b/wrappers/csharp/tutorial/load-json/ADP_TestLoadSettingsJson.cs new file mode 100644 index 0000000000..44641b644c --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/ADP_TestLoadSettingsJson.cs @@ -0,0 +1,116 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.IO; +using System.Text.RegularExpressions; + +namespace Intel.RealSense +{ + class ADP_TestLoadSettingsJson + { + + public bool LoadSettingsJson(Device device) + { + var deviceName = device.Info[CameraInfo.Name]; + var usbType = device.Info[CameraInfo.UsbTypeDescriptor]; + string[] deviceNameParts = deviceName.Split(" ".ToCharArray()); + var model = deviceNameParts.Last().Trim(); + + + SerializableDevice ser = null; + Console.WriteLine($"Device model: '{model}'"); + + var jsonFileName = $"ADP_{model}_TEST_JSON_USB{usbType}.json"; + var jsonPath = System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(), "JsonConfigs", jsonFileName); + Console.WriteLine($"Searching for a json test file: '{jsonFileName}'"); + if (!File.Exists(jsonPath)) + { + Console.WriteLine($"File not found, so no settings data will be loaded into a camera. Exiting..."); + return false; + } + + Console.WriteLine($"Json test file found: {jsonPath}. Loading it..."); + Console.WriteLine($"Loading by using of SerialiazableDevice..."); + ser = SerializableDevice.FromDevice(device); + try + { + ser.JsonConfiguration = File.ReadAllText(jsonPath); + Console.WriteLine($"Loaded"); + Console.WriteLine(ser.JsonConfiguration); + } + catch (Exception ex) + { + Console.WriteLine($"Failed to load json file: {ex.Message}"); + return false; + } + + // check for manual options setting + var sensors = device.QuerySensors(); + var depthSensor = sensors[0]; + var colorSensor = sensors[1]; + Console.WriteLine($"\nManulally read options:"); + Console.WriteLine($"--------------------------------------------------"); + Console.WriteLine($"DEPTH OPTIONS:"); + Console.WriteLine($"================"); + Console.WriteLine($"Total count: {depthSensor.Options.Count()}\n"); + for (int i = 0; i < depthSensor.Options.Count(); i++) + { + // there may be some exceptions when trying to get some options, even when going through by index. So using this relatively safe method to iterate all the options, even unacceptible + try + { + var opt = depthSensor.Options.Skip(i).Take(1).FirstOrDefault(); + if (opt != null) + { + Console.WriteLine($"{opt.Key}: {opt.Value}"); + + } + } + catch (Exception) + { + Console.WriteLine($"Error getting option №{i}"); + } + } + Console.WriteLine($"\nCOLOR OPTIONS:"); + Console.WriteLine($"================"); + Console.WriteLine($"Total count: {colorSensor.Options.Count()}\n"); + for (int i = 0; i < colorSensor.Options.Count(); i++) + { + // there may be some exceptions when trying to get some options, even when going through by index. So using this relatively safe method to iterate all the options, even unacceptible + try + { + var opt = colorSensor.Options.Skip(i).Take(1).FirstOrDefault(); + if (opt != null) + { + Console.WriteLine($"{opt.Key}: {opt.Value}"); + if (opt.Key.ToString() == "Brightness") // check if we can set value to option. We take brightness for example + { + var newValue = opt.Value + 1; + Console.Write($"\nCheck if we can set option manually: {opt.Key}: from {opt.Value} to {newValue}..."); + opt.Value = newValue; + + var optionsJson = Regex.Replace(ser.JsonConfiguration, @" ", ""); + // if we can read brightness from json settings (not all cameras returns all params), use it + if (optionsJson.IndexOf("controls-color-brightness") > 0) + { + var shouldBe = $"\"controls-color-brightness\":\"{newValue}\""; + Console.Write($"new value set: {optionsJson.IndexOf(shouldBe) > 0}\n\n"); + } + else // else just reread value from option - it's getter will get it from device + { + Console.Write($"new value set: {opt.Value == newValue}\n\n"); // opt.Value getter will read value from device + } + } + } + } + catch (Exception ex) + { + Console.WriteLine($"Error read option №{i}: {ex.Message}"); + } + } + + return true; + } + } + +} diff --git a/wrappers/csharp/tutorial/load-json/CMakeLists.txt b/wrappers/csharp/tutorial/load-json/CMakeLists.txt new file mode 100644 index 0000000000..398a2aa057 --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/CMakeLists.txt @@ -0,0 +1,34 @@ +cmake_minimum_required( VERSION 3.8.0 ) + +project(cs-tutorial-load-json) + +add_executable(${PROJECT_NAME} + Program.cs + Window.xaml + Window.xaml.cs + ADP_TestLoadSettingsJson.cs + + Properties/AssemblyInfo.cs +) + +set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_TARGET_FRAMEWORK_VERSION "v${DOTNET_VERSION_EXAMPLES}") +# set_property(TARGET ${PROJECT_NAME} PROPERTY WIN32_EXECUTABLE TRUE) + +add_dependencies(${PROJECT_NAME} Intel.RealSense) + +set_property(TARGET ${PROJECT_NAME} PROPERTY VS_DOTNET_REFERENCES + "System" + "System.Xaml" + "PresentationCore" + "PresentationFramework" + "WindowsBase" +) + +set_target_properties (${PROJECT_NAME} PROPERTIES + FOLDER Wrappers/csharp +) + +add_custom_command(TARGET ${PROJECT_NAME} PRE_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_directory + ${CMAKE_CURRENT_SOURCE_DIR}/JsonConfigs $/JsonConfigs) + diff --git a/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D415_TEST_JSON_USB2.1.json b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D415_TEST_JSON_USB2.1.json new file mode 100644 index 0000000000..360ca3414f --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D415_TEST_JSON_USB2.1.json @@ -0,0 +1,95 @@ +{ + "aux-param-autoexposure-setpoint": "400", + "aux-param-colorcorrection1": "0.461914", + "aux-param-colorcorrection10": "-0.553711", + "aux-param-colorcorrection11": "-0.553711", + "aux-param-colorcorrection12": "0.0458984", + "aux-param-colorcorrection2": "0.540039", + "aux-param-colorcorrection3": "0.540039", + "aux-param-colorcorrection4": "0.208008", + "aux-param-colorcorrection5": "-0.332031", + "aux-param-colorcorrection6": "-0.212891", + "aux-param-colorcorrection7": "-0.212891", + "aux-param-colorcorrection8": "0.68457", + "aux-param-colorcorrection9": "0.930664", + "aux-param-depthclampmax": "65536", + "aux-param-depthclampmin": "0", + "aux-param-disparityshift": "0", + "controls-autoexposure-auto": "True", + "controls-autoexposure-manual": "33000", + "controls-color-autoexposure-auto": "True", + "controls-color-autoexposure-manual": "156", + "controls-color-backlight-compensation": "0", + "controls-color-brightness": "-54", + "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-depth-white-balance-auto": "False", + "controls-laserpower": "150", + "controls-laserstate": "on", + "ignoreSAD": "0", + "param-amplitude-factor": "0", + "param-autoexposure-setpoint": "400", + "param-censusenablereg-udiameter": "9", + "param-censusenablereg-vdiameter": "9", + "param-censususize": "9", + "param-censusvsize": "9", + "param-depthclampmax": "65536", + "param-depthclampmin": "0", + "param-depthunits": "1000", + "param-disableraucolor": "0", + "param-disablesadcolor": "0", + "param-disablesadnormalize": "0", + "param-disablesloleftcolor": "0", + "param-disableslorightcolor": "0", + "param-disparitymode": "0", + "param-disparityshift": "0", + "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": "1000", + "stream-depth-format": "Z16", + "stream-fps": "15", + "stream-height": "480", + "stream-width": "640" +} \ No newline at end of file diff --git a/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D435_TEST_JSON_USB2.1.json b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D435_TEST_JSON_USB2.1.json new file mode 100644 index 0000000000..49cf96fd6b --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D435_TEST_JSON_USB2.1.json @@ -0,0 +1,94 @@ +{ + "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": "0", + "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": "61", + "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": "150", + "controls-laserstate": "on", + "ignoreSAD": "0", + "param-amplitude-factor": "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": "1000", + "param-disableraucolor": "0", + "param-disablesadcolor": "0", + "param-disablesadnormalize": "0", + "param-disablesloleftcolor": "0", + "param-disableslorightcolor": "0", + "param-disparitymode": "0", + "param-disparityshift": "0", + "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": "1000", + "stream-depth-format": "Z16", + "stream-fps": "15", + "stream-height": "480", + "stream-width": "640" +} \ No newline at end of file diff --git a/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D455_TEST_JSON_USB2.1.json b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D455_TEST_JSON_USB2.1.json new file mode 100644 index 0000000000..5f85108e87 --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_D455_TEST_JSON_USB2.1.json @@ -0,0 +1,94 @@ +{ + "aux-param-autoexposure-setpoint": "400", + "aux-param-colorcorrection1": "-0.493164", + "aux-param-colorcorrection10": "-0.272461", + "aux-param-colorcorrection11": "-0.272461", + "aux-param-colorcorrection12": "-0.355469", + "aux-param-colorcorrection2": "0.831055", + "aux-param-colorcorrection3": "0.831055", + "aux-param-colorcorrection4": "-0.368164", + "aux-param-colorcorrection5": "-0.133789", + "aux-param-colorcorrection6": "-0.323242", + "aux-param-colorcorrection7": "-0.323242", + "aux-param-colorcorrection8": "1.19141", + "aux-param-colorcorrection9": "0.90918", + "aux-param-depthclampmax": "65536", + "aux-param-depthclampmin": "0", + "aux-param-disparityshift": "0", + "controls-autoexposure-auto": "True", + "controls-autoexposure-manual": "33000", + "controls-color-autoexposure-auto": "True", + "controls-color-autoexposure-manual": "156", + "controls-color-backlight-compensation": "0", + "controls-color-brightness": "-52", + "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": "150", + "controls-laserstate": "on", + "ignoreSAD": "0", + "param-amplitude-factor": "0.08", + "param-autoexposure-setpoint": "400", + "param-censusenablereg-udiameter": "9", + "param-censusenablereg-vdiameter": "9", + "param-censususize": "9", + "param-censusvsize": "9", + "param-depthclampmax": "65536", + "param-depthclampmin": "0", + "param-depthunits": "1000", + "param-disableraucolor": "0", + "param-disablesadcolor": "0", + "param-disablesadnormalize": "0", + "param-disablesloleftcolor": "0", + "param-disableslorightcolor": "0", + "param-disparitymode": "0", + "param-disparityshift": "0", + "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": "1000", + "stream-depth-format": "Z16", + "stream-fps": "15", + "stream-height": "270", + "stream-width": "480" +} \ No newline at end of file diff --git a/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_L515_TEST_JSON_USB2.1.json b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_L515_TEST_JSON_USB2.1.json new file mode 100644 index 0000000000..46427ee000 --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_L515_TEST_JSON_USB2.1.json @@ -0,0 +1,35 @@ +{ + "Alternate IR": 1, + "Apd Temperature": 34.9951095581055, + "Confidence Threshold": 1, + "Depth Offset": 4.5, + "Depth Units": 0.000250000011874363, + "Digital Gain": 1, + "Error Polling Enabled": 1, + "Frames Queue Size": 16, + "Freefall Detection Enabled": 1, + "Global Time Enabled": 0.0, + "Host Performance": 0.0, + "Humidity Temperature": 38.7655448913574, + "Inter Cam Sync Mode": 0.0, + "Invalidation Bypass": 0.0, + "LDD temperature": 43.941764831543, + "Laser Power": 100, + "Ma Temperature": 36.6346244812012, + "Mc Temperature": 38.7828407287598, + "Min Distance": 490, + "Noise Estimation": 1614, + "Noise Filtering": 4, + "Post Processing Sharpening": 1, + "Pre Processing Sharpening": 0.0, + "Receiver Gain": 9, + "Reset Camera Accuracy Health": 0.0, + "Sensor Mode": 2, + "Trigger Camera Accuracy Health": 0.0, + "Visual Preset": 4, + "stream-depth-format": "Z16", + "stream-fps": "30", + "stream-height": "240", + "stream-ir-format": "Y8", + "stream-width": "320" +} \ No newline at end of file diff --git a/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_L515_TEST_JSON_USB3.2.json b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_L515_TEST_JSON_USB3.2.json new file mode 100644 index 0000000000..2b74fb653d --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/JsonConfigs/ADP_L515_TEST_JSON_USB3.2.json @@ -0,0 +1,37 @@ +{ + "Alternate IR": 0.0, + "Apd Temperature": -9999, + "Confidence Threshold": 1, + "Depth Offset": 4.5, + "Depth Units": 0.000250000011874363, + "Digital Gain": 1, + "Enable IR Reflectivity": 0.0, + "Enable Max Usable Range": 0.0, + "Error Polling Enabled": 1, + "Frames Queue Size": 16, + "Freefall Detection Enabled": 1, + "Global Time Enabled": 0.0, + "Host Performance": 0.0, + "Humidity Temperature": 37.8255882263184, + "Inter Cam Sync Mode": 0.0, + "Invalidation Bypass": 0.0, + "LDD temperature": 38.4872207641602, + "Laser Power": 100, + "Ma Temperature": 36.2095794677734, + "Mc Temperature": 37.4943008422852, + "Min Distance": 490, + "Noise Estimation": 0.0, + "Noise Filtering": 4, + "Post Processing Sharpening": 1, + "Pre Processing Sharpening": 0.0, + "Receiver Gain": 9, + "Reset Camera Accuracy Health": 0.0, + "Sensor Mode": 0.0, + "Trigger Camera Accuracy Health": 0.0, + "Visual Preset": 4, + "stream-depth-format": "Z16", + "stream-fps": "30", + "stream-height": "480", + "stream-ir-format": "Y8", + "stream-width": "640" +} \ No newline at end of file diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Program.cs b/wrappers/csharp/tutorial/load-json/Program.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/Program.cs rename to wrappers/csharp/tutorial/load-json/Program.cs diff --git a/wrappers/csharp/tutorial/load-json/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/load-json/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..db03bc3f74 --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Intel(R) RealSense(TM) SDK C# Wrapper Tutorial-5")] +[assembly: AssemblyDescription("Intel(R) RealSense(TM) SDK C# Wrapper Examples")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Intel(R) Corporation")] +[assembly: AssemblyProduct("Intel(R) RealSense(TM) SDK C# Wrapper")] +[assembly: AssemblyCopyright("Copyright © 2021, Intel Corporation. All rights reserved")] +[assembly: AssemblyTrademark("Intel(R) RealSense(TM)")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("71c85ee0-c7c2-4e2e-8020-6af818537a14")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/wrappers/csharp/tutorial/load-json/Window.xaml b/wrappers/csharp/tutorial/load-json/Window.xaml new file mode 100644 index 0000000000..965627d4a3 --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/Window.xaml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + diff --git a/wrappers/csharp/tutorial/load-json/Window.xaml.cs b/wrappers/csharp/tutorial/load-json/Window.xaml.cs new file mode 100644 index 0000000000..dfef0d0741 --- /dev/null +++ b/wrappers/csharp/tutorial/load-json/Window.xaml.cs @@ -0,0 +1,166 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Navigation; +using System.Windows.Shapes; +using System.Windows.Threading; + +namespace Intel.RealSense +{ + /// + /// Interaction logic for Window.xaml + /// + public partial class CaptureWindow : Window + { + private Pipeline pipeline; + private Colorizer colorizer; + private CancellationTokenSource tokenSource = new CancellationTokenSource(); + private ADP_TestLoadSettingsJson testLoadSettingsJson = new ADP_TestLoadSettingsJson(); + + static Action UpdateImage(Image img) + { + var wbmp = img.Source as WriteableBitmap; + return new Action(frame => + { + var rect = new Int32Rect(0, 0, frame.Width, frame.Height); + wbmp.WritePixels(rect, frame.Data, frame.Stride * frame.Height, frame.Stride); + }); + } + + public CaptureWindow() + { + InitializeComponent(); + + try + { + Action updateDepth; + Action updateColor; + + // The colorizer processing block will be used to visualize the depth frames. + colorizer = new Colorizer(); + + // Create and config the pipeline to strem color and depth frames. + pipeline = new Pipeline(); + + using (var ctx = new Context()) + { + + var devices = ctx.QueryDevices(); + var dev = devices[0]; + + Console.WriteLine("\nUsing device 0, an {0}", dev.Info[CameraInfo.Name]); + Console.WriteLine(" Serial number: {0}", dev.Info[CameraInfo.SerialNumber]); + Console.WriteLine(" Firmware version: {0}", dev.Info[CameraInfo.FirmwareVersion]); + + var sensors = dev.QuerySensors(); + var depthSensor = sensors[0]; + var colorSensor = sensors[1]; + + var depthProfile = depthSensor.StreamProfiles + .Where(p => p.Stream == Stream.Depth) + .OrderBy(p => p.Framerate) + .Select(p => p.As()).First(); + + var colorProfile = colorSensor.StreamProfiles + .Where(p => p.Stream == Stream.Color) + .OrderBy(p => p.Framerate) + .Select(p => p.As()).First(); + + if (!testLoadSettingsJson.LoadSettingsJson(dev)) + { + return; + } + + var cfg = new Config(); + cfg.EnableDevice(dev.Info.GetInfo(CameraInfo.SerialNumber)); + cfg.EnableStream(Stream.Depth, depthProfile.Width, depthProfile.Height, depthProfile.Format, depthProfile.Framerate); + cfg.EnableStream(Stream.Color, colorProfile.Width, colorProfile.Height, colorProfile.Format, colorProfile.Framerate); + + var pp = pipeline.Start(cfg); + SetupWindow(pp, out updateDepth, out updateColor); + + // more device info + Console.WriteLine($"--------------------------"); + foreach (var item in pp.Device.Info.ToArray()) + { + Console.WriteLine($"{item.Key} - {item.Value}"); + } + Console.WriteLine($"--------------------------"); + } + + Task.Factory.StartNew(() => + { + while (!tokenSource.Token.IsCancellationRequested) + { + // We wait for the next available FrameSet and using it as a releaser object that would track + // all newly allocated .NET frames, and ensure deterministic finalization + // at the end of scope. + using (var frames = pipeline.WaitForFrames()) + { + var colorFrame = frames.ColorFrame.DisposeWith(frames); + var depthFrame = frames.DepthFrame.DisposeWith(frames); + + // We colorize the depth frame for visualization purposes + var colorizedDepth = colorizer.Process(depthFrame).DisposeWith(frames); + + // Render the frames. + Dispatcher.Invoke(DispatcherPriority.Render, updateDepth, colorizedDepth); + Dispatcher.Invoke(DispatcherPriority.Render, updateColor, colorFrame); + + Dispatcher.Invoke(new Action(() => + { + String depth_dev_sn = depthFrame.Sensor.Info[CameraInfo.SerialNumber]; + txtTimeStamp.Text = depth_dev_sn + " : " + String.Format("{0,-20:0.00}", depthFrame.Timestamp) + "(" + depthFrame.TimestampDomain.ToString() + ")"; + })); + } + } + }, tokenSource.Token); + + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + Application.Current.Shutdown(); + } + } + + private void control_Closing(object sender, System.ComponentModel.CancelEventArgs e) + { + tokenSource.Cancel(); + } + + private void SetupWindow(PipelineProfile pipelineProfile, out Action depth, out Action color) + { + try + { + using (var p = pipelineProfile.GetStream(Stream.Depth).As()) + imgDepth.Source = new WriteableBitmap(p.Width, p.Height, 96d, 96d, PixelFormats.Rgb24, null); + } + catch (Exception ex) + { + MessageBox.Show("Unable to find Deapth Stream. " + ex.Message); + } + depth = UpdateImage(imgDepth); + try + { + using (var p = pipelineProfile.GetStream(Stream.Color).As()) + imgColor.Source = new WriteableBitmap(p.Width, p.Height, 96d, 96d, PixelFormats.Rgb24, null); + } + catch (Exception ex) + { + MessageBox.Show("Unable to find Color Stream. " + ex.Message); + } + color = UpdateImage(imgColor); + } + } +} diff --git a/wrappers/csharp/cs-tutorial-4-software-dev/app.config b/wrappers/csharp/tutorial/load-json/app.config similarity index 100% rename from wrappers/csharp/cs-tutorial-4-software-dev/app.config rename to wrappers/csharp/tutorial/load-json/app.config diff --git a/wrappers/csharp/cs-tutorial-5-pose/CMakeLists.txt b/wrappers/csharp/tutorial/pose/CMakeLists.txt similarity index 100% rename from wrappers/csharp/cs-tutorial-5-pose/CMakeLists.txt rename to wrappers/csharp/tutorial/pose/CMakeLists.txt diff --git a/wrappers/csharp/cs-tutorial-5-pose/Program.cs b/wrappers/csharp/tutorial/pose/Program.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-5-pose/Program.cs rename to wrappers/csharp/tutorial/pose/Program.cs diff --git a/wrappers/csharp/cs-tutorial-5-pose/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/pose/Properties/AssemblyInfo.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-5-pose/Properties/AssemblyInfo.cs rename to wrappers/csharp/tutorial/pose/Properties/AssemblyInfo.cs diff --git a/wrappers/csharp/cs-tutorial-5-pose/app.config b/wrappers/csharp/tutorial/pose/app.config similarity index 100% rename from wrappers/csharp/cs-tutorial-5-pose/app.config rename to wrappers/csharp/tutorial/pose/app.config diff --git a/wrappers/csharp/cs-tutorial-3-processing/CMakeLists.txt b/wrappers/csharp/tutorial/processing/CMakeLists.txt similarity index 100% rename from wrappers/csharp/cs-tutorial-3-processing/CMakeLists.txt rename to wrappers/csharp/tutorial/processing/CMakeLists.txt diff --git a/wrappers/csharp/cs-tutorial-3-processing/Program.cs b/wrappers/csharp/tutorial/processing/Program.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-3-processing/Program.cs rename to wrappers/csharp/tutorial/processing/Program.cs diff --git a/wrappers/csharp/cs-tutorial-3-processing/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/processing/Properties/AssemblyInfo.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-3-processing/Properties/AssemblyInfo.cs rename to wrappers/csharp/tutorial/processing/Properties/AssemblyInfo.cs diff --git a/wrappers/csharp/cs-tutorial-3-processing/Window.xaml b/wrappers/csharp/tutorial/processing/Window.xaml similarity index 100% rename from wrappers/csharp/cs-tutorial-3-processing/Window.xaml rename to wrappers/csharp/tutorial/processing/Window.xaml diff --git a/wrappers/csharp/cs-tutorial-3-processing/Window.xaml.cs b/wrappers/csharp/tutorial/processing/Window.xaml.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-3-processing/Window.xaml.cs rename to wrappers/csharp/tutorial/processing/Window.xaml.cs diff --git a/wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/app.config b/wrappers/csharp/tutorial/processing/app.config similarity index 100% rename from wrappers/csharp/cs-tutorial-8-D400-on-chip-calibration/app.config rename to wrappers/csharp/tutorial/processing/app.config diff --git a/wrappers/csharp/cs-tutorial-4-software-dev/CMakeLists.txt b/wrappers/csharp/tutorial/software-dev/CMakeLists.txt similarity index 100% rename from wrappers/csharp/cs-tutorial-4-software-dev/CMakeLists.txt rename to wrappers/csharp/tutorial/software-dev/CMakeLists.txt diff --git a/wrappers/csharp/tutorial/software-dev/Program.cs b/wrappers/csharp/tutorial/software-dev/Program.cs new file mode 100644 index 0000000000..c74391ac2c --- /dev/null +++ b/wrappers/csharp/tutorial/software-dev/Program.cs @@ -0,0 +1,15 @@ +using System; +using System.Linq; + +namespace Intel.RealSense +{ + class Program + { + [STAThread] + static void Main(string[] args) + { + var w = new CaptureWindow(); + w.ShowDialog(); + } + } +} diff --git a/wrappers/csharp/cs-tutorial-4-software-dev/Properties/AssemblyInfo.cs b/wrappers/csharp/tutorial/software-dev/Properties/AssemblyInfo.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-4-software-dev/Properties/AssemblyInfo.cs rename to wrappers/csharp/tutorial/software-dev/Properties/AssemblyInfo.cs diff --git a/wrappers/csharp/cs-tutorial-4-software-dev/Window.xaml b/wrappers/csharp/tutorial/software-dev/Window.xaml similarity index 100% rename from wrappers/csharp/cs-tutorial-4-software-dev/Window.xaml rename to wrappers/csharp/tutorial/software-dev/Window.xaml diff --git a/wrappers/csharp/cs-tutorial-4-software-dev/Window.xaml.cs b/wrappers/csharp/tutorial/software-dev/Window.xaml.cs similarity index 100% rename from wrappers/csharp/cs-tutorial-4-software-dev/Window.xaml.cs rename to wrappers/csharp/tutorial/software-dev/Window.xaml.cs diff --git a/wrappers/csharp/tutorial/software-dev/app.config b/wrappers/csharp/tutorial/software-dev/app.config new file mode 100644 index 0000000000..fcd0c93735 --- /dev/null +++ b/wrappers/csharp/tutorial/software-dev/app.config @@ -0,0 +1,3 @@ + + +