public static List <Point2D> GetMatchingRealWorldPolygon( List <Annotation> annotations, Circle realWorldCircle, PinholeToPlaneProjection pinholeProjection) { var matchingPolygon = GetMatchingPolygon(annotations, realWorldCircle, pinholeProjection); return(TransformToRealWorld(matchingPolygon.Points, pinholeProjection).ToList()); }
public static IEnumerable <Circle> ConstructRealWorldCircles( IEnumerable <Annotation> circleAnnotations, PinholeToPlaneProjection pinholeProjection) { foreach (var circleAnnotation in circleAnnotations) { yield return(ConstructRealWorldCircle(circleAnnotation, pinholeProjection)); } }
public static Circle ConstructRealWorldCircle( Annotation circleAnnotation, PinholeToPlaneProjection pinholeProjection) { var realWorldPoints = TransformToRealWorld(circleAnnotation.Points, pinholeProjection).ToList(); var centerPoint = CalculateCenterPoint(realWorldPoints); var radius = realWorldPoints.Average(p => p.DistanceTo(centerPoint)); return(new Circle(centerPoint, radius)); }
public DistanceMeasurementAnnotationRunner(AnnotationRunnerSettings settings, Calibration calibration) : base(settings) { if (settings.ShapeType != AnnotationShapeType.Line) { throw new ArgumentException( $"Annotation shape type must be '{nameof(AnnotationShapeType.Line)}' " + $"for {nameof(DistanceMeasurementAnnotationRunner)}"); } pinholeToPlaneProjection = new PinholeToPlaneProjection(calibration); AnnotationFinished += PerformMeasurement; }
public static Annotation GetMatchingPolygon( List <Annotation> annotations, Circle realWorldCircle, PinholeToPlaneProjection pinholeProjection) { var cheesePolygons = annotations.Where(annotation => annotation.ShapeType == AnnotationShapeType.Polygon); foreach (var cheesePolygon in cheesePolygons) { var realWorldPoints = TransformToRealWorld(cheesePolygon.Points, pinholeProjection).ToList(); var centerPoint = CalculateCenterPoint(realWorldPoints); if (centerPoint.DistanceTo(realWorldCircle.Center) < realWorldCircle.Radius) { return(cheesePolygon); } } throw new Exception("No matching cheese polygon found"); }
private static Shape GenerateCircleWithCalibration(Annotation annotation, Calibration calibration, double lineThickness) { var pinholeProjection = new PinholeToPlaneProjection(calibration); var realWorldCircle = RealWorldAnnotationHelpers.ConstructRealWorldCircles(new [] { annotation }, pinholeProjection).Single(); var imageCirclePoints = new PointCollection(100); foreach (var angle in SequenceGeneration.Linspace(-Math.PI, Math.PI, 100)) { var realWorldCirclePoint = realWorldCircle.Center + new Vector2D( realWorldCircle.Radius * Math.Cos(angle), realWorldCircle.Radius * Math.Sin(angle)); var imageCirclePoint = pinholeProjection.InverseTransform(realWorldCirclePoint); imageCirclePoints.Add(new Point(imageCirclePoint.X, imageCirclePoint.Y)); } var polygon = new Polygon { Points = imageCirclePoints, Stroke = Brushes.Red, StrokeThickness = lineThickness }; return(polygon); }
public static IEnumerable <Point2D> TransformToRealWorld(IEnumerable <Point2D> points, PinholeToPlaneProjection pinholeProjection) { return(points.Select(pinholeProjection.Transform)); }