private void DrawAndDisplayImage() { if (HeadPoint.IsEmpty) { using (Image <Bgr, byte> img = WorkingImage.Convert <Bgr, byte>()) { DisplayImage = ImageService.ToBitmapSource(img); } return; } using (Image <Bgr, byte> img = WorkingImage.Convert <Bgr, byte>()) { img.DrawPolyline(BodyContour, true, new Bgr(Color.Yellow)); img.Draw(new CircleF(HeadPoint, 2), new Bgr(Color.Red)); PointF midPoint = HeadPoints[1].MidPoint(HeadPoints[3]); img.Draw(new LineSegment2DF(midPoint, HeadPoint), new Bgr(Color.Red), 1); if (FinalWhiskers != null) { if (FinalWhiskers.LeftWhiskers != null && FinalWhiskers.LeftWhiskers.Any()) { //currentFrame.Draw(cWhiskers.LeftWhiskers[5].Line, new Bgr(Color.White), 1); foreach (IWhiskerSegment whisker in FinalWhiskers.LeftWhiskers) { Color color = Color.White; img.Draw(whisker.Line, new Bgr(color), 1); } } if (FinalWhiskers.RightWhiskers != null && FinalWhiskers.RightWhiskers.Any()) { foreach (IWhiskerSegment whisker in FinalWhiskers.RightWhiskers) { Color color = Color.White; img.Draw(whisker.Line, new Bgr(color), 1); } } } DisplayImage = ImageService.ToBitmapSource(img); } }
private void UpdateFrameImage() { WorkingImage = Video.GetGrayFrameImage(); PointF[] headPoints; Point[] bodyPoints; Rbsk.GetHeadAndBody(WorkingImage.Convert <Bgr, byte>(), out headPoints, out bodyPoints); HeadPoints = headPoints; if (headPoints == null) { HeadPoint = PointF.Empty; } else { HeadPoint = headPoints[2]; } BodyContour = bodyPoints; DrawAndDisplayImage(); }
private void Preview() { using (Image <Gray, byte> gray = WorkingImage.Convert <Gray, byte>()) { Whiskers = Rbsk.ProcessWhiskersForSingleFrame(gray, HeadPoints, BodyContour); if (WhiskerSettings.RemoveDuds) { FinalWhiskers = ModelResolver.Resolve <IWhiskerCollection>(); PointF midPoint = HeadPoints[1].MidPoint(HeadPoints[3]); Vector orientation = new Vector(HeadPoint.X - midPoint.X, HeadPoint.Y - midPoint.Y); PostProcessWhiskers2(midPoint, orientation, Whiskers, FinalWhiskers); } else { FinalWhiskers = Whiskers; } } PreviewGenerated = true; DrawAndDisplayImage(); }