demo.py 637 Bytes
# -*- coding: utf-8 -*-
###
import cv2
import numpy as np
from SDTR import sdtr


if __name__ == '__main__':
    test_img_path = './rec_test.png'
    test_img = cv2.imread(test_img_path)
    test_gray = cv2.cvtColor(test_img, cv2.COLOR_BGR2GRAY)
    h, w = test_gray.shape
    box = [np.array([[0, 0], [w, 0], [w, h], [0, h]])]
    all_time = 0
    rangetimes = 1001
    for i in range(rangetimes):
        results, rectime = sdtr.predict(test_gray, box)
        print('{:.5f}ms'.format(rectime))
        print(results)
        if i != 0:
            all_time += rectime
    print('avgtime:{:.5f}ms'.format(all_time / (rangetimes - 1)))