当前位置:网站首页>Face recognition class attendance system based on paddlepaddle platform (easydl)

Face recognition class attendance system based on paddlepaddle platform (easydl)

2022-07-06 23:02:00 Hua Weiyun

1.1 Preface

With the rapid development of social economy, science and Technology , People's lives have become more intelligent 、 make scientific . Information security has gradually attracted people's attention , The application of information continues to enter people's vision . Ordinary identification methods can not effectively ensure information security . Biometric technology with its stability 、 Uniqueness and efficiency have gradually become the object of widespread concern and research . There are many common biometric technologies , Such as iris 、 The fingerprint 、 Face, etc . among , Face recognition technology is gradually maturing . This development makes the use of face recognition technology for identity recognition and authentication become a new recognition development trend . before , The application of face recognition technology is mainly used in security 、 Finance and so on , Now face recognition technology is everywhere . Careful observation shows that , Face brushing equipment is applied to all aspects of life , For example, high-speed railway station brush face ticket machine 、 Commercial shop face brushing payment machine 、 Dormitory face brushing access control system, etc .

1.2 Computer vision

Face recognition technology is a specific application of computer vision , Computer vision specifically , It is to let the machine recognize the pictures or objects in the video taken by the camera , Detect the location of the object , And track the target object , So as to understand and describe the scene and story in the picture or video , To simulate the human visual system . therefore , Computer vision is also called machine vision , Its purpose is to establish the ability to “ perception ” The artificial system of information .

The development of computer vision technology in recent decades , It's already in traffic ( License plate recognition 、 Snapshot of road violations )、 Security ( Face brake 、 Community monitoring )、 Finance ( Brush your face to pay 、 Automatic bill identification at the counter )、 Medical care ( Medical imaging diagnosis )、 industrial production ( Automatic detection of product defects ) And so on , It affects or is changing people's daily life and industrial production mode . future , As technology evolves , More products and applications will emerge , To create greater convenience and broader opportunities for our lives .

The deep learning platform selected in this design is PaddlePaddle Of (EasyDL) frame , Flying oars provide a wealth of API, And through the underlying optimization and acceleration to ensure these API Performance of . meanwhile , The oars also provide a rich model base , Overlay image classification 、 testing 、 Division 、 Text recognition, video understanding and many other fields . Users can use these directly API Build models , It can also carry out secondary research and development based on the model library provided by the propeller .

1.3 PaddlePaddle frame

Flying oar open source framework (PaddlePaddle) It's an easy to use 、 Efficient 、 flexible 、 Extensible deep learning framework ,PaddlePaddle Of EasyDL Image frame bottom combined with Baidu AutoDL/AutoML technology , It can automatically obtain the optimal model and optimal hyperparametric combination for user data , Based on a small amount of data, excellent performance and model effect can be obtained , The deep learning framework of the propeller is combined with automatic model search , To ensure leading model effect . When training image classification and target detection models , Support multiple algorithms , To meet the different requirements of different scenarios for performance and effects . The transmission model is developed by Baidu AutoDL One of the technologies . Combined with the model network structure search 、 Transfer learning technology and automatic optimization of user data . Compared with general algorithms , Longer training time , But it is more suitable for subcategory scenarios . for example , The general algorithm can be used to distinguish cat from dog , But if we want to distinguish different kinds of cats , be AutoDL It works better , After training , The model can be deployed on the public cloud server 、 Private server , It can be encapsulated as an off-line device SDK, Or directly purchase the integrated software and hardware solution , Flexibly adapt to various use scenarios and operation environments . Flying oars provide a wealth of API, And through the underlying optimization and acceleration to ensure these API Performance of . meanwhile , The oars also provide a rich model base , Overlay image classification 、 testing 、 Division 、 Text recognition, video understanding and many other fields . Users can use these directly API Build models , It can also carry out secondary research and development based on the model library provided by the propeller .


1.4 Class attendance design

(1) Introduction to the functions of attendance system

The current face attendance recognition system is mainly divided into two parts : 1. Face recognition comparison 2. Attendance software interface design and logic processing .

The software is mainly used in Colleges and universities to check students' attendance 、 Check in processing , All functions need to be sound , Support face check-in , It supports entering student ID to sign in , Support adding students , Support deleting students ; Leave management is also supported on the interface , Students who need to ask for leave enter the reason for asking for leave in the interface , It is convenient for the teacher to know the details of the student ; While inputting student information , Input the student's student number 、 Telephone 、 full name 、 Professional information , When students are late for class , Teachers can contact by phone , Ask for information . In the past, the attendance of colleges and universities was recorded by the teacher's roll call , This is a waste of class time , With this system supporting face recognition , When students pass by, they will check in directly , Very convenient , There is no need for students to take pens for paper check-in , Improve the overall classroom efficiency .

In order to flexibly cope with different attendance periods , The software supports setting the attendance time range , Teachers can flexibly set the time range in class , In this way, you can calculate the usual score at the end of the period according to the proportion of usual attendance , It improves the efficiency of teachers .

(2) The function of attendance system is realized

At present, introduce the design interface , Writing interface , Complete the design of the whole software , Next, the operation process and interface design of the whole software are introduced . The interface of the software is cross platform QT framework design , Language adoption C++ Language , High execution efficiency , The code is simple and easy to understand , The main interface of the designed software is shown in Figure 1 :

chart 1 System main interface diagram


The software has 7 A functional interface , Plus the login page, there are 8 Interfaces , The login interface is designed with database , Verified the password account , To complete the login , The design of login interface is as follows :

chart 2 Login screen

The main functions of this system software involve two convenience , The first is face recognition comparison , The second is the logical design of attendance check-in , Attendance is the time range of attendance that can be set , Only within a reasonable time can you check in , If you exceed it, you will be late , The interface will prompt , If you come early, you will also be prompted , Don't punch in too early ; Besides face check-in , It also supports manual input of student ID for check-in .

chart 3 Set the attendance time range


chart 4 Attendance page

On the attendance status page, you can see the currently signed in student information , You can add new students on the page of adding students , When adding students, you need to face the camera and input information to add , The software needs to be connected to the network during operation , If the addition is successful, there will be a pop-up prompt , The added student information is stored in the database , Face data is saved in the cloud database of the flying oar ; After the student information is successfully added , You can see the added student information on the student management page , Then you can recognize the normal attendance .

chart 5 Add success prompt

chart 6 Student management page

The software attendance page also supports leave management , If a student asks for leave , You can add management on the page , It is convenient for the teacher to know the situation of this student .

chart 7 Leave management page

(3) Software code and interface design


Camera operation code :

// Capture the image of the current camera void Widget::processCapturedImage(int id,const QImage &image){    qDebug()<<"id:"<<id;    // Register new students 、 Save face to directory     if(word_mode==0)    {        add_student(image);    }    // Sign in     else if(word_mode==1)    {        FindFace(image);    }}// Update the camera void Widget::on_pushButton_UpdateCameraNumber_clicked(){    Find_CameraNumber();}// Find available cameras for the system void Widget::Find_CameraNumber(){    // clear list     ui->comboBox_camera_number->clear();    /* Find the currently available cameras on your computer */    cameras = QCameraInfo::availableCameras();    if(cameras.count())    {        for(int i=0;i<cameras.count();i++)        {            ui->comboBox_camera_number->addItem(tr("%1").arg(i));        }        ui->pushButton_start_camera->setEnabled(true);    }    else    {        QMessageBox::warning(this,tr(" Tips ")," There is no camera available on this computer !\n");        ui->pushButton_start_camera->setEnabled(false);    }}// Activate camera void Widget::on_pushButton_start_camera_clicked(){    // Camera activation flag     if(camera_flag) // If the camera has been activated once , To start again, you need to free up the previous space     {        camera->stop();        delete camera;        ui->horizontalLayout_camera->removeWidget(videoWidget);        delete videoWidget;    }    camera_flag=1;  // The sign camera has been activated once     // After the camera starts , You can't start again     ui->pushButton_start_camera->setEnabled(false);   /* Create a camera object , Turn on... According to the selected camera */   camera = new QCamera(cameras.at(ui->comboBox_camera_number->currentIndex()));   /* Construct captured objects */   camera_image_capture = new QCameraImageCapture(camera);   /* Set the capture destination */   camera_image_capture->setCaptureDestination(QCameraImageCapture::CaptureToFile);   // Set screenshot output 、 Buffer format 、 distinguish    camera_image_capture->setCaptureDestination(QCameraImageCapture::CaptureToBuffer);   camera_image_capture->setBufferFormat(QVideoFrame::PixelFormat::Format_Jpeg);   // Set the image size of the screenshot    iamge_setting.setResolution(320,240);   camera_image_capture->setEncodingSettings(iamge_setting);   // Correlate captured signals , When the capture screenshot signal is sent , Signal    connect(camera_image_capture,&QCameraImageCapture::imageCaptured,this,&Widget::processCapturedImage);   /* Configure the camera capture mode to frame capture mode */   camera->setCaptureMode(QCamera::CaptureViewfinder);   videoWidget = new QVideoWidget();   videoWidget->setMinimumSize(320,240);   // Add the camera display window to the layout    ui->horizontalLayout_camera->insertWidget(0,videoWidget);   /* Set the viewfinder display */   camera->setViewfinder(videoWidget);   /* Activate camera */   camera->start();}

Login interface code :

#include "LoginWindow.h"#include "ui_LoginWindow.h"LoginWindow::LoginWindow(QWidget *parent) :    QWidget(parent),    ui(new Ui::LoginWindow){    ui->setupUi(this);    this->setWindowTitle(" Welcome to face recognition class attendance system ");    // Set the theme style     SetStyle(":/blue.css");    // Set password box to password display mode     ui->lineEdit_password->setEchoMode(QLineEdit::Password);    // Set background prompt text     ui->lineEdit_password->setPlaceholderText(" Please input a password ");    // Set background prompt text     ui->lineEdit_user_name->setPlaceholderText(" Please enter a user name ");    // Read configuration     read_config();    // Read database     // Set up and open the database     if (QSqlDatabase::contains(LOG_IN_DATABASE_CONNECT_NAME))    {        database = QSqlDatabase::database(LOG_IN_DATABASE_CONNECT_NAME);    }    else    {        // Database type         database = QSqlDatabase::addDatabase("QSQLITE",LOG_IN_DATABASE_CONNECT_NAME);        database.setDatabaseName(LOG_IN_DATABASE_NAME); // Database name         database.setUserName("xl");  // user name         database.setPassword("123456"); // password     }    // Open database , Open the database if it exists , Create automatically if it doesn't exist     if(database.open()==false)    {        qDebug(" Database open failed . Please check the program running path and permissions .\n");    }    else    {        qDebug(" Successfully connected to database .\n");    }    // Build table -- Deposit account and password     CreateUserPassTAB();}LoginWindow::~LoginWindow(){    delete ui;}/* *  Set up QT The style of the interface */void LoginWindow::SetStyle(const QString &qssFile){    QFile file(qssFile);    if (file.open(QFile::ReadOnly))    {        QString qss = QLatin1String(file.readAll());        qApp->setStyleSheet(qss);        QString PaletteColor = qss.mid(20,7);        qApp->setPalette(QPalette(QColor(PaletteColor)));        file.close();    }    else    {        qApp->setStyleSheet("");    }}// Sign in void LoginWindow::on_pushButton_Login_clicked(){    if(ui->checkBox_save_password->isChecked())    {        // Save configuration         write_config();    }    else    {        QString text;        text=QCoreApplication::applicationDirPath()+"/"+CONFIG;        // Delete the file if it exists         if(QFileInfo(text).exists())        {           QFile::remove(text);        }    }    QString user=ui->lineEdit_user_name->text();    QString pass=ui->lineEdit_password->text();    // Compare passwords     if(ComparePasswords(user,pass))    {        // Close the database file         database.close();        // unload data base -- Free memory         QSqlDatabase::removeDatabase(LOG_IN_DATABASE_CONNECT_NAME);        // Open the main window         Widget *main_widget=new Widget;        main_widget->show();        // Close the current window         close();    }    else    {        QMessageBox::information(this," Tips "," Wrong account or password \n Please re-enter .",        QMessageBox::Ok,QMessageBox::Ok);    }}// Create an account and password table void LoginWindow::CreateUserPassTAB(){    // database : Build table , If it exists, it is not created , Create... If it doesn't exist     QSqlQuery sql_query(database);    // The following statement queries whether the specified table exists .    sql_query.exec(QString("select count(*) from sqlite_master where type='table' and name='%1'").arg("password"));    if(sql_query.next())    {        if(sql_query.value(0).toInt()==0)        {            qDebug(" Database tables do not exist . Ready to create .\n");            // Create a table   Create a table statement :create table <table_name> (f1 type1, f2 type2,…);            /* CREATE TABLE  Is a keyword that tells the database system to create a new table .                * CREATE TABLE  Statement followed by the unique name of the table                 *  Or identification */            /* The following statement :  Create a name password Table of , The fields are respectively stored   account number 、 password )*/            QString create_sql = "create table password(id int primary key, user varchar(100),password varchar(100))";            sql_query.prepare(create_sql);            if(!sql_query.exec())            {                Log_Text_Display(" Database table creation failed .\n");            }            else            {                Log_Text_Display(" Database table created successfully .\n");                // Initialized administrator password                 addPasswords(ROOT_USER,ROOT_PASSWORD);            }        }        else        {            Log_Text_Display(" Database tables exist . No need to create .\n");        }    }}// Show log void LoginWindow::Log_Text_Display(QString text){    qDebug()<<text;}// Insert data into database file bool LoginWindow::addPasswords(QString user,QString pass){    // Specify the database for the operation     QSqlQuery sql_query(database);    // The most inquired ID    QString select_max_sql = "select max(id) from password";    int max_id = 0;    sql_query.prepare(select_max_sql);    if(!sql_query.exec())    {        Log_Text_Display(" Database maximum ID To find the failure .\n");    }    else    {        while(sql_query.next())        {            max_id = sql_query.value(0).toInt();        }        Log_Text_Display(QString("data base max id:%1\n").arg(max_id));        // Add data         // insert data   Insert statement :insert into <table_name> values (value1, value2,…);        QString insert_sql = tr("insert into password values(?,?,?)");        sql_query.prepare(insert_sql);        //if(max_id!=0)max_id+=1; // Determine whether it is the first data         sql_query.addBindValue(max_id+1); //id        sql_query.addBindValue(user);    // account number         sql_query.addBindValue(pass);    // password         if(!sql_query.exec())        {            Log_Text_Display(" Data insertion failed .\n");        }        else        {            return true;        }    }    return false;}// Compare passwords   true success  false Failure bool LoginWindow::ComparePasswords(QString user,QString pass){    // Specify the database for the operation     QSqlQuery sql_query(database);    // Query all data     sql_query.prepare("select * from password");    if(!sql_query.exec())    {        Log_Text_Display(" Database query error .\n");    }    else    {        while(sql_query.next())        {            int id = sql_query.value(0).toInt(); //ID-- Primary key             QString sql_user = sql_query.value(1).toString(); // account number             QString sql_pass = sql_query.value(2).toString(); // password             // Compare passwords             if(user==sql_user && sql_pass==pass)            {                return true;            }        }    }    return false;}// Read configuration void LoginWindow::read_config(){    // Read configuration file     QString text;    text=QCoreApplication::applicationDirPath()+"/"+CONFIG;    QString pass;    QString user;    // Judge whether the file exists     if(QFile::exists(text))    {        QFile filenew(text);        filenew.open(QIODevice::ReadOnly);        QDataStream in(&filenew); //  Read serialized data from file         in >> user >> pass; // Extract written data         filenew.close();        // Set the interface value        ui->lineEdit_user_name->setText(user);       ui->lineEdit_password->setText(pass);       ui->checkBox_save_password->setChecked(true);    }}// Write configuration void LoginWindow::write_config(){    QString pass;    QString user;    // from UI Interface to obtain user's personalized configuration parameters     pass=ui->lineEdit_password->text();    user=ui->lineEdit_user_name->text();    /* Save data to file , Easy to load next time */    QString text;    text=QCoreApplication::applicationDirPath()+"/"+CONFIG;    QFile filesrc(text);    filesrc.open(QIODevice::WriteOnly);    QDataStream out(&filesrc);    out << user;  // Serialize user name     out << pass;  // Serialize password     filesrc.flush();    filesrc.close();}
原网站

版权声明
本文为[Hua Weiyun]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/187/202207061536056343.html