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

D400 Calibration extensions in C# #9256

Merged
merged 11 commits into from
Jul 4, 2021
Original file line number Diff line number Diff line change
Expand Up @@ -167,21 +167,24 @@ public void Calibrate(Device dev = null)
try
{
sw.Start();
calTableAfter = aCalibratedDevice.RunOnChipCalibration(calibrationConfig, out health, timeout);
ProgressCallback pc = (x) => { Console.WriteLine("Progress: {0} percents",x); };
// The following line performs the same calibration flow but does not report progress"
//calTableAfter = aCalibratedDevice.RunOnChipCalibration(calibrationConfig, out health, timeout);
calTableAfter = aCalibratedDevice.RunOnChipCalibration(calibrationConfig, out health, pc, timeout);
sw.Stop();
}
catch (Exception ex)
{
sw.Stop();
thisCalibrationfault = true;
Console.WriteLine($"\t Error during calibration: {ex.Message.Replace("\n", "\t")}");
Console.WriteLine($"\n\t Error during calibration: {ex.Message.Replace("\n", "\t")}");
Console.WriteLine($"\t Please try to change distance to target or light conditions{Environment.NewLine}");
if (ConsoleKey.N == ConsoleGetKey(new[] { ConsoleKey.Y, ConsoleKey.N },
@"Let's try calibrate one more time? (Y\N)"
))
{
Console.WriteLine("");
Console.WriteLine($"Calibration fault");
Console.WriteLine($"Calibration aborted");
Console.WriteLine($"Stopping calibration pipeline...");
pipeline.Stop();
return;
Expand All @@ -190,7 +193,7 @@ public void Calibrate(Device dev = null)

if (!thisCalibrationfault)
{
Console.WriteLine($"\t Time spend: {sw.Elapsed.ToString(@"mm\:ss\.fff")} (min:sec.millisec)");
Console.WriteLine($"\n\t Time spend: {sw.Elapsed.ToString(@"mm\:ss\.fff")} (min:sec.millisec)");
Console.WriteLine($"\t Device health: {health} ({_deviceHealthDescription[GetDeviceHealth(health)]})");

var res = ConsoleGetKey(new[] { ConsoleKey.Y, ConsoleKey.N, ConsoleKey.A }, @"Accept calibration ? Yes/No/Abort");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ public CaptureWindow()
using (var ctx = new Context())
{
var devices = ctx.QueryDevices();
if (0==devices.Count)
ev-mp marked this conversation as resolved.
Show resolved Hide resolved
{
Console.WriteLine("The tutorial {0} requires Realsense D400 device to run.\nConnect a device and rerun",
maloel marked this conversation as resolved.
Show resolved Hide resolved
System.Diagnostics.Process.GetCurrentProcess().ProcessName);
Environment.Exit(0);
maloel marked this conversation as resolved.
Show resolved Hide resolved
}
var dev = devices[0];

Console.WriteLine("Using device 0, an {0}", dev.Info[CameraInfo.Name]);
Expand Down Expand Up @@ -90,7 +96,7 @@ public CaptureWindow()
SetupWindow(pp, out updateDepth, out updateColor);
}

// Redndering task
// Rendering task
var renderingPause = false;
var rendering = Task.Factory.StartNew(() =>
{
Expand Down Expand Up @@ -119,7 +125,7 @@ public CaptureWindow()
{
String depth_dev_sn = depthFrame.Sensor.Info[CameraInfo.SerialNumber];
txtTimeStamp.Text = $"{depth_dev_sn} : {depthFrame.Timestamp,-20:0.00}({depthFrame.TimestampDomain})" +
$"{Environment.NewLine}If you want to start calibration mode, switch to opened application console and press C";
$"{Environment.NewLine}To start Auto-Calibration flow, switch focus to the application console and press C";
}));
}
}
Expand All @@ -131,7 +137,7 @@ public CaptureWindow()
while (!tokenSource.Token.IsCancellationRequested)
{
if (ConsoleKey.C == ExampleAutocalibrateDevice.ConsoleGetKey(new[] { ConsoleKey.C},
"If you want to start calibration mode, switch to opened application console and press C"))
"To start Auto-Calibration flow, switch focus to the application console and press C"))
{
renderingPause = true;
Console.WriteLine($"{Environment.NewLine}Stopping rendering pipeline...");
Expand Down