예제 #1
0
        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 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;
        }
예제 #3
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);
        }
예제 #4
0
        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;
        }
예제 #5
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();
        }
예제 #6
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;
    }
예제 #7
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 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);
            }
        }
예제 #9
0
        //初始化摄像头
        private void cameralInit()
        {
            //激活FaceSDK
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary(@"O5vT1Fmf2KYH3v4rxuEFhXL55hZPjcl/6Y412kbp1WBv9yy5S13/GtYZfTHKlXV+1a4c03NOYEeIzTsRWgVDvf6hHuyR/bD45k1kMH6dzlFsPilgR3UAcZRm01e6fbeQaomfqcVnWyMSKuXqQgCF07onN0xTKUKQKEd7cqSpuPs="))
            {
                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); //获取各个摄像头分布及其总数
            int countCam = 0;

            foreach (string cam in cameraList)
            {
                //if (cam == @"Logitech HD Webcam C270")
                if (cam == @"USB2.0 PC CAMERA1" || cam == @"USB2.0 PC CAMERA2")
                {
                    countCam++;
                }
            }

            if (count < 2)
            {
                MessageBox.Show("系统需要连接2个摄像头!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            string cameraName1 = cameraList[0];//读取摄像头,下同
            string cameraName2 = cameraList[1];

            //backgroundWorker1.RunWorkerAsync();//自动工作函数,一打开就自动开启摄像头进行检测


            FSDKCam.VideoFormatInfo[] formatList;//摄像头展现出来的视频格式数组
            FSDKCam.GetVideoFormatList(ref cameraName1, out formatList, out count);
            FSDKCam.GetVideoFormatList(ref cameraName2, out formatList, out count);
            FSDKCam.SetVideoFormat(ref cameraName1, formatList[0]);
            FSDKCam.SetVideoFormat(ref cameraName2, formatList[0]);

            int r1 = FSDKCam.OpenVideoCamera(ref cameraName1, ref cameraHandle1);
            int r2 = FSDKCam.OpenVideoCamera(ref cameraName2, ref cameraHandle2);

            if (r1 != FSDK.FSDKE_OK || r2 != FSDK.FSDKE_OK)
            {
                MessageBox.Show("开启摄像头失败!", "错误!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
        }
예제 #10
0
 void fsdk_async_funcs()
 {
     try
     {
         //    if (Init)
         //   {
         FSDKCam.CloseVideoCamera(Fitems.cameraN);
         FSDKCam.FinalizeCapturing();
         //  }
         Application.DoEvents();
         FSDKCam.InitializeCapturing();
         Init = true;
     }
     catch (AccessViolationException)
     {
         MessageBox.Show("AccessViolationException thrown\nIf you can see this error please contact visit http://godson.com.ng");
         Application.Exit();
         return;
     }
 }
예제 #11
0
        private void DaoTao_Load(object sender, EventArgs e)
        {
            //Load thư viện lên kiểm tra mã acti
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("iYL71M6OblPn4TOl8nYojjcGvZZaKo4seThAr+xuvRxW4gWSyK6glbCyrkFW9rzP1c/rLZbKCYeO15pjCoWGS9YAmb7i0U0RztaWBCPCdEqxy+YO1p0efMsRgocnVb1RM+Z2IRCMbvHoOQbg8fCZgKJ4wl+/1MfGHJKocXboYJU="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            //Khởi tạo thư viện
            FSDK.InitializeLibrary();
            //khởi tạo cammera
            FSDKCam.InitializeCapturing();

            string[] danhSachCamera;
            int      soLuongCMR;

            FSDKCam.GetCameraList(out danhSachCamera, out soLuongCMR);

            if (0 == soLuongCMR)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            TenCamera = danhSachCamera[0];
            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref TenCamera, out formatList, out soLuongCMR);

            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;
            this.MaximumSize   = new Size(this.Width, this.Height);
            this.MinimumSize   = new Size(this.Width, this.Height);
            Thread td = new Thread(nhanDien);

            td.IsBackground = true;
            td.Priority     = ThreadPriority.Highest;
            td.Start();
        }
예제 #12
0
        private void Iniciar()
        {
            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();

            #region Camaras
            //VERIFICAR CAMARAS, OBTENER LOS NOMBRE Y LA CANTIDAD DE CAMARAS.
            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];

            #endregion

            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;

            //Debug.WriteLine("Width: " + pictureBox1.Width);
            //Debug.WriteLine("Height: " + pictureBox1.Height);

            //this.Width = formatList[VideoFormat].Width + 75;
            //this.Height = formatList[VideoFormat].Height + 150;
            //Debug.WriteLine("Width: " + pictureBox1.Width);
            //Debug.WriteLine("Height: " + pictureBox1.Height);
        }
예제 #13
0
        private void ActivateFrm_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary(Global.LuxandKey))
            {
                MessageBox.Show("Invalid License Key Wizard", "Error activating IDS", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

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

            if (0 == Global.CameraList.Count())
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            cameraName = Global.DefaultCamera.CameraName;// cameraList[cameraHandle];

            try
            {
                FSDKCam.VideoFormatInfo[] formatList;
                int count = 0;
                FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);

                int VideoFormat = 0; // choose a video format
                imageBox.Width  = formatList[VideoFormat].Width;
                imageBox.Height = formatList[VideoFormat].Height;

                //Width = formatList[VideoFormat].Width;
                //Height = formatList[VideoFormat].Height;

                Refresh();
            }
            catch (Exception n)
            {
            }
        }
예제 #14
0
        private void Form1_Load(object sender, EventArgs e)
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("K1ueYIEDPy8ua3P21gjImB7sLfGWbI3UZZssU8P3gIocnsEPsKsyMj6HsPFFcYHUVG9FcSV6kYwnV4JwwW5mt78FUvpEumSAFKpqNEyw6XOr0OyOgwYf3E/64wawVk5i5ULX5kAk12j4/ZNqKi2RtQ9HrzEV/BSgYHGx3ovUtHk="))
            {
                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();
            }
            comboBox1.Items.AddRange(cameraList);
            cameraName = cameraList[0];



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

            int VideoFormat = 0;

            pictureBox1.Width  = formatList[VideoFormat].Width;
            pictureBox1.Height = formatList[VideoFormat].Height;
            this.Width         = formatList[VideoFormat].Width + 48;
            this.Height        = formatList[VideoFormat].Height + 96;
        }
예제 #15
0
        void camera()
        {
            // activate face sdk before using it...
            FSDK.ActivateLibrary("ANj63QzeUGKbORKF7KmC+s5J0f8hF7moXNMr1QrCeFStmCw3DTYD55rPZOERChnfpSbr3TguoGSPOPdrTwOodvoDuCeE3Jp/18G1GSeyvZT/uqK6q9MtvgSHtNFpna2sHVTdb1Az2rXxy8mHOOBgZ/PT5olt1Tsu0Gv8Go+3rdU=");
            //initialize sdk to enable capture
            FSDK.InitializeLibrary();
            FSDKCam.InitializeCapturing();
            String[] cameralist = new String[] { };
            int      count;

            //get clist of connected cameras and select the first one
            FSDKCam.GetCameraList(out cameralist, out count);
            if (count == 0)
            {
                MessageBox.Show("Please attach a camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
            FSDKCam.VideoFormatInfo[] formatList;
            FSDKCam.GetVideoFormatList(ref cameralist[0], out formatList, out count);
            String cameraName;

            cameraName = cameralist[0];
            if (FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle) != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error opening the first camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Close();
            }
            //a camera is opened, so disable controls unitl a face is detected
            //button1.Enabled = false;
            needClose = false;
            int tracker = 0;

            if (FSDK.FSDKE_OK != FSDK.LoadTrackerMemoryFromFile(ref tracker, TrackerMemoryFile))
            {
                FSDK.CreateTracker(ref tracker);
            }
            int err = 0;

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

            FSDK.CImage image;
            Image       frameImage;

            while (!needClose)
            {
                int ImageHandle = new int();
                if (FSDKCam.GrabFrame(cameraHandle, ref ImageHandle) != FSDK.FSDKE_OK)
                {
                    Application.DoEvents();
                    continue;
                }
                image = new FSDK.CImage(ImageHandle);
                long[] IDs        = new long[256];
                long   faceCount  = new long();
                long   sizeOfLong = 8;
                FSDK.FeedFrame(tracker, 0, image.ImageHandle, ref faceCount, out IDs, sizeOfLong * 256);
                Array.Resize(ref IDs, (int)faceCount);
                frameImage = image.ToCLRImage();
                Graphics gr;
                gr = Graphics.FromImage(frameImage);
                int i;
                for (i = 0; i <= IDs.Length - 1;)
                {
                    if (pictureBox1.Image != null)
                    {
                        // a face has been detected, grab it and close our preview source
                        needClose = true;
                        //button1.Enabled = true;
                        String user;
                        user = "******";
                        try
                        {
                            if (System.IO.Directory.Exists(Application.StartupPath + "\\images"))
                            {
                                pictureBox1.Image.Save(Application.StartupPath + "\\images\\" + user + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                            else
                            {
                                System.IO.Directory.CreateDirectory(Application.StartupPath + "\\images");
                                pictureBox1.Image.Save(Application.StartupPath + "\\images\\" + user + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
                            }
                        }
                        catch (Exception Ex)
                        {
                            Console.WriteLine(Ex.Message);
                        }
                        GC.Collect();
                        Application.DoEvents();
                        break;
                    }
                    //highlight face position in image
                    //    FSDK.TFacePosition facePosition = new FSDK.TFacePosition();
                    //    FSDK.GetTrackerFacePosition(tracker, 0, IDs[i], ref facePosition);
                    //    int left, top, w;
                    //    left = facePosition.xc = (int)(facePosition.w * 0.6);
                    //    top = facePosition.yc - (int)(facePosition.w * 0.5);
                    //    w = facePosition.w * (int)1.2;
                    //    string name;
                    //    int res;
                    //    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;
                    //        gr.DrawString(name, new System.Drawing.Font("Arial", 16), new System.Drawing.SolidBrush(System.Drawing.Color.LightGreen), facePosition.xc, top + w + 5, format);
                    //    }
                    //    Pen pen = Pens.LightGreen;
                    //    //this block assigns a name to the image and saves it in our tracker file, but we don't need it since we are storing to our DB Server
                    //    if (mouseX >= left && mouseX <= left + w && mouseY >= top && mouseY <= top + w)
                    //    {
                    //        pen = Pens.Blue;
                    //        if (programstate == ProgramStates.psRemember)
                    //        {
                    //            if (FSDK.FSDKE_OK == FSDK.LockID(tracker, IDs[i]))
                    //            {
                    //                //ibe == testdata
                    //                userName = "******";
                    //                if (userName == null)
                    //                {
                    //                    FSDK.SetName(tracker, IDs[i], "");
                    //                }
                    //                else
                    //                {
                    //                    FSDK.SetName(tracker, IDs[i], userName);
                    //                }
                    //                FSDK.UnlockID(tracker, IDs[i]);
                    //            }
                    //        }
                    //    }
                    //    gr.DrawRectangle(pen, left, top, w, w);
                }
                programstate      = ProgramStates.psRecognize;
                pictureBox1.Image = frameImage;
                //free captured resources to speed up program execution
                GC.Collect();
                Application.DoEvents();
            }
            //after capturing a valid face, tell the user and free resources
            //FSDK.SaveTrackerMemoryToFile(tracker, TrackerMemoryFile);
            //FSDK.FreeTracker(tracker);
            FSDKCam.CloseVideoCamera(cameraHandle);
            FSDKCam.FinalizeCapturing();
            MessageBox.Show("Face Image Successfully Captured!!!");
            loaddb();
            match_faces();
        }
예제 #16
0
        private void visorCamaraLuxand_Load(object sender, EventArgs e)
        {
            #region LOGIN FORM LOAD
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("mSZS6iUJqv9FC3B1C/jRhX3ASGvOLBkZ6vkufv7UbozMo3suOSsk0JeJjFLRpkWJVM8vfeJdvE2nbaAkr56KLoRA0aE6Cb5mYxaoIPhLufRgx0tHtH7mErwYclqix/DgYmXuPtV3V0BcVSS6h9ruSczSNkPcMVULXnbcmCqzuJ8="))
            {
                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();

            //FSDKCam.GetCameraListEx
            string[] cameraList;
            string[] cameras_rutas;
            int      count;
            FSDKCam.GetCameraListEx(out cameraList, out cameras_rutas, 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);
            #endregion

            #region FaceTracking
            //int cameraHandle = 0;
            //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;
            //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)
            //{
            //    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 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
            //    // make UI controls accessible
            //    Application.DoEvents();
            //}
            //FSDK.FreeTracker(tracker);
            //FSDKCam.CloseVideoCamera(cameraHandle);
            //FSDKCam.FinalizeCapturing();
            #endregion
        }
예제 #17
0
        //载入部分
        private void Form1_Load(object sender, EventArgs e)
        {
#if TIME_DEBUG
            Control.CheckForIllegalCrossThreadCalls = false;
#endif
            //激活SDK
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("PA+dByqrisjysrbGua7Vt8L1jSHlb4o1NEAQ2rLWbLjwTffKmWgmaTYtyua4lLceskJxZCFPYIBAEcyyn7U6A/7uHTvjTWVsc5KBvdZSOt8iL3D2wVLGrWQaRgD7NKxFIBRZu2YuEKFrivcdwjm1oM8UE72dHKdxoHSvUoTf7l0="))
            {
                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)
            {
                Console.WriteLine("No CameraConnected ");
                MessageBox.Show("Camera wrong", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            /*
             * for (int i = 0; i < CameraList.Length ; i++)
             * {
             *  Console.WriteLine("Camera "+i+" : "+CameraList[i]);
             * }
             */
            //Console.WriteLine("Choose the camera you want to use");
            //int choosenCamera = Convert.ToInt32( Console.ReadLine());
            int choosenCamera = 0;
            FSDKCam.GetVideoFormatList(ref CameraList[choosenCamera], out FormatList, out Count);

            /*
             * for (int i = 0; i < FormatList.Length; i++)
             * {
             *  Console.WriteLine("Format " + i + " : " + FormatList[i].Width.ToString()+" X "+FormatList[i].Height.ToString());
             * }
             */
            Console.WriteLine("Choose the format you want to use");
            //choosenFormat = Convert.ToInt32(Console.ReadLine());
            choosenFormat = 0;
            cameraName    = CameraList[choosenCamera];
            //调整窗口大小
            //resize(FormatList[choosenFormat].Width,FormatList[choosenFormat].Height);
            //变量空间申明
            faceTemplates = new List <FaceTemplate>();
            UserTemplates = new List <List <FaceTemplate> >();
            userName      = new List <string>();
            username      = "";
            //文件载入
            //loadfile();
            //网络初始化
            reset();
            Thread netserver = new Thread(new ThreadStart(this.startServer));
            netserver.Start();
            //人脸程序初始化
            Thread faceserver = new Thread(new ThreadStart(this.start));
            faceserver.Start();
        }
예제 #18
0
        private void startDetectToolStripMenuItem_Click(object sender, EventArgs e)
        {
            label1.Visible = true;
            bFirstRun      = true;
            needClose      = true;
            if (mThread != null)
            {
                mThread.Abort();
            }

            if (CameraOpened)
            {
                CameraOpened = false;

                if (FSDK.FSDKE_OK != FSDKCam.CloseVideoCamera(cameraHandle))
                {
                    MessageBox.Show("Error closing camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    Application.Exit();
                }
            }

            if (usbCamera)
            {
                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);
                    label1.Visible = false;
                    Application.Exit();
                }
                cameraName = cameraList[0];

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

                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);
                    label1.Visible = false;
                    //Application.Exit();
                }
                else
                {
                    CameraOpened = true;
                }
            }
            else
            {
                if (FSDK.FSDKE_OK != FSDKCam.OpenIPVideoCamera(FSDKCam.FSDK_VIDEOCOMPRESSIONTYPE.FSDK_MJPEG, ipcam_addr, ipcam_username, ipcam_password, 50, ref cameraHandle))
                {
                    MessageBox.Show("Error opening IP camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    label1.Visible = false;
                    //Application.Exit();
                }
                else
                {
                    CameraOpened = true;
                }
            }
            needClose = false;

            mThread = new Thread(new ThreadStart(MainLoop));
            mThread.Start();
        }