public ViewerModel(IApp app, BackgroundReadingLoop readingLoop) : base(app) { this.readingLoop = readingLoop; readingLoop.CaptureReady += ReadingLoop_CaptureReady; readingLoop.Failed += ReadingLoop_Failed; Title = readingLoop.ToString(); var colorRes = readingLoop.ColorResolution; var depthMode = readingLoop.DepthMode; // Image visualizers for color if (colorRes != ColorResolution.Off) { colorImageVisualizer = ImageVisualizer.CreateForColorBgra(dispatcher, colorRes.WidthPixels(), colorRes.HeightPixels()); if (depthMode.HasDepth()) { readingLoop.GetCalibration(out var calibration); transformation = calibration.CreateTransformation(); depthOverColorImage = new Image(ImageFormat.Depth16, colorRes.WidthPixels(), colorRes.HeightPixels()); depthOverColorImageVisualizer = ImageVisualizer.CreateForDepth(dispatcher, colorRes.WidthPixels(), colorRes.HeightPixels()); } } // Image visualizers for depth and IR (if any) if (depthMode.HasDepth()) { depthImageVisualizer = ImageVisualizer.CreateForDepth(dispatcher, depthMode.WidthPixels(), depthMode.HeightPixels()); } if (depthMode.HasPassiveIR()) { irImageVisualizer = ImageVisualizer.CreateForIR(dispatcher, depthMode.WidthPixels(), depthMode.HeightPixels()); } // Proportions between columns if (colorRes != ColorResolution.Off && depthMode.HasPassiveIR()) { IRColumnWidth = new GridLength(irImageVisualizer.WidthPixels, GridUnitType.Star); DepthColumnWidth = depthMode.HasDepth() ? IRColumnWidth : new GridLength(0, GridUnitType.Pixel); ColorColumnWidth = new GridLength( irImageVisualizer.HeightPixels * colorImageVisualizer.WidthPixels / colorImageVisualizer.HeightPixels, GridUnitType.Star); } else if (colorRes != ColorResolution.Off) { DepthColumnWidth = IRColumnWidth = new GridLength(0, GridUnitType.Pixel); ColorColumnWidth = new GridLength(1, GridUnitType.Star); } else { IRColumnWidth = new GridLength(1, GridUnitType.Star); ColorColumnWidth = new GridLength(0, GridUnitType.Pixel); DepthColumnWidth = depthMode.HasDepth() ? IRColumnWidth : ColorColumnWidth; } }
public TrackerModel(IApp app, BackgroundReadingLoop readingLoop, TrackerProcessingMode processingMode, DnnModel dnnModel, SensorOrientation sensorOrientation, float smoothingFactor) : base(app) { // try to create tracking loop first readingLoop.GetCalibration(out calibration); trackingLoop = new BackgroundTrackingLoop(in calibration, processingMode, dnnModel, sensorOrientation, smoothingFactor); trackingLoop.BodyFrameReady += TrackingLoop_BodyFrameReady; trackingLoop.Failed += BackgroundLoop_Failed; this.readingLoop = readingLoop; readingLoop.CaptureReady += ReadingLoop_CaptureReady; readingLoop.Failed += BackgroundLoop_Failed; Title = readingLoop.ToString(); // Image and skeleton visualizers for depth var depthMode = readingLoop.DepthMode; depthImageVisualizer = ImageVisualizer.CreateForDepth(dispatcher, depthMode.WidthPixels(), depthMode.HeightPixels()); depthSkeletonVisualizer = new SkeletonVisualizer(dispatcher, depthMode.WidthPixels(), depthMode.HeightPixels(), ProjectJointToDepthMap); // Image and skeleton visualizers for color var colorRes = readingLoop.ColorResolution; if (colorRes != ColorResolution.Off) { colorImageVisualizer = ImageVisualizer.CreateForColorBgra(dispatcher, colorRes.WidthPixels(), colorRes.HeightPixels()); colorSkeletonVisualizer = new SkeletonVisualizer(dispatcher, colorRes.WidthPixels(), colorRes.HeightPixels(), ProjectJointToColorImage); bodyIndexMapTransformation = new BodyIndexMapTransformation(in calibration); } // Proportions between columns if (colorRes != ColorResolution.Off) { DepthColumnWidth = new GridLength(depthImageVisualizer.WidthPixels, GridUnitType.Star); ColorColumnWidth = new GridLength( depthImageVisualizer.HeightPixels * colorImageVisualizer.WidthPixels / colorImageVisualizer.HeightPixels, GridUnitType.Star); } else { DepthColumnWidth = new GridLength(1, GridUnitType.Star); ColorColumnWidth = new GridLength(0, GridUnitType.Pixel); } }