Esempio n. 1
0
        private void Form1_Load(object sender, EventArgs e)
        {
            //Init class
            IPSSbike detector = new IPSSbike();

            //OPTIONs

            //đường dẫn chứa file output, nếu set null hoặc rỗng thì sẽ không save ảnh output
            //set output dir, if output dir is null or empty engine will not save output image
            detector.OutputFoler = @"D:\Result";


            //engine nhận tham số là ảnh hoặc đường dẫn đến ảnh
            //you can set input pameter is bitmap or image path
            BikePlate result = detector.ReadPlate(@"8892.jpg");

            //kết quả trả về là class IPSSresult gồm nhiều thuộc tính
            //.text là các ký tự biển số (phải có key mới trả về kết quả)
            //result is a class contain some values
            //.text is plate character
            label1.Text = result.text;

            //bitmap là hình ảnh kết quả
            //bimap is image has returned
            Bitmap bmp = result.bitmap;

            pictureBox1.Image = bmp;

            //thời gian xử lý
            //elapsed time read plate
            int ms = result.elapsedMilisecond;

            //mã lỗi (nếu có)
            //error code to diagnostic
            string error = result.error;

            //nếu có biển số giá trị là true
            //.hasPlate is true when found plate in image
            bool hasPlate = result.hasPlate;

            //nếu đọc đủ các ký tự thì kết quả là true
            //.isValid is true when read enough character
            bool isValid = result.isValid;
        }
Esempio n. 2
0
        //////////////////////////////////////////////////////////////////////////////////////////////////////////////

        void ReadPlate()
        {
            if (!rdCamera.Checked && !rdImage.Checked && !rdFolder.Checked)
            {
                PrintError("Source image not selected");
                return;
            }

            if (bikeDetector == null)
            {
                MessageBox.Show("Please contact to author to fix problem");
                return;
            }

            bikeDetector.OutputFoler = txtFolderOutput.Text;

            if (rdCamera.Checked) //camera
            {
                if (rdNetworkCamera.Checked)
                {
                    if (streamPlayer.IsPlaying)
                    {
                        g_bmp = streamPlayer.GetCurrentFrame();
                    }
                }
                if (g_bmp == null)
                {
                    PrintError("Image is null");
                    return;
                }

                Bitmap bmp = (Bitmap)g_bmp.Clone();
                if (bmp == null)
                {
                    return;
                }


                BikePlate result = bikeDetector.ReadPlate(bmp);
                if (result.bitmap != null)
                {
                    picResult.Image = result.bitmap;
                }

                txtResult.Text = result.text;
                PrintMessage(result.error + " (" + result.elapsedMilisecond.ToString() + " ms)");
            }
            else if (rdImage.Checked) //static image
            {
                if (g_bmp == null)
                {
                    PrintError("Image is null");
                    return;
                }
                BikePlate result = bikeDetector.ReadPlate((Bitmap)g_bmp.Clone());
                txtResult.Text = result.text;

                if (result.bitmap != null)
                {
                    picResult.Image = result.bitmap;
                }
                PrintMessage(result.error + " (" + result.elapsedMilisecond + " ms)");
            }
            else if (rdFolder.Checked) //folder
            {
                if (btnDetect.Text == "Start detect (F5)")
                {
                    if (txtFolderOutput.Text == "")
                    {
                        errorProvider1.SetError(txtFolderOutput, "Folder output is empty");
                        return;
                    }

                    if (txtFolderInput.Text == txtFolderOutput.Text && txtFolderOutput.Text != "")
                    {
                        errorProvider1.SetError(txtFolderOutput, "Folder output must different folder input");
                        return;
                    }
                    if (lstImage.Items.Count == 0)
                    {
                        PrintError("No input image");
                        return;
                    }

                    g_scaleX             = 1;
                    g_scaleY             = 1;
                    progressBar1.Visible = true;
                    timerProgressbar.Start();
                    bgWorker1.RunWorkerAsync();

                    btnDetect.Text = "Stop detect (F5)";
                }
                else
                {
                    bgWorker1.CancelAsync();
                    btnDetect.Text = "Start detect (F5)";
                }
            }
        }