-
Notifications
You must be signed in to change notification settings - Fork 0
ds570001/license_plate_NN_trainer
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
import string import random from random import randint import cv2 import numpy as np import os from PIL import Image, ImageFont, ImageDraw NUMBER_OF_PLATES = 100 first_plate = True path = "./blank_plate/" for i in range(0, NUMBER_OF_PLATES): # Pick two random letters plate_alpha = "" for _ in range(0, 2): plate_alpha += (random.choice(string.ascii_uppercase)) # Pick two random numbers num = randint(0, 99) plate_num = "{:02d}".format(num) # Write plate to image blank_plate = cv2.imread(path+'blank_plate.png') # Convert into a PIL image (this is so we can use the monospaced fonts) blank_plate_pil = Image.fromarray(blank_plate) # Get a drawing context draw = ImageDraw.Draw(blank_plate_pil) monospace = ImageFont.truetype(font="/usr/share/fonts/truetype/liberation/LiberationMono-Regular.ttf", size=165) draw.text(xy=(48, 75), text=plate_alpha + " " + plate_num, fill=(255,0,0), font=monospace) # Convert back to OpenCV image and save blank_plate = np.array(blank_plate_pil) height, width, channels = blank_plate.shape #Write license plate to file cv2.imwrite(os.path.join("./training_data/", "plate_{}{}.png".format(plate_alpha, plate_num)), blank_plate)
About
No description, website, or topics provided.
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published