private int recongnize(FaceTemplate template)
        {
            bool match = false;

            int i;

            for (i = 0; i < UserTemplates.Count; i++)
            {
                foreach (FaceTemplate t in UserTemplates[i])
                {
                    float        Siminarity = 0.0f;
                    FaceTemplate t1         = t;
                    FSDK.MatchFaces(ref template.templateData, ref t1.templateData, ref Siminarity);
                    float threashold = 0.0f;
                    //////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    FSDK.GetMatchingThresholdAtFAR(0.25f, ref threashold);
                    //0.1表示程序误认为不同的人为检测对象的几率是0.1   该取值范围0~1
                    ////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                    if (Siminarity > threashold)
                    {
                        match = true;
                        break;
                    }
                }
                if (match)
                {
                    return(i);
                }
            }
            return(-1);
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("Jl3R1DBC1qVQonaiBAq8gK7KzetXbFb4r+OF1DLzInT3KyXHvgHNLyk2Tymk5G6GBv58/Oqn+SQeOWCQfQASTV1Mcd7RQAsrmW02oOa9lhZsMockPLoEnpsH4W1I0+zmxmUwecWKEep9j4BrYhQWuiA3QcNeQO+tfyLOHASk3+M="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string [] cameraList;
            int       count;

            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = cameraList[0]; // choose the first camera

            FSDKCam.VideoFormatInfo [] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

            int VideoFormat = 0; // choose a video format

            pictureBox1.Width  = formatList[VideoFormat].Width;
            pictureBox1.Height = formatList[VideoFormat].Height;
            this.Width         = formatList[VideoFormat].Width + 48;
            this.Height        = formatList[VideoFormat].Height + 96;
        }
        private void Findface(Bitmap bitmap)
        {
            var img = 0;

            var image = bitmap;

            image.Save("test.png");
            FSDK.LoadImageFromFile(ref img, "test.png");

            Face.Source = new BitmapImage(new Uri("test.png", UriKind.Relative));

            FSDK.TPoint[] array;
            FSDK.DetectFacialFeatures(img, out array);
            if (array != null)
            {
                Face.Source = DrawPoints(image, array);
            }


            FSDK.TFacePosition[] faces;
            int faceCount = 0;

            FSDK.DetectMultipleFaces(img, ref faceCount, out faces, 10000);


            if (faces != null)
            {
                foreach (var f in faces)
                {
                    Face.Source = DrawCircle(image, f.xc, f.yc, f.w);
                }
            }
        }
Beispiel #4
0
    public void InitializeCamera(PictureBox pictureBox)
    {
        faceRecognitionController = new FaceRecognitionController();
        currentPictureBox         = pictureBox;

        if (FSDK.FSDKE_OK != FSDK.ActivateLibrary(Constants.LICENCE_KEY))
        {
            MessageBox.Show(Constants.ERROR_ACTIVATING_FACESDK, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Application.Exit();
        }

        FSDK.InitializeLibrary();
        FSDKCam.InitializeCapturing();

        string[] cameraList;
        int      cameraCount;

        FSDKCam.GetCameraList(out cameraList, out cameraCount);

        if (cameraCount == 0)
        {
            MessageBox.Show(Constants.NO_CAMERA_ERROR, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Application.Exit();
        }

        cameraName = cameraList[0];
        FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out cameraCount);

        int videoFormat = 0;

        currentPictureBox.Width  = formatList[videoFormat].Width;
        currentPictureBox.Height = formatList[videoFormat].Height;
    }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("gyYgVWQTSzjiuGB/hH8dKgg0QrrIuhoHdfUCzD9rY+vru3WRZsaezTX6YWj9osdI/cmxY1NSdLkyWuugMPCxUG7/xNLegHLeaUpzVyKpDkaWL8tJIUsIL7xv9bhmgifPbAyTDuxF3VGxXmHkv/L/MStf9kdXV/A1vVvT93QC4vQ="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string[] cameraList;
            int      count;

            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = cameraList[0];

            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

            //int VideoFormat = 0; // choose a video format
            //pictureBox1.Width = formatList[VideoFormat].Width;
            //pictureBox1.Height = formatList[VideoFormat].Height;
            //this.Width = formatList[VideoFormat].Width + 48;
            //this.Height = formatList[VideoFormat].Height + 96;
        }
        //主处理部分
        private void start()
        {
            loadUsers();
            NeedClose = false;
            int CameraHandle = CameraStart();

            //设置监测条件  其中

            /*
             * SetFaceDetectionParameters(false, false, 100);参数1将人脸的检测角度从正负15°拓展到30°
             *                                               参数2将决定是否检测人脸所处的角度
             *                                               参数3是缩放大小 值越大质量越高
             *现在有效距离1米  最大有效距离1.3米
             * /*
             * SetFaceDetectionThreshold(3);设置对于人脸的敏感性 数值越高就越对于人脸不敏感 只能在人脸十分清晰的时候才能将其检测
             */
            FSDK.SetFaceDetectionParameters(true, false, 100);
            FSDK.SetFaceDetectionThreshold(1);
            while (!NeedClose)
            {
                try
                {
                    switch (programState)
                    {
                    case ProgramState.psNormal:
                        Normalhandle();
                        break;

                    case ProgramState.psAddFace:
                        AddFacehandle();
                        lock (obj)
                        {
                            ok = true;
                            Monitor.PulseAll(obj);
                            programState = ProgramState.psNormal;
                        }
                        break;

                    case ProgramState.psRecognize:
                        Recongnizehandle();
                        lock (obj)
                        {
                            ok = true;
                            Monitor.PulseAll(obj);
                            programState = ProgramState.psNormal;
                        }
                        break;

                    case ProgramState.psNothing:
                        Nothinghandle();
                        break;
                    }
                    Application.DoEvents();
                }
                catch (Exception e)
                {
                    Console.WriteLine(e.Message);
                }
            }
        }
Beispiel #7
0
        /// <summary>
        /// Get how much the eyes are open, and how the much the person is smiling
        /// </summary>
        /// <returns>A number between 0 and 1 for each of the tuple</returns>
        /// <remarks>The face's features need to be already detected using DetectFeatures, otherwise (null, null) will be returned</remarks>
        public (float?eyesOpen, float?smile) GetExpression()
        {
            if (Features == null)
            {
                return(null, null);
            }

            if (FSDK.FSDKE_OK !=
                FSDK.DetectFacialAttributeUsingFeatures(ImageHandle, ref Features, "Expression", out string response, 128))
            {
                return(null, null);
            }

            var splitResponse = response.Split('=', ';');

            float?eyes  = null;
            float?smile = null;

            string eyesString = splitResponse[3];

            if (float.TryParse(eyesString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out float eyesTemp))
            {
                eyes = eyesTemp;
            }

            string smileString = splitResponse[1];

            if (float.TryParse(smileString, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture, out float smileTemp))
            {
                smile = smileTemp;
            }

            return(eyes, smile);
        }
Beispiel #8
0
        private void Form1_Load(object sender, EventArgs e)
        {
            FaceList = new List <TFaceRecord>();

            imageList1 = new ImageList();
            Size size100x100 = new Size();

            size100x100.Height    = 100;
            size100x100.Width     = 100;
            imageList1.ImageSize  = size100x100;
            imageList1.ColorDepth = ColorDepth.Depth24Bit;

            textBox1.Dock = DockStyle.Bottom;

            listView1.OwnerDraw      = false;
            listView1.View           = View.LargeIcon;
            listView1.Dock           = DockStyle.Right;
            listView1.LargeImageList = imageList1;

            textBox1.Text += "Initializing Luxand FaceSDK...\r\n";

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("Jl3R1DBC1qVQonaiBAq8gK7KzetXbFb4r+OF1DLzInT3KyXHvgHNLyk2Tymk5G6GBv58/Oqn+SQeOWCQfQASTV1Mcd7RQAsrmW02oOa9lhZsMockPLoEnpsH4W1I0+zmxmUwecWKEep9j4BrYhQWuiA3QcNeQO+tfyLOHASk3+M="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            if (FSDK.InitializeLibrary() != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error initializing FaceSDK!", "Error");
            }

            textBox1.Text += "Initialized\r\n";
        }
Beispiel #9
0
        /// <summary>
        /// Make and return FSDK FaceImage from a <see cref="ImageBuffer"/>
        /// </summary>
        /// <param name="imageBuffer"></param>
        /// <param name="imageHandle"></param>
        /// <returns>Handle to newly created FSDK FaceImage</returns>
        public static int CreateFsdkImageHandle(this ImageBuffer imageBuffer, out int imageHandle)
        {
            imageHandle = -1;
            var buffer       = new byte[imageBuffer.Buffer.Length];
            int bpp          = imageBuffer.BytesPerPixel;
            int bufferLength = imageBuffer.Buffer.Length;

            unsafe
            {
                fixed(byte *ob = imageBuffer.Buffer)
                fixed(byte *p = buffer)
                {
                    for (int i = 0; i < bufferLength; i += bpp)
                    {
                        p[i]     = ob[i + 2];
                        p[i + 1] = ob[i + 1];
                        p[i + 2] = ob[i];
                        p[i + 3] = ob[i + 3];
                    }
                }
            }

            int ret = FSDK.LoadImageFromBuffer(ref imageHandle, buffer, imageBuffer.Width, imageBuffer.Height, imageBuffer.Width * imageBuffer.BytesPerPixel,
                                               FsdkUtil.ImageModeFromBytesPerPixel(imageBuffer.BytesPerPixel));

            return(ret);
        }
Beispiel #10
0
        public void CreateEngine()
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("gyYgVWQTSzjiuGB/hH8dKgg0QrrIuhoHdfUCzD9rY+vru3WRZsaezTX6YWj9osdI/cmxY1NSdLkyWuugMPCxUG7/xNLegHLeaUpzVyKpDkaWL8tJIUsIL7xv9bhmgifPbAyTDuxF3VGxXmHkv/L/MStf9kdXV/A1vVvT93QC4vQ="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string[] cameraList;
            int      count;

            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = cameraList[0];

            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);
        }
Beispiel #11
0
        public Camera() : base()
        {
            Child = cameraImage;
            cameraImage.SizeMode = System.Windows.Forms.PictureBoxSizeMode.Zoom;

            var lic = File.ReadAllText("lux.txt");

            if (FSDK.FSDKE_OK == FSDK.ActivateLibrary(lic))
            {
                libIsGood = true;
                FSDK.InitializeLibrary();
                FSDKCam.InitializeCapturing();
                Directory.CreateDirectory("Captures");
            }

            TakeSnapshot = new CameraCommand(takeSnapshot,
                                             () =>
            {
                return(camIsGood && progState == PROG_STATE.RUNNING);
            });

            RetryCommand = new CameraCommand(Retry, () =>
            {
                return(camIsGood && progState == PROG_STATE.CAPTURED);
            });
        }
    private void MouseOnRect(RectInfo rectInfo, ref Pen pen, int i)
    {
        int x = rectInfo.x + formX;
        int y = rectInfo.y + formY;
        int w = rectInfo.w;

        mouseX = Cursor.Position.X;
        mouseY = Cursor.Position.Y;

        if (mouseX >= x && mouseX <= x + w && mouseY >= y && mouseY <= y + w)
        {
            pen = new Pen(Color.FromArgb(115, 55, 55, 255), 3);
            if (Control.MouseButtons == MouseButtons.Left)
            {
                String name;
                FSDK.GetAllNames(tracker, IDs[i], out name, 65536);

                if (name != "")
                {
                    friendcognition.Profile profile = new friendcognition.Profile(Convert.ToInt32(name));
                    profile.Show();
                }
                else
                {
                    MessageBox.Show("User not registered", "", MessageBoxButtons.OK);
                }
            }
        }
    }
Beispiel #13
0
        public Image drawFacialFlandmarks(long[] IDs, int tracker, Image frameImage)
        {
            Graphics gr  = Graphics.FromImage(frameImage);
            Pen      pen = new Pen(Brushes.Red);

            pen.Width    = 5.0F;
            pen.LineJoin = System.Drawing.Drawing2D.LineJoin.Bevel;
            for (int i = 0; i < IDs.Length; ++i)
            {
                FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);
                FSDK.TPoint[] facialFeatures;
                FSDK.GetTrackerFacialFeatures(tracker, 0, IDs[i], out facialFeatures);
                int          left   = facePosition.xc - (int)(facePosition.w * 0.6);
                int          top    = facePosition.yc - (int)(facePosition.w * 0.5);
                StringFormat format = new StringFormat();

                for (int x = 0; x < facialFeatures.Length; x++)
                {
                    FSDK.TPoint point = facialFeatures[x];
                    gr.FillEllipse(Brushes.DarkBlue, point.x, point.y, 4, 4);

                    GuesGenderAndAge(IDs, i, tracker);
                    personRecognize(IDs, facePosition, left, top, facePosition.w, i, tracker, frameImage);
                }
            }
            return(frameImage);
        }
 public void LoadFaceData(ref int tracker)
 {
     if (FSDK.LoadTrackerMemoryFromFile(ref tracker, trackerFile) != FSDK.FSDKE_OK)
     {
         FSDK.CreateTracker(ref tracker);
     }
 }
Beispiel #15
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("NfCVICqstH2sPcAn6lwNMiUb8SWIK7tX2ovYRPGNYdx+v55mC6uxKvRTfnCcP8M02cV4AAitelp8pN/MNp9/5JYmgk55CYH2nIf5QbYOfnRH3xHrQ+x9VbTKoSIvYFh4JVeS/gZ8X0/YNPPfEzqnNEBa27M1mEc56V1E85KYTCY="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string[] cameraList;
            int      count;

            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = cameraList[0];

            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);
            this.pictureBox1.Hide();
            this.webBrowser1.Hide();
            this.panel1.Show();
            this.button1.Show();
            this.panel2.Hide();

            button1.Parent    = pictureBox2;
            button1.BackColor = Color.Transparent;
            button1.BringToFront();
        }
Beispiel #16
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = false;
            button2.Enabled      = true;
            int cameraHandle = 0;

            needClose = false;

            int r = FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle);

            if (r != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            int tracker = 0;

            if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile)) // try to load saved tracker state
            {
                FSDK.CreateTracker(ref tracker);
            }

            int err = 0; // set realtime face detection parameters

            FSDK.SetTrackerMultipleParameters(tracker, "RecognizeFaces = true; DetectExpression = true; DetectAge=true; DetectGender=true; HandleArbitraryRotations=true; DetermineFaceRotationAngle=true; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);

            while (!needClose)
            {
                Int32 imageHandle = 0;
                if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandle, ref imageHandle)) // grab the current frame from the camera
                {
                    Application.DoEvents();
                    continue;
                }
                FSDK.CImage image = new FSDK.CImage(imageHandle);

                long[] IDs;
                long   faceCount = 0;
                FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeof(long) * 256); // maximum of 256 faces detected
                Array.Resize(ref IDs, (int)faceCount);

                Image frameImage = image.ToCLRImage();
                if (checkBox1.Checked)
                {
                    pictureBox1.Image = drawFacialFlandmarks(IDs, tracker, frameImage);
                }
                else
                {
                    pictureBox1.Image = frameImage;
                }
                GC.Collect();
                Application.DoEvents();
            }

            FSDK.SaveTrackerMemoryToFile(tracker, TrackerMemoryFile);
            FSDK.FreeTracker(tracker);
            FSDKCam.CloseVideoCamera(cameraHandle);
            FSDKCam.FinalizeCapturing();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            FaceList = new List <TFaceRecord>();

            imageList1 = new ImageList();
            Size size100x100 = new Size();

            size100x100.Height    = 100;
            size100x100.Width     = 100;
            imageList1.ImageSize  = size100x100;
            imageList1.ColorDepth = ColorDepth.Depth24Bit;

            textBox1.Dock = DockStyle.Bottom;

            listView1.OwnerDraw      = false;
            listView1.View           = View.LargeIcon;
            listView1.Dock           = DockStyle.Right;
            listView1.LargeImageList = imageList1;

            textBox1.Text += "Initializing Luxand FaceSDK...\r\n";

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("aCGamccfB6Uj3vlS7eDEryPnDrTbrZQb77ZHouPl3J8Q7o+BG4PcGevchFjppkWrVa038OU6Fghhy/BJfJV1n82InviCSijl8Vbxb11fs+VrcbSEfpESqjKSJQK8OLCqU0qYDy1oRHLRAg/3CHKCBzP/6IHuamy9Y/aY/xd1E7A="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            if (FSDK.InitializeLibrary() != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error initializing FaceSDK!", "Error");
            }

            textBox1.Text += "Initialized\r\n";
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("aCGamccfB6Uj3vlS7eDEryPnDrTbrZQb77ZHouPl3J8Q7o+BG4PcGevchFjppkWrVa038OU6Fghhy/BJfJV1n82InviCSijl8Vbxb11fs+VrcbSEfpESqjKSJQK8OLCqU0qYDy1oRHLRAg/3CHKCBzP/6IHuamy9Y/aY/xd1E7A="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string [] cameraList;
            int       count;

            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = cameraList[0];

            FSDKCam.VideoFormatInfo [] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

            int VideoFormat = 0; // choose a video format

            pictureBox1.Width  = formatList[VideoFormat].Width;
            pictureBox1.Height = formatList[VideoFormat].Height;
            this.Width         = formatList[VideoFormat].Width + 48;
            this.Height        = formatList[VideoFormat].Height + 96;
        }
Beispiel #19
0
        private void Worker_DoWork(object sender, DoWorkEventArgs e)
        {
            int image = 0;

            while (camIsGood)
            {
                if (progState == PROG_STATE.CAPTURED)
                {
                    Thread.Sleep(4);
                    continue;
                }

                FSDKCam.GrabFrame(cameraHandle, ref image);
                var cimg = new FSDK.CImage(image);
                worker.ReportProgress(0, cimg.Copy().ToCLRImage());
                if (progState == PROG_STATE.CAPTURING)
                {
                    var imgPath = Path.GetFullPath(Path.Combine("Captures", Guid.NewGuid().ToString() + ".jpg"));
                    cimg.Save(imgPath);
                    worker.ReportProgress(1, imgPath);
                }
                cimg.Dispose();
                FSDK.FreeImage(image);
                GC.Collect();
                Thread.Sleep(16);
            }

            FSDKCam.CloseVideoCamera(cameraHandle);
        }
Beispiel #20
0
 //bool _toContinue = true;
 public bool check_reg(byte[] ttp)
 {
     try
     {
         bool val = false;
         foreach (byte[] t in faceTemplates)
         {
             float  similarity = 0.0f;
             byte[] t1         = t;
             FSDK.MatchFaces(ref ttp, ref t1, ref similarity);
             float threshold = 0.0f;
             FSDK.GetMatchingThresholdAtFAR(0.001f, ref threshold); // set FAR to 1%--0.1%
             if (similarity > threshold)
             {
                 val = true;
                 setV(t1);
                 break;
             }
             Application.DoEvents();
         }
         return(val);
     }
     catch (InvalidOperationException inov)
     {
         return(false);
     }
 }
 public MainWindow()
 {
     FSDK.ActivateLibrary("GTNWg1l8Zs+7uJixJ+eBiTF9s1Iofc2pc6UYstMf2/l/MRBagDqX8gzNqXtX64KspTPaszn6+/WwtSHOVDPBQ/WRYTeUTlNJmu9p8tFSCEGDsPodYiISTxA4uoAGtS1iZ3eTbqWkrupH0dCKEdTQzLatWNz7QaCBLaTmdZvn+zU=");
     FSDK.InitializeLibrary();
     InitializeComponent();
     Faces = new List <Face>();
     InitialSettings();
 }
Beispiel #22
0
        private void loadSubject(string fileName)
        {
            FSDK.SetFaceDetectionParameters(false, true, 384);
            FSDK.SetFaceDetectionThreshold((int)FaceDetectionThreshold);

            TFaceRecord fr = new TFaceRecord();

            fr.ImageFileName = fileName;

            fr.FacePosition   = new FSDK.TFacePosition();
            fr.FacialFeatures = new FSDK.TPoint[2];
            fr.Template       = new byte[FSDK.TemplateSize];

            fr.image = new FSDK.CImage(fileName);

            fr.FacePosition = fr.image.DetectFace();
            if (0 == fr.FacePosition.w)
            {
                if (fileName.Length <= 1)
                {
                    MessageBox.Show("No faces found. Try to lower the Minimal Face Quality parameter in the Options dialog box.", "Enrollment error");
                }
            }
            else
            {
                fr.faceImage = fr.image.CopyRect((int)(fr.FacePosition.xc - Math.Round(fr.FacePosition.w * 0.5)), (int)(fr.FacePosition.yc - Math.Round(fr.FacePosition.w * 0.5)), (int)(fr.FacePosition.xc + Math.Round(fr.FacePosition.w * 0.5)), (int)(fr.FacePosition.yc + Math.Round(fr.FacePosition.w * 0.5)));

                try
                {
                    fr.FacialFeatures = fr.image.DetectEyesInRegion(ref fr.FacePosition);
                }
                catch (Exception ex2)
                {
                    MessageBox.Show(ex2.Message, "Error detecting eyes.");
                }

                try
                {
                    fr.Template = fr.image.GetFaceTemplateInRegion(ref fr.FacePosition); // get template with higher precision
                }
                catch (Exception ex2)
                {
                    MessageBox.Show(ex2.Message, "Error retrieving face template.");
                }

                FaceSearchList.Add(fr);
                FaceSearchImageList.Images.Add(fr.faceImage.ToCLRImage());
                listView1.Items.Add((FaceSearchImageList.Images.Count - 1).ToString(), fileName.Split('\\')[fileName.Split('\\').Length - 1], FaceSearchImageList.Images.Count - 1);

                using (Image img = fr.image.ToCLRImage())
                {
                    pictureBox1.Image = img;
                    pictureBox1.Refresh();
                }
            }
            pictureBox1.Image = null;
        }
Beispiel #23
0
 public MainWindow()
 {
     FSDK.ActivateLibrary("GwUHaCIMjj0EMCrjclY4umU1p3AIhphyxoTISrKyWZfaDU7bChTUgkK0adDOzouQSoJ2cSGoeoMvv/p1WUJaY4dWrcvpqxJJeOHMDykV2Qh7M95YPJyuGl+S9AMguxlhZbOzn3HvHMST6EGpOSJMqEFCEafIOawugRQ/lkp5d30=");
     FSDK.InitializeLibrary();
     InitializeComponent();
     learningFaces      = new List <Face>();
     testingFaces       = new List <Face>();
     ActivationFunction = new ActivationSigmoid();
 }
        private void Login_Load(object sender, EventArgs e)
        {
            label4.Text = uname;

            // MessageBox.Show(uname);

            TrackerMemoryFile = path + @"\tracker.dat";
            // TrackerMemoryFile = "D:\\tracker.dat";


            //con.Open();
            //cmd = new SqlCommand("select * from facetb where Name='" + uname + "' ", con);
            //SqlDataReader dr1 = cmd.ExecuteReader();
            //if (dr1.Read())
            //{
            //    byte[] photodat = (byte[])dr1["Image"];
            //    MemoryStream ms = new MemoryStream(photodat);
            //    File.WriteAllBytes(TrackerMemoryFile, photodat);
            //}
            //con.Close();



            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("gyYgVWQTSzjiuGB/hH8dKgg0QrrIuhoHdfUCzD9rY+vru3WRZsaezTX6YWj9osdI/cmxY1NSdLkyWuugMPCxUG7/xNLegHLeaUpzVyKpDkaWL8tJIUsIL7xv9bhmgifPbAyTDuxF3VGxXmHkv/L/MStf9kdXV/A1vVvT93QC4vQ="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();

            string[] cameraList;
            int      count;

            FSDKCam.GetCameraList(out cameraList, out count);

            if (0 == count)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            cameraName = cameraList[0];

            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

            int VideoFormat = 0;

            int tracker = 0;                                                                     // creating a Tracker

            if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile)) // try to load saved tracker state
            {
                FSDK.CreateTracker(ref tracker);
            }
        }
    public void Update(FSDK.CImage image, Image frameImage, bool recogniseFacialFeatures)
    {
        FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeof(long) * 256);
        Array.Resize(ref IDs, (int)faceCount);

        Graphics graphics = Graphics.FromImage(frameImage);

        for (int i = 0; i < IDs.Length; ++i)
        {
            if (recogniseFacialFeatures == true)
            {
                FSDK.TPoint[] facialFeatures;
                FSDK.GetTrackerFacialFeatures(tracker, 0, IDs[i], out facialFeatures);
                foreach (FSDK.TPoint point in facialFeatures)
                {
                    graphics.FillEllipse(Brushes.Blue, point.x, point.y, 5, 5);
                }
            }
            else
            {
                FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);

                int x = facePosition.xc - (int)(facePosition.w * 0.6);
                int y = facePosition.yc - (int)(facePosition.w * 0.6);
                int w = (int)(facePosition.w * 1.2);

                Pen pen = new Pen(Color.FromArgb(115, 115, 115, 115), 3);

                RectInfo currentRectInfo = new RectInfo(x, y, w);

                currentRectInfo = ProccessRectInfo(currentRectInfo, IDs[i]);

                /*String name;
                 * int res = FSDK.GetAllNames(tracker, IDs[i], out name, 65536);
                 *
                 * if (FSDK.FSDKE_OK == res && name.Length > 0)
                 * {
                 *  StringFormat format = new StringFormat();
                 *  format.Alignment = StringAlignment.Center;
                 *
                 *  graphics.DrawString(name, new System.Drawing.Font("Arial", 16),
                 *  new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen),
                 *  currentRectInfo.x + currentRectInfo.w / 2, currentRectInfo.y + currentRectInfo.w + 5, format);
                 * }*/
                pen = new Pen(Color.FromArgb(115, 115, 115, 115), 3);

                if (!CheckIfOpen())
                {
                    MouseOnRect(currentRectInfo, ref pen, i);
                }

                graphics.DrawRectangle(pen, currentRectInfo.x, currentRectInfo.y, currentRectInfo.w, currentRectInfo.w);
            }
        }
    }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("Jl3R1DBC1qVQonaiBAq8gK7KzetXbFb4r+OF1DLzInT3KyXHvgHNLyk2Tymk5G6GBv58/Oqn+SQeOWCQfQASTV1Mcd7RQAsrmW02oOa9lhZsMockPLoEnpsH4W1I0+zmxmUwecWKEep9j4BrYhQWuiA3QcNeQO+tfyLOHASk3+M="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
        }
        private void MainWindow_Loaded(object sender, RoutedEventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary(@"Free Activation key"))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButton.OK);
                Close();
            }

            FSDK.InitializeLibrary();
        }
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("aCGamccfB6Uj3vlS7eDEryPnDrTbrZQb77ZHouPl3J8Q7o+BG4PcGevchFjppkWrVa038OU6Fghhy/BJfJV1n82InviCSijl8Vbxb11fs+VrcbSEfpESqjKSJQK8OLCqU0qYDy1oRHLRAg/3CHKCBzP/6IHuamy9Y/aY/xd1E7A="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            FSDK.InitializeLibrary();
        }
        private void Form1_Shown(object sender, EventArgs e)
        {
            int tracker = 0;

            FSDK.CreateTracker(ref tracker);

            int err = 0; // set realtime face detection parameters

            FSDK.SetTrackerMultipleParameters(tracker, "RecognizeFaces=false; HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);

            while (!needClose)
            {
                if (CameraOpened)
                {
                    Int32 imageHandle = 0;
                    if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(cameraHandle, ref imageHandle)) // grab the current frame from the camera
                    {
                        MessageBox.Show("Error in FSDK_GrabFrame", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                        Application.DoEvents();
                        continue;
                    }
                    FSDK.CImage image = new FSDK.CImage(imageHandle);

                    long[] IDs;
                    long   faceCount = 0;
                    FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeof(long) * 256); // maximum of 256 faces detected
                    Array.Resize(ref IDs, (int)faceCount);

                    Image    frameImage = image.ToCLRImage();
                    Graphics gr         = Graphics.FromImage(frameImage);

                    for (int i = 0; i < IDs.Length; ++i)
                    {
                        FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                        FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);

                        int left = facePosition.xc - (int)(facePosition.w * 0.6);
                        int top  = facePosition.yc - (int)(facePosition.w * 0.5);
                        gr.DrawRectangle(Pens.LightGreen, left, top, (int)(facePosition.w * 1.2), (int)(facePosition.w * 1.2));
                    }

                    // display current frame
                    pictureBox1.Image = frameImage;
                }
                GC.Collect(); // collect the garbage after the deletion

                // make UI controls accessible
                Application.DoEvents();
            }

            if (CameraOpened)
            {
                FSDKCam.CloseVideoCamera(cameraHandle);
            }
        }
Beispiel #30
0
 public void DetectFeatures()
 {
     if (FacePosition == null)
     {
         FSDK.DetectFacialFeatures(ImageHandle, out Features);
     }
     else
     {
         FSDK.DetectFacialFeaturesInRegion(ImageHandle, ref FacePosition, out Features);
     }
 }