响应式网站建设好么,舆情分析软件,微信公众号服务号网站开发流程,律所网站方案PythonQt指纹录入识别考勤系统如需安装运行环境或远程调试#xff0c;见文章底部个人QQ名片#xff0c;由专业技术人员远程协助#xff01;前言这篇博客针对PythonQt指纹录入识别考勤系统编写代码#xff0c;代码整洁#xff0c;规则#xff0c;易读。 学…PythonQt指纹录入识别考勤系统如需安装运行环境或远程调试见文章底部个人QQ名片由专业技术人员远程协助前言这篇博客针对PythonQt指纹录入识别考勤系统编写代码代码整洁规则易读。 学习与应用推荐首选。文章目录 一、所需工具软件 二、使用步骤1. 引入库2. 识别图像特征3. 运行结果三、在线协助一、所需工具软件1. Pycharm, Python2. Qt, OpenCV二、使用步骤1.引入库代码如下示例# coding:utf-8
import sys
import os
import csv
import cv2
import record
import name
from PyQt5 import QtWidgets
from PyQt5 import QtWidgets, QtCore, QtGui
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from PyQt5.QtCore import *
from shutil import copyfile
from sys import exit
import os
from login import *
from register import *2.识别图像特征代码如下示例 namef.read()print(f,name)f.close()# 均值哈希算法def aHash(img):# 缩放为8*8img cv2.resize(img, (8, 8), interpolationcv2.INTER_CUBIC)# 转换为灰度图gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)# s为像素和初值为0hash_str为hash值初值为s 0hash_str # 遍历累加求像素和for i in range(8):for j in range(8):s s gray[i, j]# 求平均灰度avg s / 64# 灰度大于平均值为1相反为0生成图片的hash值for i in range(8):for j in range(8):if gray[i, j] avg:hash_str hash_str 1else:hash_str hash_str 0return hash_str# 差值感知算法def dHash(img):# 缩放8*8img cv2.resize(img, (9, 8), interpolationcv2.INTER_CUBIC)# 转换灰度图gray cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)hash_str # 每行前一个像素大于后一个像素为1相反为0生成哈希for i in range(8):for j in range(8):if gray[i, j] gray[i, j 1]:hash_str hash_str 1return hash_str# Hash值对比def cmpHash(hash1, hash2):n 0# hash长度不同则返回-1代表传参出错if len(hash1) ! len(hash2):return -1# 遍历判断for i in range(len(hash1)):# 不相等则n计数1n最终为相似度if hash1[i] ! hash2[i]:n n 1return nimport ospath fingerDataBase/file_list os.listdir(path)for file in file_list:img1 cv2.imread(temp/new.jpg)BasePathfingerDataBase/ str(file)print(BasePath: , BasePath)img2 cv2.imread(BasePath)print(img2: ,img2)hash1 aHash(img1)hash1 dHash(img1)hash2 dHash(img2)print(hash1)print(hash2)n cmpHash(hash1, hash2)print(n,n)print(差值哈希算法相似度 str(n))result相似度 str(100-n), 通过3.运行结果如下 三、在线协助 如需安装运行环境或远程调试见文章底部个人QQ名片由专业技术人员远程协助1远程安装运行环境代码调试2Qt, C, Python入门指导3界面美化4软件制作博主推荐文章https://blog.csdn.net/alicema1111/article/details/123851014个人博客主页https://blog.csdn.net/alicema1111?typeblog博主所有文章点这里https://blog.csdn.net/alicema1111?typeblog