Esempio n. 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);
        }
Esempio n. 2
0
        private void ImportOtherDrawingsData(Metadata metadata)
        {
            LinearKinematics linearKinematics = new LinearKinematics();

            // Trackable drawing's individual points.
            foreach (ITrackable trackable in metadata.TrackableDrawings())
            {
                Dictionary <string, TrackablePoint> trackablePoints = metadata.TrackabilityManager.GetTrackablePoints(trackable);

                if (trackablePoints == null)
                {
                    continue;
                }

                foreach (var pair in trackablePoints)
                {
                    TrackablePoint        tp       = pair.Value;
                    Timeline <TrackFrame> timeline = pair.Value.Timeline;
                    if (timeline.Count == 0)
                    {
                        continue;
                    }

                    List <TimedPoint>  samples = timeline.Enumerate().Select(p => new TimedPoint(p.Location.X, p.Location.Y, p.Time)).ToList();
                    FilteredTrajectory traj    = new FilteredTrajectory();
                    traj.Initialize(samples, metadata.CalibrationHelper);

                    TimeSeriesCollection tsc = linearKinematics.BuildKinematics(traj, metadata.CalibrationHelper);

                    string name  = trackable.Name;
                    Color  color = trackable.Color;

                    // Custom drawings may have dedicated names for their handles.
                    DrawingGenericPosture dgp = trackable as DrawingGenericPosture;
                    if (dgp == null)
                    {
                        name = name + " - " + pair.Key;
                    }
                    else
                    {
                        foreach (var handle in dgp.GenericPostureHandles)
                        {
                            if (handle.Reference.ToString() != pair.Key)
                            {
                                continue;
                            }

                            name  = name + " - " + (string.IsNullOrEmpty(handle.Name) ? pair.Key : handle.Name);
                            color = handle.Color == Color.Transparent ? trackable.Color : handle.Color;
                            break;
                        }
                    }

                    TimeSeriesPlotData data = new TimeSeriesPlotData(name, color, tsc);
                    timeSeriesData.Add(data);
                    filteredTrajectories.Add(data, traj);
                }
            }
        }
        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);
            AbstractDrawing drawing = new DrawingGenericPosture(id, origin, posture, timestamp, averageTimeStampsPerFrame, stylePreset);

            return(drawing);
        }