Python+Qt虹膜检测识别

news/2025/1/3 4:59:19/

程序示例精选
Python+Qt虹膜检测识别
如需安装运行环境或远程调试,见文章底部个人QQ名片,由专业技术人员远程协助!

前言

这篇博客针对《Python+Qt虹膜检测识别》编写代码,代码整洁,规则,易读。 学习与应用推荐首选。


运行结果

在这里插入图片描述


文章目录

一、所需工具软件
二、使用步骤
       1. 主要代码
       2. 运行结果
三、在线协助

一、所需工具软件

       1. Python, Qt
       2. Pycharm

二、使用步骤

代码如下(示例):

# coding:utf-8
import sys
import cv2
import cv2 as cv
import numpy as np
from PyQt5 import QtWidgets
class Ui_Dialog(object):def setupUi(self, Dialog):Dialog.setObjectName("Dialog")Dialog.resize(542, 454)sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)sizePolicy.setHorizontalStretch(0)sizePolicy.setVerticalStretch(0)sizePolicy.setHeightForWidth(Dialog.sizePolicy().hasHeightForWidth())Dialog.setSizePolicy(sizePolicy)self.gridLayout_2 = QtWidgets.QGridLayout(Dialog)self.gridLayout_2.setObjectName("gridLayout_2")self.pushButton_2 = QtWidgets.QPushButton(Dialog)sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)sizePolicy.setHorizontalStretch(0)sizePolicy.setVerticalStretch(0)sizePolicy.setHeightForWidth(self.pushButton_2.sizePolicy().hasHeightForWidth())self.pushButton_2.setSizePolicy(sizePolicy)font = QtGui.QFont()font.setFamily("微软雅黑")font.setPointSize(16)self.pushButton_2.setFont(font)self.pushButton_2.setObjectName("pushButton_2")self.gridLayout_2.addWidget(self.pushButton_2, 2, 0, 1, 1) sizePolicy.setHeightForWidth(self.frame.sizePolicy().hasHeightForWidth())self.frame.setSizePolicy(sizePolicy)self.frame.setFrameShape(QtWidgets.QFrame.Box)self.frame.setFrameShadow(QtWidgets.QFrame.Raised)self.frame.setObjectName("frame")self.gridLayout = QtWidgets.QGridLayout(self.frame)self.gridLayout.setObjectName("gridLayout")self.label = QtWidgets.QLabel(self.frame)sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)sizePolicy.setHorizontalStretch(0)sizePolicy.setVerticalStretch(1)sizePolicy.setHeightForWidth(self.label.sizePolicy().hasHeightForWidth())self.label.setSizePolicy(sizePolicy)self.label.setStyleSheet("background-color: rgb(255, 255, 255);")self.label.setAlignment(QtCore.Qt.AlignCenter)self.label.setObjectName("label")self.gridLayout.addWidget(self.label, 0, 0, 1, 1)self.label_2 = QtWidgets.QLabel(self.frame)sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Preferred, QtWidgets.QSizePolicy.Preferred)sizePolicy.setHorizontalStretch(0)sizePolicy.setVerticalStretch(1)sizePolicy.setHeightForWidth(self.label_2.sizePolicy().hasHeightForWidth())self.label_2.setSizePolicy(sizePolicy)self.label_2.setStyleSheet("background-color: rgb(255, 255, 255);")self.label_2.setAlignment(QtCore.Qt.AlignCenter)self.label_2.setObjectName("label_2")self.gridLayout.addWidget(self.label_2, 1, 0, 1, 1)self.gridLayout_2.addWidget(self.frame, 0, 1, 8, 1)self.textEdit = QtWidgets.QTextEdit(Dialog)sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Expanding, QtWidgets.QSizePolicy.Minimum)sizePolicy.setHorizontalStretch(0)sizePolicy.setVerticalStretch(0)sizePolicy.setHeightForWidth(self.textEdit.sizePolicy().hasHeightForWidth())self.textEdit.setSizePolicy(sizePolicy)self.textEdit.setMinimumSize(QtCore.QSize(0, 150))font = QtGui.QFont()font.setFamily("微软雅黑")font.setPointSize(16)self.textEdit.setFont(font)self.textEdit.setVerticalScrollBarPolicy(QtCore.Qt.ScrollBarAlwaysOff)self.textEdit.setHorizontalScrollBarPolicy(QtCore.Qt.ScrollBarAsNeeded)self.textEdit.setObjectName("textEdit")self.gridLayout_2.addWidget(self.textEdit, 4, 0, 1, 1)self.label_3 = QtWidgets.QLabel(Dialog)font = QtGui.QFont()font.setFamily("微软雅黑")font.setPointSize(12)self.label_3.setFont(font)self.label_3.setObjectName("label_3")self.gridLayout_2.addWidget(self.label_3, 3, 0, 1, 1)self.pushButton_6 = QtWidgets.QPushButton(Dialog)font = QtGui.QFont()font.setFamily("微软雅黑")font.setPointSize(16)self.pushButton_6.setFont(font)self.pushButton_6.setObjectName("pushButton_6")self.gridLayout_2.addWidget(self.pushButton_6, 1, 0, 1, 1)spacerItem = QtWidgets.QSpacerItem(17, 153, QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Expanding)self.gridLayout_2.addItem(spacerItem, 7, 0, 1, 1)self.pushButton = QtWidgets.QPushButton(Dialog)sizePolicy = QtWidgets.QSizePolicy(QtWidgets.QSizePolicy.Minimum, QtWidgets.QSizePolicy.Fixed)sizePolicy.setHorizontalStretch(1)sizePolicy.setVerticalStretch(0)sizePolicy.setHeightForWidth(self.pushButton.sizePolicy().hasHeightForWidth())
class myWin(QtWidgets.QWidget, Ui_Dialog):def __init__(self):super(myWin, self).__init__()self.setupUi(self)def openFileButton(self):imgName, imgType  = QFileDialog.getOpenFileName(self,"打开文件","./","files(*.*)")img = cv2.imread(img)cv2.imwrite("temp/new.jpg", img)height, width, pixels = img.shapeprint("width,height",width,height)print("self.label.width()",self.label.width())print("self.label.height()",self.label.height())if width>(self.label.width()):rheight=(self.label.width()*height)*widthrwidth=self.label.width()print("rwidth-if,rheight-if", width, rheight)elif height>(self.label.height()):rwidth=(self.label.height()*width)/heightrheight=self.label.height()print("rwidth-elif,rheight-elfi", rwidth, rheight)elif ((self.label.height())-height)<((self.label.width())-width):rwidth=(self.label.height()*width)/heightrheight=self.label.height()print("rwidth-elif,rheight-elfi", rwidth, rheight)_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) #设置图片显示def saveFileButton(self):img = cv2.imread("temp/new.jpg")file_path = QFileDialog.getSaveFileName(self, "save file", "./save/test","jpg files (*.jpg);;all files(*.*)")print(file_path[0])cv2.imwrite(file_path[0], img)cv2.destroyAllWindows()def Contrast(self):import ospath = "DataBase/"file_list = os.listdir(path)for file in file_list:img1 = cv2.imread('temp/new.jpg')BasePath="DataBase/" + str(file)print("BasePath: ", BasePath)img2 = cv2.imread(BasePath)print("img2: ",img2)sift = cv2.xfeatures2d.SIFT_create()kp1, des1 = sift.detectAndCompute(img1, None)kp2, des2 = sift.detectAndCompute(img2, None)indexParams = dict(algorithm=0, trees=10)searchParams = dict(checks=50)flann = cv2.FlannBasedMatcher(indexParams, searchParams)matches = flann.knnMatch(des1, des2, k=2)matches = sorted(matches, key=lambda x: x[0].distance)print("file:",file)self.textEdit.setPlainText("匹配系数:0.5")self.textEdit_2.setPlainText("匹配成功名称:"+file)print("n: ",n)height, width, pixels = img2.shapeif width > (self.label.width()):rheight = (self.label.width() * height) * widthrwidth = self.label.width()print("rwidth-if,rheight-if", width, rheight)elif height > (self.label.height()):rwidth = (self.label.height() * width) / heightrheight = self.label.height()print("rwidth-elif,rheight-elfi", rwidth, rheight)
if __name__=="__main__":app=QtWidgets.QApplication(sys.argv)Widget=myWin()Widget.showMaximized();Widget.show()sys.exit(app.exec_())
运行结果

在这里插入图片描述

三、在线协助:

如需安装运行环境或远程调试,见文章底部个人 QQ 名片,由专业技术人员远程协助!

1)远程安装运行环境,代码调试
2)Visual Studio, Qt, C++, Python编程语言入门指导
3)界面美化
4)软件制作
5)云服务器申请
6)网站制作

当前文章连接:https://blog.csdn.net/alicema1111/article/details/132666851
个人博客主页:https://blog.csdn.net/alicema1111?type=blog
博主所有文章点这里:https://blog.csdn.net/alicema1111?type=blog

博主推荐:
Python人脸识别考勤打卡系统:
https://blog.csdn.net/alicema1111/article/details/133434445
Python果树水果识别:https://blog.csdn.net/alicema1111/article/details/130862842
Python+Yolov8+Deepsort入口人流量统计:https://blog.csdn.net/alicema1111/article/details/130454430
Python+Qt人脸识别门禁管理系统:https://blog.csdn.net/alicema1111/article/details/130353433
Python+Qt指纹录入识别考勤系统:https://blog.csdn.net/alicema1111/article/details/129338432
Python Yolov5火焰烟雾识别源码分享:https://blog.csdn.net/alicema1111/article/details/128420453
Python+Yolov8路面桥梁墙体裂缝识别:https://blog.csdn.net/alicema1111/article/details/133434445


http://www.ppmy.cn/news/1231392.html

相关文章

网络连接Android设备

参考&#xff1a;https://blog.csdn.net/qq_37858386/article/details/123755700 二、网络adb调试开启步骤 1、把Android平板或者手机WiFi连接到跟PC机子同一个网段的网络&#xff0c;在设置-系统-关于-状态 下面查看设备IP,然后查看PC是否可以ping通手机的设备的IP。 2、先…

centos7 利用nc命令探测某个tcp端口是否在监听

脚本 # 安装nc yum install -y ncnc -vz 192.168.3.128 60001 if [ $? -eq 0 ]; thenecho "tcp succeed" elseecho "tcp failed" fi nc -vz 192.168.3.128 60001 探测192.168.3.128服务器上60001 tcp端口, -vz说明是探测TCP的 端口开启的情况 执行…

spark内置数据类型

在用scala编写spark的时候&#xff0c;假如我现在需要将我spark读的数据源的字段&#xff0c;做一个类型转换&#xff0c;因 为需求中要拼接出sql的create table语句&#xff0c;需要每个字段的sql中的类型&#xff0c;那么就需要去和sparksql 中的内置数据类型去比对。 写s…

Bandzip下载(好用的解压缩工具)

1.下载链接&#xff1a;Bandizip - Download Bandizip 6.x 2.点击 下载Bandzip 进行下载&#xff0c;下载到本地&#xff0c;直接安装即可

Maven-自定义插件

Maven自定义插件 一、背景二、命名规范三、插件开发四、执行插件1.执行插件2.简化命令行2.1 命令格式为 mvn groupId:artifactId:goal2.2 命令格式为 mvn ${prefix}:goal 五、构建周期执行插件总结参考链接&#xff1a; 一、背景 Maven是由一系列用于执行构建任务的插件和一个…

Spring Boot和Spring MVC的区别

1 Spring MVC 是Spring的一个模块&#xff0c;是一个web框架。分为Model&#xff0c;View&#xff0c;Controller&#xff08;模型层、视图层、控制层&#xff09;。 2 Spring Boot Spring Boot 自动配置&#xff0c;降低了项目搭建的复杂度。Spring框架需要大量的配置&…

Kubernetes Gateway API 攻略:解锁集群流量服务新维度!

Kubernetes Gateway API 刚刚 GA&#xff0c;旨在改进将集群服务暴露给外部的过程。这其中包括一套更标准、更强大的 API资源&#xff0c;用于管理已暴露的服务。在这篇文章中&#xff0c;我将介绍 Gateway API 资源&#xff0c;并以 Istio 为例来展示这些资源是如何关联的。通…

【开源】基于Vue和SpringBoot的高校宿舍调配管理系统

项目编号&#xff1a; S 051 &#xff0c;文末获取源码。 \color{red}{项目编号&#xff1a;S051&#xff0c;文末获取源码。} 项目编号&#xff1a;S051&#xff0c;文末获取源码。 目录 一、摘要1.1 项目介绍1.2 项目录屏 二、功能需求2.1 学生端2.2 宿管2.3 老师端 三、系统…