当前位置:网站首页>AI application lesson 1: C language Alipay face brushing login
AI application lesson 1: C language Alipay face brushing login
2022-07-29 08:26:00 【CPP programming】
- Project application scenario
VIP Student Kobayashi's first project :

Alipay brushes its face to pay :
- Project presentations
Demonstrate qiniu payment and login .
Environment building
Get the development template directly , Direct development . After class , Then follow the following steps to build your own .
- Configure face recognition SDK development environment
Be careful , Before configuring the environment , The first VS The platform of is adjusted to 64 Bit system ( You can also use 32 position , But face recognition SDK Also change the position 32 A version of the )
Add :
Business development , Face recognition related projects , Never develop your own face recognition
You should choose the right face recognition SDK
Choose face recognition SDK: Baidu , tencent , Ali , arcsoft
All businesses SDK, There are two versions :( R & D version 【 Free of charge 】, Distribution version 【 paid 】)
such as : UE4
Download hongruan SDK(64 position )
![]()
Configure the header file directory and library file directory
Under the project directory , establish face Catalog , Then face recognition SDK Copy the header file and library file of to the project directory face Under the table of contents

The header file
The library files
To configure SDK The header directory of
To configure SDK Library file directory
Configure additional dependencies
libarcsoft_face_engine.lib
Copy DLL Library file to executable directory


Import Rock Customized interface file

- To configure opencv development environment
opencv It's image processing , The most widely used free open source framework
Someone has developed , Use opencv Cooperate with the system of laser shelling mosquitoes ( Seconds become military , Beheading action )
opencv Use C/C++ Development ( Among them is 500 Three common interfaces are used C Language , Other uses C++), Cross platform
Qt It is a cross platform application framework
opencv It is a cross platform image processing framework
Qt + opencv
install opencv
The header file contains the directory :
D:\opencv\build\include
D:\opencv\build\include\opencv
D:\opencv\build\include\opencv2
The library file contains directories :
D:\opencv\build\x64\vc12\lib
Library used ( Additional dependencies )
( The following are the most commonly used library files , There are many other library files )
opencv_core249d.lib
opencv_highgui249d.lib
opencv_imgproc249d.lib
Dynamic library
opencv_core249d.dll
opencv_highgui249d.dll
opencv_imgproc249d.dll
- Import the 3 Square class
CVvImage
Add : The most common interview questions for high paying employment :
What third-party frameworks have you used ? Which third-party classes have been used 、 file 、 library 、 Tools ?
such as : Network development ,libevent Qt Table image processing in development :xxx
Import Rock Private tool library

- Project implementation
- Design system interface

It starts with beauty , Novice development , Start with the software interface .
IT Develop common sense
Interface design , It's up to art the final say ! The design of art works is up to the product manager to decide , Product manager's decision , It's up to Party A's father to decide !
Artistic drawing :( At the same time, provide materials )

Programmer implementation :
A picture control , Two button controls .
One minute .
Drag and drop controls

A picture control ,2 A button control
The interface at this time , Ugly appearance , Love cannot , Unusable !
Interface modification
Put the material pictures of the welcome interface , Load into project resources .
- Copy the material pictures to the project directory res subdirectories
- Add pictures to project resources
- Configure picture controls
type , Change it to :Bitmap
Images , Set to :IDB_BITMAP1
- Adjust the layout of the interface
problem : The interface cannot be adjusted !
skill : Because the picture of the picture control is too big , The dialog window cannot be operated
Put the type of picture control , Set it to frame, Then drag and drop the window to a larger , Then switch the type of picture back to Bitmap
Finally, narrow the window to a proper extent .
- Modify the text of the button
Set as “ register ”、“ Sign in ”
Design effect :

HBITMAP pic = (HBITMAP)LoadImage(NULL, L"mm1.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_img.SetBitmap(pic); |
HBITMAP pic = (HBITMAP)LoadImage(NULL, L"mm2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_img.SetBitmap(pic); |
The test results .
- Using the camera
Use face brush certification , You must use a camera .
principle :
Use timer , Capture the image data of the camera regularly , Put the captured image frame , Display to the picture control .
- Add tool library
tools.h tools.cpp CvvImage.h CvvImage.cpp
(tools.h 、tools.cpp yes Rock Written , Functions specially used for camera processing , It can be used as your own private tool )
Copy these two files to the project directory , And add to the project .
- Timed camera variables
#include <opencv2/opencv.hpp> using namespace cv; // Define a camera variable VideoCapture cap; |
In the event handler of the register button , Turn on the camera , And create timers
// 1. Turn on the camera cap.open(0); // Turn on the default camera // 2. Create timer SetTimer( 1, // The number of the timer 100,// every other 100ms Remind once NULL); // When it's time , Which function to perform ,NULL It means to execute the default timing processing function |
- Create a scheduled message for the dialog
First select the dialog , Then in the properties window of the dialog box “ news ” tab , add to “VM_TIMER” news

- In the timing handler , Realize timing capture
#include "tools.h" void COpenCVTmpDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add message handler code and / Or call the default value if (nIDEvent == 1) { // Turn the camera on cap Captured image frames , Put it in the current window m_hWnd Of IDC_STATIC_IMG Control refreshCamera(&cap, m_hWnd, IDC_STATIC_IMG); } CDialogEx::OnTimer(nIDEvent); } |
- Implement registration
Method : Use the camera to countdown and take photos , Then save the photo .
#include <mmsystem.h> #pragma comment(lib, "winmm.lib") void COpenCVTmpDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add message handler code and / Or call the default value static int count1 = 0; if (nIDEvent == 1) { // Turn the camera on cap Captured image frames , Put it in the current window m_hWnd Of IDC_STATIC_IMG Control refreshCamera(&cap, m_hWnd, IDC_STATIC_IMG); count1++; if (count1 == 1) { mciSendString(_T("play res/zhuche.mp3"), 0, 0, 0); // Play 3 Second countdown function } else if (count1 == 30) { paiZhao(&cap, "Rock.jpg"); count1 = 0; KillTimer(1); // off timer cap.release(); // Turn off camera MessageBox(_T(" Registered successfully !")); // Switch the screen to the first welcome screen HBITMAP hbitmap = (HBITMAP)LoadImage(NULL, "res/start.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_img.SetBitmap(hbitmap); } } CDialogEx::OnTimer(nIDEvent); } |
- Face recognition
Face recognition analysis :
Direct pixel contrast is not appropriate , You can't use the way of continuous viewing .
Solution :
Use face recognition SDK
- face scan
Similar to login .
void COpenCVTmpDlg::OnBnClickedButtonLogin() { // TODO: Add control notification handler code here //HBITMAP pic = (HBITMAP)LoadImage(NULL, "mm2.bmp", IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); //m_img.SetBitmap(pic); cap.open(0); SetTimer(2, 100, NULL); } void COpenCVTmpDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add message handler code and / Or call the default value static int count1 = 0; if (nIDEvent == 1) { ...... } else if (nIDEvent == 2) { refreshCamera(&cap, m_hWnd, IDC_STATIC_IMG); } CDialogEx::OnTimer(nIDEvent); } |
- Define face recognition interface
- Import face recognition tool library faceTool.h faceTool.cpp To project .
- Add header file
#include "faceTool.h" |
- Define face recognition module variables
// Module variables of face recognition MHandle handle; |
- Initialize module variables
In the initialization function of the dialog window , add to :faceInit(&handle);
- Define the interface of face recognition faceCheck
BOOL faceCheck(const char* name1, const char* name2) { // Read two photos // Data types are case sensitive ! IplImage* img1 = cvLoadImage(name1); IplImage* img2 = cvLoadImage(name2); if (!img1 || !img2) { return false; //FALSE } float ret = faceCompare(handle, img1, img2); // return ret >= 0.95 if (ret < 0.95) { return false; } else { return true; |
- Realize face recognition login
Method :
The first 1 At the end of seconds , Take pictures automatically 、 And face recognition ,
The first 2 At the end of seconds , Refresh the interface according to the recognition result of the last second
Code implementation
void COpenCVTmpDlg::OnTimer(UINT_PTR nIDEvent) { // TODO: Add message handler code and / Or call the default value static int count1 = 0; static int count2 = 0; static bool success = false; // Indicates whether the recognition result is successful if (nIDEvent == 1) { ...... } else if (nIDEvent == 2) { refreshCamera(&cap, m_hWnd, IDC_STATIC_IMG); count2++; if (count2 == 10) { paiZhao(&cap, "Rock2.jpg"); // Taking pictures // Face recognition if (faceCheck("Rock.jpg", "Rock2.jpg")) { success = true; // Play a successful login sound , continued 1S mciSendString("play res/login.mp3", 0, 0, 0); } } else if (count2 == 20) { count2 = 0; KillTimer(2); cap.release(); const char* fileName = success ? "res/bgInit.bmp" : "res/bgError.bmp"; HBITMAP hbitmap = (HBITMAP)LoadImage(NULL, fileName, IMAGE_BITMAP, 0, 0, LR_LOADFROMFILE); m_img.SetBitmap(hbitmap); success = false; } } CDialogEx::OnTimer(nIDEvent); } |
- The project is perfect
- In vivo detection
Open your mouth , Shake your head to the left , Shake your head to the right , Nod your head , Blink, blink ( Financial related !)
- Multi user account login
Using a database
VIP Course No 3 volume
Employed students are in research and development ,90% The above needs to use database .
- Cross platform
Use Qt Migrate to other mobile platforms
VIP Course No 5 volume , Guarantee of fast and high salary employment .
- Project summary
- Project development is , Get started with requirements , The process of gradual improvement .
- The technocrats , It all starts from zero basis , Gradual upgrade , The process of becoming stronger
- Xiao Xiang - Sophomores began to be confused , At the beginning of study , It's enough just to get a job , Later, I joined Baidu server development , Annual salary 30W
- Marin, 32 I started to study at the age of , At first, I just wanted to change careers quickly ,6 I'll be in after three months C++ Audio and video server development , a monthly salary 15K,4 After a month , a monthly salary 18K
- Jia Jia , Junior internship , Just don't practice in the factory designated by the school , Now I'm on the job C++ It's been developing for more than a year
Today's sharing is here , Everyone should study hard C Language /C++ yo ~
For preparing to learn C/C++ Programming partners , If you want to better improve your core programming skills ( Internal skill ) From now on !
C Language C++ Programming learning communication circle ,QQ Group :763855696【 Click to enter 】
C Language from entry to mastery (C Introduction to language C Language course C Language zero basis C Language foundation C Language learning C
Organize and share ( Years of study Source code 、 Project practice video 、 Project notes , Introduction to Basics )
Welcome to change and study Programming The partners , Using more information to learn and grow faster than thinking about it yourself !
Programming learning video sharing :



边栏推荐
- The first week of postgraduate freshman training: deep learning and pytorch Foundation
- Lora opens a new era of Internet of things -asr6500s, asr6501/6502, asr6505, asr6601
- Smart energy management system solution
- Ga-rpn: recommended area network for guiding anchors
- 110 MySQL interview questions and answers (continuously updated)
- Implementation of support vector machine with ml11 sklearn
- Huawei wireless device configuration uses WDS technology to deploy WLAN services
- Security baseline of network security
- Play Parkour with threejs Technology
- [opencv] - Operator (Sobel, canny, Laplacian) learning
猜你喜欢

Application scheme of charging pile

数字人民币时代隐私更安全

Solve the problem of MSVC2017 compiler with yellow exclamation mark in kits component of QT

Crawling JS encrypted data of playwright actual combat case

Simple calculator wechat applet project source code

Simulation of four way responder based on 51 single chip microcomputer
![[robomaster] a board receives jy-me01 angle sensor data -- Modbus Protocol & CRC software verification](/img/0e/e5be0fffb154d081c20b09832530d4.png)
[robomaster] a board receives jy-me01 angle sensor data -- Modbus Protocol & CRC software verification

Segment paging and segment page combination

Background management system platform of new energy charging pile

Stm8s003 domestic substitute for dp32g003 32-bit microcontroller chip
随机推荐
Intelligent temperature control system
Segment paging and segment page combination
Deep learning (2): image and character recognition
Compatible with cc1101/cmt2300-dp4301 sub-1g wireless transceiver chip
MFC integration QT verification and problem handling
torch.Tensor.to的用法
Proteus simulation based on msp430f2491 (realize water lamp)
Chrony 时间同步
Intelligent shelf safety monitoring system
Phy6252 is an ultra-low power Bluetooth wireless communication chip for the Internet of things
DC motor control system based on DAC0832
Application scheme of charging pile
MySQL中的时间函数
Background management system platform of new energy charging pile
Simplefoc parameter adjustment 2- speed and position control
Brief introduction and use of commonjs import and export and ES6 modules import and export
What constitutes the smart charging pile system?
Stm32ff030 replaces domestic MCU dp32g030
torch.nn.functional.one_hot()
Inclination sensor accuracy calibration test