Ejemplo n.º 1
0
        public MainForm2()
        {
            //Thread t = new Thread(new ThreadStart(Loading));
            //t.Start();
            //for (int i = 0; i <= 1000; i++)
            //    Thread.Sleep(10);
            // t.Abort();
            InitializeComponent();
            lbID.Text    = "";
            svm          = SVMExtension.Create();
            _lprPlateIn  = new LPR(svm);
            _lprPlateOut = new LPR(svm);
            lbPlate.Text = "";
            _dataContext.LoadTraningFace(out _listFace, out _listLabel);
            _recognition.Update(_listFace, _listLabel);
            lbCount.Text = _dataContext.GetCountGoOut().ToString();
            #region Khởi tạo Camera nếu là Demo
            if (_isDemo)
            {
                _capturePlateIn = new Emgu.CV.VideoCapture(PATH_PLATE_IN);
                _capturePlateIn.SetCaptureProperty(CapProp.FrameWidth, 640);
                _capturePlateIn.SetCaptureProperty(CapProp.FrameHeight, 480);
                _fpsPlateIn        = (Int32)_capturePlateIn.GetCaptureProperty(CapProp.Fps);
                _totalFramePlateIn = Convert.ToInt32(_capturePlateIn.GetCaptureProperty(CapProp.FrameCount)) - 4;

                _captureFaceIn = new Emgu.CV.VideoCapture(PATH_FACE_IN);
                _captureFaceIn.SetCaptureProperty(CapProp.FrameWidth, 320);
                _captureFaceIn.SetCaptureProperty(CapProp.FrameHeight, 240);
                _fpsFaceIn           = (Int32)_captureFaceIn.GetCaptureProperty(CapProp.Fps);
                _totalFrameFaceIn    = (Int32)_captureFaceIn.GetCaptureProperty(CapProp.FrameCount) - 4;
                timerFaceIn.Enabled  = true;
                timerPlateIn.Enabled = true;
            }
            #endregion
            #region Khởi tạo Camera bình thường
            else
            {
                _capturePlateIn = new Emgu.CV.VideoCapture(1);
                _capturePlateIn.SetCaptureProperty(CapProp.FrameWidth, 640);
                _capturePlateIn.SetCaptureProperty(CapProp.FrameHeight, 480);

                _captureFaceIn = new Emgu.CV.VideoCapture(0);
                _captureFaceIn.SetCaptureProperty(CapProp.FrameWidth, 320);
                _captureFaceIn.SetCaptureProperty(CapProp.FrameHeight, 240);

                timerFaceIn.Enabled  = true;
                timerPlateIn.Enabled = true;



                //_capturePlateOut = new Emgu.CV.VideoCapture(1);
                //_capturePlateOut.SetCaptureProperty(CapProp.FrameWidth, 640);
                //_capturePlateOut.SetCaptureProperty(CapProp.FrameHeight, 480);

                //_captureFaceOut = new Emgu.CV.VideoCapture(0);
                //_captureFaceOut.SetCaptureProperty(CapProp.FrameWidth, 320);
                //_captureFaceOut.SetCaptureProperty(CapProp.FrameHeight, 240);

                //timerFaceOut.Enabled = true;
                //timerPlateOut.Enabled = true;
            }
            #endregion

            //if (_captureFaceOut == null)
            //{
            //    Image_Xe_Ra_Truoc.Image = (new Image<Bgr, byte>("Picture\\camera_not_found.png")).Bitmap;
            //    Image_Xe_Ra_Truoc.Update();
            //}
            //if (_capturePlateOut == null)
            //{
            //    Image_Xe_Ra_Sau.Image = (new Image<Bgr, byte>("Picture\\camera_not_found.png")).Bitmap;
            //    Image_Xe_Ra_Sau.Update();
            //}
            //if (_captureFaceIn == null)
            //{
            //    Image_Xe_Vao_Truoc.Image = (new Image<Bgr, byte>("Picture\\camera_not_found.png")).Bitmap;
            //    Image_Xe_Vao_Truoc.Update();
            //}
            //if (_capturePlateIn == null)
            //{
            //    Image_Xe_Vao_Sau.Image = (new Image<Bgr, byte>("Picture\\camera_not_found.png")).Bitmap;
            //    Image_Xe_Vao_Sau.Update();
            //}
            //Application.Idle += new EventHandler(FrameGrabber);
            //timer1.Interval = 1000 / _fpsFaceIn;
            //timer1.Tick += new EventHandler(timer1_Tick);
            //timer1.Start();
        }