Exemplo n.º 1
0
        private static void ParsePosture(GenericPosture posture, OpenPosePerson person)
        {
            // We assume pixel values for x and y. (See flag keypoint_scale)
            // The order of entries in the custom tool is the same.
            for (int i = 0; i < person.pose_keypoints_2d.Count; i += 3)
            {
                float x = person.pose_keypoints_2d[i + 0];
                float y = person.pose_keypoints_2d[i + 1];
                float c = person.pose_keypoints_2d[i + 2];

                int index = i / 3;
                posture.PointList[index] = new PointF(x, y);

                // Visibility of the point and incoming segments depends on confidence.
                if (options.ContainsKey(index) && posture.Options.ContainsKey(options[index]))
                {
                    posture.Options[options[index]].Value = c >= confidenceThreshold;
                }
            }
        }
Exemplo n.º 2
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);
        }