Exemplo n.º 1
0
 def __init__(self):
     self.model = pr.LPR("model/cascade.xml", "model/model12.h5", "model/ocr_plate_all_gru.h5")
     print('init')
     pass
Exemplo n.º 2
0
                self.__nicknames[user_id] = None
        f.close()

        if has_receive == filesize:
            print('\n[Server] successfully received!')
            connection.sendall(
                json.dumps('[Server] successfuly received the file!').encode(
                    'utf-8'))

            # start processing file, send the processing time to client
            proc_results, proc_time = SpeedTest(
                os.path.join(RECV_FOLDER, filename))
            proc_result_info = {
                'proc_results': proc_results,
                'proc_time': proc_time
            }
            connection.sendall(json.dumps(proc_result_info).encode("utf-8"))

        # 处理完关闭当前连接
        # self.__connections[user_id].close()
        # del self.__connections[user_id]
        # del self.__nicknames[user_id]


if __name__ == '__main__':
    # 打开图像处理模型,并一直开着
    model = pr.LPR("model/cascade.xml", "model/model12.h5",
                   "model/ocr_plate_all_gru.h5")
    server = Server()
    server.start()
Exemplo n.º 3
0
def init():
    global model
    print('目录:', BASE_PATH)
    model = pr.LPR(os.path.join(BASE_PATH, "model", "cascade.xml"),
                   os.path.join(BASE_PATH, "model", "model12.h5"),
                   os.path.join(BASE_PATH, "model", "ocr_plate_all_gru.h5"))
Exemplo n.º 4
0
    parser.add_argument('--cascade_model_path',
                        action='store',
                        default='model/cascade.xml')
    parser.add_argument('--mapping_vertical_model_path',
                        action='store',
                        default='model/model12.h5')
    parser.add_argument('--ocr_plate_model_path',
                        action='store',
                        default='model/ocr_plate_all_gru.h5')
    parser.add_argument('--save_result_flag', action='store', default='True')
    parser.add_argument('--plot_result_flag', action='store', default='True')
    parser.add_argument('--save_path', action='store', default=None)

    args = parser.parse_args()

    model = pr.LPR(args.cascade_model_path, args.mapping_vertical_model_path,
                   args.ocr_plate_model_path)

    for filename in os.listdir(args.detect_parent_path):
        path = os.path.join(args.detect_parent_path, filename)
        if path.endswith(".jpg") or path.endswith(".png"):
            grr = cv2.imread(path)
            t0 = time.time()
            image = grr
            for pstr, confidence, rect in model.SimpleRecognizePlateByE2E(grr):
                if confidence > 0.7:
                    image = drawRectBox(image, rect,
                                        pstr + " " + str(round(confidence, 3)))
                    print("plate_str:")
                    print(pstr)
                    print("plate_confidence")
                    print(confidence)
Exemplo n.º 5
0
              addText, (255, 255, 255),
              font=fontC)
    imagex = np.array(img)
    return imagex


import HyperLPRLite as pr
import cv2
import numpy as np

SpeedTest("images_rec/2_resized.jpg")

img = Image.open("images_rec/1_resized.jpg")
model = pr.LPR("export_graph/edgetpu_models/detection_model_edgetpu.tflite",
               "export_graph/model12.h5",
               "export_graph/edgetpu_models/ocr_model_edgetpu.tflite",
               cnn=True,
               tpu=True)
for pstr, confidence, rect in model.SimpleRecognizePlateByE2E(img):
    #if confidence>0.1:
    image = drawRectBox(cv2.cvtColor(np.array(img), cv2.COLOR_RGB2BGR), rect,
                        pstr + " " + str(round(confidence, 3)))
    print("plate_str:")
    print(pstr)
    print("plate_confidence")
    print(confidence)

cv2.imshow("image", image)
cv2.waitKey(0)

cv2.destroyAllWindows()
Exemplo n.º 6
0
                  (int(rect[0] + rect[2]), int(rect[1] + rect[3])),
                  (0, 0, 255), 2, cv2.LINE_AA)
    cv2.rectangle(image, (int(rect[0] - 1), int(rect[1]) - 16),
                  (int(rect[0] + 115), int(rect[1])), (0, 0, 255), -1,
                  cv2.LINE_AA)
    img = Image.fromarray(image)
    draw = ImageDraw.Draw(img)
    draw.text((int(rect[0] + 1), int(rect[1] - 16)),
              addText, (255, 255, 255),
              font=fontC)
    imagex = np.array(img)
    return imagex


model = pr.LPR(os.path.join(BASE_PATH, "model/cascade.xml"),
               os.path.join(BASE_PATH, "model/model12.h5"),
               os.path.join(BASE_PATH, "model/ocr_plate_all_gru.h5"))

# SpeedTest("images_rec/2.jpg")


def demo():
    grr = cv2.imread(os.path.join(BASE_PATH, "images_rec/1.jpg"))
    for pstr, confidence, rect in model.SimpleRecognizePlateByE2E(grr):
        if confidence > 0.7:
            # image = drawRectBox(grr, rect, pstr+" " +
            #                     str(round(confidence, 3)))
            print("plate_str:")
            print(pstr)
            print("plate_confidence")
            print(confidence)
Exemplo n.º 7
0
                  cv2.LINE_AA)
    img = Image.fromarray(image)
    draw = ImageDraw.Draw(img)
    draw.text((int(rect[0]+1), int(rect[1]-16)), addText.decode("utf-8"), (255, 255, 255), font=fontC)
    imagex = np.array(img)
    return imagex





import HyperLPRLite as pr
import cv2
import numpy as np
grr = cv2.imread("images_rec/21jk.jpg")
model = pr.LPR("model/cascade_lbp.xml","model/model12.h5","model/model.h5")
for pstr,confidence,rect in model.SimpleRecognizePlateByE2E(grr):
        if confidence>0.7:
            image = drawRectBox(grr, rect, pstr+" "+str(round(confidence,3)))
            print ("plate_str:")
            print (pstr)
            print ("plate_confidence")
            print (confidence)
            print ("plate_borders:")
            print (rect)
            
cv2.imshow("image",image)
cv2.waitKey(0)