Exemplo n.º 1
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();
            FSDK.SetFaceDetectionParameters(true, true, 384);
        }
Exemplo n.º 2
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();
            FSDK.SetFaceDetectionParameters(true, true, 384);
        }
Exemplo n.º 3
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();
            }
        }
Exemplo n.º 4
0
        public static bool ActivateRecognition()
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("DWysHuomlBcczVM2MQfiz/3WraXb7r+fM0th71X5A9z+gsHn2kpGOgWrVh9D/9sQWlPXO00CFmGMvetl9A+VEr9Y5GVBIccyV32uaZutZjKYH5KB2k87NJAAw6NPkzK0DSQ5b5W7EO0yg2+x4HxpWzPogGyIIYcAHIYY11/YGsU="))
            {
                return(false);
            }

            FSDK.InitializeLibrary();
            FSDK.SetFaceDetectionParameters(true, true, 384);

            return(true);
        }
Exemplo n.º 5
0
        private void InitializeSDK()
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("VBsVmYmHr/5JxUlk3q0KHjILz7R3Hb5OEhCQ7KdCg/tPbQqJfAaz8ok/9+iTgDp/KjGjkBi23HeCaUq8KKtKeXXN3xbe+bKfQ8q/3mfG6sad3AGUYDj6E+Qi2pzCWFgb4vqWDB3pLzUw+hnOZ7///CBV63IaB1kh7XF6VCaGtNw="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            if (FSDK.InitializeLibrary() != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Error initializing FaceSDK!", "Error");
            }
        }
Exemplo n.º 6
0
        private void Form1_Load(object sender, EventArgs e)
        {
            int panel_size = 120;

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("ql0enzjOpt6Eg/bKTjTnmV/CHacZsldzhWFqaWe54rvlnqKxP+QIBGPN6tBluefo7pprgH+pNOxaUy4ZrwJWJsSDlJWcv7N7mZn5c5+8ssAuowWDqMjAn5O9IeheV2kP3VXx0xaVLEGIXcm2p/aERbQQQesBNeoGEHidf7ew2F8="))
            {
                MessageBox.Show("Sytem Error", "System Erorr", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            FSDK.InitializeLibrary();
            FSDK.SetFaceDetectionParameters(false, true, 384);
        }
Exemplo n.º 7
0
        private void PersonFrm_Load(object sender, EventArgs e)
        {
            this.Location          = new Point(Screen.PrimaryScreen.WorkingArea.Width - (Width + 200), Screen.PrimaryScreen.WorkingArea.Height - (Height + 200));
            comTitle.SelectedIndex = 0;
            comSex.SelectedIndex   = 0;


            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("vzm3vx/iIfmU4NsxPHciqHwP/fdsnVT4vo3MpwZvuI0e3oqsOjq1Gp4CeTC4m963GGJdSFwgR40MB3jdXKvT+IB9uuaFhdTS6Y5kbi/LXu4MqGkNDVHRKcP47VaP/djTvJFOsfP9gxH4qneFm/C5m0jHEzdPTc5O8tPmsC7EOoE="))
            {
                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();
            FSDK.SetFaceDetectionParameters(true, true, 384);
        }
 private void attendance_Load(object sender, EventArgs e)
 {
     //timer1.Enabled = true;
     // label2.Text = "Current Camera Location" + new Home().location;
     FSDK.ActivateLibrary("7E92A165BF635F1767BF514733B46E3A4640821E9BD40FE7DCB716BBC33F219B9C8C6B346A8A58DF103DA9C29DE5E6F4E0DADFEDED0A026229DBDA7B6CA5F455");
     FSDK.InitializeLibrary();
     names         = new List <string>();
     rooms         = new List <string>();
     matrics       = new List <string>();
     Allstudents   = new List <string[]>();
     pres          = new List <string>();
     faceTemplates = new List <byte[]>();
     new System.Threading.Thread(new System.Threading.ThreadStart(load_XML)).Start();
     new System.Threading.Thread(new System.Threading.ThreadStart(load_db)).Start();
     //  getStreams();
 }
Exemplo n.º 9
0
        private void Form1_Load(object sender, EventArgs e)
        {
            label4.Text = uname;

            // MessageBox.Show(uname);

            TrackerMemoryFile = path + "\\tracker.dat";



            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;

            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);
            }
        }
Exemplo n.º 10
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);
            }
        }
Exemplo n.º 11
0
        public MainFrm()
        {
            InitializeComponent();

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

            DisplayCameraOnMenu();

            Fx.GetPersons();

            //Size = new Size(100, 100);
        }
Exemplo n.º 12
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();
        }
Exemplo n.º 13
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);
        }
Exemplo n.º 14
0
        public void CreateDB()
        {
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("VBsVmYmHr/5JxUlk3q0KHjILz7R3Hb5OEhCQ7KdCg/tPbQqJfAaz8ok/9+iTgDp/KjGjkBi23HeCaUq8KKtKeXXN3xbe+bKfQ8q/3mfG6sad3AGUYDj6E+Qi2pzCWFgb4vqWDB3pLzUw+hnOZ7///CBV63IaB1kh7XF6VCaGtNw="))
            {
                MessageBox.Show("Please run the License Key Wizard (Start - Luxand - FaceSDK - License Key Wizard)", "Error activating FaceSDK", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

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

            SqlCeEngine en = new SqlCeEngine(stringCon);

            if (!File.Exists("FaceDB.sdf"))
            {
                en.CreateDatabase();
                CreateTable();
                CreateSettingsTable();
            }
        }
Exemplo n.º 15
0
        public FacesManager()
        {
            known_faces_list   = new List <Face>();
            face_recog_results = new FaceRecognitionResult();

            //ACTIVATE THE FACE SDK LIBRARY USING A VALID LICENCE KEY
            int result = FSDK.ActivateLibrary(LICENSE_KEY);

            //IF LIBRARY IS ACTIVATED
            if (result == FSDK.FSDKE_OK)
            {
                //INITILIAZE THE LIBARARY
                Debug.WriteLine("Library activated");
                Debug.WriteLine("SIMILARITY THESHOLD=" + SIMILARITY_THRESHOLD);
                FSDK.InitializeLibrary();
            }
            else
            {
                throw new ArgumentException("FSDK Library must be activated with valid key for this to work");
            }
        }
Exemplo n.º 16
0
        private void Form2_Load(object sender, EventArgs e)
        {
            FaceList   = new List <TFaceRecord>();
            imageList1 = new ImageList();
            Size size100x100 = new Size(100, 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;
            listView1.Visible        = false;
            this.Width = this.Width - listView1.Width;

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("iYL71M6OblPn4TOl8nYojjcGvZZaKo4seThAr+xuvRxW4gWSyK6glbCyrkFW9rzP1c/rLZbKCYeO15pjCoWGS9YAmb7i0U0RztaWBCPCdEqxy+YO1p0efMsRgocnVb1RM+Z2IRCMbvHoOQbg8fCZgKJ4wl+/1MfGHJKocXboYJU="))
            {
                MessageBox.Show("Lỗi dùng chùa !", "Error ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }

            if (FSDK.InitializeLibrary() != FSDK.FSDKE_OK)
            {
                MessageBox.Show("Chưa cài đặt được!", "Error");
            }
            if (FaceList.Count != 0)
            {
                listView1.Visible = true;
                for (int i = 0; i < FaceList.Count; i++)
                {
                    imageList1.Images.Add(FaceList[i].faceImage.ToCLRImage());
                    string fn = FaceList[i].ImageFileName;
                    listView1.Items.Add((imageList1.Images.Count - 1).ToString(), fn.Split('\\')[fn.Split('\\').Length - 1], i);
                    listView1.SelectedIndices.Clear();
                    listView1.SelectedIndices.Add(listView1.Items.Count - 1);
                }
            }
        }
Exemplo n.º 17
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)
            {
            }
        }
Exemplo n.º 18
0
        private void Form1_Load(object sender, EventArgs e)
        {
            listView1.ContextMenuStrip = contextMenuStrip1;
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("iYL71M6OblPn4TOl8nYojjcGvZZaKo4seThAr+xuvRxW4gWSyK6glbCyrkFW9rzP1c/rLZbKCYeO15pjCoWGS9YAmb7i0U0RztaWBCPCdEqxy+YO1p0efMsRgocnVb1RM+Z2IRCMbvHoOQbg8fCZgKJ4wl+/1MfGHJKocXboYJU="))
            {
                MessageBox.Show("Lỗi dùng chùa !", "Lỗi ", MessageBoxButtons.OK, MessageBoxIcon.Error);
                Application.Exit();
            }
            FSDK.InitializeLibrary();
            this.Height       = this.Height - groupBox3.Height;
            groupBox3.Visible = false;

            imageList2 = new ImageList();
            Size size100x100 = new Size(100, 100);

            imageList2.ImageSize  = size100x100;
            imageList2.ColorDepth = ColorDepth.Depth24Bit;

            listView2.OwnerDraw = false;
            listView2.View      = View.LargeIcon;

            listView2.LargeImageList = imageList2;
        }
Exemplo n.º 19
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;
        }
Exemplo n.º 20
0
        public MainForm()
        {
            InitializeComponent();

            // Enable double duffering to stop flickering.
            SetStyle(ControlStyles.DoubleBuffer, true);
            SetStyle(ControlStyles.AllPaintingInWmPaint, true);
            SetStyle(ControlStyles.UserPaint, true);
            SetStyle(ControlStyles.SupportsTransparentBackColor, false);
            SetStyle(ControlStyles.Opaque, false);
            SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
            SetStyle(ControlStyles.ResizeRedraw, true);

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("DWysHuomlBcczVM2MQfiz/3WraXb7r+fM0th71X5A9z+gsHn2kpGOgWrVh9D/9sQWlPXO00CFmGMvetl9A+VEr9Y5GVBIccyV32uaZutZjKYH5KB2k87NJAAw6NPkzK0DSQ5b5W7EO0yg2+x4HxpWzPogGyIIYcAHIYY11/YGsU="))
            {
                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();
            FSDK.SetFaceDetectionParameters(true, true, 384);

            //       btnImportVector.Visible = btnExportVector.Visible = btnEditPoint.Visible = false;   // служебные кнопки. для показа старику не нужны.
        }
Exemplo n.º 21
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";

            LoadDB();
        }
Exemplo n.º 22
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("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";

            LoadDB();
        }
Exemplo n.º 23
0
        private void Subjects_Load(object sender, EventArgs e)
        {
            DBConnection db = new DBConnection();

            db.LoadDB();
            TFaceRecord tr = new TFaceRecord();

            tr = db.dbList[0];
            MessageBox.Show(tr.Template.ToString());



            FaceList = new List <TFaceRecord>();
            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("VBsVmYmHr/5JxUlk3q0KHjILz7R3Hb5OEhCQ7KdCg/tPbQqJfAaz8ok/9+iTgDp/KjGjkBi23HeCaUq8KKtKeXXN3xbe+bKfQ8q/3mfG6sad3AGUYDj6E+Qi2pzCWFgb4vqWDB3pLzUw+hnOZ7///CBV63IaB1kh7XF6VCaGtNw="))
            {
                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");
            }
        }
Exemplo n.º 24
0
        private void Server_Load(object sender, EventArgs e)
        {
            Text          = Application.ProductName;
            FaceList      = new List <TFaceRecord>();
            FaceName      = new List <string>();
            imageList1    = new ImageList();
            threadClients = new List <Thread>();

            Size size100x100 = new Size();

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

            listView1.OwnerDraw      = false;
            listView1.View           = View.LargeIcon;
            listView1.LargeImageList = imageList1;

            add("Initializing FaceSDK...");

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("fVrFCzYC5wOtEVspKM/zfLWVcSIZA4RNqx74s+QngdvRiCC7z7MHlSf2w3+OUyAZkTFeD4kSpfVPcRVIqAKWUZzJG975b/P4HNNzpl11edXGIyGrTO/DImoZksDSRs6wktvgr8lnNCB5IukIPV5j/jBKlgL5aqiwSfyCR8UdC9s="))
            {
                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");
            }

            add("FaceSDK Initialized");

            string      hostname = Dns.GetHostName();
            IPHostEntry iphost   = Dns.Resolve(hostname);

            IPAddress[] addresses = iphost.AddressList;

            ipAddress = addresses[addresses.Length - 1].ToString();
            add("Starting Face Recognition server @ " + ipAddress);

            try
            {
                listener = new TcpListener(IPAddress.Parse(ipAddress), 5005);
                listener.Start();

                Text += " @ " + ipAddress;
                add("Waiting for client to connect...");
                add("Don't forget to enroll a faces to the database.");
            }
            catch (Exception ex)
            {
                add(ex.Message);
            }

            Task.Run(() =>
            {
                try
                {
                    TcpClient client = listener.AcceptTcpClient();
                    Thread thread    = new Thread(handleClients);
                    tcpClients.Add(thread.ManagedThreadId, client);
                    threadClients.Add(thread);
                    thread.Start(thread.ManagedThreadId);
                }
                catch (Exception ex)
                {
                    add(ex.Message);
                }
            });
        }
Exemplo n.º 25
0
        public Form1()
        {
            try
            {
                InitializeComponent();
                label1.Visible = false;
                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();

                SetDoubleBuffered(pictureBox1);
                model_file = "frozen_inference_graph.pb";
                model_text = "mscoco_complete_label_map.pbtxt";

                LoadingForm loadingPannel = new LoadingForm();
                mGraph = new TFGraph();
                Thread loadingThread = new System.Threading.Thread(delegate()
                {
                    if (loadingPannel.InvokeRequired)
                    {
                        loadingPannel.Invoke(new Action <string>(s =>
                        {
                            loadingPannel.ShowDialog();
                        }), " ");
                    }
                    else
                    {
                        loadingPannel.ShowDialog();
                    }
                });
                try
                {
                    loadingThread.Start();
                    mCatalog = CatalogUtil.ReadCatalogItems(model_text);
                    var model = File.ReadAllBytes(model_file);
                    mGraph.Import(new TFBuffer(model));
                    session = new TFSession(mGraph);
                }
                catch (Exception e)
                {
                    MessageBox.Show(e.Message);
                }
                finally
                {
                    if (loadingPannel.InvokeRequired)
                    {
                        loadingPannel.Invoke(new MethodInvoker(delegate()
                        {
                            loadingPannel.Close();
                        }), " ");
                    }
                    else
                    {
                        loadingPannel.Close();
                    }
                }
            }catch (Exception e)
            {
                MessageBox.Show(e.Message);
            }
        }
Exemplo n.º 26
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();
        }
Exemplo n.º 27
0
        /// <summary>
        ///  Путь на волосы и аксессуары приходит в виде ссылке на картинку, Там же с тем же названием должен лежать обж.
        /// Мне проще обработать такие ссылки тут, чем в яве
        ///                             <img src=\"http://printahead.net/printahead.online/Library/Hair/Standard/20.jpg\" </summary>
        /// <param name="manTypeInt"></param>
        /// <param name="sessionID"></param>
        /// <param name="hairPath"></param>
        /// <param name="hairMaterialPath"></param>
        /// <param name="accessoryPath"></param>
        /// <param name="accessoryMaterialPath"></param>
        /// <param name="size">96% (3.2"), 113%(3.8"), 134%(4.5") ( 1 это 3.2, 2 - 3.8 дюйма и т.п.</param>
        public void CreateObj(int manTypeInt, string sessionID, string hairPath, string hairMaterialPath, string accessoryPath, string accessoryMaterialPath, string basePath, string baseMaterialPath, string addonPath1, string addonPath2, string addonPath3, string addonPath4, string addonMaterialPath, int oldMorphingValue, int fatMorphingValue, int smoothingValue, int size, string ftpOutputName)
        {
            var manType = ManType.Male;

            switch (manTypeInt)
            {
            case 1:
                manType = ManType.Female;
                break;

            case 2:
            case 3:
                manType = ManType.Child;
                break;
            }

            #region Создание проекта

            WebClient client = new WebClient();

            var    imagePath  = "https://printahead.net/printahead.online/PrintAhead_images/" + sessionID + ".jpeg";
            byte[] imageBytes = client.DownloadData(imagePath);

            var ms            = new MemoryStream(imageBytes);
            var templateImage = new Bitmap(ms);


            ProgramCore.Project            = new Project(sessionID, null, null, GenesisType.Genesis2, manType, null, false, 1024, false);
            ProgramCore.Project.FrontImage = templateImage;
            //ProgramCore.Project.LoadMeshes();
            #endregion

            #region активация охуенной распознавалки

            if (FSDK.FSDKE_OK != FSDK.ActivateLibrary("DWysHuomlBcczVM2MQfiz/3WraXb7r+fM0th71X5A9z+gsHn2kpGOgWrVh9D/9sQWlPXO00CFmGMvetl9A+VEr9Y5GVBIccyV32uaZutZjKYH5KB2k87NJAAw6NPkzK0DSQ5b5W7EO0yg2+x4HxpWzPogGyIIYcAHIYY11/YGsU="))
            {
                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();
            FSDK.SetFaceDetectionParameters(true, true, 384);

            #endregion

            Recognize(templateImage);
            var aabb = ProgramCore.Project.RenderMainHelper.InitializeShapedotsHelper(true);
            ProgramCore.Project.RenderMainHelper.LoadProject(true, aabb, imagePath, false);

            headMeshesController.InitializeTexturing(autodotsShapeHelper.GetBaseDots(), HeadController.GetIndices());
            autodotsShapeHelper.Transform(headMeshesController.TexturingInfo.Points.ToArray());
            headController.StartAutodots();
            ProgramCore.Project.RenderMainHelper.UpdateUserCenterPositions();

            for (var i = 0; i < headMeshesController.RenderMesh.Parts.Count; i++)
            {
                var part = headMeshesController.RenderMesh.Parts[i];
                if (part.Texture == 0)
                {
                    part.Texture     = ProgramCore.Project.RenderMainHelper.HeadTextureId;
                    part.TextureName = ProgramCore.Project.RenderMainHelper.GetTexturePath(part.Texture);
                }
            }

            headController.EndAutodots();

            #region Загружаем и применяем морфинги

            #region Старость

            if (oldMorphingValue != 20)          // назачем морфить, если по дефолту итак так. чтобы время на загрузку не тратить
            {
                var intTemp = 0;

                var oldMorphingPath = "ftp://108.167.164.209/public_html/printahead.online/PrintAhead_DefaultModels/" + manType.GetObjDirPath(false) + "/Old.obj";       // загружаем трансформации для старения
                oldMorphingPath = oldMorphingPath.Replace(@"\", "/");
                if (FTPHelper.IsFileExists(oldMorphingPath))
                {
                    OldMorphing = ProgramCore.Project.RenderMainHelper.pickingController.LoadPartsMorphInfo(oldMorphingPath, headMeshesController.RenderMesh, ref intTemp);
                }

                if (OldMorphing != null)
                {
                    var delta = oldMorphingValue == 20 ? 0 : oldMorphingValue / 80f;
                    foreach (var m in OldMorphing)
                    {
                        m.Value.Delta = delta;
                    }
                    ProgramCore.Project.AgeCoefficient = delta;
                }
            }

            #endregion

            #region Толстость

            if (fatMorphingValue != 0)
            {
                var intTemp         = 0;
                var fatMorphingPath = "ftp://108.167.164.209/public_html/printahead.online/PrintAhead_DefaultModels/" + manType.GetObjDirPath(false) + "/Fat.obj";  // загружаем трансформации для толстения
                fatMorphingPath = fatMorphingPath.Replace(@"\", "/");
                if (FTPHelper.IsFileExists(fatMorphingPath))
                {
                    FatMorphing = ProgramCore.Project.RenderMainHelper.pickingController.LoadPartsMorphInfo(fatMorphingPath, headMeshesController.RenderMesh, ref intTemp);
                }

                if (FatMorphing != null)
                {
                    var delta = fatMorphingValue == 0 ? 0 : fatMorphingValue / 30f;
                    foreach (var m in FatMorphing)
                    {
                        m.Value.Delta = delta;
                    }
                    ProgramCore.Project.FatCoefficient = delta;
                }
            }

            #endregion

            float?k = null;
            if (smoothingValue != 0)
            {
                var delta = (100 - smoothingValue) / 100f;

                ProgramCore.Project.MorphingScale = delta;
                k = delta;
            }

            DoMorth(k);

            #endregion

            FTPHelper.UpdateAddress(@"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID);

            ProgramCore.Project.RenderMainHelper.InitializeHairPositions();
            ProgramCore.Project.RenderMainHelper.InitializeAccessoryPositions();

            ZipOutputStream zipStream = null;

            MemoryStream outputMemStream = new MemoryStream();
            if (!string.IsNullOrEmpty(ftpOutputName))
            {
                zipStream = new ZipOutputStream(outputMemStream); // заодно все будем паковать в архивчик
                zipStream.SetLevel(3);
            }

            #region Attach hair

            var hairObjPath = string.Empty;
            if (string.IsNullOrEmpty(hairPath))
            {
                switch (manTypeInt)
                {
                case 0:
                    hairObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Hair/Standard/20.obj";          // мужик
                    break;

                case 1:
                    hairObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Hair/Standard/3.obj";           // баба
                    break;

                case 2:
                    hairObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Hair/Standard/10C.obj";         // мальчик
                    break;

                case 3:
                    hairObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Hair/Standard/12C.obj";         // девочка
                    break;
                }
            }
            else
            {
                hairObjPath = GetParcedHairAccessoriesLink(hairPath, manType == ManType.Child ? "C.obj" : ".obj");
            }

            if (!string.IsNullOrEmpty(hairObjPath) && FTPHelper.IsFileExists(hairObjPath))
            {
                hairMaterialPath = GetParcedHairAccessoriesLink(hairMaterialPath, "T.jpg").Replace("/Icons/", "/Materials/");
                if (string.IsNullOrEmpty(hairMaterialPath))
                {
                    hairMaterialPath = "ftp://108.167.164.209/public_html/printahead.online/Library/Hair/Materials/H7T.jpg";
                }

                var temp     = @"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID + "/Textures";
                var fileName = Path.GetFileNameWithoutExtension(hairMaterialPath) + ".jpg";

                FTPHelper.CopyFromFtpToFtp(hairMaterialPath, temp, fileName, zipStream, fileName);
                hairMaterialPath = @"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID + "/Textures/" + fileName;

                ProgramCore.Project.RenderMainHelper.AttachHair(hairObjPath, hairMaterialPath, manType);
            }

            #endregion

            #region Attach accessories

            var accessoryObjPath = string.Empty;
            if (string.IsNullOrEmpty(accessoryPath))
            {
                switch (manType)
                {
                case ManType.Child:
                    accessoryObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Accessory/Standard/I.obj";
                    break;

                case ManType.Female:
                    accessoryObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Accessory/Standard/HF.obj";
                    break;

                default:
                    accessoryObjPath = @"ftp://108.167.164.209/public_html/printahead.online/Library/Accessory/Standard/HM.obj";
                    break;
                }
            }
            else
            {
                accessoryObjPath = GetParcedHairAccessoriesLink(accessoryPath, manType == ManType.Child ? "C.obj" : ".obj");
            }

            if (!string.IsNullOrEmpty(accessoryObjPath) && FTPHelper.IsFileExists(accessoryObjPath))
            {
                accessoryMaterialPath = GetParcedHairAccessoriesLink(accessoryMaterialPath, "T.jpg").Replace("/Icons/", "/Materials/");;
                if (string.IsNullOrEmpty(accessoryMaterialPath))
                {
                    accessoryMaterialPath = "ftp://108.167.164.209/public_html/printahead.online/Library/Accessory/Materials/lgreenT.jpg";
                }

                var temp     = @"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID + "/Textures";
                var fileName = Path.GetFileNameWithoutExtension(accessoryMaterialPath) + ".jpg";

                FTPHelper.CopyFromFtpToFtp(accessoryMaterialPath, temp, fileName, zipStream, fileName);
                accessoryMaterialPath = @"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID + "/Textures/" + fileName;

                ProgramCore.Project.RenderMainHelper.AttachAccessory(accessoryObjPath, accessoryMaterialPath, manType);
            }

            #region Base

            var baseObjPath = string.Empty;
            if (!string.IsNullOrEmpty(basePath))
            {
                baseObjPath = GetParcedHairAccessoriesLink(basePath, manType == ManType.Child ? "C.obj" : ".obj");
            }

            if (!string.IsNullOrEmpty(baseObjPath) && FTPHelper.IsFileExists(baseObjPath))
            {
                baseMaterialPath = GetParcedHairAccessoriesLink(baseMaterialPath, "T.jpg").Replace("/Icons/", "/Materials/");
                if (string.IsNullOrEmpty(baseMaterialPath))
                {
                    baseMaterialPath = "ftp://108.167.164.209/public_html/printahead.online/Library/Accessory/Materials/lgreenT.jpg";
                }

                var temp     = @"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID + "/Textures";
                var fileName = Path.GetFileNameWithoutExtension(baseMaterialPath) + ".jpg";

                FTPHelper.CopyFromFtpToFtp(baseMaterialPath, temp, fileName, zipStream, fileName);
                baseMaterialPath = @"ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + sessionID + "/Textures/" + fileName;

                ProgramCore.Project.RenderMainHelper.AttachAccessory(baseObjPath, baseMaterialPath, manType);
            }

            #endregion

            #region Addons

            var addonObjPath = GetParcedHairAccessoriesLink(addonPath1, manType == ManType.Child ? "C.obj" : ".obj");
            AttachAddon(addonObjPath, ref addonMaterialPath, sessionID, manType, ref zipStream);

            addonObjPath = GetParcedHairAccessoriesLink(addonPath2, manType == ManType.Child ? "C.obj" : ".obj");
            AttachAddon(addonObjPath, ref addonMaterialPath, sessionID, manType, ref zipStream);

            addonObjPath = GetParcedHairAccessoriesLink(addonPath3, manType == ManType.Child ? "C.obj" : ".obj");
            AttachAddon(addonObjPath, ref addonMaterialPath, sessionID, manType, ref zipStream);

            addonObjPath = GetParcedHairAccessoriesLink(addonPath4, manType == ManType.Child ? "C.obj" : ".obj");
            AttachAddon(addonObjPath, ref addonMaterialPath, sessionID, manType, ref zipStream);

            #endregion

            #endregion


            ProgramCore.Project.RenderMainHelper.SaveMergedHead(sessionID, zipStream, size);
            ProgramCore.Project.RenderMainHelper.SaveSmoothedTextures(zipStream);


            var address        = "ftp://108.167.164.209/public_html/printahead.online/PrintAhead_models/" + ProgramCore.Project.ProjectName + "/Textures";
            var profileImgPath = sessionID + ".jpeg";

            var ftpHelper = new FTPHelper(address);
            var stream    = new MemoryStream();
            templateImage.Save(stream, ImageFormat.Jpeg);
            ftpHelper.Upload(stream, profileImgPath);

            if (zipStream != null)
            {
                ms.Seek(0, SeekOrigin.Begin);
                var newEntry = new ZipEntry(profileImgPath);
                zipStream.PutNextEntry(newEntry);
                ms.CopyTo(zipStream);
                zipStream.CloseEntry();

                zipStream.IsStreamOwner = false; // False stops the Close also Closing the underlying stream.
                zipStream.Close();               // Must finish the ZipOutputStream before using outputMemStream.

                outputMemStream.Position = 0;
                address   = "ftp://108.167.164.209/public_html/printahead.online/PrintAhead_output/";
                ftpHelper = new FTPHelper(address);
                ftpHelper.Upload(outputMemStream, ftpOutputName + ".zip");
            }
        }
Exemplo n.º 28
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();
        }
Exemplo n.º 29
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
        }