Example #1
0
        //------------------------------------------------------
        // Note:
        // When using the planar calibration, the projection of the circle in world space and back in image space
        // creates an ellipse whose center is not exactly on the center of the original circle.
        // This is why there are extra checks to move the minilabel attachment point everytime the drawing moves,
        // changes size, or when the calibration changes.
        //------------------------------------------------------

        #region Constructor
        public DrawingCircle(PointF center, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            this.center = center;
            miniLabel.SetAttach(center, true);

            if (transformer != null)
            {
                this.radius = transformer.Untransform(25);
            }

            this.radius      = Math.Min(radius, 10);
            this.infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            styleHelper.Color         = Color.Empty;
            styleHelper.LineSize      = 1;
            styleHelper.PenShape      = PenShape.Solid;
            styleHelper.ValueChanged += StyleHelper_ValueChanged;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Circle");
            }

            style = preset.Clone();
            BindStyle();

            ReinitializeMenu();
        }
Example #2
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Chrono"));
     style.Bind(styleHelper, "Bicolor", "color");
     style.Bind(styleHelper, "Font", "font size");
     style.Bind(styleHelper, "Clock", "clock");
 }
Example #3
0
        public DrawingLine(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            points["a"]  = origin;
            points["b"]  = origin.Translate(10, 0);
            labelMeasure = new KeyframeLabel(GetMiddlePoint(), Color.Black, transformer);

            styleHelper.Color    = Color.DarkSlateGray;
            styleHelper.LineSize = 1;

            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Line");
            }

            style = preset.Clone();
            BindStyle();

            // Fading
            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            // Context menu
            mnuShowMeasure.Click += mnuShowMeasure_Click;
            mnuShowMeasure.Image  = Properties.Drawings.measure;
            mnuSealMeasure.Click += mnuSealMeasure_Click;
            mnuSealMeasure.Image  = Properties.Drawings.linecalibrate;
        }
Example #4
0
        private void CreateStaticExtraDrawings()
        {
            // Add the static extra drawings.
            // These drawings are unique and not attached to any particular key image.

            spotlightManager        = new SpotlightManager();
            autoNumberManager       = new AutoNumberManager(ToolManager.GetStylePreset("AutoNumbers"));
            drawingCoordinateSystem = new DrawingCoordinateSystem(Point.Empty, ToolManager.GetStylePreset("CoordinateSystem"));
            drawingTestGrid         = new DrawingTestGrid();

            extraDrawings.Add(spotlightManager);
            extraDrawings.Add(autoNumberManager);
            extraDrawings.Add(drawingCoordinateSystem);
            extraDrawings.Add(drawingTestGrid);

            // totalStaticExtraDrawings is used to differenciate between static extra drawings like multidrawing managers
            // and dynamic extra drawings like tracks and chronos.
            totalStaticExtraDrawings = extraDrawings.Count;

            spotlightManager.TrackableDrawingAdded += (s, e) =>
            {
                if (AddTrackableDrawingCommand != null)
                {
                    AddTrackableDrawingCommand.Execute(e.TrackableDrawing);
                }
            };

            spotlightManager.TrackableDrawingDeleted += (s, e) => DeleteTrackableDrawing(e.TrackableDrawing);
        }
Example #5
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Rectangle"));
     style.Bind(styleHelper, "Color", "color");
     style.Bind(styleHelper, "LineSize", "line size");
     style.Bind(styleHelper, "PenShape", "pen shape");
 }
Example #6
0
        public DrawingPlane(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null)
        {
            // Decoration
            styleHelper.Color         = Color.Empty;
            styleHelper.GridDivisions = 8;
            styleHelper.Perspective   = true;
            styleHelper.ValueChanged += StyleHelper_ValueChanged;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Plane");
            }

            style = preset.Clone();
            BindStyle();

            infosFading               = new InfosFading(timestamp, averageTimeStampsPerFrame);
            infosFading.UseDefault    = false;
            infosFading.AlwaysVisible = true;

            planeWidth  = 100;
            planeHeight = 100;
            quadPlane   = new QuadrilateralF(planeWidth, planeHeight);

            mnuCalibrate.Click += new EventHandler(mnuCalibrate_Click);
            mnuCalibrate.Image  = Properties.Drawings.linecalibrate;
        }
Example #7
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Plane"));
     style.Bind(styleHelper, "Color", "color");
     style.Bind(styleHelper, "GridDivisions", "divisions");
     style.Bind(styleHelper, "Perspective", "perspective");
 }
Example #8
0
        public DrawingChrono(PointF p, long start, long averageTimeStampsPerFrame, DrawingStyle preset = null)
        {
            // Core
            visibleTimestamp       = start;
            startCountingTimestamp = long.MaxValue;
            stopCountingTimestamp  = long.MaxValue;
            invisibleTimestamp     = long.MaxValue;
            countdown = false;
            mainBackground.Rectangle = new RectangleF(p, SizeF.Empty);

            timecode = "error";

            styleHelper.Bicolor = new Bicolor(Color.Black);
            styleHelper.Font    = new Font("Arial", 16, FontStyle.Bold);

            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Chrono");
            }

            style = preset.Clone();
            BindStyle();

            label     = "";
            showLabel = true;

            // We use the InfosFading utility to fade the chrono away.
            // The refererence frame will be the frame at which fading start.
            // Must be updated on "Hide" menu.
            infosFading = new InfosFading(invisibleTimestamp, averageTimeStampsPerFrame);
            infosFading.FadingFrames = allowedFramesOver;
            infosFading.UseDefault   = false;
        }
Example #9
0
        public DrawingLine(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            points["a"] = origin;
            points["b"] = origin.Translate(10, 0);
            miniLabel.SetAttach(GetMiddlePoint(), true);

            styleHelper.Color         = Color.DarkSlateGray;
            styleHelper.LineSize      = 1;
            styleHelper.LineShape     = LineShape.Solid;
            styleHelper.LineEnding    = LineEnding.None;
            styleHelper.ValueChanged += StyleHelper_ValueChanged;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Line");
            }

            style = preset.Clone();
            BindStyle();

            // Fading
            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            // Context menu
            ReinitializeMenu();
            mnuCalibrate.Click += mnuCalibrate_Click;
            mnuCalibrate.Image  = Properties.Drawings.linecalibrate;
        }
Example #10
0
        public DrawingAngle(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            int length = 50;

            if (transformer != null)
            {
                length = transformer.Untransform(50);
            }

            points.Add("o", origin);
            points.Add("a", origin.Translate(0, -length));
            points.Add("b", origin.Translate(length, 0));

            styleHelper.Bicolor = new Bicolor(Color.Empty);
            styleHelper.Font    = new Font("Arial", 12, FontStyle.Bold);

            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Angle");
            }

            style = preset.Clone();
            BindStyle();

            // Fading
            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            mnuInvertAngle.Click += mnuInvertAngle_Click;
            mnuInvertAngle.Image  = Properties.Drawings.angleinvert;
        }
Example #11
0
        public DrawingPolyline(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null)
        {
            points["0"] = origin;
            points["1"] = origin;

            styleHelper.Color    = Color.DarkSlateGray;
            styleHelper.LineSize = 1;

            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Polyline");
            }

            style = preset.Clone();
            BindStyle();

            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            mnuFinish.Click        += mnuFinish_Click;
            mnuAddThenFinish.Click += mnuAddThenFinish_Click;
            mnuCloseMenu.Click     += mnuCloseMenu_Click;

            mnuFinish.Image        = Properties.Drawings.tick_small;
            mnuAddThenFinish.Image = Properties.Drawings.plus_small;
            mnuCloseMenu.Image     = Properties.Drawings.cross_small;
        }
Example #12
0
        public DrawingAngle(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            int length = 50;

            if (transformer != null)
            {
                length = transformer.Untransform(50);
            }

            points.Add("o", origin);
            points.Add("a", origin.Translate(length, 0));
            points.Add("b", origin.Translate(0, -length));

            styleHelper.Bicolor = new Bicolor(Color.Empty);
            styleHelper.Font    = new Font("Arial", 12, FontStyle.Bold);

            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Angle");
            }

            style = preset.Clone();
            BindStyle();

            // Fading
            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            mnuSignedAngle.Click         += mnuSignedAngle_Click;
            mnuSignedAngle.Checked        = signedAngle;
            mnuCounterClockwise.Click    += mnuCounterClockwise_Click;
            mnuCounterClockwise.Checked   = counterClockwise;
            mnuSupplementaryAngle.Click  += mnuSupplementaryAngle_Click;
            mnuSupplementaryAngle.Checked = supplementaryAngle;
        }
Example #13
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Line"));
     style.Bind(styleHelper, "Color", "color");
     style.Bind(styleHelper, "LineSize", "line size");
     style.Bind(styleHelper, "LineShape", "line shape");
     style.Bind(styleHelper, "LineEnding", "arrows");
 }
        public override AbstractDrawing GetNewDrawing(PointF origin, long timestamp, long averageTimeStampsPerFrame, IImageToViewportTransformer transformer)
        {
            if (ToolManager.Tools.ContainsKey(name))
            {
                stylePreset = ToolManager.GetStylePreset(name);
            }

            GenericPosture posture = GenericPostureManager.Instanciate(id, false);

            return(new DrawingGenericPosture(origin, posture, timestamp, averageTimeStampsPerFrame, stylePreset));
        }
Example #15
0
        public DrawingChrono(PointF p, long start, long averageTimeStampsPerFrame, DrawingStyle preset = null)
        {
            // Core
            visibleTimestamp         = 0;
            startCountingTimestamp   = long.MaxValue;
            stopCountingTimestamp    = long.MaxValue;
            invisibleTimestamp       = long.MaxValue;
            clockOriginTimestamp     = long.MaxValue;
            mainBackground.Rectangle = new RectangleF(p, SizeF.Empty);

            timecode = "error";

            styleHelper.Bicolor = new Bicolor(Color.Black);
            styleHelper.Font    = new Font("Arial", 16, FontStyle.Bold);
            styleHelper.Clock   = false;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Chrono");
            }

            style = preset.Clone();
            BindStyle();

            label     = "";
            showLabel = true;

            // We use the InfosFading utility to fade the chrono away.
            // The refererence frame will be the frame at which fading start.
            // Must be updated on "Hide" menu.
            infosFading = new InfosFading(invisibleTimestamp, averageTimeStampsPerFrame);
            infosFading.FadingFrames = allowedFramesOver;
            infosFading.UseDefault   = false;

            mnuVisibility.Image  = Properties.Drawings.persistence;
            mnuShowBefore.Image  = Properties.Drawings.showbefore;
            mnuShowAfter.Image   = Properties.Drawings.showafter;
            mnuHideBefore.Image  = Properties.Drawings.hidebefore;
            mnuHideAfter.Image   = Properties.Drawings.hideafter;
            mnuShowBefore.Click += MnuShowBefore_Click;
            mnuShowAfter.Click  += MnuShowAfter_Click;
            mnuHideBefore.Click += MnuHideBefore_Click;
            mnuHideAfter.Click  += MnuHideAfter_Click;
            mnuVisibility.DropDownItems.AddRange(new ToolStripItem[] { mnuShowBefore, mnuShowAfter, new ToolStripSeparator(), mnuHideBefore, mnuHideAfter });

            mnuStart.Image       = Properties.Drawings.chronostart;
            mnuStop.Image        = Properties.Drawings.chronostop;
            mnuMarkOrigin.Image  = Properties.Resources.marker;
            mnuStart.Click      += mnuStart_Click;
            mnuStop.Click       += mnuStop_Click;
            mnuMarkOrigin.Click += mnuMarkOrigin_Click;
        }
Example #16
0
        public DrawingRectangle(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            quadImage = new QuadrilateralF(origin, origin.Translate(50, 0), origin.Translate(50, 50), origin.Translate(0, 50));

            styleHelper.Color    = Color.Empty;
            styleHelper.LineSize = 1;
            styleHelper.PenShape = PenShape.Solid;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Rectangle");
            }

            style = preset.Clone();
            BindStyle();

            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);
        }
        public DrawingPencil(PointF origin, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            pointList.Add(origin);
            pointList.Add(origin.Translate(1, 0));
            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            styleHelper.Color    = Color.Black;
            styleHelper.LineSize = 1;
            styleHelper.PenShape = PenShape.Solid;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Pencil");
            }

            style = preset.Clone();
            BindStyle();
        }
        public DrawingDistortionGrid(PointF point, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null)
        {
            styleHelper.Color = Color.Empty;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("DistortionGrid");
            }

            style = preset.Clone();
            BindStyle();

            infosFading               = new InfosFading(timestamp, averageTimeStampsPerFrame);
            infosFading.UseDefault    = true;
            infosFading.AlwaysVisible = false;

            mnuCalibrate.Click += new EventHandler(mnuCalibrate_Click);
            mnuCalibrate.Image  = Properties.Drawings.linecalibrate;
        }
Example #19
0
        public DrawingText(PointF p, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null)
        {
            text = "";
            background.Rectangle = new RectangleF(p, SizeF.Empty);
            arrowEnd             = p.Translate(-50, -50);
            showArrow            = false;

            styleHelper.Bicolor = new Bicolor(Color.Black);
            styleHelper.Font    = new Font("Arial", defaultFontSize, FontStyle.Bold);
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Label");
            }

            style = preset.Clone();
            BindStyle();

            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);
            editing     = false;

            fontText = styleHelper.GetFontDefaultSize(defaultFontSize);

            textBox = new TextBox()
            {
                Visible     = false,
                BackColor   = Color.White,
                BorderStyle = BorderStyle.None,
                Multiline   = true,
                Text        = text,
                Font        = fontText
            };

            textBox.Margin    = new Padding(0, 0, 0, 0);
            textBox.TextAlign = HorizontalAlignment.Left;
            textBox.WordWrap  = false;

            textBox.TextChanged += TextBox_TextChanged;
            UpdateLabelRectangle();

            mnuShowArrow.Click += new EventHandler(mnuShowArrow_Click);
            mnuShowArrow.Image  = Properties.Drawings.arrow;
        }
Example #20
0
        public DrawingCrossMark(PointF center, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            points["0"] = center;
            miniLabel   = new MiniLabel(points["0"], Color.Black, transformer);

            // Decoration & binding with editors
            styleHelper.Color         = Color.CornflowerBlue;
            styleHelper.ValueChanged += StyleHelper_ValueChanged;
            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("CrossMark");
            }

            style = preset.Clone();
            BindStyle();

            infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            ReinitializeMenu();
        }
Example #21
0
        public DrawingCircle(PointF center, long timestamp, long averageTimeStampsPerFrame, DrawingStyle preset = null, IImageToViewportTransformer transformer = null)
        {
            this.center = center;

            if (transformer != null)
            {
                this.radius = transformer.Untransform(25);
            }

            this.radius      = Math.Min(radius, 10);
            this.infosFading = new InfosFading(timestamp, averageTimeStampsPerFrame);

            styleHelper.Color    = Color.Empty;
            styleHelper.LineSize = 1;

            if (preset == null)
            {
                preset = ToolManager.GetStylePreset("Circle");
            }

            style = preset.Clone();
            BindStyle();
        }
Example #22
0
 public DrawingText(PointF p, long timestamp, long averageTimeStampsPerFrame, string text)
     : this(p, timestamp, averageTimeStampsPerFrame, ToolManager.GetStylePreset("Label"))
 {
     this.text = TextHelper.FixMissingCarriageReturns(text);
     UpdateLabelRectangle();
 }
Example #23
0
        private static AbstractDrawing CreateDrawing(Metadata metadata, long timestamp, OpenPosePerson person)
        {
            // We only support files created using the BODY_25 model, not COCO or MPI.
            if (person.pose_keypoints_2d != null && person.pose_keypoints_2d.Count != 75)
            {
                return(null);
            }

            string toolName = "OpenPoseBody25";
            DrawingToolGenericPosture tool = ToolManager.Tools[toolName] as DrawingToolGenericPosture;

            if (tool == null)
            {
                return(null);
            }

            GenericPosture posture = GenericPostureManager.Instanciate(tool.ToolId, true);

            ParsePosture(posture, person);

            DrawingGenericPosture drawing = new DrawingGenericPosture(tool.ToolId, PointF.Empty, posture, timestamp, metadata.AverageTimeStampsPerFrame, ToolManager.GetStylePreset(toolName));

            drawing.Name = "OpenPose";

            // Disable onion skinning.
            drawing.InfosFading.UseDefault                = false;
            drawing.InfosFading.ReferenceTimestamp        = timestamp;
            drawing.InfosFading.AverageTimeStampsPerFrame = metadata.AverageTimeStampsPerFrame;
            drawing.InfosFading.AlwaysVisible             = false;
            drawing.InfosFading.OpaqueFrames              = 1;
            drawing.InfosFading.FadingFrames              = 0;

            return(drawing);
        }
Example #24
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Label"));
     style.Bind(styleHelper, "Bicolor", "back color");
     style.Bind(styleHelper, "Font", "font size");
 }
Example #25
0
 public DrawingPencil(XmlReader xmlReader, PointF scale, TimestampMapper timestampMapper, Metadata parent)
     : this(PointF.Empty, 0, 0, ToolManager.GetStylePreset("Pencil"))
 {
     ReadXml(xmlReader, scale, timestampMapper);
 }
Example #26
0
        /// <summary>
        /// Get the cursor for the passed tool.
        /// This must be called every time the active tool changes or the image scale changes.
        /// </summary>
        public Cursor GetToolCursor(AbstractDrawingTool tool, double stretchFactor)
        {
            if (tool is DrawingToolPointer)
            {
                return(((DrawingToolPointer)tool).GetCursor());
            }

            // Custom cursors.
            // The general guideline is that
            // - We try to use custom cursor where it make sense like for pencil.
            // - Otherwise we fallback to either precision cross or the tool icon.
            // - Drawings that splat themselves at once on the canvas (no dragging a second leg), should use the icon,
            // - Drawings that are created in several steps should use the precision cross.

            if (tool is DrawingToolGenericPosture || tool is DrawingToolAutoNumbers)
            {
                // Many of the GenericPosture tools have a color style element that doesn't really serve any purpose,
                // as the lines making the drawing can have their own color defined in the XML.
                // They are also drawn at once on the canvas like a stamp.
                // So for these we reuse the drawing tool icon as a cursor.
                return(GetCursorIcon(tool));
            }
            else if (tool is DrawingTool)
            {
                // These are the standard tool but defined in XML.
                // For these we try to use a precision cursor or a semantic one.
                DrawingStyle style = ToolManager.GetStylePreset(tool.Name);

                if (tool.Name == "Pencil")
                {
                    return(GetCursorPencil(style, stretchFactor));
                }
                else if (tool.Name == "CrossMark")
                {
                    return(GetCursorCrossMark(style));
                }
                else if (tool.Name == "Grid" ||
                         tool.Name == "Plane" ||
                         tool.Name == "DistortionGrid" ||
                         tool.Name == "Label")
                {
                    // These are stamp-like.
                    return(GetCursorIcon(tool));
                }
                else
                {
                    return(GetCursorPrecision(style, false));
                }
            }
            else if (tool is DrawingToolCoordinateSystem ||
                     tool is DrawingToolMagnifier ||
                     tool is DrawingToolSpotlight ||
                     tool is DrawingToolTestGrid)
            {
                // Special internal tools.
                // Still nice to use a precision cursor with them, but the color might not make sense.
                DrawingStyle style = ToolManager.GetStylePreset(tool.Name);
                return(GetCursorPrecision(style, false));
            }
            else
            {
                return(null);
            }
        }
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("DistortionGrid"));
     style.Bind(styleHelper, "Color", "color");
 }
Example #28
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("CrossMark"));
     style.Bind(styleHelper, "Color", "back color");
 }
Example #29
0
 public DrawingPlane(XmlReader xmlReader, PointF scale, TimestampMapper timestampMapper, Metadata parent)
     : this(false, 0, 0, ToolManager.GetStylePreset("Grid"))
 {
     ReadXml(xmlReader, scale, timestampMapper);
 }
Example #30
0
 private void BindStyle()
 {
     DrawingStyle.SanityCheck(style, ToolManager.GetStylePreset("Angle"));
     style.Bind(styleHelper, "Bicolor", "line color");
 }