Electronic device and image recognition method, system on chip and medium thereof
By using two processors in the electronic device to process face detection and alignment in parallel, and using the parameters of the previous frame of image to act on the next frame of image, the time-consuming and lengthy process caused by the serialization of the four-stage algorithms in the face recognition process is solved. The big delay problem is solved and more efficient image processing is achieved.
Patent Information
- Application Number
- CN202110913181.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-08-10
- Publication Date
- 2024-09-13
- Estimated Expiration
- 2041-08-10
AI Technical Summary
In a system containing a neural network processor (NPU) and an image signal processor (ISP), the four-stage algorithm (face detection, alignment, feature extraction and recognition) in the face recognition process works serially, resulting in long and time-consuming Big delay.
By using two processors in the electronic device for parallel processing, the first processor is responsible for face detection and alignment, and the second processor is responsible for region of interest extraction and feature matching, and uses the frame selection parameters and alignment parameters of the previous frame image. Acts on the next frame of image to reduce the time for ISP to calculate frame selection and alignment, thereby achieving asynchronous processing.
It reduces the end-to-end delay of the four-stage algorithm processing, shortens the image processing time, and improves the efficiency of face recognition.
Smart Images

Figure CN113627328B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing, and in particular to an electronic device and an image recognition method thereof, a system on a chip, and a medium. Background Art
[0002] With the rapid development of artificial intelligence (AI), neural network processing units (NPUs) are being used more and more widely in intelligent electronic devices.
[0003] In a system or chip including an NPU and an image signal processor (ISP), the NPU uses a neural network model to perform image recognition processing on the input image, such as face recognition.
[0004] Generally, in the process of face recognition, the NPU processes the image obtained from the ISP through a series of AI algorithms, for example, the following four-stage algorithm processing: face detection (including extraction of the face region of interest ROI), face alignment (converting an image with an incorrect angle into an image with a correct angle), face feature extraction, and face recognition. However, the above four-stage algorithms work in series and are processed in sequence, which takes a long time and has a large delay. Summary of the invention
[0005] Embodiments of the present application provide an electronic device and an image recognition method thereof, a system on a chip, and a medium.
[0006] In a first aspect, an embodiment of the present application provides an image recognition method, the method is applied to an electronic device, the electronic device includes a first processor and a second processor, the method includes:
[0007] The electronic device performs face recognition on the frame image in the video to be recognized by using the first processor and the second processor, wherein the processing method of the electronic device after acquiring the Mth frame image is as follows:
[0008] The first processor performs face detection and face alignment on the M-th frame image to obtain a first frame selection parameter and a first alignment parameter, and the second processor uses the second frame selection parameter and the second alignment parameter to extract the face region of interest and align the face on the M-th frame image; wherein the second frame selection parameter and the second alignment parameter are obtained by the first processor performing face detection and face alignment on the M-1-th frame image after the electronic device acquires the M-1-th frame image;
[0009] The first processor performs facial feature extraction and feature matching on the Mth frame image based on the facial region of interest extraction result and face alignment result of the Mth frame image by the second processor to obtain a face recognition result of the Mth frame image.
[0010] It can be understood that the face region of interest extraction result may include the target face frame selection area in the following embodiments, and the face alignment result may include the target face image adjusted to a preset angle in the following embodiments.
[0011] It can be understood that if M is the N-1th frame in the following embodiment, then the M-1th frame is the N-2th frame in the following embodiment. If M is the Nth frame in the following embodiment, then the M-1th frame is the N-1th frame in the following embodiment.
[0012] In the embodiment of the present application, since the position and posture of the face in two adjacent frames of face images in a high frame rate (such as 30 frames) video stream are not much different, the frame selection parameters and face alignment parameters of the previous frame (N-1 frame) calculated by NPU104 can be used to act on the next frame (N frame) in ISP103. ISP103 extracts the face region of interest and aligns the face on the face image of the next frame (N frame). The time consumption is: the first time period T1'+the second time period T2'. Since the frame selection parameters and face alignment parameters are N PU104 calculates in advance and transmits it to ISP103, which saves the time for ISP103 to calculate the frame selection parameters and face alignment parameters. Therefore, the first time period T1'+the second time period T2' is less than the first time period T1+the second time period T2. The overall time consumption of the four stages of the embodiment of the present application is: the first time period T1'+the second time period T2'+the third time period T3+the fourth time period T4, which is less than the time consumption in the prior art: the first time period T1+the second time period T2+the third time period T3+the fourth time period T4. In this way, the end-to-end delay caused by the serial processing of the above four-stage algorithm is reduced, the end-to-end image processing time is shortened to a certain extent, and the efficiency of the algorithm processing is improved.
[0013] In a possible implementation of the first aspect above, the first processor is a neural network processor, and the second processor is an image signal processor.
[0014] In a possible implementation of the first aspect above, the face region of interest extraction result includes a target face frame selection area, and the face alignment result includes a target face image adjusted to a preset angle.
[0015] It can be understood that the target face image at a preset angle may refer to a frontal face image obtained by converting a side face image or an image with an incorrect angle.
[0016] In a possible implementation of the first aspect above, the frame selection parameters include coordinate data of the edge of the target face frame selection area; and the alignment parameters include affine transformation matrix data for adjusting the target face to a preset angle.
[0017] In a possible implementation of the first aspect above, the target face frame selection area is a rectangle, and the frame selection parameters are coordinate data of two vertices on a diagonal line of the target face frame selection area or coordinate data of four vertices of the target face frame selection area.
[0018] In a possible implementation of the first aspect above, the video to be identified is a video with a frame rate greater than a preset frame rate.
[0019] It is understandable that, in some embodiments, ISP 103 can obtain frame images in the video stream from image sensor 102. Image sensor 102 can also send frame images in the video stream to memory 107 for storage, and ISP 103 obtains two adjacent frames of images in the video stream from memory 107. In addition, it is understandable that the video stream can be a high frame rate video stream, and the high frame rate is also called high frame rate format (High Frame Rate / HFR), which refers to shooting video at a frequency of 30 frames per second or more. For example, 30FPS, 48FPS, 60FPS. FPS is a definition in the field of images, which refers to the number of frames transmitted per second, that is, the number of frames of animation or video.
[0020] In a high frame rate face recognition system, the position and posture of the target face images in two adjacent frames are not much different. The target face ROI and face affine transformation of the previous frame can be used to act on the target face ROI of the next frame. The following will specifically introduce how to act on the target face ROI and face affine transformation of the previous frame to the target face ROI of the next frame.
[0021] In a possible implementation of the first aspect above, the preset frame rate is 30 frames per second.
[0022] In a second aspect, an embodiment of the present application provides a readable medium having instructions stored thereon, which, when executed by an image signal processor, can implement the image recognition method described in the first aspect.
[0023] In a third aspect, an embodiment of the present application provides an electronic device, comprising: a memory for storing instructions executed by one or more processors of the electronic device; and
[0024] The first processor and the second processor are used to support the first processor or the second processor to execute the image recognition method described in any one of the first aspects.
[0025] In a third aspect, an embodiment of the present application provides a system on chip, a memory for storing instructions executed by one or more processors of the system on chip; and
[0026] The first processor and the second processor are used to support the first processor or the second processor to execute the image recognition method described in any one of the first aspects. BRIEF DESCRIPTION OF THE DRAWINGS
[0027] Figure 1 A schematic diagram showing the NPU performing face recognition on an image;
[0028] Figure 2A A schematic diagram is shown when NPU 104 and ISP 103 perform face recognition on the N-1th frame image and the Nth frame image in parallel;
[0029] Figure 2B According to the embodiment of the present application, corresponding to Figure 1 and Figure 2A , showing a schematic diagram of the principle of a parallel algorithm processing provided by an embodiment of the present application, which improves the algorithm processing efficiency compared with the serial algorithm processing in the prior art;
[0030] Figure 2C A schematic diagram is shown in which the NPU 104 and the ISP 103 perform face recognition on the N-2th frame image to the N+1th frame image in parallel;
[0031] Figure 3 According to some embodiments of the present application, a schematic structural diagram of an electronic device 100 is shown;
[0032] Figure 4 According to the embodiment of the present application, the interactive process of using NPU104 to perform face feature extraction and face recognition after the image data is processed by ISP 103 for face region of interest extraction and face alignment is shown;
[0033] Figure 5 According to some embodiments of the present application, a schematic diagram of the structure of ISP 103 is shown;
[0034] Figure 6 A schematic diagram showing a process of processing image data by a general function module is shown;
[0035] Figure 7 According to some embodiments of the present application, a schematic structural diagram of a system on chip is shown. DETAILED DESCRIPTION
[0036] Illustrative embodiments of the present application include, but are not limited to, electronic devices and image recognition methods and media thereof.
[0037] As mentioned above, the following technical problems are mentioned in the background technology:
[0038] The four stages of face detection, face alignment, face feature extraction and face recognition take a long time and have a large delay when the NPU works in series. For example, Figure 1 FIG. 4 shows a schematic diagram of NPU performing face recognition on an image. Figure 1 As shown, when NPU104 performs face recognition on an image, it needs to go through the following stages: face detection in the first time period, face alignment in the second time period, face feature extraction in the third time period, and face recognition in the fourth time period. The above four-stage algorithms work in series, which takes time: first time period T1 + second time period T2 + third time period T3 + fourth time period T4.
[0039] In the embodiment of the present application, part of the algorithm processing in the NPU is handed over to the ISP for asynchronous processing. For example, the ISP mainly performs face region of interest extraction (directly extracting the face region of interest ROI according to the frame selection parameters) and face alignment (directly converting the image with incorrect angle into the image with correct angle according to the affine transformation matrix), and the NPU mainly performs face feature extraction and face recognition. The ISP and NPU work in parallel to reduce the end-to-end delay caused by the serial processing of the four-stage algorithm, which can shorten the image processing time to a certain extent and improve the efficiency of the algorithm processing. For example, Figure 2A FIG. 1 shows a schematic diagram of NPU 104 and ISP 103 performing face recognition on the N-1th frame image and the Nth frame image in parallel. Figure 2A As shown, since the positions and postures of the facial images of two adjacent frames are not much different, the frame selection parameters and face alignment parameters of the previous frame (N-1 frame) calculated by NPU104 can be used to act on the next frame (N frame) in ISP103. ISP103 extracts the facial region of interest and aligns the face of the facial image of the next frame (N frame), and the time consumption is: first time period T1'+second time period T2'. Since the frame selection parameters and face alignment parameters are calculated in advance by NPU104 and transmitted to ISP103, the time for ISP103 to calculate the frame selection parameters and face alignment parameters is saved. Therefore, the first time period T1'+second time period T2' is less than the first time period T1+second time period T2. The overall time consumption of the four stages of the embodiment of the present application is: first time period T1'+second time period T2'+third time period T3+fourth time period T4, which is less than the time consumption in the prior art: first time period T1+second time period T2+third time period T3+fourth time period T4. In this way, the end-to-end delay caused by the serial processing of the above four stages of algorithms is reduced, the image processing time is shortened to a certain extent, and the efficiency of algorithm processing is improved.
[0040] Figure 2B According to the embodiment of the present application, corresponding to Figure 1and Figure 2A , shows a schematic diagram of the principle of a parallel algorithm processing provided by an embodiment of the present application, which improves the algorithm processing efficiency compared to the serial algorithm processing in the prior art. Figure 2B As shown, A n-1 Indicates that NPU104 performs face selection on the N-1th frame image, B n-1 Indicates that NPU104 performs face alignment on the N-1th frame image, C n-1 NPU 104 extracts facial features from the N-1th frame image, D n-1 It indicates that NPU 104 performs face recognition on the N-1th frame image.
[0041] Similarly, A n Indicates that NPU104 performs face selection on the Nth frame image, B n Indicates that NPU104 performs face alignment on the Nth frame image, C n NPU 104 extracts facial features from the Nth frame image, D n It indicates that NPU 104 performs face recognition on the Nth frame image.
[0042] A n-1 "Indicates that ISP103 obtains the frame selection parameters of the previous frame image from NPU104 and performs face frame selection on the N-1th frame image. n "Indicates that ISP103 obtains the frame selection parameters of the previous frame image from NPU104 and performs face frame selection on the Nth frame image. n-1 "Indicates that ISP103 obtains the face alignment parameters of the previous frame image from NPU104 and performs face alignment on the N-1th frame image, B n-1 " indicates that ISP103 obtains the face alignment parameters of the previous frame image from NPU104 and performs face alignment on the N-1th frame image.
[0043] T1' represents the time it takes for ISP103 to obtain the selection parameters of the previous frame image from NPU104, and extract the face region of interest (face selection) for the current frame image (for example, the N-1th frame and the Nth frame). T2' represents the time it takes for ISP103 to obtain the face alignment parameters of the previous frame image from NPU104, and perform face alignment on the current frame image (for example, the N-1th frame and the Nth frame). T3 represents the time it takes for NPU104 to extract facial features of the current frame image. T4 represents the time it takes for NPU104 to perform face recognition on the Nth frame image.
[0044] In the prior art, the time taken by NPU104 to perform face detection, face alignment, face feature extraction and face recognition on the N-1 frame image is: T1+T2+T3+T4. In the embodiment of the present application, the time taken by ISP103 and NPU104 to perform face interest region extraction, face alignment, face feature extraction and face recognition on the N-1 frame image in parallel is: T1'+T2'+T3+T4. Since the frame selection parameters and face alignment parameters are calculated by NPU104 in advance and transmitted to ISP103, the time taken by ISP103 to calculate the frame selection parameters and face alignment parameters is saved. Therefore, T1' is less than T1, T2' is less than T2, and T1'+T2'+T3+T4 is less than T1+T2+T3+T4, which reduces the end-to-end delay caused by NPU104 performing face detection, face alignment, face feature extraction and face recognition on the N-1 frame image in sequence, shortens the image processing time to a certain extent, and improves the efficiency of algorithm processing.
[0045] Similarly, in the embodiment of the present application, ISP103 and NPU104 perform face region of interest extraction, face alignment, face feature extraction and face recognition on the N-1 frame image in parallel, and the time consumed is: T1'+T2'+T3+T4, which is less than T1+T2+T3+T4. In the prior art, the time consumed by NPU104 to perform face detection, face alignment, face feature extraction and face recognition on the N-1 frame image is: T1+T2+T3+T4, and T1'+T2'+T3+T4 is less than T1+T2+T3+T4, which reduces the end-to-end delay caused by NPU104 performing face detection, face alignment, face feature extraction and face recognition on the N-1 frame image in sequence, shortens the end-to-end image processing time to a certain extent, and improves the efficiency of algorithm processing.
[0046] Figure 2C FIG. 1 shows a schematic diagram of NPU 104 and ISP 103 processing N-2 frame image to N+1 frame image in parallel and asynchronously. Figure 2CAs shown, the entire system (NPU104 and ISP103) performs face recognition process on the N-2th frame image to the N+1th frame image. For each frame image, NPU104 and ISP103 perform face interest region extraction, face alignment, face feature extraction and face recognition on the N-2th frame image to the N-1th frame image in parallel and asynchronously. Similarly, NPU104 and ISP103 also perform parallel asynchronous processing on the N-1th frame image to the Nth frame image and the Nth frame image to the N+1th frame image. Specifically, NPU104 performs parallel asynchronous processing on the N-1th frame image to the Nth frame image and the Nth frame image to the N+1th frame image. The frame selection parameters and face alignment parameters are obtained by performing face detection and face alignment on the N-2 frame image to the N+1 frame image. The ISP always obtains the frame selection parameters and face alignment parameters of the previous frame image from the NPU104 as the frame selection parameters and face alignment parameters of the current frame. After the frame selection parameters and face alignment parameters of the previous frame image are used to perform target face frame selection and target face alignment on the current frame image, the target face alignment image is sent to the NPU104, and the NPU104 then performs face feature extraction and face recognition on the target face alignment image. In this way, the end-to-end delay caused by the NPU104 performing face detection, face alignment, face feature extraction and face recognition on each frame of the face image from the N-2 frame image to the N+1 frame image in sequence is reduced, the end-to-end image processing time is shortened to a certain extent, and the efficiency of the algorithm processing is improved.
[0047] The image recognition method of the present application is applicable to various image processing scenarios, for example, face recognition in video streams shot at railway station gates, user authentication through face images in videos by bank systems, user authentication through face images in videos by mobile phones, user authentication through face images in videos in quick payments, and user authentication through face images in videos by vehicle-mounted face systems.
[0048] The terms involved in the embodiments of the present application are explained below to facilitate understanding.
[0049] (1) Region of interest (ROI): In image processing, the area to be processed is selected from the processed image in the form of a box, circle, ellipse, irregular polygon, etc., which is called the ROI. In the embodiment of the present application, the target face ROI is the area containing the face selected from the processed image.
[0050] (2) Face Detection, also known as face selection, is to detect the location of the face in the image and extract the face region of interest. The input of the face detection algorithm is an image, and the output is the target face ROI, or called the face selection area, such as 1 target face ROI or multiple target face ROIs. Generally, the output target face ROI is a square facing upward, but some face detection technologies output an upward rectangle or a rectangle with a rotation direction. For example, in an embodiment of the present application, as shown in Figure 2, NPU104 detects a rectangular target face ROI from the N-1 frame image.
[0051] (3) Face alignment: A frontal face image is obtained by converting a side face or an image with an incorrect angle. Face alignment technology can improve the accuracy of face recognition. In the embodiment of the present application, a frontal face image can be obtained by converting a side face or an image with an incorrect angle.
[0052] (4) Face Feature Extraction is the process of converting a face image into a string of vector values of fixed length. This string of values is called "face feature" and has the ability to represent the characteristics of the face. For example, eye features, mouth features, eyebrow features, nose features, and ear features.
[0053] (5) Face Recognition is an algorithm that identifies the identity corresponding to the input face image. Its input is a face feature, which is compared one by one with the features corresponding to N identities registered in the database to find the "one" feature with the highest similarity to the input feature. This highest similarity value is compared with the preset threshold. If it is greater than the threshold, the identity corresponding to the feature is returned, otherwise it returns "not in the database".
[0054] The technical solutions and beneficial effects of the embodiments of the present application are further described below in conjunction with the accompanying drawings.
[0055] Figure 3 According to some embodiments of the present application, a schematic diagram of the structure of an electronic device 100 is shown. The electronic device 100 can perform image acquisition, face detection (including extracting target face ROI), face alignment (converting an image with an incorrect angle into an image with a correct angle), and then face feature extraction and face recognition. Figure 1As shown, the electronic device 100 includes: a camera 101, an image sensor 102, an ISP 103, an NPU 104, a central processing unit (CPU) 105, a display 106, a memory 107 and an interface module 108. Among them, the camera 101 is connected to the image sensor 102, the image sensor 702 is connected to the ISP 103, and the ISP 103, the NPU 104, the CPU 105, the display 106, the memory 107 and the interface module 108 are coupled via a bus 109. The ISP 103, the NPU 104, the CPU 105 and the memory 107 can be coupled via the bus 109 to form a system on chip (SOC) 1000. In other embodiments, the ISP 103, the NPU 104, the CPU 105 and the memory 107 can also be independent devices.
[0056] The camera 101 is used to collect light signals reflected by the scene and present them on the image sensor 102. The camera 101 can be a fixed-focus lens, a zoom lens, a fisheye lens, a panoramic lens, etc.
[0057] The image sensor 102 is used to convert the light signal reflected by the scene collected by the camera 101 into an electrical signal to generate raw image (RAW) data, for example, data in Bayer format. The image sensor can be a charge coupled device (CCD) or a complementary metal-oxide-semiconductor (CMOS) phototransistor.
[0058] ISP 103 is an application-specific integrated circuit (ASIC) for image data processing, and is used to further process the image data formed by image sensor 102 to obtain better image quality. In some embodiments, ISP 103 is also used to extract the face region of interest and align the face of the image data.
[0059] NPU 104 is an ASIC designed for deep learning. In some embodiments, it can quickly process input information by drawing on the structure of biological neural networks, such as the transmission mode between neurons in the human brain. Deep learning model reasoning can be performed through NPU, for example, facial feature extraction and face recognition can be performed using a neural network model.
[0060] The CPU 105 may include one or more processing units, for example, a processing module or processing circuit including a central processing unit (CPU), a graphics processing unit (GPU), a digital signal processor (DSP), a microprocessor (MCU), an AI (Artificial Intelligence) processor, or a programmable logic device (FPGA) (Field Programmable Gate Array), etc. Different processing units may be independent devices or integrated into one or more processors.
[0061] The display panel of the display 106 may be a liquid crystal display (LCD), an organic light-emitting diode (OLED), an active-matrix organic light-emitting diode or an active-matrix organic light-emitting diode (AMOLED), a flexible light-emitting diode (FLED), a Mini LED, a Micro LED, a Micro OLED, a quantum dot light-emitting diode (QLED), etc. The display 106 may be used to display image data processed by the ISP 103, and may also be used to display the operation results of the NPU 104, such as displaying a face image and a face recognition result.
[0062] The memory 107 can be used to store data, software programs and modules, and can be a volatile memory, such as a random-access memory (RAM) or a double data rate synchronous dynamic random access memory (DDR SDRAM).
[0063] The interface module 108 includes an external memory interface, a universal serial bus (USB) interface, etc. The external memory interface can be used to connect an external non-volatile memory (Non-Volatile Memory), such as a read-only memory (ROM), a flash memory (Flash Memory), a hard disk (HDD) or a solid-state drive (SSD); or a combination of the above types of memory, or a removable storage medium, such as a secure digital (SD) memory card, etc., to expand the storage capacity of the electronic device 100.
[0064] The bus 109 is used to couple the ISP 103, the NPU 104, the CPU 105, the display 106, the memory 107 and the interface module 108. The bus 109 may be an advanced high-performance bus (AHB) or other types of data buses.
[0065] Understandably, Figure 3 The structure of the electronic device 100 shown is only an example, and may be any electronic device 100 including an ISP and an NPU, and does not constitute a specific limitation on the electronic device 100. In other embodiments, the electronic device 100 may include more or fewer modules, and may also combine or split some modules, which is not limited in the embodiments of the present application.
[0066] It can be understood that the electronic device 100 may include but is not limited to: a laptop computer, a desktop computer, a tablet, a mobile phone, a server, a wearable device, a portable game console, a television, etc.
[0067] In one embodiment, the electronic device 100 can capture images through the camera 101, the image sensor 102, and the ISP 103. The specific scene / person forms an optical signal on the image sensor 102 through the camera 101. The image sensor 102 converts the optical signal into an electrical signal and transmits it to the ISP 103. The ISP 103 performs a series of processing on the original format image data, including facial region of interest extraction and facial alignment.
[0068] Corresponds to Figure 2A , Figure 4 According to an embodiment of the present application, an interactive process of using NPU 104 to perform facial feature extraction and face recognition after image data has been processed by ISP 103 for facial region of interest extraction and face alignment is shown, including the following steps.
[0069] Step 401: ISP 103 obtains the N-1th frame image in the video stream.
[0070] It is understandable that, in some embodiments, ISP 103 can obtain frame images in the video stream from image sensor 102. Image sensor 102 can also send frame images in the video stream to memory 107 for storage, and ISP 103 obtains frame images in the video stream from memory 107. In addition, it is understandable that the video stream can be a high frame rate video stream, and high frame rate is also called high frame rate format (High Frame Rate / HFR), which refers to shooting video at a frequency of 30 frames per second or more. For example, 30FPS, 48FPS, 60FPS. FPS is a definition in the field of images, which refers to the number of frames transmitted per second, that is, the number of frames of animation or video.
[0071] In a high frame rate face recognition system, the position and posture of the target face images in two adjacent frames are not much different. The target face ROI and face affine transformation of the previous frame can be used to act on the target face of the next frame. The following will specifically introduce how to apply the target face ROI and face affine transformation of the previous frame to the target face of the next frame.
[0072] Step 402 : NPU 104 reads the N−1th frame image from ISP 103 .
[0073] It can be understood that N is a natural number greater than 2. When N is 2, the NPU 104 reads the first frame of image from the ISP 103. When N is 3, the NPU 104 reads the second frame of image from the ISP 103. And so on.
[0074] Step 403: NPU 104 performs face detection on the N-1th frame image to obtain frame selection parameters of the target face ROI of the N-1th frame image (hereinafter referred to as the face frame selection parameters of the N-1th frame).
[0075] For example, as shown in FIG2 , NPU 104 performs face detection on the N-1 frame image and obtains frame selection parameters: the coordinates (x1, y1) of the upper left vertex a11 and the coordinates (x2, y2) of the lower right vertex a12. Although FIG2 only shows one face, the technical solution of the present application can be adapted to the situation of processing multiple faces in one image at the same time.
[0076] It can be understood that the common face detection network is basically a CNN convolutional neural network. Multiple convolution operators perform convolution operations on the entire image to form feature layers with different feature representations. The face detection network is composed of multiple convolution layers. Common typical detection networks include SSD (single-shot detection), YOLO (You only look once), MTCCN (Multi-task convolutional neural network), etc. The above network structure can be modified for the field of face detection.
[0077] In an embodiment of the present application, NPU104 outputs the selection parameters of the target face ROI after running the CNN face detection network, for example, in a given xy coordinate system, the upper left vertex coordinates (x1, y1) and the lower right vertex coordinates (x2, y2) of the target face ROI.
[0078] In this way, ISP103 can select a target face ROI of a preset size, based on the upper left vertex coordinates (x1, y1) and the lower right vertex coordinates (x2, y2) in a given xy coordinate system, which are surrounded by two straight lines passing through the upper left vertex coordinates (x1, y1) and parallel to the x and y directions, and two straight lines passing through the lower right vertex coordinates (x2, y2) and parallel to the x and y directions.
[0079] In addition, in other embodiments, NPU 104 directly determines the coordinates (x, y) of the four vertices of the ROI during the target face detection process.
[0080] Step 404: ISP 103 obtains the Nth frame image in the video stream.
[0081] It can be understood that in some other embodiments, step 404 may also occur at any time after step 405 and before step 406.
[0082] Step 405: NPU 104 sends the face selection parameters of the N-1th frame to ISP 103.
[0083] It can be understood that in the embodiment of the present application, NPU104 performs face detection on the N-1th frame image, obtains the frame selection parameters of the target face ROI of the N-1th frame image, and then sends the face frame selection parameters of the N-1th frame to ISP 103.
[0084] Step 406: ISP103 uses the face selection parameters of the N-1th frame to extract the face region of interest from the Nth frame image to obtain the target face ROI of the Nth frame image.
[0085] For example, as shown in FIG2 , the ISP determines the coordinates of the upper left vertex b21 and the lower right vertex b22 of the target face ROIB1 of the N-th frame image according to the face selection parameters of the N-1th frame: the coordinates (x1, y1) of the upper left vertex a11 and the coordinates (x2, y2) of the lower right vertex a12, thereby determining the target face ROIB1 of the N-th frame image. Specifically, ISP103 can determine the upper left vertex b21 and the lower right vertex b22 of the target face ROIB1 of the N-th frame image according to the face selection parameters of the N-1th frame in a given xy coordinate system: the coordinates (x1, y1) of the upper left vertex a11 and the coordinates (x2, y2) of the lower right vertex a12, and select a target face ROI of a preset size surrounded by two straight lines passing through the upper left vertex b21 and parallel to the x and y directions, and two straight lines passing through the lower right vertex b22 and parallel to the x and y directions.
[0086] In addition, in other embodiments, the ISP determines the four vertex coordinates (x, y) of the target face ROI of the Nth frame image based on the face selection parameters of the N-1th frame: the four vertex coordinates (x, y) of the ROI, and selects the target face ROI of a preset size based on the four vertex coordinates (x, y).
[0087] Step 407: NPU 104 performs face alignment on the face image of the target face ROI of the N-1th frame image to obtain the face alignment parameters of the target face ROI of the N-1th frame image (hereinafter referred to as the N-1th frame face alignment parameters).
[0088] It can be understood that NPU104 runs the facial key point model to obtain the coordinates of the facial key points. According to the facial key points output by the facial key point model and the provided face template, an affine transformation (warpAffine) is performed to solve the matrix to obtain the affine transformation matrix, which is the face alignment parameter. In this way, the face is adjusted to a predetermined size and shape to achieve face alignment, and the abnormal perspective is transformed to a normal perspective to achieve face alignment. Among them, affine transformation mainly includes translation transformation, rotation transformation, scaling transformation (also called scale transformation), tilt transformation (also called misalignment transformation, shear transformation, offset transformation), and flip transformation. The size of the affine transformation matrix is generally a 3*3 matrix, including translation, rotation and scaling coefficients.
[0089] The input of the facial feature key point model is the target face ROI, and the output is the coordinate sequence of the facial feature key points. The number of facial feature key points is a pre-set fixed value, which can be defined according to different semantics (common ones are 5 points, 68 points, 90 points, etc.).
[0090] Step 408: NPU 104 sends the face alignment parameters of the N-1th frame to ISP 103.
[0091] Step 409: ISP 103 performs face alignment on the face image in the target face ROI of the Nth frame image using the face alignment parameters of the N-1th frame image to obtain the Nth frame face aligned image.
[0092] For example, Figure 2A As shown, the face image in the target face ROI of the N-1th frame image is subjected to face alignment calculation to obtain the face alignment parameters of the face alignment image A2. ISP103 performs face alignment on the face image in the target face ROI of the Nth frame image according to the face alignment parameters of the N-1th frame image to obtain the Nth frame face alignment image B2.
[0093] It can be understood that, similar to the technical solution of step 406, ISP103 can adjust the face ROI image to a predetermined size and shape through an affine transformation operation to achieve face alignment. In some embodiments, ISP103 multiplies the coordinates of the face ROI image by the face alignment parameters (affine transformation matrix) of the N-1th frame image to obtain a face-aligned image.
[0094] Step 410: ISP 103 sends the Nth face alignment image to NPU 104.
[0095] Step 411: NPU 104 extracts facial features from the Nth frame of face alignment image to obtain facial feature data of the Nth frame.
[0096] It can be understood that in some embodiments, ISP 103 can extract facial features from the face alignment image in the Nth frame image by using a convolutional neural network model or the like.
[0097] Step 412: NPU 104 performs face recognition based on the facial feature data of the Nth frame.
[0098] ISP 103 may perform face recognition on the face features of the face alignment image extracted from the Nth frame image by using a convolutional neural network model or the like.
[0099] In summary, face detection obtains affine matrix parameters of ROI and face alignment, which are passed to ISP103. ISP103 directly outputs the image after ROI and face alignment to NPU104 for AI processing in the next frame, including face feature extraction and face recognition. This is equivalent to NPU104 mainly performing face feature extraction and face recognition in the end-to-end algorithm processing of the next frame, thereby reducing system latency.
[0100] If NPU104 supports simultaneous processing of multiple models, the processing of the current frame, face detection and face alignment, face feature extraction and face recognition can be distributed to two or more NPU104 inference tasks, which can maximize the utilization of resources and reduce system latency.
[0101] further, Figure 5 According to some embodiments of the present application, a schematic diagram of the structure of ISP 103 is shown. Figure 5 As shown, the ISP 103 includes a processor 1031 , an image transmission interface 1032 , a general peripheral device 1033 , an image recognition module 1034 , and a general function module 1035 .
[0102] Processor 1031 is used for logic control and scheduling in ISP 103 .
[0103] The image transmission interface 1032 is used for transmitting image data.
[0104] The general peripheral device 1033 includes but is not limited to: a bus and its controller for coupling the various modules of the ISP 103, a bus for coupling with other devices, such as an advanced high-performance bus (AHB), which enables the ISP to communicate with other devices (such as DSP, CPU, etc.) with high performance; a watchdog unit (WATCHDOG) for monitoring the working status of the ISP.
[0105] The ROI module and the affine transformation module 1034 are used to extract the ROI region according to the extracted ROI frame selection parameters and obtain an aligned image according to the provided affine transformation matrix.
[0106] The general function module 1035 is used to process the image input to the ISP 103, including but not limited to: black level compensation (BLC), bad pixel correction (BPC), lens shading correction (LSC), demosaic, denoise, automatic white balance (AWB), color correction, gamma correction, color gamut conversion, etc. When the image sensor passes the image data in RAW format to the image signal processor 1030, it is first processed by the function module. The general function module may include a RAW domain processing module, a YUV domain processing module, and an RGB domain processing module. Figure 6A schematic diagram of a process of processing image data by a general function module is shown, which includes the following steps.
[0107] The RAW domain processing module performs bad pixel correction, black level correction and automatic white balance on the image data.
[0108] The image data processed in the RAW domain is interpolated to obtain the image data in the RGB domain, and then the RGB domain processing module performs gamma correction and color correction on the image data in the RGB domain.
[0109] The image data processed in the RGB domain is converted into the YUV domain image data through the color domain conversion, and then the YUV domain processing module performs noise reduction, edge enhancement, brightness / contrast / chromaticity adjustment on the YUV domain image data.
[0110] It can be understood that after the image data is processed by the general function module, it can be output to the ROI module and the affine transformation module 1034 for image data filling. Among them, the color gamut of the image data output to the ROI module and the affine transformation module 1034 can be RGB, YUV, or grayscale image, which is not limited in the embodiment of the present application.
[0111] Understandably, Figure 7 The structure of ISP 103 shown is only an example. Those skilled in the art should understand that it may include more or fewer modules, and may combine or split some modules, which is not limited in the embodiments of the present application.
[0112] The embodiment of the present application also provides a system on chip, Figure 7 According to some embodiments of the present application, a schematic diagram of the structure of a system on a chip is shown, such as Figure 7 As shown, the system on chip 1000 includes an ISP 103, an NPU 104, a CPU 105, and a memory 107. The ISP 103, the NPU 104, the CPU 105, and the memory 107 are coupled via a bus 109. The ISP 103 can extract and align the face region of interest of the image, and output the face ROI and the corrected face image. The NPU 104 reads the image after the face region of interest extraction and face alignment from the ISP 103 to perform face feature extraction and face matching, thereby shortening the image processing time, reducing the end-to-end delay caused by the serial processing of the four-stage algorithm, and improving the real-time performance.
[0113] Understandably, Figure 7 In the embodiment, some components may be increased or decreased, for example, a bus control unit, an interrupt management unit, a coprocessor, etc. may be added, and some components may be split or combined, for example, ISP103 and NPU 104 may be integrated together, which is not limited in the embodiment of the present application.
[0114] The various embodiments of the mechanism disclosed in the present application can be implemented in hardware, software, firmware or a combination of these implementation methods. The embodiments of the present application can be implemented as a computer program or program code executed on a programmable system, which includes at least one processor, a storage system (including volatile and non-volatile memory and / or storage elements), at least one input device and at least one output device.
[0115] Program code can be applied to input instructions to perform the functions described in this application and generate output information. The output information can be applied to one or more output devices in a known manner. For the purposes of this application, a processing system includes any system having a processor such as, for example, a digital signal processor (DSP), a microcontroller, an application specific integrated circuit (ASIC), or a microprocessor.
[0116] Program code can be implemented with high-level programming language or object-oriented programming language to communicate with the processing system. When necessary, program code can also be implemented with assembly language or machine language. In fact, the mechanism described in this application is not limited to the scope of any specific programming language. In either case, the language can be a compiled language or an interpreted language.
[0117] In some cases, the disclosed embodiments may be implemented in hardware, firmware, software, or any combination thereof. The disclosed embodiments may also be implemented as instructions carried or stored on one or more temporary or non-temporary machine-readable (e.g., computer-readable) storage media, which may be read and executed by one or more processors. For example, instructions may be distributed over a network or through other computer-readable media. Therefore, machine-readable media may include any mechanism for storing or transmitting information in a machine (e.g., computer) readable form, including, but not limited to, floppy disks, optical disks, optical disks, read-only memories (CD-ROMs), magneto-optical disks, read-only memories (ROM), random access memories (RAM), erasable programmable read-only memories (EPROM), electrically erasable programmable read-only memories (EEPROM), magnetic cards or optical cards, flash memory, or tangible machine-readable memories for transmitting information (e.g., carrier waves, infrared signal digital signals, etc.) using the Internet in electrical, optical, acoustic, or other forms of propagation signals. Accordingly, machine-readable media include any type of machine-readable media suitable for storing or transmitting electronic instructions or information in a form readable by a machine (eg, a computer).
[0118] In the accompanying drawings, some structural or method features may be shown in a specific arrangement and / or order. However, it should be understood that such a specific arrangement and / or order may not be required. Instead, in some embodiments, these features may be arranged in a manner and / or order different from that shown in the illustrative drawings. In addition, the inclusion of structural or method features in a particular figure does not mean that such features are required in all embodiments, and in some embodiments, these features may not be included or may be combined with other features.
[0119] It should be noted that the units / modules mentioned in the various device embodiments of the present application are all logical units / modules. Physically, a logical unit / module can be a physical unit / module, or a part of a physical unit / module, or can be implemented as a combination of multiple physical units / modules. The physical implementation method of these logical units / modules themselves is not the most important. The combination of functions implemented by these logical units / modules is the key to solving the technical problems proposed by the present application. In addition, in order to highlight the innovative part of the present application, the above-mentioned device embodiments of the present application do not introduce units / modules that are not closely related to solving the technical problems proposed by the present application, which does not mean that there are no other units / modules in the above-mentioned device embodiments.
[0120] It should be noted that in the examples and description of this patent, the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of more restrictions, an element defined by the sentence "comprises one" does not exclude the existence of other identical elements in the process, method, article or device including the element.
[0121] Although the present application has been illustrated and described with reference to certain preferred embodiments thereof, it will be apparent to those skilled in the art that various changes in form and details may be made therein without departing from the spirit and scope of the present application.
Claims
1. An image recognition method, It is characterized in that The method is applied to an electronic device, the electronic device includes a first processor and a second processor, the first processor is a neural network processor, and the second processor is an image signal processor, the method includes: The electronic device performs face recognition on the frame image in the video to be recognized by using the first processor and the second processor, wherein the processing method of the electronic device after acquiring the Mth frame image is as follows: The first processor performs face detection and face alignment on the M-th frame image to obtain a first frame selection parameter and a first alignment parameter, and the second processor uses the second frame selection parameter and the second alignment parameter to extract the face region of interest and align the face on the M-th frame image; wherein the second frame selection parameter and the second alignment parameter are obtained by the first processor performing face detection and face alignment on the M-1-th frame image after the electronic device acquires the M-1-th frame image; The first processor performs facial feature extraction and feature matching on the Mth frame image based on the facial region of interest extraction result and face alignment result of the Mth frame image by the second processor to obtain a face recognition result of the Mth frame image.
2. The method according to claim 1, It is characterized in that The face region of interest extraction result includes a target face frame selection area, and the face alignment result includes a target face image adjusted to a preset angle.
3. The method according to claim 1, It is characterized in that The frame selection parameters include coordinate data of the edge of the target face frame selection area; the alignment parameters include affine transformation matrix data used to adjust the target face to a preset angle.
4. The method according to claim 2, It is characterized in that The target face frame selection area is a rectangle, and the frame selection parameters are coordinate data of two vertices on a diagonal line of the target face frame selection area or coordinate data of four vertices of the target face frame selection area.
5. The method according to claim 1, It is characterized in that The video to be identified is a video with a frame rate greater than a preset frame rate.
6. The method according to claim 5, It is characterized in that The preset frame rate is 30 frames per second.
7. A readable medium, It is characterized in that The readable medium stores instructions, which, when executed on an electronic device, enable the electronic device to execute the image recognition method according to any one of claims 1 to 6.
8. An electronic device, It is characterized in that include: a memory for storing instructions to be executed by one or more processors of the electronic device; as well as The first processor and the second processor are used to support the first processor or the second processor to execute the image recognition method according to any one of claims 1 to 6.
9. A system on a chip, It is characterized in that include: a memory for storing instructions to be executed by one or more processors of the system on chip; as well as The first processor and the second processor are used to support the first processor or the second processor to execute the image recognition method according to any one of claims 1 to 6.
