コード例 #1
0
 public void Execute()
 {
     while (!this._stop)
     {
         this._haveVido.WaitOne();
         if (!this._stop)
         {
             try
             {
                 if (this._image != null)
                 {
                     if (this._a >= this._faceCompreaSet.FrameRate)
                     {
                         Image <Bgr, byte> image = this._image.Copy();
                         byte[]            data  = image.Mat.GetData(new int[0]);
                         int         cols        = image.Mat.Cols;
                         int         rows        = image.Mat.Rows;
                         int         widthstep   = image.Mat.Cols * 3;
                         FaceModel[] array       = null;
                         int         num;
                         if (this._faceCompreaSet.FaceCompareType != FaceCompareType.FaceCompareV4)
                         {
                             WisFace[] array2;
                             num = this._winFaceCore.DetectFaces(data, cols, rows, widthstep, out array2, 20);
                             if (num > 0)
                             {
                                 array = new FaceModel[num];
                                 for (int i = 0; i < num; i++)
                                 {
                                     array[i] = FaceUnit.WisFaceToFaceModel(array2[i]);
                                 }
                                 if (this.DrawLinsEventHandler != null)
                                 {
                                     this.OnDrawLinsEventHandler(array.ToList <FaceModel>(), image.Size);
                                 }
                             }
                         }
                         else
                         {
                             num = this._faceDetectV4.DetectFaces4Image_only(data, cols, rows, widthstep, out array, 20);
                             if (num > 0)
                             {
                                 array = array.Take(num).ToArray <FaceModel>();
                                 if (this.DrawLinsEventHandler != null)
                                 {
                                     this.OnDrawLinsEventHandler(array.ToList <FaceModel>(), image.Size);
                                 }
                             }
                         }
                         if (num > 0)
                         {
                             this._faceCompreaThread.Start(image.Clone(), array.ToArray <FaceModel>());
                         }
                         image.Dispose();
                         this._a = 1;
                     }
                     else
                     {
                         this._a++;
                     }
                 }
             }
             catch (Exception arg)
             {
                 this._log.Error("fd" + arg);
             }
         }
     }
 }