Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Detect license plate

so i have two images (check below) and whatever the camera angel i want to detect the plate using findContours and i am using java so hard to use ROTATEDRECT so i am using normal RECT

and i found such solution [here] but not sure how to implement such points especially point 1 (http://www.sciencedirect.com/science/article/pii/S1110016813000276)

  1. Rectangle check Checking that the candidate regions for plate had rectangle shape by compare white pixels count of these regions to their areas with ±5% tolerance If count of white pixels = ±5% area of these region This region may be a plate Else This region not a plate
  2. Plate dimension check The Egyptian plate had a fixed dimension with height equal to 17 cm and width equal to 32 cm, so the ratio between heights to width approximately 1:2. After rectangle check, the dimension check applied of the succeed regions of rectangle shapes, If 1.5 < width/height of the succeed region < 2.5

This region may be a plate • Else This region not a plate

image1 image 2

Detect license plate

so i have two images (check below) and whatever the camera angel i want to detect the plate using findContours and i am using java so hard to use ROTATEDRECT so i am using normal RECT

and i found such solution [here] but not sure how to implement such points especially point 1 (http://www.sciencedirect.com/science/article/pii/S1110016813000276)

  1. Rectangle check Checking that the candidate regions for plate had rectangle shape by compare white pixels count of these regions to their areas with ±5% tolerance If count of white pixels = ±5% area of these region This region may be a plate Else This region not a plate
  2. Plate dimension check The Egyptian plate had a fixed dimension with height equal to 17 cm and width equal to 32 cm, so the ratio between heights to width approximately 1:2. After rectangle check, the dimension check applied of the succeed regions of rectangle shapes, If 1.5 < width/height of the succeed region < 2.5

This region may be a plate • Else This region not a plate

this is my code trying to implement

    Mat hierarchy = new Mat();
            Mat sorted = new Mat();
            Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

            for (MatOfPoint contour : contours) {

                Rect rec = Imgproc.boundingRect(contour);
                if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

                    for (int i = 0; i < contours.size(); i++) {
                        if (verifysize(rec)) {

{

    //                    Imgproc.drawContours(image, contours, i, new Scalar(0, 0, 255), -1, 8, hierarchy, 0, new Point());
                            Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                        }

                    }
                    Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/41.jpg", image);
                }
            }

        }

        public static boolean verifysize(Rect re) {

            //Egyptian car plate size: 35*17 
            final float aspect = (float) 0.5;
            float region = (float) (re.size().width / re.size().height);
            System.out.println(region);
            if (1.5 < region && region < 2.5) {
                return true;
            } else {
                return false;
            }
        }

image1 image 2

Detect license plate

so i have two images (check below) and whatever the camera angel i want to detect the plate using findContours and i am using java so hard to use ROTATEDRECT so i am using normal RECT

and i found such solution [here] but not sure how to implement such points especially point 1 (http://www.sciencedirect.com/science/article/pii/S1110016813000276)

  1. Rectangle check Checking that the candidate regions for plate had rectangle shape by compare white pixels count of these regions to their areas with ±5% tolerance If count of white pixels = ±5% area of these region This region may be a plate Else This region not a plate
  2. Plate dimension check The Egyptian plate had a fixed dimension with height equal to 17 cm and width equal to 32 cm, so the ratio between heights to width approximately 1:2. After rectangle check, the dimension check applied of the succeed regions of rectangle shapes, If 1.5 < width/height of the succeed region < 2.5

This region may be a plate • Else This region not a plate

this is my code trying to implement

    Mat hierarchy = new Mat();
            Mat sorted = new Mat();
            Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

            for (MatOfPoint contour : contours) {

                Rect rec = Imgproc.boundingRect(contour);
                if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

                    for (int i = 0; i < contours.size(); i++) {
                        if (verifysize(rec)) {

{

    //                    Imgproc.drawContours(image, contours, i, new Scalar(0, 0, 255), -1, 8, hierarchy, 0, new Point());
                            Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                        }

                    }
                    Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/41.jpg", image);
                 }
            }

        }

        public static boolean verifysize(Rect re) {

            //Egyptian car plate size: 35*17 
            final float aspect = (float) 0.5;
            float region = (float) (re.size().width / re.size().height);
            System.out.println(region);
            if (1.5 < region && region < 2.5) {
                return true;
            } else {
                return false;
            }
        }

image1 image 2

Detect license plate

so i have two images (check below) when i use the following code the first image provide a rectangle around the plate and whatever in the camera angel second it doesn't i want believe this is because different distance or image size my questions is why? and how to detect my region of interest which is the plate using findContours and i am using java so hard (what to use ROTATEDRECT so i am using normal RECT

and i found such solution [here] but not sure how to implement such points especially point 1 (http://www.sciencedirect.com/science/article/pii/S1110016813000276)

  1. Rectangle check Checking that the candidate regions for plate had rectangle shape by compare white pixels count of these regions to their areas with ±5% tolerance If count of white pixels = ±5% area of these region This region may be a plate Else This region not a plate
  2. Plate dimension check The Egyptian plate had a fixed dimension with height equal to 17 cm and width equal to 32 cm, so the ratio between heights to width approximately 1:2. After rectangle check, the dimension check applied of the succeed regions of rectangle shapes, If 1.5 < width/height of the succeed region < 2.5

This region may be a plate • Else This region not a plate

this is my code trying to implement do?)

public void run() throws IOException {

    Mat image = Imgcodecs.imread("/home/tomna/NetBeansProjects/MainClass/src/mainclass/cars/1.jpg");
    Mat image_gray = new Mat();
    Mat image_bilateral = new Mat();
    Mat image_sobel = new Mat();
    Mat image_threshold = new Mat();
    Mat image_morph = new Mat();
    Mat strel = getStructuringElement(MORPH_RECT, new Size(35, 35));
    Mat Kernel = Mat.ones(new Size(3, 3), MORPH_RECT);

    Imgproc.cvtColor(image, image_gray, Imgproc.COLOR_BGR2GRAY);

    Imgproc.bilateralFilter(image_gray, image_bilateral, 15, 10, 14);
    Imgproc.equalizeHist(image_bilateral, image_bilateral);

    Imgproc.morphologyEx(image_bilateral, image_morph, Imgproc.MORPH_CLOSE, strel);
    Core.subtract(image_morph, image_bilateral, image_threshold);
    Imgproc.threshold(image_threshold, image_threshold, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
    Imgproc.Canny(image_threshold, strel, 250, 225);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);

    Vector<MatOfPoint> contours = new Vector<MatOfPoint>();

    Mat hierarchy = new Mat();
     Mat sorted = new Mat();
     Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

     for (MatOfPoint contour : contours) {
         Rect rec = Imgproc.boundingRect(contour);
         if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

             for (int i = 0; i < contours.size(); i++) {
                  if (verifysize(rec)) {

{

    //                    Imgproc.drawContours(image, contours, i, new Scalar(0, 0, 255), -1, 8, hierarchy, 0, new Point());
                            Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                        }

                    }

                }
            }

        }

        }
            }

        }
        Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/Dadcar2.jpg", image);

    }
}

public static boolean verifysize(Rect re) {

            //Egyptian car plate size: 35*17 
            final float aspect = (float) 0.5;
     float region = (float) (re.size().width / re.size().height);
            System.out.println(region);
        (float)re.size().height);
    if (1.5 < region && region < 2.5) {
         return true;
     } else {
         return false;
            }
        }

}

image1 image 2image description

image1

image description

Detect license plate

so i have two images when i use the following code the first image provide a rectangle around the plate and in the second it doesn't i believe this is because different distance or image size my questions is why? and how to detect my region of interest which is the plate (what to do?)

public void run() throws IOException {

    Mat image = Imgcodecs.imread("/home/tomna/NetBeansProjects/MainClass/src/mainclass/cars/1.jpg");
    Mat image_gray = new Mat();
    Mat image_bilateral = new Mat();
    Mat image_sobel = new Mat();
    Mat image_threshold = new Mat();
    Mat image_morph = new Mat();
    Mat strel = getStructuringElement(MORPH_RECT, new Size(35, 35));
    Mat Kernel = Mat.ones(new Size(3, 3), MORPH_RECT);

    Imgproc.cvtColor(image, image_gray, Imgproc.COLOR_BGR2GRAY);

    Imgproc.bilateralFilter(image_gray, image_bilateral, 15, 10, 14);
    Imgproc.equalizeHist(image_bilateral, image_bilateral);

    Imgproc.morphologyEx(image_bilateral, image_morph, Imgproc.MORPH_CLOSE, strel);
    Core.subtract(image_morph, image_bilateral, image_threshold);
    Imgproc.threshold(image_threshold, image_threshold, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
    Imgproc.Canny(image_threshold, strel, 250, 225);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);

    Vector<MatOfPoint> contours = new Vector<MatOfPoint>();

    Mat hierarchy = new Mat();
    Mat sorted = new Mat();
    Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

    for (MatOfPoint contour : contours) {
        Rect rec = Imgproc.boundingRect(contour);
        if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

            for (int i = 0; i < contours.size(); i++) {

                if (verifysize(rec)) {
                    Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                }
            }

        }
        Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/Dadcar2.jpg", image);

    }
}

public static boolean verifysize(Rect re) {
    final float aspect = (float) 0.5;
    float region = (float) (re.size().width / (float)re.size().height);
    if (1.5 < region && region < 2.5) {
        return true;
    } else {
        return false;
    }

}

image description

image1

image description

Detect license plate

so i have two images when i use the following code the first image provide a rectangle around the plate and in the second it doesn't i believe this is because different distance or image size my questions is why? and how to detect my region of interest which is the plate (what to do?)

public void run() throws IOException {

    Mat image = Imgcodecs.imread("/home/tomna/NetBeansProjects/MainClass/src/mainclass/cars/1.jpg");
    Mat image_gray = new Mat();
    Mat image_bilateral = new Mat();
    Mat image_sobel = new Mat();
    Mat image_threshold = new Mat();
    Mat image_morph = new Mat();
    Mat strel = getStructuringElement(MORPH_RECT, new Size(35, 35));
    Mat Kernel = Mat.ones(new Size(3, 3), MORPH_RECT);

    Imgproc.cvtColor(image, image_gray, Imgproc.COLOR_BGR2GRAY);

    Imgproc.bilateralFilter(image_gray, image_bilateral, 15, 10, 14);
    Imgproc.equalizeHist(image_bilateral, image_bilateral);

    Imgproc.morphologyEx(image_bilateral, image_morph, Imgproc.MORPH_CLOSE, strel);
    Core.subtract(image_morph, image_bilateral, image_threshold);
    Imgproc.threshold(image_threshold, image_threshold, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
    Imgproc.Canny(image_threshold, strel, 250, 225);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);

    Vector<MatOfPoint> contours = new Vector<MatOfPoint>();

    Mat hierarchy = new Mat();
    Mat sorted = new Mat();
    Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

    for (MatOfPoint contour : contours) {
        Rect rec = Imgproc.boundingRect(contour);
        if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

            for (int i = 0; i < contours.size(); i++) {

                if (verifysize(rec)) {
                    Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                }
            }

        }
        Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/Dadcar2.jpg", image);

    }
}

public static boolean verifysize(Rect re) {
    final float aspect = (float) 0.5;
    float region = (float) (re.size().width / (float)re.size().height);
    if (1.5 < region && region < 2.5) {
        return true;
    } else {
        return false;
    }

}

image description

image1

image description

UPDATE

so i decided to resize any image to (720,1280) according to the image that detected the plate (first pic) so the output i think is better but still not sure the right decision because it worked for the just two pictures

here is the code

    Size s = new Size(720,1280);
    Imgproc.resize(image,image,s);
    System.err.println("resizing...");

output images

image description image description image description

Detect license plate

so i have two images when i use the following code the first image provide a rectangle around the plate and in the second it doesn't i believe this is because different distance or image size my questions is why? and how to detect my region of interest which is the plate (what to do?)

public void run() throws IOException {

    Mat image = Imgcodecs.imread("/home/tomna/NetBeansProjects/MainClass/src/mainclass/cars/1.jpg");
    Mat image_gray = new Mat();
    Mat image_bilateral = new Mat();
    Mat image_sobel = new Mat();
    Mat image_threshold = new Mat();
    Mat image_morph = new Mat();
    Mat strel = getStructuringElement(MORPH_RECT, new Size(35, 35));
    Mat Kernel = Mat.ones(new Size(3, 3), MORPH_RECT);

    Imgproc.cvtColor(image, image_gray, Imgproc.COLOR_BGR2GRAY);

    Imgproc.bilateralFilter(image_gray, image_bilateral, 15, 10, 14);
    Imgproc.equalizeHist(image_bilateral, image_bilateral);

    Imgproc.morphologyEx(image_bilateral, image_morph, Imgproc.MORPH_CLOSE, strel);
    Core.subtract(image_morph, image_bilateral, image_threshold);
    Imgproc.threshold(image_threshold, image_threshold, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
    Imgproc.Canny(image_threshold, strel, 250, 225);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);

    Vector<MatOfPoint> contours = new Vector<MatOfPoint>();

    Mat hierarchy = new Mat();
    Mat sorted = new Mat();
    Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

    for (MatOfPoint contour : contours) {
        Rect rec = Imgproc.boundingRect(contour);
        if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

            for (int i = 0; i < contours.size(); i++) {

                if (verifysize(rec)) {
                    Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                }
            }

        }
        Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/Dadcar2.jpg", image);

    }
}

public static boolean verifysize(Rect re) {
    final float aspect = (float) 0.5;
    float region = (float) (re.size().width / (float)re.size().height);
    if (1.5 < > region && region < > 2.5) {
        return false;
    } else {
        return true;
    } else {
        return false;
    }

}

image description

image1

image description

UPDATE

so i decided to resize any image to (720,1280) according to the image that detected the plate (first pic) so the output i think is better but still not sure the right decision because it worked for the just two pictures

here is the code

    Size s = new Size(720,1280);
    Imgproc.resize(image,image,s);
    System.err.println("resizing...");

output images

image description image description image description

Detect license plate

so i have two images when i use the following code the first image provide a rectangle around the plate and in the second it doesn't i believe this is because different distance or image size my questions is why? and how to detect my region of interest which is the plate (what to do?)

public void run() throws IOException {

    Mat image = Imgcodecs.imread("/home/tomna/NetBeansProjects/MainClass/src/mainclass/cars/1.jpg");
    Mat image_gray = new Mat();
    Mat image_bilateral = new Mat();
    Mat image_sobel = new Mat();
    Mat image_threshold = new Mat();
    Mat image_morph = new Mat();
    Mat strel = getStructuringElement(MORPH_RECT, new Size(35, 35));
    Mat Kernel = Mat.ones(new Size(3, 3), MORPH_RECT);

    Imgproc.cvtColor(image, image_gray, Imgproc.COLOR_BGR2GRAY);

    Imgproc.bilateralFilter(image_gray, image_bilateral, 15, 10, 14);
    Imgproc.equalizeHist(image_bilateral, image_bilateral);

    Imgproc.morphologyEx(image_bilateral, image_morph, Imgproc.MORPH_CLOSE, strel);
    Core.subtract(image_morph, image_bilateral, image_threshold);
    Imgproc.threshold(image_threshold, image_threshold, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
    Imgproc.Canny(image_threshold, strel, 250, 225);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);

    Vector<MatOfPoint> contours = new Vector<MatOfPoint>();

    Mat hierarchy = new Mat();
    Mat sorted = new Mat();
    Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

    for (MatOfPoint contour : contours) {
        Rect rec = Imgproc.boundingRect(contour);
        if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {

            for (int i = 0; i < contours.size(); i++) {

                if (verifysize(rec)) {
                    Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
                }
            }

        }
        Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/Dadcar2.jpg", image);

    }
}

public static boolean verifysize(Rect re) {
    float region = (float) (re.size().width / (float)re.size().height);
    if (1.5 > region && region > 2.5) {
        return false;
    } else {
        return true;
    }

}

image description

image1

image description

UPDATE

so i decided to resize any image to (720,1280) according to the image that detected the plate (first pic) so the output i think is better but still not sure the right decision because it worked for the just two pictures

here is the code

    Size s = new Size(720,1280);
    Imgproc.resize(image,image,s);
    System.err.println("resizing...");

output images

image description image description image description

Detect license plate

ok i am working on how to detect the plate on different image sizes so i have two images when i use the following code the first image provide a rectangle around the plate and in the second it doesn't i believe read from this link that there is because different distance or image size my questions is why? and how to detect my region of interest which is the plate (what to do?)technique as follow link

public void run() throws IOException {

        1.Rectangle check   
     Checking that the candidate regions for plate had rectangle shape by compare white pixels count of these regions to their areas with ±5% tolerance  
 If count of white pixels = ±5% area of these region   
This region may be a plate 
  Else This region not a plate
     2. Plate dimension check 
 The Egyptian plate had a fixed dimension with height equal to 17 cm and width equal to 32 cm, so the ratio between heights to width approximately 1:2.   After rectangle check, the dimension check applied of the succeed regions of rectangle shapes, 
 If 1.5 < width/height of the succeed region <2.5    
            This region may be a plate   
              Else This region not a plate

so after findcontours such if conditions should be applies and here is my code

Mat image = Imgcodecs.imread("/home/tomna/NetBeansProjects/MainClass/src/mainclass/cars/1.jpg");
    Mat image_gray hierarchy = new Mat();
    Mat image_bilateral = new Mat();
    Mat image_sobel = new Mat();
    Mat image_threshold = new Mat();
    Mat image_morph = new Mat();
    Mat strel = getStructuringElement(MORPH_RECT, new Size(35, 35));
    Mat Kernel = Mat.ones(new Size(3, 3), MORPH_RECT);

    Imgproc.cvtColor(image, image_gray, Imgproc.COLOR_BGR2GRAY);

    Imgproc.bilateralFilter(image_gray, image_bilateral, 15, 10, 14);
    Imgproc.equalizeHist(image_bilateral, image_bilateral);

    Imgproc.morphologyEx(image_bilateral, image_morph, Imgproc.MORPH_CLOSE, strel);
    Core.subtract(image_morph, image_bilateral, image_threshold);
    Imgproc.threshold(image_threshold, image_threshold, 0, 255, Imgproc.THRESH_OTSU + Imgproc.THRESH_BINARY);
    Imgproc.Canny(image_threshold, strel, 250, 225);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);
    Imgproc.dilate(image_threshold, image_threshold, Kernel);

    Vector<MatOfPoint> contours = new Vector<MatOfPoint>();

    Mat hierarchy = new Mat();
    Mat sorted = new Mat();
    Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

//        Rect rectCrop = new Rect();
        Mat m = new Mat();
        for (MatOfPoint contour : contours) {
         Rect rec = Imgproc.boundingRect(contour);
         if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {
              for (int i = 0; i < contours.size(); i++) {

                 if (verifysize(rec)) {
                        System.out.println("first test");
                        Core.extractChannel(contour, m, 0);
                        int n = Core.countNonZero(m);
                        float area = (float) (rec.size().height * (float) rec.size().width); 
                        int minarea = (int) area - (int) (area / 100 * 6);
                        int maxarea = (int) area + (int) (area / 100 * 6);
                        if (minarea < n || n < maxarea) {
                            System.err.println("second test");
//                            Imgproc.drawContours(image, contours, i, new Scalar(0, 0, 255), -1, 8, hierarchy, 0, new Point());
                            Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
//                        rectCrop = new Rect(rec.x, rec.y, rec.width, rec.height);
                        }
             }
          }
        Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/Dadcar2.jpg", 
            }
            Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/121.jpg", image);

    }
 }

public static boolean verifysize(Rect re) {
     float region ratio = (float) (re.size().width re.size().width / (float)re.size().height);
(float) re.size().height;
    if (1.5 (2.0 > region && region ratio || ratio > 2.5) 2.3) {
        return false;
    } else {
        return true;
    }

}

image description

image1

image description

UPDATE

so i decided to resize any image to (720,1280) according to the image that detected the plate (first pic) so the output i think is better but still not sure the right decision because it worked for the just two pictures

here is the code

    Size s = new Size(720,1280);
    Imgproc.resize(image,image,s);
    System.err.println("resizing...");

output images

image description image description image description

Detect license plate

ok i am working on how to detect the plate on different image sizes so i have read from this link that there is technique as follow link

    1.Rectangle check   
     Checking that the candidate regions for plate had rectangle shape by compare white pixels count of these regions to their areas with ±5% tolerance  
 If count of white pixels = ±5% area of these region   
This region may be a plate 
  Else This region not a plate
     2. Plate dimension check 
 The Egyptian plate had a fixed dimension with height equal to 17 cm and width equal to 32 cm, so the ratio between heights to width approximately 1:2.   After rectangle check, the dimension check applied of the succeed regions of rectangle shapes, 
 If 1.5 < width/height of the succeed region <2.5    
            This region may be a plate   
              Else This region not a plate

so after findcontours such if conditions should be applies and here is my code

Mat hierarchy = new Mat();
        Imgproc.findContours(image_threshold.clone(), contours, hierarchy, Imgproc.RETR_EXTERNAL, Imgproc.CHAIN_APPROX_NONE);

//        Rect rectCrop = new Rect();
        Mat m = new Mat();
        for (MatOfPoint contour : contours) {

            Rect rec = Imgproc.boundingRect(contour);

            if (hierarchy.size().height > 0 && hierarchy.size().width > 0) {
                for (int i = 0; i < contours.size(); i++) {

                    if (verifysize(rec)) {
                        System.out.println("first test");
                        Core.extractChannel(contour, m, 0);
                        int n = Core.countNonZero(m);
                        float area = (float) (rec.size().height * (float) rec.size().width); 
                        int minarea = (int) area - (int) (area / 100 * 6);
                        int maxarea = (int) area + (int) (area / 100 * 6);
                        if (minarea < n || n < maxarea) {
                            System.err.println("second test");
//                            Imgproc.drawContours(image, contours, i, new Scalar(0, 0, 255), -1, 8, hierarchy, 0, new Point());
                            Imgproc.rectangle(image, rec.tl(), rec.br(), new Scalar(0, 0, 255), 3);
//                        rectCrop = new Rect(rec.x, rec.y, rec.width, rec.height);
                        }
                    }
                }

            }
            Imgcodecs.imwrite("/home/tomna/NetBeansProjects/MainClass/src/mainclass/121.jpg", image);
        }

public static boolean verifysize(Rect re) {

    float ratio = (float) re.size().width / (float) re.size().height;
    if (2.0 (1.5 > ratio || ratio > 2.3) 2.5) {
        return false;
    } else {
        return true;
    }

}