예제 #1
0
 public void Execute()
 {
     while (!this._stop)
     {
         this._haveImage.WaitOne();
         if (!this._stop)
         {
             try
             {
                 if (this._image != null && this._faceModels != null)
                 {
                     Image <Bgr, byte> image = this._image.Copy();
                     FaceModel[]       array = this._faceModels.ToArray <FaceModel>();
                     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[] array2      = array;
                     for (int i = 0; i < array2.Length; i++)
                     {
                         FaceModel faceModel = array2[i];
                         if (faceModel.FaceRect.fConf >= this._faceCompreaSet.FaceConf)
                         {
                             Rectangle         rect   = FaceHelper.MC_GetRectangleByRect(faceModel.FaceRect, image.Size);
                             Image <Bgr, byte> image2 = image.GetSubRect(rect).Copy();
                             this.OnShowFaceDeteiveImageEventHandler(image2.ToJpegData(95), faceModel, "");
                             FaceModel faceModel2 = faceModel.Clone();
                             if (this._ifaceCompareBase.ExtractFeature(data, cols, rows, widthstep, ref faceModel2) >= 0)
                             {
                                 List <ResultInfo> list = new List <ResultInfo>();
                                 foreach (FaceTemplate current in this._faceCompreaSet.FaceTemplates.ToList <FaceTemplate>())
                                 {
                                     float num = this._ifaceCompareBase.Compare2Feature(faceModel2.Feature, current.FaceFeature);
                                     if (num >= this._faceCompreaSet.Threshold)
                                     {
                                         list.Add(new ResultInfo
                                         {
                                             FaceImage    = image2.ToJpegData(95),
                                             FaceTemplate = current,
                                             FaceModel    = faceModel2,
                                             Score        = num
                                         });
                                     }
                                 }
                                 image2.Dispose();
                                 if (list.Count > 0)
                                 {
                                     IEnumerable <ResultInfo> arg_1E8_0 = list;
                                     Func <ResultInfo, float> arg_1E8_1;
                                     if ((arg_1E8_1 = FaceCompreaThread.class_c.class_c_9__13_0) == null)
                                     {
                                         arg_1E8_1 = (FaceCompreaThread.class_c.class_c_9__13_0 = new Func <ResultInfo, float>(FaceCompreaThread.class_c.class_c_9._Execute_b__13_0));
                                     }
                                     list = arg_1E8_0.OrderByDescending(arg_1E8_1).Take(this._faceCompreaSet.CompareSuccessCount).ToList <ResultInfo>();
                                     this.OnCompareSuccessEventHandler(list);
                                 }
                             }
                             if (this._faceCompreaSet.IsMaxFace)
                             {
                                 break;
                             }
                         }
                     }
                     image.Dispose();
                 }
             }
             catch (Exception message)
             {
                 this._log.Error(message);
             }
         }
     }
 }