Example #1
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);
        }
        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));
        }
        public void ReadXml(XmlReader xmlReader, PointF scale, TimestampMapper timestampMapper)
        {
            // The tool id must be read before the point list.

            if (xmlReader.MoveToAttribute("id"))
            {
                identifier = new Guid(xmlReader.ReadContentAsString());
            }

            if (xmlReader.MoveToAttribute("name"))
            {
                name = xmlReader.ReadContentAsString();
            }

            xmlReader.ReadStartElement();
            while (xmlReader.NodeType == XmlNodeType.Element)
            {
                switch (xmlReader.Name)
                {
                case "ToolId":
                    toolId         = new Guid(xmlReader.ReadElementContentAsString());
                    genericPosture = GenericPostureManager.Instanciate(toolId, true);
                    break;

                case "Positions":
                    if (genericPosture != null)
                    {
                        ParsePointList(xmlReader, scale);
                    }
                    else
                    {
                        xmlReader.ReadOuterXml();
                    }
                    break;

                case "DrawingStyle":
                    style = new DrawingStyle(xmlReader);
                    BindStyle();
                    break;

                case "InfosFading":
                    infosFading.ReadXml(xmlReader);
                    break;

                default:
                    string unparsed = xmlReader.ReadOuterXml();
                    log.DebugFormat("Unparsed content in KVA XML: {0}", unparsed);
                    break;
                }
            }

            xmlReader.ReadEndElement();
            SignalAllTrackablePointsMoved();

            if (genericPosture != null)
            {
                Init();
            }
            else
            {
                genericPosture = new GenericPosture("", true, false);
            }
        }