예제 #1
0
        public string ProcessImage(Image<Bgr, byte> image)
        {
            string strSpotCode = string.Empty;
            string plateNumber = string.Empty;

            //count++;
            try
            {
                strSpotCode = "001";
                // license pate image list
                List<Image<Gray, Byte>> licensePlateImagesList = new List<Image<Gray, byte>>();
                strSpotCode = "002";

                // filter license pate image list
                List<Image<Gray, Byte>> filteredLicensePlateImagesList = new List<Image<Gray, byte>>();
                strSpotCode = "003";
                List<MCvBox2D> licenseBoxList = new List<MCvBox2D>();

                strSpotCode = "004";
                _licensePlateDetector = new LicensePlates();
                List<List<Word>> words = _licensePlateDetector.DetectLicensePlate(
                   image,
                   licensePlateImagesList,
                   filteredLicensePlateImagesList,
                   licenseBoxList);
                if (words.Count > 0)
                {
                    plateNumber = String.Format("{0}", String.Join(" ", words[0].ConvertAll<String>(delegate(Word w) { return w.Text; }).ToArray()));

                    plateNumber = FilterLicensePlate(plateNumber);
                }

                Point startPoint = new Point(10, 10);
                strSpotCode = "005";
                for (int i = 0; i < words.Count; i++)
                {
                    strSpotCode = "006";
                    //AddLabelAndImage(
                    //   ref startPoint,
                    //   String.Format("{0}", String.Join(" ", words[i].ConvertAll<String>(delegate(Word w) { return w.Text; }).ToArray())),
                    //   licensePlateImagesList[i].ConcateVertical(filteredLicensePlateImagesList[i]));

                    image.Draw(licenseBoxList[i], new Bgr(Color.Red), 2);
                }
            }
            catch (Exception ex)
            {
                // log file
                return null;
            }

            //  count++;
            //imageBox1.Image = image;
            //plateNumber = LicensePlate(image);

            //  if (count == 4) count = 0;
            plateNumber = FilterLicensePlate(plateNumber);
            return plateNumber;
        }
예제 #2
0
        public string ProcessImage(Image <Bgr, byte> image)
        {
            string strSpotCode = string.Empty;
            string plateNumber = string.Empty;

            //count++;
            try
            {
                strSpotCode = "001";
                // license pate image list
                List <Image <Gray, Byte> > licensePlateImagesList = new List <Image <Gray, byte> >();
                strSpotCode = "002";

                // filter license pate image list
                List <Image <Gray, Byte> > filteredLicensePlateImagesList = new List <Image <Gray, byte> >();
                strSpotCode = "003";
                List <MCvBox2D> licenseBoxList = new List <MCvBox2D>();

                strSpotCode           = "004";
                _licensePlateDetector = new LicensePlates();
                List <List <Word> > words = _licensePlateDetector.DetectLicensePlate(
                    image,
                    licensePlateImagesList,
                    filteredLicensePlateImagesList,
                    licenseBoxList);
                if (words.Count > 0)
                {
                    plateNumber = String.Format("{0}", String.Join(" ", words[0].ConvertAll <String>(delegate(Word w) { return(w.Text); }).ToArray()));

                    plateNumber = FilterLicensePlate(plateNumber);
                }

                Point startPoint = new Point(10, 10);
                strSpotCode = "005";
                for (int i = 0; i < words.Count; i++)
                {
                    strSpotCode = "006";
                    //AddLabelAndImage(
                    //   ref startPoint,
                    //   String.Format("{0}", String.Join(" ", words[i].ConvertAll<String>(delegate(Word w) { return w.Text; }).ToArray())),
                    //   licensePlateImagesList[i].ConcateVertical(filteredLicensePlateImagesList[i]));

                    image.Draw(licenseBoxList[i], new Bgr(Color.Red), 2);
                }
            }
            catch (Exception ex)
            {
                // log file
                return(null);
            }

            //  count++;
            //imageBox1.Image = image;
            //plateNumber = LicensePlate(image);

            //  if (count == 4) count = 0;
            plateNumber = FilterLicensePlate(plateNumber);
            return(plateNumber);
        }