def __init__(self): print("------- Initial E2E") self.image = np.empty((28, 28, 1)) self.detectLP = detectNumberPlate() print("------- Loaded detectNumberPlate model") self.detect_vehicle = DetectVehicle(threshold=0.5) # self.recogChar = CNN_Model(trainable=False).model # self.recogChar.load_weights('./weights/original_weight.h5') # print ("------- Loaded recogChar model") self.candidates = [] self.prev_candidates = dict() # print("------- Before load VehicleDetection") # self.vehicle_detection = VehicleDetection() # print("------- After load VehicleDetection") print("------- Before load LicensePlateDetection") self.license_plate_detection = LicensePlateDetection() print("------- After load LicensePlateDetection") print("------- Before load OCR") self.ocr = OCR(ocr_threshold=0.1) print("------- After load OCR") print("------- Before load GenOutput") self.gen_output = GenOutput() print("------- After load GenOutput")
def __init__(self): self.image = np.empty((28, 28, 1)) self.detectLP = detectNumberPlate() self.recogChar = CNN_Model(trainable=False).model self.recogChar.load_weights('./weights/weight.h5') self.candidates = [] self.preLpCnt = None
def save_a_img(link_img, output): model = detectNumberPlate() file_name = os.path.basename(link_img) img = cv2.imread(link_img) coordinates = model.detect(img) for coordinate in coordinates: pts = order_points(coordinate) ls_region = perspective.four_point_transform(img, pts) cv2.imwrite(os.path.join(output, file_name), ls_region) return ls_region
def save_img(data_dir, output_dir): model = detectNumberPlate() #initizial class to detect image list_file = glob.glob(data_dir + "/*.jpg") #take list file for file in list_file: #take each file in list file file_name = os.path.basename(file) #name file match with list file original img = cv2.imread(file) #read file coordinates = model.detect(img) #detect file for coordinate in coordinates: # detect license plate by yolov3 # candidates = [] # convert (x_min, y_min, width, height) to coordinate(top left, top right, bottom left, bottom right) pts = order_points(coordinate) # crop number plate used by bird's eyes view transformation lp_region = perspective.four_point_transform(img, pts) cv2.imwrite(os.path.join(output_dir, file_name), lp_region)