Exemplo n.º 1
0
        public virtual int DetectFaces4Image_only(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel, int maxFaceCount)
        {
            int result;

            try
            {
                object obj = this._obj;
                lock (obj)
                {
                    FaceModelRectV4[] array = new FaceModelRectV4[10];
                    int num = FaceDetectV4._FacesDetects(this._faceEngne, bgr24, width, height, widthstep, array, 10);
                    if (num > 0)
                    {
                        FaceModelV4[] array2 = new FaceModelV4[num];
                        for (int i = 0; i < num; i++)
                        {
                            array2[i].FaceRect = array[i];
                        }
                        faceModel = FaceUnit.FaceModelV4ToFaceModel(array2);
                    }
                    else
                    {
                        faceModel = new FaceModel[0];
                    }
                    result = num;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 2
0
        public static FaceModel WisFaceToFaceModel(WisFace wisFace)
        {
            //return new FaceModel
            //{
            //	FaceRect = FaceUnit.WisRectToFaceModelRect(wisFace),
            //	LeftEyeFacePoint = FaceUnit.WisPointToFaceModelPoint(wisFace.ptLeftEye),
            //	RightEyeFacePoint = FaceUnit.WisPointToFaceModelPoint(wisFace.ptRightEye),
            //	LeftMouthFacePoint = FaceUnit.WisPointToFaceModelPoint(wisFace.ptMouthLeft),
            //	RightMouthFacePoint = FaceUnit.WisPointToFaceModelPoint(wisFace.ptMouthRight),
            //	Nose = FaceUnit.WisPointToFaceModelPoint(wisFace.ptNose),
            //	FaceRect =
            //	{
            //		fConf = wisFace.conf,
            //		Roll = wisFace.roll,
            //		Yaw = wisFace.yaw,
            //		Pitch = wisFace.pitch
            //	}
            //};

            FaceModel y = new FaceModel
            {
                FaceRect            = FaceUnit.WisRectToFaceModelRect(wisFace),
                LeftEyeFacePoint    = FaceUnit.WisPointToFaceModelPoint(wisFace.ptLeftEye),
                RightEyeFacePoint   = FaceUnit.WisPointToFaceModelPoint(wisFace.ptRightEye),
                LeftMouthFacePoint  = FaceUnit.WisPointToFaceModelPoint(wisFace.ptMouthLeft),
                RightMouthFacePoint = FaceUnit.WisPointToFaceModelPoint(wisFace.ptMouthRight),
                Nose = FaceUnit.WisPointToFaceModelPoint(wisFace.ptNose),
            };

            y.FaceRect.fConf = wisFace.conf;
            y.FaceRect.Roll  = wisFace.roll;
            y.FaceRect.Yaw   = wisFace.yaw;
            y.FaceRect.Pitch = wisFace.pitch;
            return(y);
        }
Exemplo n.º 3
0
        int IFaceCompare.ExtractFeature(byte[] bgr24, int width, int height, int widthstep, ref FaceModel faceModel)
        {
            int result;

            try
            {
                object obj = FaceComparePro._obj;
                lock (obj)
                {
                    FaceModelV3[] array = new FaceModelV3[1];
                    int           num   = FaceComparePro._FacesDetect_AlphaPro(FaceComparePro.FaceEngne, bgr24, width, height, widthstep, array, 1);
                    if (num > 0)
                    {
                        faceModel = FaceUnit.FaceModelV3ToFaceModel(array.FirstOrDefault <FaceModelV3>());
                    }
                    else
                    {
                        faceModel = new FaceModel();
                        num       = -1;
                    }
                    result = num;
                }
            }
            catch (Exception arg_56_0)
            {
                throw arg_56_0;
            }
            return(result);
        }
Exemplo n.º 4
0
        int IFaceCompare.DetectFaces4Image(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel)
        {
            int result;

            try
            {
                object obj = FaceCompareV2._obj;
                lock (obj)
                {
                    FaceModelV2[] array = new FaceModelV2[20];
                    int           num   = FaceCompareV2._FacesDetect(FaceCompareV2._faceEngne, bgr24, width, height, widthstep, array, 20);
                    if (num > 0)
                    {
                        for (int i = 0; i < num; i++)
                        {
                            FaceCompareV2._ExtractFeature(FaceCompareV2._faceEngne, bgr24, width, height, widthstep, ref array[i]);
                        }
                    }
                    faceModel = FaceUnit.FaceModelV2ToFaceModel(array.Take(num).ToArray <FaceModelV2>());
                    result    = num;
                }
            }
            catch (Exception arg_7A_0)
            {
                throw arg_7A_0;
            }
            return(result);
        }
Exemplo n.º 5
0
 public static FaceModel FaceModelV4ToFaceModel(FaceModelV4 faceModelV4)
 {
     return(new FaceModel
     {
         FaceRect = FaceUnit.FaceModelRectV3ToFaceModelRect(faceModelV4.FaceRect),
         Feature = faceModelV4.Feature
     });
 }
Exemplo n.º 6
0
 public static FaceModel[] FaceModelV4ToFaceModel(FaceModelV4[] faceModelV4)
 {
     FaceModel[] array = new FaceModel[faceModelV4.Length];
     for (int i = 0; i < faceModelV4.Length; i++)
     {
         array[i] = FaceUnit.FaceModelV4ToFaceModel(faceModelV4[i]);
     }
     return(array);
 }
Exemplo n.º 7
0
        public static FaceModel FaceModelV2ToFaceModel(FaceModelV2 faceModelV2)
        {
            //return new FaceModel
            //{
            //    FaceRect = FaceUnit.FaceModelRectV3ToFaceModelRect(faceModelV2.FaceRect),
            //    Feature = faceModelV2.Feature,
            //    LeftEyeFacePoint = FaceUnit.ToFaceModelPoint(faceModelV2.LeftEyeFacePointInt),
            //    LeftMouthFacePoint = FaceUnit.ToFaceModelPoint(faceModelV2.LeftMouthFacePointInt),
            //    Nose = FaceUnit.ToFaceModelPoint(faceModelV2.Nose),
            //    RightEyeFacePoint = FaceUnit.ToFaceModelPoint(faceModelV2.RightEyeFacePointInt),
            //    RightMouthFacePoint = FaceUnit.ToFaceModelPoint(faceModelV2.RightMouthFacePointInt),
            //    FaceRect.fConf = faceModelV2.Conf,
            //    FaceRect.fRotAngle = faceModelV2.Angle
            //    //FaceRect =
            //    //{
            //    //    fConf = faceModelV2.Conf,
            //    //    fRotAngle = faceModelV2.Angle
            //    //}

            //    //FaceRect.fConf = faceModelV2.Conf;
            //    //FaceRect.fRotAngle = faceModelV2.Angle;
            //    //    =
            //    //{
            //    //    fConf = faceModelV2.Conf,
            //    //    fRotAngle = faceModelV2.Angle
            //    //}
            //};
            FaceModel x = new FaceModel
            {
                FaceRect           = FaceUnit.FaceModelRectV3ToFaceModelRect(faceModelV2.FaceRect),
                Feature            = faceModelV2.Feature,
                LeftEyeFacePoint   = FaceUnit.ToFaceModelPoint(faceModelV2.LeftEyeFacePointInt),
                LeftMouthFacePoint = FaceUnit.ToFaceModelPoint(faceModelV2.LeftMouthFacePointInt),
                Nose = FaceUnit.ToFaceModelPoint(faceModelV2.Nose),
                RightEyeFacePoint   = FaceUnit.ToFaceModelPoint(faceModelV2.RightEyeFacePointInt),
                RightMouthFacePoint = FaceUnit.ToFaceModelPoint(faceModelV2.RightMouthFacePointInt)
                                      //FaceRect.fConf = faceModelV2.Conf,
                                      //FaceRect.fRotAngle = faceModelV2.Angle
                                      //FaceRect =
                                      //{
                                      //    fConf = faceModelV2.Conf,
                                      //    fRotAngle = faceModelV2.Angle
                                      //}

                                      //FaceRect.fConf = faceModelV2.Conf;
                                      //FaceRect.fRotAngle = faceModelV2.Angle;
                                      //    =
                                      //{
                                      //    fConf = faceModelV2.Conf,
                                      //    fRotAngle = faceModelV2.Angle
                                      //}
            };

            x.FaceRect.fConf     = faceModelV2.Conf;
            x.FaceRect.fRotAngle = faceModelV2.Angle;
            return(x);
        }
Exemplo n.º 8
0
 public static FaceModel FaceModelV3ToFaceModel(FaceModelV3 faceModelV3)
 {
     return(new FaceModel
     {
         FaceRect = FaceUnit.FaceModelRectV3ToFaceModelRect(faceModelV3.FaceRect),
         Feature = faceModelV3.Feature,
         LeftEyeFacePoint = FaceUnit.ToFaceModelPoint(faceModelV3.LeftEyeFacePointInt),
         LeftMouthFacePoint = FaceUnit.ToFaceModelPoint(faceModelV3.LeftMouthFacePointInt),
         Nose = FaceUnit.ToFaceModelPoint(faceModelV3.Nose),
         RightEyeFacePoint = FaceUnit.ToFaceModelPoint(faceModelV3.RightEyeFacePointInt),
         RightMouthFacePoint = FaceUnit.ToFaceModelPoint(faceModelV3.RightMouthFacePointInt)
     });
 }
Exemplo n.º 9
0
 public static FaceModel[] FaceModelV2ToFaceModel(FaceModelV2[] faceModelV2)
 {
     FaceModel[] array = new FaceModel[faceModelV2.Length];
     for (int i = 0; i < faceModelV2.Length; i++)
     {
         array[i] = FaceUnit.FaceModelV2ToFaceModel(faceModelV2[i]);
     }
     if (array.Length > 1)
     {
         IEnumerable <FaceModel> arg_4C_0 = array;
         Func <FaceModel, int>   arg_4C_1;
         if ((arg_4C_1 = FaceUnit.class_c.class_c_9__0_0) == null)
         {
             arg_4C_1 = (FaceUnit.class_c.class_c_9__0_0 = new Func <FaceModel, int>(FaceUnit.class_c.class_c_9._FaceModelV2ToFaceModel_b__0_0));
         }
         array = arg_4C_0.OrderByDescending(arg_4C_1).ToArray <FaceModel>();
     }
     return(array);
 }
Exemplo n.º 10
0
        public static int DetectFaces4Image_AlphaPro(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel, int maxFaceCount)
        {
            int result;

            try
            {
                object obj = FaceCompare._obj;
                lock (obj)
                {
                    FaceModelV3[] array = new FaceModelV3[maxFaceCount];
                    int           num   = FaceCompare._FacesDetect_AlphaPro(FaceCompare.FaceEngne, bgr24, width, height, widthstep, array, maxFaceCount);
                    faceModel = FaceUnit.FaceModelV3ToFaceModel(array.Take(num).ToArray <FaceModelV3>());
                    result    = num;
                }
            }
            catch (Exception arg_4D_0)
            {
                throw arg_4D_0;
            }
            return(result);
        }
Exemplo n.º 11
0
        int IFaceCompare.ExtractFeature(byte[] bgr24, int width, int height, int widthstep, ref FaceModel faceModel)
        {
            int result;

            try
            {
                object obj = FaceCompareV2._obj;
                lock (obj)
                {
                    FaceModelV2 faceModelV = faceModel.ToFaceModelV2();
                    int         arg_33_0   = FaceCompareV2._ExtractFeature(FaceCompareV2._faceEngne, bgr24, width, height, widthstep, ref faceModelV);
                    faceModel = FaceUnit.FaceModelV2ToFaceModel(faceModelV);
                    result    = arg_33_0;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 12
0
        int IFaceCompare.DetectFaces4Image_only(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel, int maxFaceCount)
        {
            int result;

            try
            {
                object obj = FaceCompareV2._obj;
                lock (obj)
                {
                    FaceModelV2[] array = new FaceModelV2[maxFaceCount];
                    int           num   = FaceCompareV2._FacesDetect(FaceCompareV2._faceEngne, bgr24, width, height, widthstep, array, maxFaceCount);
                    faceModel = FaceUnit.FaceModelV2ToFaceModel(array.Take(num).ToArray <FaceModelV2>());
                    result    = num;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }
Exemplo n.º 13
0
        int IFaceCompare.DetectFaces4Image(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel)
        {
            int result;

            try
            {
                object obj = FaceCompareBase._obj;
                lock (obj)
                {
                    FaceModelV3[] array = new FaceModelV3[20];
                    int           num   = FaceCompareBase._FacesDetect(FaceCompareBase._faceEngne, bgr24, width, height, widthstep, array, 20);
                    faceModel = FaceUnit.FaceModelV3ToFaceModel(array.Take(num).ToArray <FaceModelV3>());
                    result    = num;
                }
            }
            catch (Exception arg_4E_0)
            {
                throw arg_4E_0;
            }
            return(result);
        }
Exemplo n.º 14
0
        public static int MC_DetectFaces4Image(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel, int MaxCount)
        {
            int result;

            try
            {
                object obj = FaceCompare._obj;
                lock (obj)
                {
                    FaceModelV3[] array    = new FaceModelV3[20];
                    int           arg_32_0 = FaceCompare._FacesDetect(FaceCompare.FaceEngne, bgr24, width, height, widthstep, array, 20);
                    faceModel = FaceUnit.FaceModelV3ToFaceModel(array);
                    result    = arg_32_0;
                }
            }
            catch (Exception arg_3F_0)
            {
                throw arg_3F_0;
            }
            return(result);
        }
Exemplo n.º 15
0
        public static int MC_DetectFaces4Image(Image <Bgr, byte> image, out FaceModel[] faceModel)
        {
            int result;

            try
            {
                object obj = FaceCompare._obj;
                lock (obj)
                {
                    FaceModelV3[] array    = new FaceModelV3[20];
                    int           arg_4A_0 = FaceCompare._FacesDetect(FaceCompare.FaceEngne, image.Bytes, image.Width, image.Height, image.MIplImage.WidthStep, array, 20);
                    faceModel = FaceUnit.FaceModelV3ToFaceModel(array);
                    result    = arg_4A_0;
                }
            }
            catch (Exception arg_57_0)
            {
                throw arg_57_0;
            }
            return(result);
        }
Exemplo n.º 16
0
        public static int MC_ExtractFeature(Image <Bgr, byte> image, ref FaceModel faceModel)
        {
            int result;

            try
            {
                object obj = FaceCompare._obj;
                lock (obj)
                {
                    FaceModelV3 faceModelV = faceModel.ToFaceModelV3();
                    int         arg_49_0   = FaceCompare._ExtractFeature(FaceCompare.FaceEngne, image.Bytes, image.Width, image.Height, image.MIplImage.Width, ref faceModelV);
                    faceModel = FaceUnit.FaceModelV3ToFaceModel(faceModelV);
                    result    = arg_49_0;
                }
            }
            catch (Exception arg_56_0)
            {
                throw arg_56_0;
            }
            return(result);
        }
Exemplo n.º 17
0
        int IFaceCompare.DetectFaces4Image(byte[] bgr24, int width, int height, int widthstep, out FaceModel[] faceModel, int maxFaceCount)
        {
            int result;

            try
            {
                object obj = this._obj;
                lock (obj)
                {
                    FaceModelRectV4[] array = new FaceModelRectV4[maxFaceCount];
                    int num = FaceCompareV4._FacesDetects(this._faceEngne, bgr24, width, height, widthstep, array, 10);
                    if (num > 0)
                    {
                        FaceModelV4[] array2 = new FaceModelV4[num];
                        for (int i = 0; i < num; i++)
                        {
                            array2[i].FaceRect = array[i];
                            byte[] feature = new byte[512];
                            if (FaceCompareV4._ExtractFeature(this._faceEngne, bgr24, width, height, widthstep, array[i], feature) == 0)
                            {
                                array2[i].Feature = feature;
                            }
                        }
                        faceModel = FaceUnit.FaceModelV4ToFaceModel(array2);
                    }
                    else
                    {
                        faceModel = new FaceModel[0];
                    }
                    result = num;
                }
            }
            catch (Exception)
            {
                throw;
            }
            return(result);
        }