Ask Your Question

Revision history [back]

How to detect license plate from image in java?

I try to detect the license plate from image.

My steps:

1/ Filter noise (Smooth Gaussian)

2/Convert to gray Image

3/ThresholdBinary

4/Dilation and Erosion

5/ Cany filter and findContours But I have a problem with find and draw contours around the license. I am binner in java. I really really want to help. Please hepl me. Thanks.!

original image Original image egde image Egde image Image I want Image I want And here is my code

public class ex1 {
public static void main(String[] args) {
//read image
IplImage orgImg = cvLoadImage("F:\\bs9.jpg");
//smooth Gaussian
cvSmooth(orgImg,orgImg,CV_GAUSSIAN,7);
// gray image
IplImage grayImg = cvCreateImage(cvGetSize(orgImg),orgImg.depth(),1);
cvCvtColor(orgImg,grayImg,CV_BGR2GRAY);
//Threshold binary
cvThreshold(grayImg,grayImg,230,255,CV_THRESH_BINARY_INV);      


//dalition - erosion

cvErode(grayImg,grayImg,null,3);
cvDilate(grayImg,grayImg,null,2);

// canny filter
IplImage egde = cvCreateImage(cvSize(grayImg.width(),grayImg.height()),IPL_DEPTH_8U,1);
cvCanny(grayImg,egde,140,240,7);
// show image
cvShowImage("org",orgImg);
cvShowImage("binary",grayImg);
cvShowImage("edge",egde);
//save image
cvWaitKey();
click to hide/show revision 2
retagged

updated 2015-02-23 09:43:22 -0600

berak gravatar image

How to detect license plate from image in java?

I try to detect the license plate from image.

My steps:

1/ Filter noise (Smooth Gaussian)

2/Convert to gray Image

3/ThresholdBinary

4/Dilation and Erosion

5/ Cany filter and findContours But I have a problem with find and draw contours around the license. I am binner in java. I really really want to help. Please hepl me. Thanks.!

original image Original image egde image Egde image Image I want Image I want And here is my code

public class ex1 {
public static void main(String[] args) {
//read image
IplImage orgImg = cvLoadImage("F:\\bs9.jpg");
//smooth Gaussian
cvSmooth(orgImg,orgImg,CV_GAUSSIAN,7);
// gray image
IplImage grayImg = cvCreateImage(cvGetSize(orgImg),orgImg.depth(),1);
cvCvtColor(orgImg,grayImg,CV_BGR2GRAY);
//Threshold binary
cvThreshold(grayImg,grayImg,230,255,CV_THRESH_BINARY_INV);      


//dalition - erosion

cvErode(grayImg,grayImg,null,3);
cvDilate(grayImg,grayImg,null,2);

// canny filter
IplImage egde = cvCreateImage(cvSize(grayImg.width(),grayImg.height()),IPL_DEPTH_8U,1);
cvCanny(grayImg,egde,140,240,7);
// show image
cvShowImage("org",orgImg);
cvShowImage("binary",grayImg);
cvShowImage("edge",egde);
//save image
cvWaitKey();