卒業プロジェクト - Qt、PYTHONインテリジェントキャンパス防御システムアプリケーションに基づいて、カメラデータ収集、顔認識、マスク認識、データ統計およびその他の機能を実現

卒業プロジェクト:QtとPYTHONのインテリジェントキャンパス防衛システムアプリケーションをベースに、カメラデータ収集、顔認識、マスク認識、データ統計などの機能を実装

プロジェクトの完全なアドレス: https://download.csdn.net/download/lijunhcn/88453470

プロジェクトの構造

環境の選択
  1. 言語: Python
  2. オペレーティングシステム: Windows
  3. データベース: MySQL
  4. ウィンドウインターフェイス: PyQT
  5. APIインターフェース:Baidu AIインターフェース、顔ログインと登録を実現するために使用
リモート MySQL テーブル構造

リモートテーブル構造の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 '设备id',
  stu_id int(1) int(11)  UNSIGNED NOT NULL DEFAULT '00000' COMMENT '学生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 '学生名字',
  stu_status enum('0','1','2') NOT NULL DEFAULT '0' COMMENT '学生状态',
  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;
プロジェクトの背景

スマート キャンパス防御ソフトウェアは、カメラ データ収集、顔認識、マスク認識、およびデータ統計に基づいた早期警告システムを実装しています。この防御システムは、顔認識と教室に設置された固定カメラを通じて管理者のログインと打刻を行うことができます。教室内のクラスメートの画像をリアルタイムで収集して、マスクを着用しているかどうかを判断し、監視画面上でマークして警備員に注意を促します。OpenCV/クローラデータ収集の使用、Numpy、Pandas、および特徴エンジニアリングの使用、データ前処理のためのモデル集約、および CNN モデルトレーニングフレームワークを使用します。

ソースコードの一部:

# *coding:utf-8 *
from Global import CONFIG
import pymysql


class CDbOpt:
    def __init__(self):
        """
        MySql操纵类函数的相关初始化数值
        """
        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):
        """
        析构函数: 关闭Sql连接
        """
        self.conn_mysql.close()

    def Db_Selete(self, *args, **kwargs):
        # 获取数据字段
        # 整理出sql
        # 调用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):
        # 获取数据字段
        # 整理出sql
        # 调用db
        cursor = self.conn_mysql.cursor()
        cursor.execute(sql)
        result = cursor.fetchall()
        return result

    def Db_Update_SQL(self, sql):
        # 调用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}'"

        # 调用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()

おすすめ

転載: blog.csdn.net/lijunhcn/article/details/135177307