License Plate Photos Database

Autor:rubens
Data:08/11/2012

Description

The License Plate Photos Database for testing the Licensing Plate Recognition algorithms is organized in groups of similar characteristics. The database images can be accessed using the functions provided in this file. Each image has attributes such as region of interest (ROI) of the vehicle license plate and the license code in the format 'AAA-9999'. There are examples below to show how the database is organized and how it can be accessed.

Functions

lcounts = lprGetCounts()
Returns a list with the number of photos in each group. The photos are grouped by the type and place of acquisition.
image, grID = lprGetPhoto(phID)
Returns an image corresponding to the index phID in the database. Also returns grID with the group number of the image.
(image, phID), ... = lprGetPhotos(count=1, group=1, start=None)
Allows retrieving multiple images from a given group. The first image is specified by the integer parameter start; if not, the images are fetched randomly. Also returns the photo index phID.
x1, y1, x2, y2 = lprGetPlateROI(phID)
Returns a list with the image ROI that contains the vehicle plate. The four elements of the list are upper left corner (x1,y1) and bottom right corner (x2,y2).
x1, y1, x2, y2 = lprGetPlateBBox(phID)
Returns a list with the image tight ROI that contains only the vehicle plate characters. The four elements of the list are upper left corner (x1,y1) and bottom right corner (x2,y2).
s = lprGetPlateLabel(phID)
Returns the string s containing the plate characters in the format 'AAA-9999'.
labels, images, polys = lprGetChars(phID)
Returns three lists of equal lengths containing the character labels, images and the bounding polygons referenced to the original image. May return less than seven characters.

Examples

lprGetCounts

In this example, we list the number of images in the database in each group. The main function to use is lprGetCounts. Note that to find the total number of the images in the database, one can just sum all the list elements.

1 import iaLPR
2 
3 ng = iaLPR.lprGetCounts()
4 print 'List of image groups: ', ng
5 for i, nb in enumerate(ng):
6     print 'Group %2d has %4d images' % (i+1, nb)
7 
8 print
9 print 'Total:       %4d images' % sum(ng)
List of image groups:  [197, 58, 2470, 65, 125, 24, 503, 1113, 1460, 244, 645, 40]
Group  1 has  197 images
Group  2 has   58 images
Group  3 has 2470 images
Group  4 has   65 images
Group  5 has  125 images
Group  6 has   24 images
Group  7 has  503 images
Group  8 has 1113 images
Group  9 has 1460 images
Group 10 has  244 images
Group 11 has  645 images
Group 12 has   40 images

Total:       6944 images

lprGetPhoto, lprGetPlateROI, lprGetPlateLabel

In this example, a particular image from the data base is displayed. The index must be within the total number of the images in the database. The group and plane region of interest (ROI) is returned using lprGetPlateROI and lprGetPlateLabel returns the decoded license plate.

 1 import ia636
 2 def draw_roi(image, roi, color='red'):
 3     draw = adDraw(image, rgb=1)
 4     draw. rectangle(roi, outline=color)
 5     return draw.get_image()
 6 
 7 phID = 2732
 8 image, grID = iaLPR.lprGetPhoto(phID)
 9 print ia636.iaimginfo(image)
10 roi = iaLPR.lprGetPlateROI(phID)
11 bbox = iaLPR.lprGetPlateBBox(phID)
12 label = iaLPR.lprGetPlateLabel(phID)
13 print 'Image shape: ',image.shape
14 print 'Plate ROI:      ', roi
15 print 'Plate Tight ROI:', bbox
16 
17 imagec = draw_roi(image, roi)
18 imagec = draw_roi(imagec, bbox, 'blue')
19 adshow(imagec, title='Image G%d #%d: %s **%s**' % (grID, phID, image.shape, label))
<type 'numpy.ndarray'> (240, 320) uint8 0 255
Image shape:  (240, 320)
Plate ROI:       (35, 52, 207, 138)
Plate Tight ROI: (66, 82, 176, 106)

Image G4 #2732: (240, 320) GZA-2477

lprGetPhotos

In this example, three random images from each group in the database are displayed with their ROIs and number plates.

1 N = len(iaLPR.lprGetCounts()) # total number of groups is the length of the lprGetCounts() list
2 for i in range(1,N+1):
3     for image, phID in iaLPR.lprGetPhotos(count=3, group=i): # 3 random photos from group i
4         roi = iaLPR.lprGetPlateROI(phID)
5         box = iaLPR.lprGetPlateBBox(phID)
6         label = iaLPR.lprGetPlateLabel(phID)
7         imagec = draw_roi(image, roi)
8         imagec = draw_roi(imagec, box, 'blue')
9         adshow(imagec, title='Image G%d #%d: %s **%s**' % (i, phID, image.shape, label))

Image G1 #156: (240, 640) EJD-8085

Image G1 #139: (240, 640) CVT-8997

Image G1 #26: (240, 640) DQB-7570

Image G2 #254: (480, 640) LOF-3405

Image G2 #220: (480, 640) LAG-5887

Image G2 #244: (480, 640) LNZ-1724

Image G3 #768: (455, 640) CFT-7810

Image G3 #530: (455, 640) BST-0821

Image G3 #2287: (455, 640) DPA-1868

Image G4 #2753: (240, 320) LAR-7207

Image G4 #2765: (240, 320) LIK-3988

Image G4 #2780: (240, 320) LNZ-3777

Image G5 #2802: (240, 320) GTR-4203

Image G5 #2885: (240, 320) LNT-5505

Image G5 #2792: (240, 320) AKP-8105

Image G6 #2938: (385, 640) LWX-1424

Image G6 #2926: (385, 640) CMY-1971

Image G6 #2934: (385, 640) DFE-0214

Image G7 #3095: (480, 640) BYE-8482

Image G7 #3178: (480, 640) CPI-6315

Image G7 #3205: (480, 640) CVN-1998

Image G8 #3802: (240, 352) BYD-8685

Image G8 #3553: (240, 352) BMJ-8535

Image G8 #4227: (240, 352) CGL-6954

Image G9 #5923: (480, 640) LIE-6350

Image G9 #5689: (480, 640) DPB-0647

Image G9 #4770: (480, 640) BQY-1927

Image G10 #6221: (450, 640) JTY-0007

Image G10 #6257: (450, 640) MPZ-2391

Image G10 #6053: (450, 640) GOX-5504

Image G11 #6848: (240, 640) IQR-4860

Image G11 #6803: (240, 640) EQG-3669

Image G11 #6800: (240, 640) EQC-8880

Image G12 #6924: (264, 352) DCG-3455

Image G12 #6929: (264, 352) DGI-1022

Image G12 #6906: (264, 352) ALR-7951

lprGetChars

From one image:

1 phID = 1000
2 labels, images, bboxes = iaLPR.lprGetChars(phID)
3 for label, image, bbox in zip(labels, images, bboxes):
4     print 'label=',label
5     print 'bbox=', bbox
6     adshow(mmneg(image),title='phID = %d, label=%s'% (phID, label))
label= C
bbox= [[277 219]
 [278 251]
 [300 251]
 [299 219]]
label= L
bbox= [[306 219]
 [306 251]
 [328 251]
 [327 219]]
label= S
bbox= [[330 219]
 [331 251]
 [355 251]
 [354 219]]
label= 5
bbox= [[370 219]
 [371 251]
 [391 251]
 [390 219]]
label= 9
bbox= [[393 219]
 [394 251]
 [414 251]
 [413 219]]
label= 8
bbox= [[415 219]
 [416 250]
 [436 250]
 [435 219]]
label= 1
bbox= [[438 219]
 [439 251]
 [450 251]
 [449 219]]

phID = 1000, label=C

phID = 1000, label=L

phID = 1000, label=S

phID = 1000, label=5

phID = 1000, label=9

phID = 1000, label=8

phID = 1000, label=1

From two images of each group:

 1 N = len(iaLPR.lprGetCounts())
 2 for i in range(1,N+1):
 3     for img, phID in iaLPR.lprGetPhotos(count=2, group=i):
 4         labels, images, bboxes = iaLPR.lprGetChars(phID)
 5         for label, image, bbox in zip(labels, images, bboxes):
 6             xx1, yy1 = bbox.min(0)
 7             xx2, yy2 = bbox.max(0)
 8             adshow(img[yy1:yy2+1,xx1:xx2+1], title='-')
 9             image = iaLPR.fix_aspect_ratio(image, ar=3/4.0)
10             image = where(image == 0, 64, image)
11             adshow(mmneg(image), title=label)
12         for i in range(len(labels)-7):
13             adshow(255*np.ones_like(images[0]), title='.')
14             adshow(255*np.ones_like(images[0]), title='..')

-

E

-

B

-

Y

-

3

-

4

-

4

-

1

-

E

-

I

-

W

-

3

-

7

-

6

-

9

-

L

-

O

-

E

-

2

-

0

-

2

-

2

-

L

-

N

-

P

-

5

-

5

-

6

-

9

-

D

-

E

-

C

-

4

-

6

-

2

-

6

-

K

-

L

-

F

-

8

-

2

-

3

-

5

-

L

-

N

-

Z

-

4

-

2

-

9

-

2

-

K

-

M

-

N

-

0

-

8

-

5

-

7

-

L

-

A

-

I

-

0

-

3

-

2

-

7

-

L

-

C

-

N

-

6

-

9

-

9

-

4

-

G

-

Q

-

T

-

8

-

0

-

0

-

8

-

D

-

D

-

G

-

9

-

3

-

2

-

7

-

A

-

K

-

A

-

8

-

9

-

9

-

6

-

C

-

V

-

N

-

7

-

9

-

5

-

9

-

C

-

C

-

X

-

8

-

0

-

9

-

3

-

B

-

M

-

H

-

5

-

8

-

3

-

0

-

B

-

S

-

G

-

9

-

8

-

7

-

2

-

M

-

D

-

Y

-

8

-

9

-

5

-

9

-

K

-

E

-

P

-

0

-

0

-

8

-

8

-

H

-

Z

-

M

-

8

-

2

-

2

-

4

-

D

-

V

-

B

-

0

-

5

-

2

-

1

-

E

-

N

-

R

-

3

-

8

-

8

-

3

-

D

-

G

-

I

-

1

-

0

-

2

-

2

-

D

-

U

-

N

-

3

-

5

-

9

-

6