QT+Python停车场车牌识别计费管理系统

程序示例精选

Python停车场车牌识别计费管理系统

如需安装运行环境或远程调试,见文章底部微信名片!

前言

QT+Python是非常经典的窗体编程组合,功能完善,可视化界面美观易维护,这篇博客针对停车场车牌识别计费方面编写代码,代码整洁,规则,易读,对学习与使用Python有较好的帮助。


文章目录

        一、所需工具软件

        二、使用步骤

                1. 引入库

                2. 导入车牌

                3. 车牌识别

                4. 运行结果

         三在线协助


一、所需工具软件

          1. Python3.6以上

          2. Pycharm代码编辑器

          3. PyQT, OpenCV, Tensorflow, CSV, PIL库

二、使用步骤

1.引入库

代码如下(示例):

# coding:utf-8
import csv
import cv2
import numpy as np

from PIL import Image, ImageTk
from tensorflow import keras
from core import locate_and_correct
from Unet import unet_predict
from CNN import cnn_predict

from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *

import time

2.导入车牌

代码如下(示例):

    def displayPlate(self):
        # 显示相片到label_2
        imgName, imgType  = QFileDialog.getOpenFileName(self,"打开文件","./","files(*.*)")
        img = cv2.imread(imgName)
        #img = cv2.imread("test_img/aa.jpg")
        cv2.imwrite('temp.jpg', img)
        height, width, pixels = img.shape
        frame = cv2.resize(img, (int(rwidth), int(rheight)))
        img2 = cv2.cvtColor(frame, cv2.COLOR_BGR2RGB)  # opencv读取的bgr格式图片转换成rgb格式
        _image = QtGui.QImage(img2[:], img2.shape[1], img2.shape[0], img2.shape[1] * 3, QtGui.QImage.Format_RGB888)
        jpg_out = QtGui.QPixmap(_image).scaled(rwidth, rheight)  # 设置图片大小
        self.label.setPixmap(jpg_out)  # 设置图片显示

该处使用的url网络请求的数据。

3.车牌识别:

代码如下(示例):

    def carPlateRecogIn(self):
        print("carPlateRecog start")
        self.img_src_path="temp.jpg"
        img_src = cv2.imdecode(np.fromfile(self.img_src_path, dtype=np.uint8), -1)  # 从中文路径读取时用
        h, w = img_src.shape[0], img_src.shape[1]
        print("aa")
        if h * w <= 240 * 80 and 2 <= w / h <= 5:  # 满足该条件说明可能整个图片就是一张车牌,无需定位,直接识别即可
            lic = cv2.resize(img_src, dsize=(240, 80), interpolation=cv2.INTER_AREA)[:, :, :3]  # 直接resize为(240,80)
            img_src_copy, Lic_img = img_src, [lic]
        else:  # 否则就需通过unet对img_src原图预测,得到img_mask,实现车牌定位,然后进行识别
            img_src, img_mask = unet_predict(self.unet, self.img_src_path)
            img_src_copy, Lic_img = locate_and_correct(img_src, img_mask)  # 利用core.py中的locate_and_correct函数进行车牌定位和矫正
            print("aa")

        Lic_pred = cnn_predict(self.cnn, Lic_img)  # 利用cnn进行车牌的识别预测,Lic_pred中存的是元祖(车牌图片,识别结果)
        if Lic_pred:
            # 显示相片到label_2
            img = cv2.imread("temp.jpg")
            self.label.setPixmap(QPixmap(""))
            height, width, pixels = img.shape

            frame = cv2.resize(img, (int(rwidth), int(rheight)))
            img2 = cv2.cvtColor(img_src_copy, cv2.COLOR_BGR2RGB)  # opencv读取的bgr格式图片转换成rgb格式
            _image = QtGui.QImage(img2[:], img2.shape[1], img2.shape[0], img2.shape[1] * 3, QtGui.QImage.Format_RGB888)
            jpg_out = QtGui.QPixmap(_image).scaled(rwidth, rheight)  # 设置图片大小
            self.label.setPixmap(jpg_out)  # 设置图片显示

            for i, lic_pred in enumerate(Lic_pred):
                if i == 0:
                    print("i: ", i)
                    print("lic_pred[1]: ",lic_pred[1])
                    self.textEdit.setPlainText("车牌编号:"+lic_pred[1])
                elif i == 1:
                    print("i: ", i)
                    self.textEdit.setPlainText("车牌编号:"+lic_pred[1])
                elif i == 2:
                    print("i: ", i)
                    self.textEdit.setPlainText("车牌编号:"+lic_pred[1])
                plateNumber=lic_pred[1]
                print("lic_pred[1]2: ", lic_pred[1])


                msg_box = QMessageBox(QMessageBox.Warning, '信息', '门已打开,请进入.....')
                msg_box.exec_()

        else:  # Lic_pred为空说明未能识别
            print("无车牌发现")
            msg_box = QMessageBox(QMessageBox.Warning, '信息', '停车费已收取,请出门.....')
            msg_box.exec_()

4.运行结果如下: 

 

三、在线协助: 

如需安装运行环境或远程调试,见文章底部微信名片!

  • 1
    点赞
  • 30
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
对于停车场管理系统中的车牌识别功能,可以使用Qt开发Qt提供了丰富的图形界面和多媒体处理功能,非常适合开发这样的应用程序。 要实现车牌识别功能,可以使用开源的车牌识别库,例如OpenALPR。OpenALPR是一个功能强大的车牌识别引擎,支持各种类型的车牌识别,包括中国的车牌。通过将OpenALPR集成到Qt应用程序中,可以轻松实现车牌识别功能。 首先,你需要在Qt项目中添加OpenALPR库的依赖。然后,在你的Qt代码中调用OpenALPR提供的API来进行车牌识别。你可以使用摄像头捕捉图像,并将图像传递给OpenALPR进行处理。OpenALPR将返回识别到的车牌信息,你可以根据需要进行进一步处理,例如保存到数据库或显示在界面上。 除了车牌识别功能,你还可以考虑以下几点来完善停车场管理系统: 1. 支持车辆出入记录的管理,包括进出时间、车牌号码、停车时长等信息的记录和查询。 2. 支持停车位的管理,包括实时监测停车位的占用情况,提供空闲停车位的查询功能。 3. 支持车主信息的管理,包括车主姓名、联系方式等信息的录入和查询。 4. 支持停车费用的计算和收费功能,可以根据停车时长和车型等条件进行费用的自动计算。 5. 支持报警功能,当有未经授权的车辆进入停车场停车时间超过规定时间时,系统可以自动报警。

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

荷塘月色2

您的鼓励将是我创作最大的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值