赞
踩
1.基于python-opencv
的车牌识别,代码主要参考CSDN上几篇博主的代码,对预处理部分的代码进行了一定的优化,提高了识别的准确率。
2.重写了一个GUI界面,添加数据导出功能。
使用的模块版本:
PyQt5:5.11.3
opencv-python:3.4.3
运行截图如下:
1.导入工程包
- import cv2
- import sys, os, xlwt
- import numpy as np
2.建立GUI界面,实现将图片导入,和到处识别数据
- class Ui_MainWindow(object):
-
- def __init__(self):
- self.RowLength = 0
- self.Data = [['文件名称', '录入时间', '车牌号码', '车牌类型', '识别耗时', '车牌信息']]
-
- def setupUi(self, MainWindow):
- MainWindow.setObjectName("MainWindow")
- MainWindow.resize(1213, 670)
- MainWindow.setFixedSize(1213, 670) # 设置窗体固定大小
- MainWindow.setToolButtonStyle(QtCore.Qt.ToolButtonIconOnly)
- self.centralwidget = QtWidgets.QWidget(MainWindow)
- self.centralwidget.setObjectName("centralwidget")
- self.scrollArea = QtWidgets.QScrollArea(self.centralwidget)
- self.scrollArea.setGeometry(QtCore.QRect(690, 10, 511, 491))
- self.scrollArea.setWidgetResizable(True)
- self.scrollArea.setObjectName("scrollArea")
- self.scrollAreaWidgetContents = QtWidgets.QWidget()
- self.scrollAreaWidgetContents.setGeometry(QtCore.QRect(0, 0, 509, 489))
- self.scrollAreaWidgetContents.setObjectName("scrollAreaWidgetContents")
- self.label_0 = QtWidgets.QLabel(self.scrollAreaWidgetContents)
- self.label_0.setGeometry(QtCore.QRect(10, 10, 111, 20))
- font = QtGui.QFont()
- font.setPointSize(11)
- self.label_0.setFont(font)
- self.label_0.setObjectName("label_0")
- self.label = QtWidgets.QLabel(self.scrollAreaWidgetContents)
- self.label.setGeometry(QtCore.QRect(10, 40, 481, 441))
- self.label.setObjectName("label")
- self.label.setAlignment(Qt.AlignCenter)
- self.scrollArea.setWidget(self.scrollAreaWidgetContents)
- self.scrollArea_2 = QtWidgets.QScrollArea(self.centralwidget)
- self.scrollArea_2.setGeometry(QtCore.QRect(10, 10, 671, 631))
- self.scrollArea_2.setWidgetResizable(True)
- self.scrollArea_2.setObjectName("scrollArea_2")
- self.scrollAreaWidgetContents_1 = QtWidgets.QWidget()
- self.scrollAreaWidgetContents_1.setGeometry(QtCore.QRect(0, 0, 669, 629))
- self.scrollAreaWidgetContents_1.setObjectName("scrollAreaWidgetContents_1")
- self.label_1 = QtWidgets.QLabel(self.scrollAreaWidgetContents_1)
- self.label_1.setGeometry(QtCore.QRect(10, 10, 111, 20))
- font = QtGui.QFont()
- font.setPointSize(11)
- self.label_1.setFont(font)
- self.label_1.setObjectName("label_1")
- self.tableWidget = QtWidgets.QTableWidget(self.scrollAreaWidgetContents_1)
- self.tableWidget.setGeometry(QtCore.QRect(10, 40, 651, 581)) # 581))
- self.tableWidget.setObjectName("tableWidget")
- self.tableWidget.setColumnCount(6)
- self.tableWidget.setColumnWidth(0, 140) # 设置1列的宽度
- self.tableWidget.setColumnWidth(1, 130) # 设置2列的宽度
- self.tableWidget.setColumnWidth(2, 65) # 设置3列的宽度
- self.tableWidget.setColumnWidth(3, 75) # 设置4列的宽度
- self.tableWidget.setColumnWidth(4, 65) # 设置5列的宽度
- self.tableWidget.setColumnWidth(5, 174) # 设置6列的宽度
-
- self.tableWidget.setHorizontalHeaderLabels(["图片名称", "录入时间", "识别耗时", "车牌号码", "车牌类型", "车牌信息"])
- self.tableWidget.setRowCount(self.RowLength)
- self.tableWidget.verticalHeader().setVisible(False) # 隐藏垂直表头)
- # self.tableWidget.setStyleSheet("selection-background-color:blue")
- # self.tableWidget.setAlternatingRowColors(True)
- self.tableWidget.setEditTriggers(QAbstractItemView.NoEditTriggers)
- self.tableWidget.raise_()
- self.scrollArea_2.setWidget(self.scrollAreaWidgetContents_1)
- self.scrollArea_3 = QtWidgets.QScrollArea(self.centralwidget)
- self.scrollArea_3.setGeometry(QtCore.QRect(690, 510, 341, 131))
- self.scrollArea_3.setWidgetResizable(True)
- self.scrollArea_3.setObjectName("scrollArea_3")
- self.scrollAreaWidgetContents_3 = QtWidgets.QWidget()
- self.scrollAreaWidgetContents_3.setGeometry(QtCore.QRect(0, 0, 339, 129))
- self.scrollAreaWidgetContents_3.setObjectName("scrollAreaWidgetContents_3")
- self.label_2 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3)
- self.label_2.setGeometry(QtCore.QRect(10, 10, 111, 20))
- font = QtGui.QFont()
- font.setPointSize(11)
- self.label_2.setFont(font)
- self.label_2.setObjectName("label_2")
- self.label_3 = QtWidgets.QLabel(self.scrollAreaWidgetContents_3)
- self.label_3.setGeometry(QtCore.QRect(10, 40, 321, 81))
- self.label_3.setObjectName("label_3")
- self.scrollArea_3.setWidget(self.scrollAreaWidgetContents_3)
- self.scrollArea_4 = QtWidgets.QScrollArea(self.centralwidget)
- self.scrollArea_4.setGeometry(QtCore.QRect(1040, 510, 161, 131))
- self.scrollArea_4.setWidgetResizable(True)
- self.scrollArea_4.setObjectName("scrollArea_4")
- self.scrollAreaWidgetContents_4 = QtWidgets.QWidget()
- self.scrollAreaWidgetContents_4.setGeometry(QtCore.QRect(0, 0, 159, 129))
- self.scrollAreaWidgetContents_4.setObjectName("scrollAreaWidgetContents_4")
- self.pushButton_2 = QtWidgets.QPushButton(self.scrollAreaWidgetContents_4)
- self.pushButton_2.setGeometry(QtCore.QRect(20, 50, 121, 31))
- self.pushButton_2.setObjectName("pushButton_2")
- self.pushButton = QtWidgets.QPushButton(self.scrollAreaWidgetContents_4)
- self.pushButton.setGeometry(QtCore.QRect(20, 90, 121, 31))
- self.pushButton.setObjectName("pushButton")
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。