コード例 #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;
        }
コード例 #2
0
        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 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;
    }
コード例 #4
0
ファイル: Form1.cs プロジェクト: kwyz/FaceRecognition-Csharp
        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();
        }
コード例 #5
0
        int Normalhandle()
        {
            try
            {
                Int32 ImageHandle = 0;
                if (FSDK.FSDKE_OK != FSDKCam.GrabFrame(CameraHandle, ref ImageHandle))
                {
                    return(-1);
                }
                FSDK.CImage Image      = new FSDK.CImage(ImageHandle);
                Image       FrameImage = Image.ToCLRImage();
                gr = Graphics.FromImage(FrameImage);
                pictureBox1.Image = FrameImage;

                FSDK.TFacePosition[] FacePosition = Image.DetectMultipleFaces();

                for (int person = 0; person < FacePosition.Length; person++)
                {
                    draw(FacePosition[person]);
                }

                GC.Collect(); // collect the garbage after the deletion
                return(0);
            }
            catch
            {
                return(-1);
            }
        }
コード例 #6
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();
        }
コード例 #7
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);
        }
コード例 #8
0
 void closing(Object sender, FormClosingEventArgs e)
 {
     //set staff image in main form
     if (button1.Enabled == true)
     {
         //f.update_img();
         GC.Collect();
         this.Dispose();
     }
     else
     {
         try
         {
             //FSDK.FreeTracker(tracker);
             needClose = true;
             FSDKCam.CloseVideoCamera(cameraHandle);
             //FSDKCam.FinalizeCapturing();
             GC.Collect();
             this.Dispose();
             this.Close();
         }
         catch (Exception ex)
         {
             //log error
         }
     }
 }
コード例 #9
0
ファイル: Camera.cs プロジェクト: Aqudei/RescueClient
        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);
            });
        }
コード例 #10
0
ファイル: Camera.cs プロジェクト: Aqudei/RescueClient
        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);
        }
コード例 #11
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;
        }
コード例 #12
0
    public void StartStreaming(bool recogniseFacialFeatures, Point location)
    {
        if (FSDKCam.OpenVideoCamera(ref cameraName, ref cameraHandle) != FSDK.FSDKE_OK)
        {
            MessageBox.Show(Constants.CAMERA_OPEN_ERROR, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            Application.Exit();
        }

        FaceRecognitionController faceRecognitionController = new FaceRecognitionController();

        faceRecognitionController.Initialize(location);

        cameraWorking = true;

        while (cameraWorking)
        {
            Application.DoEvents();
            Int32 imageHandle = 0;
            FSDKCam.GrabFrame(cameraHandle, ref imageHandle);
            FSDK.CImage image      = new FSDK.CImage(imageHandle);
            Image       frameImage = image.ToCLRImage();

            faceRecognitionController.Update(image, frameImage, recogniseFacialFeatures);

            currentPictureBox.Image = frameImage;
            GC.Collect();
        }

        faceRecognitionController.Stop();

        FSDKCam.CloseVideoCamera(cameraHandle);
        FSDKCam.FinalizeCapturing();
    }
コード例 #13
0
 void stop()
 {
     username = "";
     reset();
     NeedClose = true;
     FSDKCam.CloseVideoCamera(CameraHandle);
     FSDKCam.FinalizeCapturing();
 }
コード例 #14
0
        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);
            }
        }
コード例 #15
0
        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);
            }
        }
コード例 #16
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();
            }
        }
コード例 #17
0
ファイル: Camera.cs プロジェクト: Aqudei/RescueClient
 public int InitializeCamera()
 {
     if (libIsGood)
     {
         FSDKCam.GetCameraList(out cameraList, out cameraCount);
         worker = new BackgroundWorker();
         worker.WorkerReportsProgress = true;
         worker.DoWork          += Worker_DoWork;
         worker.ProgressChanged += Worker_ProgressChanged;
     }
     return(cameraCount);
 }
コード例 #18
0
ファイル: Camera.cs プロジェクト: Aqudei/RescueClient
 public void StartCamera()
 {
     if (cameraCount > 0)
     {
         camIsGood = FSDK.FSDKE_OK == FSDKCam.OpenVideoCamera(ref cameraList[0], ref cameraHandle);
         if (camIsGood)
         {
             progState = PROG_STATE.RUNNING;
             worker.RunWorkerAsync();
         }
     }
 }
コード例 #19
0
        private int CameraStart()
        {
            //摄像头启动
            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();
            }
            FSDKCam.SetVideoFormat(ref cameraName, FormatList[choosenFormat]);
            return(CameraHandle);
        }
コード例 #20
0
        private void button1_Click(object sender, EventArgs e)
        {
            if (CameraOpened && FSDK.FSDKE_OK != FSDKCam.CloseVideoCamera(cameraHandle))
            {
                MessageBox.Show("Error closing camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            if (FSDK.FSDKE_OK != FSDKCam.OpenIPVideoCamera(FSDKCam.FSDK_VIDEOCOMPRESSIONTYPE.FSDK_MJPEG, AddressBox.Text, UsernameBox.Text, PasswordBox.Text, 50, ref cameraHandle))
            {
                MessageBox.Show("Error opening IP camera", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            CameraOpened = true;
        }
コード例 #21
0
        private void camera_select(object sender, EventArgs e)
        {
            progressBar1.Value = 0;
            int s = camera.SelectedIndex;

            if (s != Fitems.cameraN)
            {
                Fitems.init = false;
            }
            if ((Fitems.cameraN == s) && Fitems.init == true)
            {
                doneLoadingCamera(); return;
            }

            //   System.Threading.Thread t = new System.Threading.Thread(new System.Threading.ThreadStart(fsdk_async_funcs));
            //  t.IsBackground = true;
            //  t.SetApartmentState(System.Threading.ApartmentState.STA);
            // t.Priority = System.Threading.ThreadPriority.BelowNormal;
            //  t.Start();
            backgroundWorker1.RunWorkerAsync();

            string cameraName = (string)camera.SelectedItem;


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

            if (r != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error opening camera\nCamera Busy", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            int count;

            String[] cameraList;
            FSDKCam.GetCameraList(out cameraList, out count);

            FSDK.SetFaceDetectionParameters(Fitems.facerotationB, Fitems.faceAngle, Fitems.faceWidth);
            FSDK.SetFaceDetectionThreshold(Fitems.facethreshold);

            FSDKCam.VideoFormatInfo[] formatList;

            FSDKCam.GetVideoFormatList(ref cameraName, out formatList, out count);
            Fitems.CamX    = formatList[0].Width;
            Fitems.CamY    = formatList[0].Height;
            Fitems.cameraN = s;
            Application.DoEvents();
            Fitems.init = true;
        }
コード例 #22
0
        public void start()
        {
            //if (Fitems.init) MessageBox.Show(Fitems.cameraN.ToString());
            if (camera.InvokeRequired)
            {
                camera.Invoke(new System.Threading.ThreadStart(start), new object[] { });
                Application.DoEvents();
                return;
            }
            //
            //

            FSDK.ActivateLibrary(DBvars.FSDK_KEY[DBvars.FSDK_KEY.Length - 1]);
            FSDK.InitializeLibrary();
            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();
            }
            bool camSel = false;

            camera.Items.Clear();

            for (int i = 0; i < count; i++)
            {
                //MessageBox.Show(cameraList[i] + " : " + i.ToString());
                camera.Items.Add(cameraList[i]);
                if (cameraList[i].Contains("USB 2.0 Camera"))
                {
                    //   Fitems.cameraN = i;
                    //  camSel = true;
                    //   camera.SetSelected(i, true);
                }
                if (i == 1)
                {
                }
                Application.DoEvents();
            }
            if (!camSel)
            {
                camera.SetSelected(Fitems.cameraN, true);
            }
        }
コード例 #23
0
    public bool Register(DataTable dt)
    {
        Int32 imageHandle = 0;

        FSDKCam.GrabFrame(cameraHandle, ref imageHandle);
        FSDK.CImage image      = new FSDK.CImage(imageHandle);
        Image       frameImage = image.ToCLRImage();

        Application.DoEvents();

        List <SqlParameter> sqlParams = new List <SqlParameter>();

        sqlParams.Add(new SqlParameter("Image", DataController.Instance().ConvertImageToByteArray(frameImage)));
        sqlParams.Add(new SqlParameter("Id", dt.Rows[0]["Id"]));
        DataController.Instance().ExecSP("StoreImage", sqlParams);

        return(faceRecognitionController.Register(image, dt));
    }
コード例 #24
0
        private CameraClass[] GetCameras()
        {
            CameraClass[] cam = null;

            int i = FSDKCam.GetCameraList(out CameraList, out CameraCount);

            cam = new CameraClass[CameraCount];

            for (int c = 0; c < CameraCount; c++)
            {
                CameraClass ca = new CameraClass();
                ca.CameraIndex = c;
                ca.CameraName  = CameraList[c];

                cam[c] = ca;
            }

            return(cam);
        }
コード例 #25
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;
     }
 }
コード例 #26
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);
        }
コード例 #27
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();
        }
コード例 #28
0
ファイル: ActivateFrm.cs プロジェクト: Hyedima/Abubakar
        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)
            {
            }
        }
コード例 #29
0
ファイル: Form1.cs プロジェクト: kwyz/FaceRecognition-Csharp
        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;
        }
コード例 #30
0
        private void button1_Click(object sender, EventArgs e)
        {
            this.button1.Enabled = false;
            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; DetectFacialFeatures=true; HandleArbitraryRotations=false; DetermineFaceRotationAngle=false; InternalResizeWidth=100; FaceDetectionThreshold=5;", ref err);

            this.button1.Hide();

            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();
                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);

                    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);
                    gr.DrawRectangle(Pens.LightGreen, left, top, (int)(facePosition.w * 1.2), (int)(facePosition.w * 1.2));

                    foreach (FSDK.TPoint point in facialFeatures)
                    {
                        gr.FillEllipse(Brushes.DarkBlue, point.x, point.y, 5, 5);
                    }
                }

                // display current frame
                pictureBox1.Image = frameImage;

                GC.Collect(); // collect the garbage after the deletion

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

            FSDKCam.CloseVideoCamera(cameraHandle);
            FSDKCam.FinalizeCapturing();
        }