Click here to Skip to main content
15,881,139 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:


hi i am doing number plate detection in emgu c#.i want to detect only the number plate of a vehicle.my project is running without any exception or errors but i am getting more frames including frames of number plate.my prob is i want only number plate frame.pls help me.i cant find solution for this for more than a month.
here is my code
C#
namespace NumberPlateRecognition
{
    public partial class npr : Form
    {
        
        private Tesseract tess;
        private Capture _capture = null;
        Image<Bgr, Byte> frame;
        private LicensePlateDetector _licensePlateDetector;

         public npr()
        {

            InitializeComponent();
            _licensePlateDetector = new LicensePlateDetector("");
            _capture = new Capture();

            tess = new Tesseract("tessdata", "eng", Tesseract.OcrEngineMode.OEM_DEFAULT);//**comment**//

           
        }

        private delegate void displaydelegate(Bitmap image, PictureBox control);
        private void displayimage(Bitmap image, PictureBox control)
        {
            if (picCamera.InvokeRequired)
            {
                try
                {
                    displaydelegate di = new displaydelegate(displayimage);
                    this.BeginInvoke(di, new object[] { image, control });
                }
                catch (Exception ex)
                {
                    MessageBox.Show(ex.Message);
                }
            }
            else
            {
                control.Image = image;
            }
        }

        private void ProcessImage(Image<Bgr, byte> image)
        {
            List<Image<Gray, Byte>> licensePlateImagesList = new List<Image<Gray, byte>>();
            List<Image<Gray, Byte>> filteredLicensePlateImagesList = new List<Image<Gray, byte>>();
            List<MCvBox2D> licenseBoxList = new List<MCvBox2D>();
            List<string> words = _licensePlateDetector.DetectLicensePlate(
               image,
               licensePlateImagesList,
               filteredLicensePlateImagesList,
               licenseBoxList);

            panel1.Controls.Clear();
            Point startPoint = new Point(10, 10);
            for (int i = 0; i < words.Count; i++)
            {
                AddLabelAndImage(
                   ref startPoint,
                   String.Format("License: {0}", words[i]),
                   licensePlateImagesList[i].ConcateVertical(filteredLicensePlateImagesList[i]));
                image.Draw(licenseBoxList[i], new Bgr(Color.Red), 2);
            }

            displayimage(image.Bitmap, picCamera);
            

        }

       
        public Image<Bgr, byte> GetFrame(double frameNum)
        {
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_POS_FRAMES,1);
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_WIDTH,800);
            _capture.SetCaptureProperty(Emgu.CV.CvEnum.CAP_PROP.CV_CAP_PROP_FRAME_HEIGHT,500);
            return _capture.QueryFrame();
        }
        private void timerCapture_Tick(object sender, EventArgs e)
        {

            frame = _capture.QueryFrame();
            Image<Gray, byte> yellow = frame.InRange(new Bgr(80, 150, 150), new Bgr(170, 255, 255));
            
            Image<Gray, byte> white = frame.InRange(new Bgr(100, 100, 150), new Bgr(205, 200, 255));
            ProcessImage(frame);
          
           displayimage(white.Bitmap, picLicenceAreaGray);
        }
Posted
Comments
Bernhard Hiller 18-Sep-14 2:32am    
Do you actually understand your code snippet above?
I doubt. Because it looks to me that the most important part of te code is in _licensePlateDetector.DetectLicensePlate, i.e. you did not show it.
By the way, can your software "learn" from training data?
Member 11090879 18-Sep-14 3:32am    
i dont know what to add,i am new to this project.
Richard MacCutchan 18-Sep-14 3:37am    
You need to collect more information (use your debugger) to trace exactly what is happening. You really cannot expect anyone else to guess what is going on in this code.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900