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# tutorial 2 fixes #8559

Merged
merged 2 commits into from
Mar 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 30 additions & 5 deletions wrappers/csharp/cs-tutorial-2-capture/Window.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,38 @@ public CaptureWindow()
// Create and config the pipeline to strem color and depth frames.
pipeline = new Pipeline();

var cfg = new Config();
cfg.EnableStream(Stream.Depth, 640, 480);
cfg.EnableStream(Stream.Color, Format.Rgb8);
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<VideoStreamProfile>()).First();

var colorProfile = colorSensor.StreamProfiles
.Where(p => p.Stream == Stream.Color)
.OrderBy(p => p.Framerate)
.Select(p => p.As<VideoStreamProfile>()).First();

var cfg = new Config();
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);
var pp = pipeline.Start(cfg);

SetupWindow(pp, out updateDepth, out updateColor);
SetupWindow(pp, out updateDepth, out updateColor);
}

Task.Factory.StartNew(() =>
{
Expand Down