Ejemplo n.º 1
0
        private Plate Clone()
        {
            Plate newPlate = null;

            newPlate = new Plate(this.image);

            return(newPlate);
        }
Ejemplo n.º 2
0
 public void ClearImage()
 {
     if (null != image)
     {
         Cv.ReleaseImage(image);
         image = null;
     }
     if (null != plateCopy)
     {
         plateCopy.ClearImage();
         plateCopy = null;
     }
 }
Ejemplo n.º 3
0
        public void Normalize(Int32 method)
        {
            IplImage tempImage = null;
            Plate    clone1    = this.Clone();

            VerticalEdgeDetector(clone1.GetImage);
            //clone1.GetImage.SaveImage(@"C:\temp\newImages\newVerticalEdgeDetector.png");
            PlateVerticalGraph vertical = clone1.HistogramYaxis(clone1.GetImage);

            tempImage = CutTopBottom(image, vertical);
            Cv.ReleaseImage(image);
            image = tempImage;
            // JIVAN
            //plateCopy.image.SaveImage(@"C:\temp\newImages\newBEFOREVerticalCutTopBottom.png");
            tempImage = CutTopBottom(plateCopy.image, vertical);
            Cv.ReleaseImage(plateCopy.image);
            plateCopy.image = tempImage;
            // JIVAN
            //plateCopy.image.SaveImage(@"C:\temp\newImages\newVerticalCutTopBottom.png");
            Plate clone2 = this.Clone();

            if (1 == horizontalDetectionType)
            {
                HorizontalEdgeDetector(clone2.GetImage);
                //TODO JIVAN Remove these 2 lines when project gest done
                //clone2.ClearImage();
                //clone2 = new Plate(new IplImage(@"C:\temp\HorizontalEdgeDetector.png"));
                //clone2.GetImage.SaveImage(@"C:\temp\newImages\newCloneHorizontalEdgeDetector.png");
            }

            PlateHorizontalGraph horizontal = clone1.HistogramXaxis(clone2.GetImage);

            tempImage = CutLeftRight(image, horizontal, method);
            Cv.ReleaseImage(image);
            image     = tempImage;
            tempImage = CutLeftRight(plateCopy.image, horizontal, method);
            Cv.ReleaseImage(plateCopy.image);
            plateCopy.image = tempImage;
            // JIVAN
            //plateCopy.image.SaveImage(@"C:\temp\newImages\newHorizontalCutLeftRight.png");

            clone2.ClearImage();
            clone1.ClearImage();
        }
Ejemplo n.º 4
0
 public PlateGraph(Plate pHandle)
 {
     handle = pHandle;
 }
Ejemplo n.º 5
0
        public String ImageAnalysis(IplImage image, Int32 method)
        {
            String      plateData = null;
            Double      plateWHratio;
            Plate       plate = null;
            List <Char> chars = null;


            try
            {
                plate = new Plate(image);
                // JIVAN
                //plate.SavePlateCopyImage(@"C:\temp\newImages\newImageAdaptativeThreshold1.png");
                plate.Normalize(method);

                plateWHratio = (Double)((Double)plate.GetWidth / (Double)plate.GetHeight);
                if (plateWHratio < Constants.MIN_PLATE_WIDTH_HEIGHT_RATIO ||
                    plateWHratio > Constants.MAX_PLATE_WIDTH_HEIGHT_RATIO)
                {
                    return(plateData);
                }

                // JIVAN
                //plate.SavePlateCopyImage(@"C:\temp\newImages\newImageAdaptativeThreshold2.png");
                chars = plate.GetChars();

                //  JIVAN

                /*Int32 count2 =0;
                 * foreach(Char ch in chars)
                 * {
                 *  ch.GetImage.SaveImage(String.Format(@"C:\temp\newImages\newBeforeNormImageCh{0}.png", count2));
                 *  ch.GetThresholdedImage.SaveImage(String.Format(@"C:\temp\newImages\newImageThresholdedCh{0}.png", count2++));
                 * }
                 */

                if (chars.Count < Constants.INTELLIGENCE_MIN_CHARS ||
                    chars.Count > Constants.INTELLIGENCE_MAX_CHARS)
                {
                    return(plateData);
                }

                if (plate.GetCharsWidthDispertion(chars) > Constants.INTELLIGENCE_MAX_CHAR_WIDTH_DISP)
                {
                    return(plateData);
                }

                RecognizedPlate recognizedPlate = new RecognizedPlate();
                //Int32 count =0;
                foreach (Char ch in chars)
                {
                    ch.Normalize();
                    // JIVAN
                    //ch.GetImage.SaveImage(String.Format(@"C:\temp\newImages\newNormImageCh{0}.png",count++));
                }

                Double averageHeight     = plate.GetAveragePieceHeight(chars);
                Double averageContrast   = plate.GetAveragePieceContrast(chars);
                Double averageBrightness = plate.GetAveragePieceBrightness(chars);
                Double averageHue        = plate.GetAveragePieceHue(chars);
                Double averageSaturation = plate.GetAveragePieceSaturation(chars);

                foreach (Char chr in chars)
                {
                    Double widthHeightRatio = (Double)(chr.PieceWidth);
                    widthHeightRatio /= (Double)(chr.PieceHeight);

                    if (widthHeightRatio < Constants.INTELLIGENCE_MIN_CHAR_WIDTH_HEIGHT_RATIO ||
                        widthHeightRatio > Constants.INTELLIGENCE_MAX_CHAR_WIDTH_HEIGHT_RATIO)
                    {
                        continue;
                    }


                    if ((chr.PositionInPlate.X1 < 2 ||
                         chr.PositionInPlate.X2 > plate.GetWidth - 1) &&
                        widthHeightRatio < 0.12)
                    {
                        continue;
                    }

                    Double contrastCost   = Math.Abs(chr.StatisticContrast - averageContrast);
                    Double brightnessCost = Math.Abs(chr.StatisticAverageBrightness - averageBrightness);
                    Double hueCost        = Math.Abs(chr.StatisticAverageHue - averageHue);
                    Double saturationCost = Math.Abs(chr.StatisticAverageSaturation - averageSaturation);
                    Double heightCost     = (chr.PieceHeight - averageHeight) / averageHeight;

                    if (brightnessCost > Constants.INTELLIGENCE_MAX_BRIGHTNESS_COST_DISPERSION)
                    {
                        continue;
                    }

                    if (contrastCost > Constants.INTELLIGENCE_MAX_CONTRAST_COST_DISPERSION)
                    {
                        continue;
                    }

                    if (hueCost > Constants.INTELLIGENCE_MAX_HUE_COST_DISPERSION)
                    {
                        continue;
                    }

                    if (saturationCost > Constants.INTELLIGENCE_MAX_SATURATION_COST_DISPERSION)
                    {
                        continue;
                    }

                    if (heightCost < -(Constants.INTELLIGENCE_MAX_HIGHT_COST_DISPERSION))
                    {
                        continue;
                    }

                    Double similarityCost = 0.0;
                    CharacterRecognizer.RecognizedChar rc = null;

                    rc             = chrRecog.Recognize(chr);
                    similarityCost = rc.GetPatterns()[0].GetCost;
                    if (similarityCost <= Constants.INTELLIGENCE_MAX_SIMILARITY_COST_DISPERSION)
                    {
                        recognizedPlate.AddChar(rc);
                    }
                }

                if (recognizedPlate.GetChars.Count < Constants.INTELLIGENCE_MIN_CHARS)
                {
                    return(plateData);
                }

                plateData = parser.Parse(recognizedPlate, Constants.INTELLIGENCE_SYNTAX_ANALYSIS_MODE);
            }
            finally
            {
                if (null != chars)
                {
                    foreach (Char ch in chars)
                    {
                        ch.ClearImage();
                    }
                }

                if (null != plate)
                {
                    plate.ClearImage();
                }
            }

            return(plateData);
        }
 public PlateVerticalGraph(Plate pHandle)
 {
     handle = pHandle;
 }
Ejemplo n.º 7
0
 public PlateHorizontalGraph(Plate pHandle)
 {
     handle = pHandle;
 }
Ejemplo n.º 8
0
 public Plate(IplImage pImage)
 {
     image           = pImage.Clone();
     plateCopy       = new Plate(image, true);
     plateCopy.image = AdaptiveThresholding(plateCopy.image);
 }
Ejemplo n.º 9
0
 public Plate()
 {
     image = null; plateCopy = null;
 }