畢設(shè)項目:基于Qt、PYTHON智能校園防御系統(tǒng)應(yīng)用程序,實現(xiàn)了攝像頭數(shù)據(jù)采集、人臉識別、口罩識別、 數(shù)據(jù)統(tǒng)計等功能
完整項目地址:https://download.csdn.net/download/lijunhcn/88453470
項目結(jié)構(gòu)
環(huán)境選型
- 語言:Python
- 操作系統(tǒng):Windows
- 數(shù)據(jù)庫:MySQL
- 窗口界面:PyQT
- API接口:百度AI接口,用以實現(xiàn)人臉登陸與注冊
遠(yuǎn)程MySQL表結(jié)構(gòu)
遠(yuǎn)程表結(jié)構(gòu)sql腳本
DROP TABLE IF EXISTS `access_record_table`;
CREATE TABLE `access_record_table` (
record_id int(11) NOT NULL AUTO_INCREMENT COMMENT '主鍵',
has_mask enum('0','1') NOT NULL DEFAULT '0' COMMENT '是否佩戴口罩',
access_time timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '記錄時間',
place_id int(11) UNSIGNED NOT NULL DEFAULT '00000' COMMENT '設(shè)備id',
stu_id int(1) int(11) UNSIGNED NOT NULL DEFAULT '00000' COMMENT '學(xué)生id',
PRIMARY KEY (record_id)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `place_table`;
CREATE TABLE `place_table` (
place_id int,
place_name varchar(32) DEFAULT NULL COMMENT '地點名字',
place_time timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '記錄時間',
foreign key(place_id) references access_record_table(place_id) on delete cascade on update cascade
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `stu_table`;
CREATE TABLE `stu_table` (
stu_id int,
stu_name varchar(32) DEFAULT NULL COMMENT '學(xué)生名字',
stu_status enum('0','1','2') NOT NULL DEFAULT '0' COMMENT '學(xué)生狀態(tài)',
stu_times timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '記錄時間',
foreign key(stu_id) references access_record_table(stu_id) on delete cascade on update cascade
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
DROP TABLE IF EXISTS `usr_table`;
CREATE TABLE `usr_table` (
stu_id int(11) NOT NULL AUTO_INCREMENT COMMENT '主鍵',
usr_name varchar(32) DEFAULT NULL COMMENT '用戶名稱',
usr_pic varchar(32) DEFAULT NULL COMMENT '用戶圖片名稱',
usr_times timestamp DEFAULT CURRENT_TIMESTAMP COMMENT '記錄時間',
PRIMARY KEY (stu_id)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_bin;
項目背景
智能校園防御軟件是實現(xiàn)了一款基于攝像頭數(shù)據(jù)采集、人臉識別、口罩識別、 數(shù)據(jù)統(tǒng)計的預(yù)警系統(tǒng),該種防御系統(tǒng)能夠通過人臉識別進(jìn)行管理員登錄打卡,通過安裝在教室內(nèi)的固定攝像頭,實時采集教室內(nèi)上課同學(xué)的圖像,判斷是否有帶口罩,從而在監(jiān)控屏幕中予以標(biāo)記提示警衛(wèi)人員。采用 OpenCV/爬蟲數(shù)據(jù)采集、利用 Numpy、Pandas 及特征工程、模型聚合進(jìn)行數(shù)據(jù)預(yù)處理、CNN 模型訓(xùn)練框架。文章來源:http://www.zghlxwxcb.cn/news/detail-763730.html
部分源碼:文章來源地址http://www.zghlxwxcb.cn/news/detail-763730.html
# *coding:utf-8 *
from Global import CONFIG
import pymysql
class CDbOpt:
def __init__(self):
"""
MySql操縱類函數(shù)的相關(guān)初始化數(shù)值
"""
self.conn_mysql = pymysql.Connect(
database=CONFIG["@mysql_opt"]["mysql_db"],
user=CONFIG["@mysql_opt"]["mysql_user"],
password=CONFIG["@mysql_opt"]["mysql_pwd"],
host=CONFIG["@mysql_opt"]["mysql_host"],
port=CONFIG["@mysql_opt"]["mysql_port"],
charset=CONFIG["@mysql_opt"]["mysql_charset"],
)
def __del__(self):
"""
析構(gòu)函數(shù): 關(guān)閉Sql連接
"""
self.conn_mysql.close()
def Db_Selete(self, *args, **kwargs):
# 獲取數(shù)據(jù)字段
# 整理出sql
# 調(diào)用db
table = args[0]
where_fields = ''
data = kwargs.get('data')
where_list = data.get('where_list')
select_list = data.get('select_list')
if where_list != None:
del data['where_list']
if select_list != None:
del data['select_list']
for k, v in data.items():
if k in where_list:
if where_fields == '':
where_fields += f"{k}='{v}'"
else:
where_fields += f"and {k}='{v}'"
fields = ','.join(select_list)
cursor = self.conn_mysql.cursor()
sql = f"""select {fields} from {table} where {where_fields}"""
cursor.execute(sql)
result = cursor.fetchall()
return result
def Db_SELECT_SQL(self, sql):
# 獲取數(shù)據(jù)字段
# 整理出sql
# 調(diào)用db
cursor = self.conn_mysql.cursor()
cursor.execute(sql)
result = cursor.fetchall()
return result
def Db_Update_SQL(self, sql):
# 調(diào)用sql
cursor = self.conn_mysql.cursor()
try:
cursor.execute(sql)
self.conn_mysql.commit()
return True
except Exception as e:
print(e)
self.conn_mysql.rollback()
return False
def Db_Update(self, *args, **kwargs):
table = args[0]
fields = ''
where_fields = ''
data = kwargs.get('data')
where_list = data.get('where_list')
select_list = data.get('select_list')
if where_list != None:
del data['where_list']
if select_list != None:
del data['select_list']
for k, v in data.items():
if k in where_list:
if where_fields == '':
where_fields += f"{k}='{v}'"
else:
where_fields += f"and {k}='{v}'"
else:
if fields == '':
fields += f"{k}='{v}'"
else:
fields += f", {k}='{v}'"
# 調(diào)用sql
cursor = self.conn_mysql.cursor()
sql = f"""update {table} set {fields} where {where_fields}"""
try:
cursor.execute(sql)
self.conn_mysql.commit()
except Exception as e:
print(e)
self.conn_mysql.rollback()
def Db_Insert(self, *args, **kwargs):
table = args[0]
fields = ''
where_fields = ''
data = kwargs.get('data')
where_list = data.get('where_list')
select_list = data.get('select_list')
if where_list != None:
del data['where_list']
if select_list != None:
del data['select_list']
num = 0
for k, v in data.items():
if num == 0:
where_fields += f"{k}"
fields += f"'{v}'"
else:
where_fields += f", {k}"
fields += f", '{v}'"
num += 1
cursor = self.conn_mysql.cursor()
sql = f"""insert into {table} ({where_fields}) values({fields})"""
try:
cursor.execute(sql)
self.conn_mysql.commit()
return True
except Exception as e:
print(e)
self.conn_mysql.rollback()
return False
def Db_Delete(self, *args, **kwargs):
table = args[0]
fields = ''
where_fields = ''
data = kwargs.get('data')
where_list = data.get('where_list')
select_list = data.get('select_list')
if where_list != None:
del data['where_list']
if select_list != None:
del data['select_list']
for k, v in data.items():
if fields == '':
fields += f"{k}='{v}'"
else:
fields += f", {k}='{v}'"
if k in where_list:
if where_fields == '':
where_fields += f"{k}='{v}'"
else:
where_fields += f"and {k}='{v}'"
cursor = self.conn_mysql.cursor()
sql = f"""delete from {table} where {where_fields}"""
try:
cursor.execute(sql)
self.conn_mysql.commit()
except Exception as e:
print(e)
self.conn_mysql.rollback()
到了這里,關(guān)于畢設(shè)項目——基于Qt、PYTHON智能校園防御系統(tǒng)應(yīng)用程序,實現(xiàn)了攝像頭數(shù)據(jù)采集、人臉識別、口罩識別、 數(shù)據(jù)統(tǒng)計等功能的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!