利用HyperLPR车牌识别项目检测视频文件

题目:如何利用HyperLPR车牌识别项目测试视频文件

一.下载项目,也可以Git clone。
HyperLPR项目下载链接:https://github.com/zeusees/HyperLPR

二.测试图片效果
下载HyperLPR项目后,用pycharm打开工程,界面如下所示:
在这里插入图片描述
新建python.file文件,命名为test_image.py。编写test_image.py,如下图所示:

import HyperLPRLite as pr
import cv2
import demo
demo.drawRectBox(image,rect,addText)

grr = cv2.imread("images_rec/8.jpg")
model = pr.LPR("model/cascade.xml","model/model12.h5","model/ocr_plate_all_gru.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)

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

其中,cv.imread( )为读取测试图片,根据需要可以自行修改路径。确认路径无误后,run,结果如下所示:
在这里插入图片描述

三.测试视频文件
新建python.file文件,命名为test_video.py。编写test_video.py,如下图所示:

# -*- coding: utf-8 -*-
import time
import cv2
from hyperlpr_py3 import pipline as pp
import click


@click.command()
@click.option('--video', help = 'input video file')
def main(video):
    print("[INFO] starting video stream...")
    # vs = VideoStream(src=0).start()
    #修改测试视频路径
    stream = cv2.VideoCapture("E:/HyperLPR/demo_images/video.mp4")
    time.sleep(2.0)

    while True:
        # grab the frame from the threaded video stream
        grabbed, frame = stream.read()
        if not grabbed:
            print('No data, break.')
            break

        _, res = pp.SimpleRecognizePlate(frame)

        # convert the input frame from BGR to RGB then resize it to have
        # a width of 750px (to speedup processing)
        # rgb = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)
        # rgb = imutils.resize(frame, width = 750)
        # r = frame.shape[1] / float(rgb.shape[1])

        cv2.putText(frame, str(res), (50, 50), cv2.FONT_HERSHEY_SIMPLEX, 0.75, (0, 255, 255), 2)

        cv2.imshow("Frame", frame)
        key = cv2.waitKey(1) & 0xFF

        # if the `q` key was pressed, break from the loop
        if key == ord("q"):
            break

    # do a bit of cleanup
    cv2.destroyAllWindows()
    stream.release()


if __name__ == '__main__':
    main()

其中,cv.VideoCapture( )为读取测试视频,根据需要可以自行修改路径。确认路径无误后,run。检测速度较慢,不再展示run结果。

注:

本文参考文献:[https://blog.csdn.net/yang1159/article/details/89492368

配置环境可以参考:
https://www.cnblogs.com/zhupengfei/p/12104504.html
亲测好用!

如还有其他问题可以评论留言,大家一起解决难题。

  • 1
    点赞
  • 14
    收藏
    觉得还不错? 一键收藏
  • 3
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值