# -*- coding: utf-8 -*-
"""
Module implementing MainWindow.
"""
import sys
sys.path.append('./CustomTitlebar')
from PyQt5.QtCore import pyqtSlot
from PyQt5.QtWidgets import QMainWindow
from PyQt5 import QtCore, QtGui, QtWidgets
from PyQt5.QtCore import *
from PyQt5.QtGui import *
from PyQt5.QtWidgets import *
from Ui_face_book import Ui_MainWindow
#import threadpool
#import time
#import threading
#import dlib
import cv2
from facecompare import Face
from SqlOperator import SqlOperator
from information import Information
from book_detial import Book_detial
from CameraThread import VideoThread
from RecomThread import RecomThread
import random
from PyQt5.QtGui import QImage
from Styles.CommonHelper import CommonHelper
class MainWindow(QMainWindow, Ui_MainWindow, QThread):
"""
Class documentation goes here.
"""
#PictureFrame = pyqtSignal(int)
def book_detial_1(self, item):
self.book_detial = Book_detial(item)
self.__book_detial = CommonHelper.FrameCustomerTitle(self.book_detial, "图书详情界面")
self.__book_detial.move(160, 100)
self.__book_detial.resize(850, 660)
self.__book_detial.show()
def __init__(self, parent=None,):
super(MainWindow, self).__init__(parent)
self.setupUi(self)
#item1=None
#导入外部定义的Class
self.Face = Face()
self.SqlOperator = SqlOperator()
self.information = Information()
self.cameraThread = VideoThread()
self.recomThread = RecomThread()
self.ret = ''
self.num =''
#self.major = ''
#self.infor_img = []
# self.git_thread = CloneThread()
self.__information = CommonHelper.FrameCustomerTitle(self.information, "信息采集界面")
self.__information.move(160, 110)
self.__information.resize(765, 443)
# self.book_infor = Book_infor(self.item)
# self.__book_infor = CommonHelper.FrameCustomerTitle(self.book_infor, "图书详情界面")
# self.__book_infor.move(160, 100)
# self.__book_infor.resize(850, 660)
self.QMessageBox = QtWidgets.QMessageBox()
self.icon = QtGui.QIcon() #设置图标
self.item = QtWidgets.QListWidgetItem()
self.font = QtGui.QFont() #设置字体
self.font.setPointSize(12)
self.Logopic()#logo图片
#显示时间
timer = QTimer(self)
timer.timeout.connect(self.showtime)
timer.start()
# self.openCamera.clicked.connect(self.OpenCamera)
# self.cameraThread.VideoFrame.connect(self.Fresh_Video)#Video_Thread线程开启后捕捉摄像头调用Fresh_Video刷新界面
# self.cameraThread.OpenVideoFlag.connect(self.Un_Open_Camera) #开启摄像头失败触发Un_Open_Camera函数
#logo图片
def Logopic(self):
Im = cv2.imread('D:\\Face_book\\logo.png') # 通过Opencv读入一张图片
image_height, image_width= Im.shape[:2] # 获取图像的高,宽
QIm = cv2.cvtColor(Im, cv2.COLOR_BGR2RGB) # opencv读图片是BGR,qt显示要RGB,所以需要转换一下
QIm = QImage(QIm.data, image_width, image_height, QImage.Format_RGB888)
self.LogoLabel.setScaledContents(True)#图片自适应大小
self.LogoLabel.setPixmap(QPixmap.fromImage(QIm)) # 将QImage显示在之前创建的QLabel控件中
#视频区初始化图片
self.CameraLabel.setScaledContents(True)#图片自适应大小
self.CameraLabel.setPixmap(QPixmap.fromImage(QIm))
#显示时间
def showtime(self):
now = QDate.currentDate()
data = now.toString(Qt.DefaultLocaleLongDate)#2018年10月5日
time_1 = QTime.currentTime()
time_1 = time_1.toString(Qt.DefaultLocaleLongDate)#10:36:35
self.time_label.setText(data + time_1)
# def OpenCamera(self):
# #打开摄像头
# global t
# #isopend=1
#
# self.cap = cv2.VideoCapture()
# if (not self.cap.isOpened()):
# self.cap.open(0)
# self.cap.set(3, 500)
# self.cap.set(4, 600)
# #isopend=0
# #self.PictureFrame.emit(isopend)
## pool = threadpool.ThreadPool(10)
## requests = threadpool.makeRequests(self.Show_img, ())
## [pool.putRequest(req) for req in requests]
## pool.wait()
# t =threading.Thread(target=self.Show_img,args=())
# t.start()
#
## #获取当前帧图片
# def Show_img(self):
# while True:
# # QtCore.QCoreApplication.processEvents()
# time.sleep(0.001)
# self.ret, self.imread_img = self.cap.read()
# rert_1, self.infor_img = self.cap.read()
# if not self.ret:
# print('error: failed to capture image')
# return -1
#
# self.detectorface()
#
# height, width= self.imread_img.shape[:2]
# self.input_img = cv2.cvtColor(self.imread_img, cv2.COLOR_BGR2RGB)
# self.show_pic = QImage(self.input_img.data, width, height, QImage.Format_RGB888)
# self.CameraLabel.setScaledContents(True)#图片自适应大小
# #self.label_show_camera.setGeometry(0, 0, 241, 211)#图片显示的位置(最左上角的点+大小)
# # 转为QImage对象
# self.CameraLabel.setPixmap(QPixmap.fromImage(self.show_pic))
#
# def detectorface(self):
# self.detector = dlib.get_frontal_face_detector()
# img_gray = cv2.cvtColor(self.imread_img, cv2.COLOR_RGB2GRAY)
# faces = self.detector(img_gray, 0)
# # faces = facecompare.Face.detect(self.input_img)
# if (len(faces) != 0):
# # for i in range(len(faces)):
# for k, d in enumerate(faces):
# # 用红色矩形框出人脸
# cv2.rectangle(self.imread_img, (d.left(), d.top()), (d.right(), d.bottom()), (0, 0, 255), 3)
def OpenCamera(self):
if not self.cameraThread.isRunning():
self.cameraThread.start()
self.openCamera.setText("关闭摄像头")
else:
self.cameraThread.Stop_Video()
self.Logopic()
def Fresh_Video(self,show_pic):
self.CameraLabel.setScaledContents(True)#图片自适应大小
self.CameraLabel.setPixmap(QPixmap.fromImage(show_pic))
#self.VideoLabel.setPixmap(QPixmap.fromImage(qImg))
def Un_Open_Camera(self,bool):
QtWidgets.QMessageBox.warning(self,"警告","打开摄像头失败")
#self.openCamera.setText("打开摄像头")
def start_recomThread(self):
if not self.recomThread.start():
self.recomThread.start()
def start_gidentify(self):
#self.recomThread.start()
self.num, score= self.recomThread.gidentify()
print(self.num)
print(score)
if(self.num ==-1 and score == -1):
self.QMessageBox.warning(self, '警告', '未检测到人脸,请检查网络连接或靠近识别')
return 0
if(self.num != -1 and score > 0.80):
result = self.recomThread.info_gidentify(self.num)#读取数据库信息
#print(result)
if result == None:
self.QMessageBox.warning(self, '警告', '数据库可能没有您的数据或者靠近再次识别')
else:
self.Name_label.setText(result[2])
self.Num_label.setText(result[3])
self.Class_label.setText(result[5])
self.Major_label.setText(result[4])
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。 python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的基于人脸识别的图书馆推荐系统(可作为毕业设计期末大作业).zip下载即用无需修改,项目完整确保可以运行。python实现的
资源推荐
资源详情
资源评论
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
![rar](https://img-home.csdnimg.cn/images/20210720083606.png)
![zip](https://img-home.csdnimg.cn/images/20210720083736.png)
收起资源包目录
![package](https://csdnimg.cn/release/downloadcmsfe/public/img/package.f3fc750b.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![folder](https://csdnimg.cn/release/downloadcmsfe/public/img/folder.005fa2e5.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/JPG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/UNKNOWN.png)
![file-type](https://csdnimg.cn/release/download/static_files/pc/images/minetype/PNG.png)
共 32 条
- 1
资源评论
![avatar-default](https://csdnimg.cn/release/downloadcmsfe/public/img/lazyLogo2.1882d7f4.png)
- m0_744167322024-04-23资源不错,对我启发很大,获得了新的灵感,受益匪浅。
![avatar](https://profile-avatar.csdnimg.cn/3c1ed7f2fabc439d9d14e4ccad1864d6_chengxuyuanlaow.jpg!1)
不安分的小女孩
- 粉丝: 1w+
- 资源: 2502
上传资源 快速赚钱
我的内容管理 展开
我的资源 快来上传第一个资源
我的收益
登录查看自己的收益我的积分 登录查看自己的积分
我的C币 登录后查看C币余额
我的收藏
我的下载
下载帮助
![voice](https://csdnimg.cn/release/downloadcmsfe/public/img/voice.245cc511.png)
![center-task](https://csdnimg.cn/release/downloadcmsfe/public/img/center-task.c2eda91a.png)
安全验证
文档复制为VIP权益,开通VIP直接复制
![dialog-icon](https://csdnimg.cn/release/downloadcmsfe/public/img/green-success.6a4acb44.png)