Artificial intelligence algorithm to realize facial recognition

Technology design 2020/05/23
← Return to technical article

1.1 The study ' s background face recognition is a biometric technique that automatically carries out identification, also known as facial recognition, based on the characteristics of the human face. It began in the 1960s, when computer technology and optical imaging developed more and more, leading to improved and enhanced face recognition techniques, and began to receive initial applications in the 1990s...

  • 1 Background of the study

Human face recognition is a biometric technique that automatically carries out identification based on human face characteristics, also known as facial recognition. It began in the 1960s with the development of computer technology and optical imaging, which led to improvements and improvements in human face recognition techniques, and began to be applied initially in the 1990s. Human face recognition uses a variety of specialized techniques, such as artificial intelligence, machine learning, machine recognition, modelling theory, video image processing, and so forth. This is the latest application of biometric recognition.

  • 2 Research status
  • 2.1 Foreign research status and development

Science and technology have evolved rapidly, and since the 1960s, many countries have started to study human face recognition, and many countries in the West have achieved remarkable results in human face recognition because of advanced computer technology. These countries are mainly developed countries such as the United States, European countries, and Japan. The leading research institutions are Media Lab, AI Lab, Human-Computer Interface Institute, Microsoft Research, and British Department of Engineering in University of Cambridge, United States of America.

Since the 1990s, computer technology has made breakthrough progress in human face recognition, from the beginning of the semi-manual semi-automatic process to the time when the machine has now achieved automatic face recognition. Worldwide, there are a number of methods of face recognition, including:

Face recognition is the systematic processing of the images that will be acquired, and there are many ways to handle them, and we have to use different ways to achieve different functions.

The face of a human being is complex, and we want to acquire a person's face identity by using colour extracts, which distinguish the colours of a person's face in the image and mark them in different colours. Colour extraction is a more reliable method of extraction, with a high success rate and a rapid pace of extraction.

The brightness of the image changes because of the different environments in which it is used. Identification can have an impact on the result. At this point, it is particularly important to adjust the brightness to the normal state, which is usually too dark for the light to lead to the failure of identification, and we can increase the brightness to achieve recognition.

In order to reduce the computing burden of computers, the greyscale processing of colour images is done, and the basic information of the images is kept.

The contrast is increased by pulling the contrast between the human face of the image and the surrounding environment, making the face more visible, mainly through the concentration of pixels.

  • 1.1 Operational feasibility

We use Windows 10, Python 3.7.4, PyCharm 2019.2.3 X64, PyQt 5-5.14.2, OpenCV 3.4.7, pip 20.0.2. Users need 64-bit versions of Microsoft Windows 10, 8 with a minimum of 2 GB RAM, recommendation 8 GB RAM, 2.5 GB hard drive space, with a recommended SSD (solid hard drive), a minimum of 1024 x 768 screen resolution, Python 2.7 or Python 3.5 or higher, so long as the above software and packages can be installed.

  • Face recognition method based on geometric features.
  • Face recognition method based on template matching.
  • Eigenface method based on K-L transformation.
  • A method based on hidden Markov models.
  • Neural network identification method.
  • flexchart matching method based on dynamic link structure.
  • The method of face recognition using motion and colour information for dynamic image sequences.
  • 2.2 Domestic research status and development

China’s research on face recognition began late because of computer-based constraints. In the 1980’s, a number of Chinese universities and academies of science began researching human face recognition techniques. Our research direction is different from that of Western countries, where research and development of face recognition are carried out, starting with the automatic recognition of human faces based on geometric characteristics, of human faces based on algebraic characteristics and of human faces based on connectivity mechanisms.

  • 3 Research Significance

The most important reason for people to look at human face recognition is because they have to look at human eyes and understand the nature of human face eye recognition. At the same time, human face recognition is a branch of artificial intelligence, and the study of human face recognition is an application that drives artificial intelligence. The ultimate purpose of the human face recognition system is to create automatic machine intelligence to recognize human face. The system of identification on the market now includes fingerprinting, DNA, iris testing, etc., which, while they can also identify a person, also has disadvantages such as the need to contact a person, the high cost, the long time of identification, etc., and the human face identification system can solve these problems perfectly. First, human face recognition does not require physical contact with the person being tested and is not offensive; Second, it is inexpensive and easy to install, and as long as there are cameras, cameras, mobile phones, the user does not need a special installation; finally, the entire testing process is uninvolved, and the computer can be automatically performed on a preset basis.

Face recognition, which marks a shift from weak artificial intelligence to strong artificial intelligence, is now being widely applied in many areas, including government, military, banking, social security, safety protection, etc., is becoming more mature, and society is becoming more familiar with face recognition, and I am confident that it will be widely applied in a wider range of areas.

  • 4 Research goals and content

Through the LBPH face recognition algorithm with OpenCV, a closed door system was designed using the python platform, mainly for human face recognition.

The first thing to do for human face recognition is to collect images of human face, to collect different faces through a camera, to find a human face in an image, to use a human face test, to distinguish a term face recognition from a human face test, to locate a human face in a photograph; a human face recognition is to compare a human face to that of a human face in a human face database, and to identify a human face that corresponds to a human face that is to be identified, a process of distinguishing between a human face and a human face.

The images are then pre-processed. Since most of the images collected are not directly usable because of the influence of external factors, they must be converted to greyscale, noise filters, etc.

The last step before identification is the characterization of a processed image, which can be used in facial recognition systems, usually divided into visual features, pixel statistical characteristics, facial image transformation coefficient characteristics and facial image algebra. The characterization of a person's face includes the extraction of a facial feature on certain features of the face. The characterization of a person's face (also known as the human face representation) is a characterization modelling process of a person's face. The characterization of a person's face can be divided into two types: one based on knowledge; The other category is representational methods based on algebra characteristics or statistical learning.

In the process of identification, each person's face is built into a model, different faces are models, the process of identification is compared with existing models, and then the human face is attributed to the corresponding model. Human face recognition is subdivided into two categories: identification and identification. Identification refers to the computer's answer to the question “Who I am”, who everyone is identified in many pictures; and confirmation refers to the computer's identification of the person in the photograph or video, “Is it me or not”, a one-to-one image comparison. The recognition mode therefore clearly requires a higher than the recognition of the algorithm's speed.

  • 5 Advantages and difficulties of face recognition technology
  • 5.1 Advantages

Human face recognition technology, which is now the mainstream of identification technology, has the natural advantages that other identification techniques do not have.

First, the human face recognition technique automatically identifies the human face and identifies the person through the biological characteristics of the human face, as does the human face recognition, a humanized approach that is not available for fingerprinting and iris recognition.

Second, human face recognition techniques are not easily detected by individuals, and your information is known to computers without realizing it.

Finally, the human face recognition technique does not require machine-to-human contact, does not give rise to an anti-detection and can be tested and identified on many occasions.

  • 5.2 Disadvantages

But the human face, as the most complex visual feature in the world, is very difficult to identify automatically. Because of the complex and variable nature of the human face, it makes it very difficult to identify the machine.

First, the first person to be detected may be a bearded person, without glasses, who will be recorded in a human face, and the next time he is identified, he shaves, wears glasses and changes his hair, which may lead to a failure in identification. And there are twins, in which case, it is almost impossible to identify a successful face.

At the same time, different scenes of detection and identification, resulting in different light, environments and decorations, can also lead to an increase in the failure rate of face recognition.

In addition, the growing age of the human being over time can also change the face. This change is particularly evident for adolescents.

As a result, face recognition is still a major challenge.

1 Summary of theoretical and technical aspects of the Human Face Identification System

  • 1 OpenCV Overview

OpenCV (Open Source Computer Vision Library) is an open-source computer visual library that provides a number of functions that can efficiently achieve computer visual algorithms. It is developed by C and C++, along with interfaces in other languages, such as Python, Java, Matlab. It can operate on operating systems like Windows, Linux, Mac OS, Android, iOS. OpenCV applications are very extensive in image processing, human interaction, and face recognition. OpenCV emphasizes efficient real-time application development.

OpenCV is an open-source, free-of-charge visual library, which means that OpenCV can be used for both scientific and commercial purposes, and that source code can be seen and modified. If one of the functions in OpenCV lacks some of the functions you think about, you can modify the functions and add them. The purpose of the OpenCV function library is to promote research and commerce.

OpenCV is divided into four layers, at the bottom of which is the optimization of hardware, the core of OpenCV, most advanced functions and codes contributed by developers, language binding and illustrative applications, and at the top, interaction with operating systems.

  • 2 Overview of LBPH face recognition algorithm
  • 2.1 The principles of the LBPH face recognition algorithm
  • Load data

Stores image data separately from image corresponding labels.

  • Training data

(1) Parameter initialization

Initialization of radius (radius = 1), neighbourhood size (neighbors = 8), number of grids in the direction of width and height, and histogram distance threshold (threshold = DBL MAX).

Initialize the label array.

(2) LBP encoding

Calculate LBPi, the size is

Artificial intelligence algorithm to realize facial recognition

。

  • Calculate histogram

Each LBPi image corresponds to the width of the histogram matrix as

, height is

。

(1) Calculate the height and width of the grid:

。

(2) Each row of the histogram matrix is organized in rows at the height of the hetogram within each grid, divided by the height of each hetogram

, the histogram matrix is finally converted to a vector matrix of one row.

(3) Insert the all-face training image histogram matrix into the member variable with the number of rows of the member variable

The number of columns is N.

  • Update Model

People's faces are not static, and when people's faces change, we need to update their models. The labels are unchanged, the image data are updated.

  • Forecast

When human face recognition is performed, the histogram matrix of the image to be identified is calculated, and then the hetogram with the smallest distance in the model is identified and trained. If the threshold of the histogram is lower than the threshold at the time of initialization, this person is the corresponding person of the histogram.

  • 2.2 LBPH theoretical basis

The images obtained by the camera are divided into nine blocks using a nine-gauge, using the pixel value of the middle as a standard threshold, then calculating the greyscale value of the eight pieces of pixel around it, and then comparing it with the middle threshold, marking the position of the pixel as one if the pixel's greyscale value is greater than the middle threshold; and marking the position of the pixel as zero if it is smaller or equal to the middle threshold. This allows the location mark at eight locations to form an eight-digit binary number, and then converts this binary number into a decimal, i.e., LBP code. So you can get the LBP value of this image, which reflects the image's characteristics.

  • 3 PyQt5 overview

PyQt5 consists of a series of Python modules with more than 620 classes and 6,000 functions. It is a cross-platform toolkit that operates on all mainstream operating systems, including Windows, Linux and Mac OS. PyQt5 is the popular development component of the python development interface.

  • 3.1 PyQt5 main classes

(1) QApplication Category

The QApplication category is the most important control stream and main setting for the production of the GUI, which controls the back-office management of the GUI. As long as PyQt is used to develop the GUI application, QApplication objects must be used.

To use the QApplication category, it has to be initialized, usually after the Python script's if name = = "main": statement, similar to the C-main function, which serves as the entry to the main program. Because QApplication objects have been substantially initialized, it has to be created before the window is created.

When QApplication is initialized, the whole program is run and responds to the events of each control through the event response function. The entire application ends only when the exit function is Sys.exit() is called.

(3)QWidget

QWidget is a base category for all user interface categories that can receive all external and other system window events.

(4)Qdialog

Qdialog is the parent of the standard dialogue box, which has many subcategories that allow changes in characters, fonts, colours, and the selection of files.

(5)QMainWindow

QMainWindow (main window) is the "face" of the application, adding controls such as buttons to the main window. It can be inherited, making the encapsulation of the control above it simple.

  • 4 Haar cascade

Photographs may contain a lot of pleasant details. But, because of the diversity of the photographers, changes in the environment, and changes in camera vibrating and digital noises, it is difficult to extract images. People are not affected by these external factors when identifying their faces, but it is difficult for machines to do so.

Thus, identification can only be made easier by extracting stable image classification results. The derived image classification results are referred to as characteristics. While any pixel can affect multiple features, the characteristics should be much less than the pixels. The similarity of the two images can be measured by measuring the European distance of the corresponding characteristics of the two images.

The Haar feature is a feature used for real-time facial tracking. Each Haar feature describes the contrast pattern of the adjacent image area. For example, the edge, the vertebrates and the fine lines can generate a classification feature. The Haar feature is divided into four categories: marginal features, linear features, central features and diagonal features, which have been combined into a feature template. The Haar feature values reflect a dark change in the black and white colour of the image. For example, the eye is darker than the cheek, the side of the nose is darker than the nose, and the mouth is darker than the surrounding colour. However, rectangular characteristics have some limitations and only a few simple images can be characterizationd.

1 Summary of theoretical and technical aspects of the Human Face Identification System

  • 1 OpenCV Overview

OpenCV (Open Source Computer Vision Library) is an open-source computer visual library that provides a number of functions that can efficiently achieve computer visual algorithms. It is developed by C and C++, along with interfaces in other languages, such as Python, Java, Matlab. It can operate on operating systems like Windows, Linux, Mac OS, Android, iOS. OpenCV applications are very extensive in image processing, human interaction, and face recognition. OpenCV emphasizes efficient real-time application development.

OpenCV is an open-source, free-of-charge visual library, which means that OpenCV can be used for both scientific and commercial purposes, and that source code can be seen and modified. If one of the functions in OpenCV lacks some of the functions you think about, you can modify the functions and add them. The purpose of the OpenCV function library is to promote research and commerce.

OpenCV is divided into four layers, at the bottom of which is the optimization of hardware, the core of OpenCV, most advanced functions and codes contributed by developers, language binding and illustrative applications, and at the top, interaction with operating systems.

  • 2 Overview of LBPH face recognition algorithm
  • 2.1 The principles of the LBPH face recognition algorithm
  • Load data

Stores image data separately from image corresponding labels.

  • Training data

(1) Parameter initialization

Initialization of radius (radius = 1), neighbourhood size (neighbors = 8), number of grids in the direction of width and height, and histogram distance threshold (threshold = DBL MAX).

Initialize the label array.

(2) LBP encoding

Calculate LBPi, the size is

。

  • Calculate histogram

Each LBPi image corresponds to the width of the histogram matrix as

, height is

。

(1) Calculate the height and width of the grid:

。

(2) Each row of the histogram matrix is organized in rows at the height of the hetogram within each grid, divided by the height of each hetogram

, the histogram matrix is finally converted to a vector matrix of one row.

(3) Insert the all-face training image histogram matrix into the member variable with the number of rows of the member variable

The number of columns is N.

  • Update Model

People's faces are not static, and when people's faces change, we need to update their models. The labels are unchanged, the image data are updated.

  • Forecast

When human face recognition is performed, the histogram matrix of the image to be identified is calculated, and then the hetogram with the smallest distance in the model is identified and trained. If the threshold of the histogram is lower than the threshold at the time of initialization, this person is the corresponding person of the histogram.

  • 2.2 LBPH theoretical basis

The images obtained by the camera are divided into nine blocks using a nine-gauge, using the pixel value of the middle as a standard threshold, then calculating the greyscale value of the eight pieces of pixel around it, and then comparing it with the middle threshold, marking the position of the pixel as one if the pixel's greyscale value is greater than the middle threshold; and marking the position of the pixel as zero if it is smaller or equal to the middle threshold. This allows the location mark at eight locations to form an eight-digit binary number, and then converts this binary number into a decimal, i.e., LBP code. So you can get the LBP value of this image, which reflects the image's characteristics.

  • 3 PyQt5 overview

PyQt5 consists of a series of Python modules with more than 620 classes and 6,000 functions. It is a cross-platform toolkit that operates on all mainstream operating systems, including Windows, Linux and Mac OS. PyQt5 is the popular development component of the python development interface.

  • 3.1 PyQt5 main classes

(1) QApplication Category

The QApplication category is the most important control stream and main setting for the production of the GUI, which controls the back-office management of the GUI. As long as PyQt is used to develop the GUI application, QApplication objects must be used.

To use the QApplication category, it has to be initialized, usually after the Python script's if name = = "main": statement, similar to the C-main function, which serves as the entry to the main program. Because QApplication objects have been substantially initialized, it has to be created before the window is created.

When QApplication is initialized, the whole program is run and responds to the events of each control through the event response function. The entire application ends only when the exit function is Sys.exit() is called.

(3)QWidget

QWidget is a base category for all user interface categories that can receive all external and other system window events.

(4)Qdialog

Qdialog is the parent of the standard dialogue box, which has many subcategories that allow changes in characters, fonts, colours, and the selection of files.

(5)QMainWindow

QMainWindow (main window) is the "face" of the application, adding controls such as buttons to the main window. It can be inherited, making the encapsulation of the control above it simple.

  • 4 Haar cascade

Photographs may contain a lot of pleasant details. But, because of the diversity of the photographers, changes in the environment, and changes in camera vibrating and digital noises, it is difficult to extract images. People are not affected by these external factors when identifying their faces, but it is difficult for machines to do so.

Thus, identification can only be made easier by extracting stable image classification results. The derived image classification results are referred to as characteristics. While any pixel can affect multiple features, the characteristics should be much less than the pixels. The similarity of the two images can be measured by measuring the European distance of the corresponding characteristics of the two images.

The Haar feature is a feature used for real-time facial tracking. Each Haar feature describes the contrast pattern of the adjacent image area. For example, the edge, the vertebrates and the fine lines can generate a classification feature. The Haar feature is divided into four categories: marginal features, linear features, central features and diagonal features, which have been combined into a feature template. The Haar feature values reflect a dark change in the black and white colour of the image. For example, the eye is darker than the cheek, the side of the nose is darker than the nose, and the mouth is darker than the surrounding colour. However, rectangular characteristics have some limitations and only a few simple images can be characterizationd.