Ejemplo n.º 1
0
 public void LoadDetectionResults(List <DetectionResult> detectionResults)
 {
     foreach (var detectionResult in detectionResults)
     {
         var faceControl = new FaceControl();
         faceControl.FaceImageSource = detectionResult.ExtractFrame;
         int faceFrameSeconds = FaceImageHelper.ExtractSecondsInFaceImageName(detectionResult.ExtractFrame);
         faceControl.FaceName = string.Format("{0}s, {1}%", faceFrameSeconds, detectionResult.Confidence * 100);
         flpResult.Controls.Add(faceControl);
     }
 }
Ejemplo n.º 2
0
 public Task <List <string> > ExportToImagesAsync(IEnumerable <FrameHighlight> frameHighlights, string outputDir)
 {
     return(Task.Run(() =>
     {
         List <string> facesList = new List <string>();
         using (VideoFileReader reader = new VideoFileReader())
         {
             reader.Open(VideoInputPath);
             long currentFrame = 0;
             int lastTime = -1;
             foreach (var frameHighlight in frameHighlights)
             {
                 int frameTime = (int)frameHighlight.Time;
                 if (lastTime < frameTime)
                 {
                     using (var frameImage = GetBitmap(reader, ref currentFrame, frameTime))
                     {
                         if (frameImage == null)
                         {
                             break;
                         }
                         for (int i = 0; i < frameHighlight.HighlightRects.Length; ++i)
                         {
                             var rect = frameHighlight.HighlightRects[i];
                             if (!rect.IsEmpty)
                             {
                                 using (var faceImage = CropBitmap(frameImage, rect))
                                 {
                                     string faceFilePath = Path.Combine(outputDir, FaceImageHelper.BuildFaceImageName(frameTime, i));
                                     faceImage.Save(faceFilePath);
                                     facesList.Add(faceFilePath);
                                 }
                             }
                         }
                     }
                     lastTime = frameTime;
                 }
             }
         }
         return facesList;
     }));
 }