main.py 文件源码

python
阅读 32 收藏 0 点赞 0 评论 0

项目:Automatic-Plate-Number-Recognition-APNR 作者: kagan94 项目源码 文件源码
def process_single_image(images=[], plot_plates=False):
    '''
    :param images: list (full path to images to be processed)
    '''
    if images:
        img_n = 1
        for path_to_image in images:
            t_start = time.time()
            img = cv2.imread(path_to_image)

            # Resizing of the image
            r = 400.0 / img.shape[1]
            dim = (400, int(img.shape[0] * r))
            img = cv2.resize(img, dim, interpolation=cv2.INTER_AREA)

            mask = np.zeros_like(img)  # init mask

            contours = find_contours(img)
            # cv2.drawContours(img, contours, -1, (0, 255, 255))
            # cv2.waitKey(0)
            plates, plates_images, mask = find_plate_numbers(img, contours, mask)

            print "Time needed to complete: %s" % (time.time() - t_start)
            print "Plate Numbers: %s" % ", ".join(plates)

            # Apply mask to image and plot image
            img = cv2.add(img, mask)

            if plot_plates:
                plot_plate_numbers(plates_images)

            cv2.imshow('Resized Original image_%s + Detected Plate Number' % img_n, img)
            img_n += 1

        cv2.waitKey(0)
        cv2.destroyAllWindows()
    else:
        exit('Images are not provided!')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号