示例#1
0
        // starts detector
        public override void Run(IProgress <DetectionResults> progress)
        {
            // detection loop - detects on each frame
            while (!userWantsToExit) // setting userWantsToExit to true breaks this loop
            {
                // get latest detected frame from input, which we set during the config
                if (opWrapper.WaitAndPop(out datumProcessed))                                     // detection data gets put into datumProcessed
                {
                    if (datumProcessed != null && datumProcessed.TryGet(out data) && !data.Empty) // if datumProcessed exists && we can get the data sucessfully && retrieved data exists
                    {
                        Datum d = data.ToArray()[0].Get();                                        // retrieve datum object which contains the keypoint data

                        progress.Report(new DetectionResults()                                    // report calculated keypoint data with DetectionResults object
                        {
                            data       = d,                                                       // keypoint data
                            isFinished = false                                                    // are we finished with the detection
                        });
                    }
                }
                else // can't get next frame, so we end the detection loop
                {
                    OpenPose.Log("Processed datum could not be emplaced.", Priority.High);
                    userWantsToExit = true;
                    break;
                }
            }

            progress.Report(new DetectionResults() // when finished, we report with isFinished set to true
            {
                data       = null,
                isFinished = true
            });

            opWrapper.Dispose(); // dispose of openpose wrapper
        }
 public Datum ProcessFrame(Mat image)                                              // gets result keypoints from OpenPoseDotNet.Mat
 {
     datumProcessed = opWrapper.EmplaceAndPop(image);                              // method detects on OpenPoseDotNet.Mat
     if (datumProcessed != null && datumProcessed.TryGet(out data) && !data.Empty) // if datumProcessed exists && we can get the data sucessfully && retrieved data exists
     {
         Datum result = data.ToArray()[0].Get();                                   // retrieve datum object which contains the keypoint data
         opWrapper.Dispose();                                                      // dispose of wrapper after detection
         return(result);
     }
     else
     {
         OpenPose.Log("Nullptr or empty datumsPtr found.", Priority.High);
         return(null);
     }
 }