public CImage()
 {
     hImage = -1;
     CheckForError(FSDK.CreateEmptyImage(ref hImage));
     height = 0;
     width  = 0;
 }
            public IntPtr GetHbitmap()
            {
                IntPtr bmh = IntPtr.Zero;

                CheckForError(FSDK.SaveImageToHBitmap(hImage, ref bmh));
                return(bmh);
            }
            public CImage Copy()
            {
                int NewImage = -1;

                CheckForError(FSDK.CreateEmptyImage(ref NewImage));
                CheckForError(FSDK.CopyImage(hImage, NewImage));
                return(new CImage(NewImage));
            }
            public CImage Rotate90(int Multiplier)
            {
                int NewImage = -1;

                CheckForError(FSDK.CreateEmptyImage(ref NewImage));
                CheckForError(FSDK.RotateImage90(hImage, Multiplier, NewImage));
                return(new CImage(NewImage));
            }
            public CImage Rotate(double Angle)
            {
                int NewImage = -1;

                CheckForError(FSDK.CreateEmptyImage(ref NewImage));
                CheckForError(FSDK.RotateImage(hImage, Angle, NewImage));
                return(new CImage(NewImage));
            }
            public CImage Resize(double Ratio)
            {
                int NewImage = -1;

                CheckForError(FSDK.CreateEmptyImage(ref NewImage));
                CheckForError(FSDK.ResizeImage(hImage, Ratio, NewImage));
                return(new CImage(NewImage));
            }
Beispiel #7
0
 public Face(byte[] face_template, FSDK.TFacePosition face_pos, FSDK.TPoint[] facial_features, FSDK.CImage face_image)
 {
     this.face_template   = face_template;
     this.face_position   = FacePosition.FromFSDK(face_pos);
     this.facial_features = facial_features;
     this.image           = face_image;
     this.face_image      = face_image;
 }
Beispiel #8
0
 public FacsRecognition(FSDK.TPoint[] firstFaceFeatures)
 {
     _firstFaceFeatures = firstFaceFeatures;
     if (_streamWriter == null)
     {
         _streamWriter = new StreamWriter(File.OpenWrite("prueba.txt"));
     }
 }
            public CImage CopyRectReplicateBorder(int x1, int y1, int x2, int y2)
            {
                int NewImage = -1;

                CheckForError(FSDK.CreateEmptyImage(ref NewImage));
                CheckForError(FSDK.CopyRectReplicateBorder(hImage, x1, y1, x2, y2, NewImage));
                return(new CImage(NewImage));
            }
            public FSDK.TFacePosition[] DetectMultipleFaces()
            {
                FSDK.TFacePosition [] FaceArray;
                int detected = 0;
                int res      = FSDK.DetectMultipleFaces(hImage, ref detected, out FaceArray, FSDK.sizeofTFacePosition * 1024);

                if (FSDKE_FACE_NOT_FOUND == res)
                {
                    FaceArray = new FSDK.TFacePosition[0];
                }
                else
                {
                    CheckForError(res);
                }
                return(FaceArray);
            }
 private void Dispose(bool disposing)
 {
     if (!this.disposed)
     {
         if (disposing)
         {
             //dispose managed components
         }
         if (hImage >= 0)
         {
             FSDK.FreeImage(hImage);
             hImage = -1;
         }
     }
     disposed = true;
 }
            public TFacePosition DetectFace()
            {
                TFacePosition fp  = new FSDK.TFacePosition();
                int           res = FSDK.DetectFace(hImage, ref fp);

                if (FSDKE_FACE_NOT_FOUND == res)
                {
                    fp       = new FSDK.TFacePosition();
                    fp.xc    = 0;
                    fp.yc    = 0;
                    fp.angle = 0;
                    fp.w     = 0;
                }
                else
                {
                    CheckForError(res);
                }
                return(fp);
            }
Beispiel #13
0
        public IDictionary<int, ActionUnit> SetActionUnits(FSDK.TPoint[] actualFaceFeatures)
        {
            _actualFaceFeatures = actualFaceFeatures;
            var cheekMotion = 0d;
            var firstLeftCheekMotion = Distance(0, 52, true);
            var actualLeftCheekMotion = Distance(0, 52);
            cheekMotion = -1 * ((actualLeftCheekMotion - firstLeftCheekMotion) / firstLeftCheekMotion);

            double eyebrows, lips, mouth, lipHeight;
            eyebrows = Distance(24, 13) + Distance(0, 16) + Distance(23, 12);
            lips = Distance(3, 4);
            mouth = Distance(9, 56) + Distance(11, 54);

            double browsDistance, browsD, browsD0;
            double eyeHeight, eyeHeightNeutral;
            double lipsH10, lipsH20, lipsH1, lipsH2;
            double lipsWidth, lipsWidthNeutral;
            double lipsDistance, lipsD, lipsD0, lipsDistanceI, lipsDI, lipsD0I;
            double innerBrow, outerBrow, iBrow, oBrow, iBrow0, oBrow0;

            browsD0 = Distance(13, 14, true);
            browsD = Distance(13, 14);
            browsDistance = (browsD - browsD0) / browsD0;

            iBrow0 = Distance(13, 24, true);
            iBrow = Distance(13, 24);
            innerBrow = (iBrow - iBrow0) / iBrow0;

            oBrow0 = Distance(12, 23, true);
            oBrow = Distance(12, 23);
            outerBrow = (oBrow - oBrow0) / oBrow0;

            lipsH10 = Distance(54, 61, true);
            lipsH20 = Distance(55, 64, true);

            lipsH1 = Distance(54, 61);
            lipsH2 = Distance(55, 64);
            lipsWidthNeutral = Distance(3, 4, true);
            lipsWidth = Distance(3, 4);

            lipsD0 = Distance(3, 27, true);
            lipsD = Distance(3, 27);
            lipsDistance = -1 * ((lipsD - lipsD0) / lipsD0);

            lipsD0I = Distance(4, 31, true);
            lipsDI = Distance(4, 31);
            lipsDistanceI = -1 * ((lipsD - lipsD0) / lipsD0);

            lipHeight = ((lipsH1 + lipsH2) - (lipsH10 + lipsH20)) / (lipsH10 + lipsH20);
            _lipsWidthMovement = (lipsWidth - lipsWidthNeutral) / lipsWidthNeutral;

            eyeHeightNeutral = Distance(27, 28, true);
            eyeHeight = Distance(27, 28);
            _eyeHeightMovement = (eyeHeight - eyeHeightNeutral) / eyeHeightNeutral;

            int totalFrame = 0;
            int iBefore = totalFrame - 1;// - 1;
            var actionUnits = new ActionUnits()
                .With(AUMovement.CheekMotion, cheekMotion)
                .With(AUMovement.LipHeight, lipHeight)
                .With(AUMovement.LipsWidth, _lipsWidthMovement)
                .With(AUMovement.LipsDistanceI, lipsDistanceI)
                .With(AUMovement.LipsDistance, lipsDistance)
                .GetActionUnits();
            return actionUnits;
        }
        private void draw(FSDK.TFacePosition FacePosition)
        {
            if (FacePosition.w != 0)
            {
                gr.DrawRectangle(Pens.LightPink,
                                FacePosition.xc - FacePosition.w / 2,
                                FacePosition.yc - FacePosition.w / 2,
                                FacePosition.w,
                                FacePosition.w);//标示人脸

            }
        }
 public FSDK.TPoint[] DetectFacialFeaturesInRegion(ref FSDK.TFacePosition FacePosition)
 {
     FSDK.TPoint[] feats;
     CheckForError(FSDK.DetectFacialFeaturesInRegion(hImage, ref FacePosition, out feats));
     return(feats);
 }
 public FSDK.TPoint[] DetectFacialFeatures()
 {
     FSDK.TPoint[] feats;
     CheckForError(FSDK.DetectFacialFeatures(hImage, out feats));
     return(feats);
 }
 CImage(System.Drawing.Image ImageObject)
 {
     hImage = -1;
     CheckForError(FSDK.LoadImageFromCLRImage(ref hImage, ImageObject));
     PopulateHeightAndWidth();
 }
 public CImage MirrorVertical()
 {
     CheckForError(FSDK.MirrorImage(hImage, false));
     return(this);
 }
 public CImage(string FileName)
 {
     hImage = -1;
     CheckForError(FSDK.LoadImageFromFile(ref hImage, FileName));
     PopulateHeightAndWidth();
 }
 CImage(IntPtr BitmapHandle)
 {
     hImage = -1;
     CheckForError(FSDK.LoadImageFromHBitmap(ref hImage, BitmapHandle));
     PopulateHeightAndWidth();
 }
 public byte[] GetFaceTemplateUsingEyes(ref FSDK.TPoint[] EyeCoords)
 {
     byte[] tmpl;
     CheckForError(FSDK.GetFaceTemplateUsingEyes(hImage, ref EyeCoords, out tmpl));
     return(tmpl);
 }
 public CImage MirrorHorizontal()
 {
     CheckForError(FSDK.MirrorImage(hImage, true));
     return(this);
 }
 public byte[] GetFaceTemplateInRegion(ref FSDK.TFacePosition FacePosition)
 {
     byte[] tmpl;
     CheckForError(FSDK.GetFaceTemplateInRegion(hImage, ref FacePosition, out tmpl));
     return(tmpl);
 }
 private void PopulateHeightAndWidth()
 {
     CheckForError(FSDK.GetImageHeight(hImage, ref height));
     CheckForError(FSDK.GetImageWidth(hImage, ref width));
 }
 public byte[] GetFaceTemplateUsingEyes(ref FSDK.TPoint[] EyeCoords)
 {
     byte[] tmpl;
     CheckForError(FSDK.GetFaceTemplateUsingEyes(hImage, ref EyeCoords, out tmpl));
     return tmpl;
 }
 public FSDK.TPoint[] DetectFacialFeaturesInRegion(ref FSDK.TFacePosition FacePosition)
 {
     FSDK.TPoint[] feats;
     CheckForError(FSDK.DetectFacialFeaturesInRegion(hImage, ref FacePosition, out feats));
     return feats;
 }
 public void Save(string FileName)
 {
     CheckForError(FSDK.SaveImageToFile(hImage, FileName));
 }
 public byte[] GetFaceTemplateInRegion(ref FSDK.TFacePosition FacePosition)
 {
     byte[] tmpl;
     CheckForError(FSDK.GetFaceTemplateInRegion(hImage, ref FacePosition, out tmpl));
     return tmpl;
 }
 public System.Drawing.Image ToCLRImage()
 {
     System.Drawing.Image img = new System.Drawing.Bitmap(1, 1);
     CheckForError(FSDK.SaveImageToCLRImage(hImage, ref img));
     return(img);
 }
Beispiel #30
0
 public static FacePosition FromFSDK(FSDK.TFacePosition obj)
 {
     return new FacePosition(obj.angle, obj.w, obj.xc, obj.yc);
 }
 public byte[] GetFaceTemplate()
 {
     byte[] tmpl;
     CheckForError(FSDK.GetFaceTemplate(hImage, out tmpl));
     return(tmpl);
 }