예제 #1
0
 private void TryDetectFace(VideoFrame frame)
 {
     try
     {
         ++this._device.FrameCount;
         using (Bitmap imageFromArray = BasicComponents.ImageConverter.GetImageFromArray(frame.Frame))
         {
             FaceInfo[] faceInfoArray = this._engine.DetectAllFaces(ModelImageConverter.ConvertFrom(imageFromArray), this._detectionConfiguration);
             ++this._device.DetectionCount;
             this._device.DetectionFaces += faceInfoArray.Length;
             StoredFace[] storedFaceArray = this.TrySaveFullFrameImage(this.FilterFaces((IEnumerable <FaceInfo>)faceInfoArray), frame, imageFromArray);
             if (storedFaceArray.Length == 0)
             {
                 return;
             }
             foreach (StoredFace face1 in storedFaceArray)
             {
                 FaceFrame face2 = Detector.CropFaceToExtractor(face1, (System.Drawing.Image)imageFromArray);
                 face2.FrameIndex = frame.FrameIndex;
                 face2.Date       = frame.Date;
                 this.AddFaceFrame(face2);
             }
         }
     }
     catch (Exception ex)
     {
         this._log.Error((object)("DetectFace Error Device: " + this._device.Name), ex);
         ++this._device.DetectionErrors;
     }
 }
예제 #2
0
 private static byte[] ExtractTemplate(FaceFrame faceFrame, IEngine engine)
 {
     using (Bitmap imageFromArray = BasicComponents.ImageConverter.GetImageFromArray(faceFrame.Frame))
     {
         FaceData face1 = faceFrame.Face;
         FaceInfo face2 = new FaceInfo()
         {
             DetectionProbability = (double)faceFrame.Face.DetectionProb,
             YawAngle             = (double)face1.YawAngle,
             PitchAngle           = (double)face1.InplaneAngle,
             FaceRectangle        = new TS.Core.Model.Rectangle((double)face1.LeftX, (double)face1.LeftY, (double)face1.Width, (double)face1.Height),
             LeftEye  = new TS.Core.Model.Point((double)face1.LeftEyeX, (double)face1.LeftEyeY),
             RightEye = new TS.Core.Model.Point((double)face1.RightEyeX, (double)face1.RightEyeY)
         };
         return(engine.ExtractTemplate(ModelImageConverter.ConvertFrom(imageFromArray), face2));
     }
 }