Face extraction method based on face template and sliding window
By introducing a combination of face templates and sliding windows in the face recognition technology, the problems of low computing efficiency and high resource occupation in the prior art are solved, and efficient and accurate face recognition is achieved, which is suitable for embedded devices.
Patent Information
- Application Number
- CN202411512411.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-03-28
- Estimated Expiration
- 2044-10-28
AI Technical Summary
The prior art has low computational efficiency, unstable recognition accuracy in facial recognition, and high resource utilization, making it difficult to achieve efficient facial recognition on embedded devices.
A face extraction method based on face templates and sliding windows is adopted to reduce unnecessary calculations through preliminary filtering, combine sliding window detection and template matching, and local sliding window detection is used to detect feature points, and multiple features (edge distribution, density) are considered to improve the robustness of the detection.
It significantly improves processing speed and recognition accuracy, reduces the use of memory and computing resources, making it more suitable for efficient face recognition on embedded devices.
Smart Images

Figure CN119723630A_ABST
Abstract
Description
Technical Field
[0001] The invention relates to the technical field of computer vision, and in particular to a face extraction method based on a face template and a sliding window. Background Art
[0002] In the field of face extraction, with the emergence of deep learning, a large number of excellent recognition technologies have emerged, bringing revolutionary progress and development to the field of computer vision. Its advantage lies in the fact that a large amount of data can be trained through neural networks to quickly and accurately perform face recognition.
[0003] However, methods such as deep learning and OpenCV require the use of a large number of network parameters and training models. This will consume a lot of hardware resources for embedded devices. In recent years, the development of embedded systems has shown a trend of lightweight, but smaller network scales and lightweight memory resources are often difficult to achieve excellent recognition performance. The prior art still has problems of low computing efficiency and unstable recognition accuracy in practical applications. At the same time, resource occupancy has not been fully optimized. Therefore, the present invention proposes a face extraction method based on face templates and sliding windows. By optimizing the feature detection algorithm and introducing the concept of face templates, it not only significantly improves the processing speed and recognition accuracy, but also greatly reduces the occupancy of memory and computing resources, making it more suitable for realizing efficient face recognition on embedded devices. Summary of the invention
[0004] In view of the deficiencies in the prior art, the present invention provides a face extraction method based on a face template and a sliding window.
[0005] The innovation of this method is that it can reduce unnecessary calculations through preliminary filtering on the basis of the current methods, combine sliding window detection with template matching through custom face templates, perform local sliding window detection through feature points, and consider multiple features (edge distribution, distribution density) at the same time, thereby improving the robustness of detection.
[0006] A face extraction method based on a face template and a sliding window comprises the following steps:
[0007] Step (1) Batch face image input.
[0008] Step (2) converts the image into a grayscale image and uses the Sobel operator to perform edge detection to obtain edge intensity features.
[0009] Step (3) preprocesses the grayscale image, including mean filtering, binary image conversion, dilation, and erosion.
[0010] Step (4) calculates an integral image for the processed image, which is used to count the sum of pixels in the area.
[0011] Step (5) assigns a threshold to the face template that satisfies the rule based on the face template.
[0012] Step (6) calculates the pixel density feature based on the integral image, and then marks the face candidate area in combination with the edge strength feature.
[0013] Step (7) uses a sliding window to detect the candidate face area, and combines it with the face template to find the specific face position and draw the face box.
[0014] Furthermore, the picture input in step (1) is a bmp format picture actually taken by the device required for detection.
[0015] Furthermore, the specific method of step (2) is as follows:
[0016] The feature grayscale image conversion adopts the weighted average method. The grayscale image weighting formula is as follows:
[0017] I(x,y)=0.299×R(x,y)+0.587×G(x,y)+0.114×B(x,y)
[0018] Where I(x,y) represents the grayscale value of the pixel (x,y), and an edge intensity matrix E(x,y) is obtained by processing with the Sobel operator. Since the image is stored in a one-dimensional array, the horizontal and vertical coordinates of the pixel can be calculated based on its index index:
[0019] x = index%w
[0020] Hum = index / w
[0021] Among them, w is the width of the image.
[0022] The details are as follows:
[0023] The horizontal gradient G x (x, y):
[0024] G x (x,y)=(I(x+1,y-1)+2×I(x+1,y)+I(x+1,y+1))
[0025] -(I(x-1,y-1)+2×I(x-1,y)+I(x-1,y+1))
[0026] The vertical gradient G y (x, y):
[0027] G y (x,y)=(I(x-1,y+1)+2×I(x,y+1)+I(x+1,y+1))
[0028] -(I(x-1,y-1)+2×I(x,y-1)+I(x+1,y-1))
[0029] Then the edge strength matrix is:
[0030]
[0031] Furthermore, the convolution kernel used in the mean filter conversion in step (3) is a 5×5 mean filter convolution kernel, and the feature binary image conversion adopts an adaptive threshold method.
[0032] Furthermore, the steps in step (4) are specifically:
[0033] The integral map IGmap is calculated based on the position of each pixel in the image and its specific value. The advantage of introducing the integral map is that it can calculate the sum of pixels in any rectangular area in constant time. First of all, the integral map is a picture of the same size as the original image IMAGE. Since the pixels of the bmp format picture are stored in a one-dimensional array in the structure, the order is from left to right and from top to bottom. The specific calculation process is as follows: index is the position index of the pixel, that is, the position of the pixel in the picture; the length and width of the picture are stored in im.h and im.w respectively, and the information of the picture pixels is stored in im.color, where color is four channels (blue, green, red, transparency):
[0034] IGmap.w = im.w
[0035] IGmap.h = im.h
[0036] For the first pixel:
[0037] IGmap.data[0]=(im.color[0].blue!=255||im.color[0].red!
[0038] =255||im.color[0].green! =255)? 1:0
[0039] For the first row of pixels:
[0040] IGmap.data[index]
[0041] =IGmap.data[index-1]+(im.color[index].blue=
[0042] =0)? 1:0
[0043] For the first column of pixels:
[0044] IGmap.data[index]
[0045] =IGmap.data[index-im.w]
[0046] +(im.color[index].blue==0)? 1:0
[0047] For other pixels:
[0048] IGmap.data[index]
[0049] =IGmap.data[index-1]
[0050] +IGmap.data[index-im.w]
[0051] -IGmap.data[index-im.w-1]
[0052] +(im.color[index].blue==0)? 1:0
[0053] The function of the integral map is to calculate the total number of pixels in a certain area. Since the bmp format image is stored in a one-dimensional array, only two points (leftTop, rightBottom) are needed to frame a square area. The specific calculation is as follows:
[0054] x0 = leftTop%IGmap.w
[0055] y0=leftTop / IGmap.w
[0056] x1=rightBottom%IGmap.w
[0057] y1 = rightBottom / IGmap.w
[0058] The integral value of this area is calculated as follows:
[0059] Count=IGmap.data[y1*IGmap.w+x1]
[0060] -((y0>0)?IGmap.data[(y0-1)*IGmap.w
[0061] +x1]:0)-((x0
[0062] >0)? IGmap.data[y1*IGmap.w+(x0-1)]:0)
[0063] +(x0>0&&y0
[0064] >0)? IGmap.data[(y0-1)*IGmap.w+(x0
[0065] -1)]:0
[0066] Furthermore, the steps in step (5) are specifically:
[0067] The real photo taken by the equipment required for detection is used as a template. The face template is defined as a square area. The required standard face part is cut from the real photo to obtain the face template. After grayscale and preprocessing, the face template is divided into 25 5*5 sub-areas and numbered w1~W according to the row priority. 25 , use the integral image to calculate the sum of the pixels in the 25 sub-areas and assign it to w1~w 25 .w all It is the sum of the 25 sub-regions of the face template. Based on the distribution of pixels of multiple standard faces after facial preprocessing, the threshold value that satisfies the rules of the face template is assigned as follows:
[0068]
[0069] w3 <BLANK (7)
[0070] Among them, EYES_MIN and EYES_MAX represent the lower and upper limits of the ratio of the pixels of the two eyes, EYES_OF_FACE_MIN and EYES_OF_FACE_MAX represent the lower and upper limits of the ratio of the left or right eye to the overall pixel points of the face, NOSE_OF_FACE_MIN and NOSE_OF_FACE_MAX represent the lower and upper limits of the ratio of the nose to the overall pixel points of the face, MOUSE_OF_FACE_MIN and MOUSE_OF_FACE_MAX represent the lower and upper limits of the ratio of the mouth to the overall pixel points of the face. CHEEK represents the lower and upper limits of the ratio of the cheeks to the overall pixel points of the face. BLANK represents the number of pixels distributed in the blank area of the face.
[0071] Furthermore, the steps in step (6) are specifically:
[0072] For the preprocessed images, the pixel density features are calculated based on the integral image, and then the face candidate areas are marked based on the multi-dimensional judgment of the edge intensity features, and the areas without clear edge features are excluded.
[0073] Define the side length n of the preliminary sliding window. The preliminary sliding window starts from the upper left corner of the image and slides with a step length d until the entire image area is covered. The sliding window is defined as follows during the sliding process: the sliding window consists of a starting point (x, y) and a window side length n. The starting point is set to the upper left corner of the window. This is because the pixels are stored in a structure image with row priority during the storage stage. Therefore, by defining the starting point and side length, the coordinates of the pixels contained in the window can be calculated. During each sliding scan, the edge strength features and pixel density features of the preliminary sliding window area are calculated and compared with the set threshold T. E 、T μ , Compare. For the area that meets any set feature threshold, mark the face candidate area: store the starting point and side length of the area into the candidate face position array X. The calculation operation of the edge strength feature and pixel density feature of the specific area is as follows:
[0074] First, the region is marked based on the edge strength feature, and the conditions are as follows:
[0075] The coordinates of the upper left corner of the region are (x a ,y a ), the side length is n, then the coordinates of the lower right corner are (x a +n-1,y a +n-1). Calculate the sum of edge strengths in the region:
[0076]
[0077] Then compare the sum of edge strengths with the threshold: if S is greater than the preset threshold T E , then mark the area as a face candidate area.
[0078] At the same time, based on the integral image, the pixel density feature is calculated to perform density detection: the facial features (eyes, nose, etc.) are detected in the image, that is, the areas with high pixel density, and they are also marked as possible candidate face areas. The facial features pixel density detection is as follows:
[0079] Compute the average of the pixel values in a region:
[0080]
[0081] Calculate the variance of the pixel values (the smaller the variance value, the higher the pixel density within the window):
[0082]
[0083] If the mean value of pixels in the current area exceeds the mean threshold T μ, it is considered that the current region contains important facial features (eyes, nose, mouth, etc.), and the region is marked as a candidate face region.
[0084] If the variance of the pixels in the current area is lower than the variance threshold If the pixel density is high, it is considered that the current area contains important facial features (eyes, nose, mouth, etc.), and the area is marked as a candidate face area.
[0085] In summary, the work of the preliminary sliding window is to find the candidate face position by calculating the edge strength features and pixel density features contained in the window area.
[0086] Furthermore, the steps in step (7) are specifically:
[0087] The side length of the new sliding window is defined as C, which is specifically expressed as follows:
[0088] C=α*n
[0089] Where n is the length of the side of the preliminary sliding window. α is the scaling factor for scaling the side of the preliminary sliding window, which is usually set between 0.45 and 1.
[0090] The step size of the new sliding window is set to Δc, and its specific value is usually an integer between 1 and 5.
[0091] When searching, the new sliding window directly searches each face candidate region in order. First, a new sliding window is generated for each face candidate region (the region information recorded when the initial sliding window is scanned), that is, a new sliding window that is smaller than the initial sliding window is used to perform a more detailed scan in the face candidate region.
[0092] Specifically, the side length of the new sliding window is set to C, and within the face candidate area (a square area with a side length of n framed by the initial sliding window), the step size is set to Δc, and scanning is performed in row priority order.
[0093] Each time a scan is performed, the detection area selected by the new sliding window is matched with the preset face template, and the calculation is performed based on the given 7 face templates satisfying the rules: Similarly, the detection area is divided into 25 equal blocks. If any one of the rules (1) to (5) is satisfied, it is considered that the detection area may contain a face, and the confidence of the detection area is calculated: each time a rule is satisfied, the confidence is increased in proportion to the weight corresponding to each rule, and the position coordinates of the detection area are stored. Finally, the confidence ω corresponding to each detection area Y of the current face candidate area is obtained. Y , and the corresponding detection area position coordinates.
[0094] After the new sliding window detection in each face candidate area is traversed once in row priority order, the side length of the new sliding window needs to be reduced by 10 pixels and traversed again until the side length of the new sliding window reaches the set minimum side length C min .
[0095] C min =180
[0096] While reducing the side length of the new sliding window, set its corresponding step size Δc:
[0097]
[0098] After all candidate face regions are scanned, only the position coordinates of the top five detection regions with the highest confidence are extracted and identified as the five final selected regions.
[0099] For the detected final selection area, if there are multiple detection areas in the final selection area that are adjacent to or repeated with the detection area corresponding to the maximum confidence, they will be merged to avoid missing part of the face.
[0100] The two detection windows A and B and their repetition rate O are defined as follows (the width and height of the two rectangular areas A and B are set to be W respectively A , H A , W B , H B ):
[0101] W A∩B =max(0,min(x A +W A ,x B +W B )
[0102] -max(x A ,x B ))
[0103] H A∩B =max(0,min(y A +H A ,y B +H B )
[0104] -max(y A ,y B ))
[0105] Area(A∩B)=W A∩B *H A∩B
[0106] Area(A∪B)=W A *H A +WB *H B -Area(A∩B)
[0107]
[0108] If the final overlap rate O is greater than 0.5, it is considered to be repeated and merged. The merged area is selected. If not, the detection area with the maximum confidence is directly selected.
[0109] The final selected area is marked on the original image and the detection data is output.
[0110] The beneficial effects of the present invention are as follows:
[0111] The present invention introduces a combination of face template and adaptive sliding window detection technology, and uses the matching degree between the detection area and the face template to enhance the accuracy of detection. The present invention adopts a local sliding window based on feature points to avoid the detection of invalid areas and invalid features, predicts the approximate position of the face by detecting edge strength features and pixel density features, and searches for the specific position of the face in combination with the face template. The present invention integrates a sliding window with multiple features, considers the information of face edges and facial features during the detection process, and conducts a detailed search around the area that meets multiple features to enhance robustness. In the process of sliding window traversal search, the present invention intelligently skips some areas according to the results of the last traversal search, avoids redundant calculations and invalid areas, and saves computing resources. The present invention merges multiple windows with high detection repetition, can accurately retain all facial information, and avoid incomplete facial retention. In summary, the present invention can process images in batches. A rich preprocessing method is adopted to extract effective facial features of the picture. The present invention does not need to introduce a neural network, and uses a lightweight sliding window search to extract faces from preprocessed pictures. BRIEF DESCRIPTION OF THE DRAWINGS
[0112] Figure 1 Flowchart of execution of the method according to an embodiment of the present invention. DETAILED DESCRIPTION
[0113] The specific embodiments of the present invention will be further described below in conjunction with the accompanying drawings.
[0114] The present invention mainly proposes a face extraction method based on face template and sliding window. Figure 1 It is the specific implementation step of the present invention:
[0115] Step (1) Input a face image image. A bmp format image with a size of 1280*960, read its information, and retain the length h, width w, and color four-channel data (stored in the color structure and stored in row priority).
[0116] Step (2) converts the image image into a grayscale image using the weighted average method, and uses the Sobel operator to perform edge detection and calculate the edge intensity matrix E (the size of the E matrix is the same as the original image size, which is 1280*960).
[0117] Step (3) preprocesses the grayscale image.
[0118] First, a mean filter operation is performed. A mean filter convolution kernel KERNELS
[25] is introduced. This is a 5*5 convolution kernel composed of all 1s. It is convolved with the image image to remove noise. The second step is to use the adaptive threshold method to binarize the image and retain the key edge information. Then, through a dilation and an erosion operation, the key feature information of the image is highlighted. The preprocessing operation only operates on the RGB channels of the image.
[0119] Step (4) calculates the integral map of the processed image. The size of the integral map is the same as the original image, and the information stored inside it is related to the regional pixel points. The input is a preprocessed binary image image, and the output integral map structure IGmap, where the structure contains the image's h, w, the pixel points corresponding to each pixel point, and the information array data. The value at each pixel point (x, y) has the following meanings:
[0120] x = index%w
[0121] y=index / w
[0122]
[0123] Where index represents the one-dimensional index of the pixel in IGmap, n (x,y) It represents the value of the pixel on the integral image, and B(x, y) represents the value of the pixel on the binary image (in the binary image, black pixels are 1, otherwise they are 0)
[0124] Step (5) introduces a face template. In this embodiment, a real photo taken by the device required for detection is introduced as a template. The required standard face part is intercepted and divided into 25 5*5 blocks and numbered. The threshold value of the face template meeting the rule is assigned based on the distribution of pixel points after facial preprocessing of multiple standard faces, as follows:
[0125]
[0126]
[0127] w3<3
[0128] Step (6) For a 1280*960 image, define the sliding window with a side length of n=400 pixels, start the sliding window from the upper left corner of the image, and slide with a step length d of 20. During each sliding scan, calculate the edge intensity feature and pixel density feature of the preliminary sliding window area and compare them with the set threshold T E , T μ , Compare until the entire image area is covered. Mark the face candidate area for the area that meets any set feature threshold.
[0129] Set the edge strength threshold T E The threshold is 810000, which is used to compare the edge intensity matrix E(x,y) calculated using the sobel operator in the grayscale image stage:
[0130]
[0131] If the window slides and the threshold is met (i.e. S>T E ), then the current window starting point (x, y) and the side length n are recorded in the candidate face position array X.
[0132] Set the mean threshold T μ is 50, which is used to compare the mean value μ of the pixels in the current sliding window:
[0133]
[0134] If the mean value of the pixels in the current window exceeds the threshold, it is considered that the current window contains important facial features (eyes, nose, mouth, etc.), and the starting point (x, y) and side length n of the current window are recorded in the candidate facial position array X.
[0135] Setting the variance threshold is 500. This threshold is used to compare the pixel variance σ in the current sliding window. 2 :
[0136]
[0137] If the variance of the pixels in the current window is lower than the threshold, indicating that the pixel density is high, it is considered that the current window contains important facial features (eyes, nose, mouth, etc.), and the starting point (x, y) and side length n of the current window are recorded in the candidate facial position array X.
[0138] In step (7), the new sliding window is used to further screen each candidate face area, and combined with the face template to find the specific face position. The method of drawing the face box is as follows:
[0139] The new sliding window will scan each face candidate area in detail. Set the side length of the new sliding window to C. Under the control of the scale factor α, the side length of the new sliding window will start from 400 pixels. After each traversal, it will be reduced by 10 pixels until the side length is reduced to 180 pixels. And the step length will also be reduced from 5 to 1 in proportion to the side length of the new sliding window. Then after each face candidate area is scanned, the next face candidate area will be scanned until the end.
[0140] When the new sliding window is scanning, it will compare the selected detection area with the face template satisfaction rule with the added threshold: Now divide the detection area equally into 25 blocks, and then calculate whether it meets the first five rules of the face template satisfaction. If it does, the position coordinates of the detection area are recorded, and the confidence is calculated based on all the face template satisfaction rules.
[0141] The confidence calculation process requires the use of seven set rules and the confidence calculation formula:
[0142]
[0143] w3<3 (7)
[0144]
[0145] After the scanning is completed, the coordinates of the top five detection areas with the highest confidence are selected as the five final selected areas. The final face area is selected by appropriate merging according to the merging rules. The final face area needs to contain two coordinates (x leftTop ,y leftTop )、(x rightBottom ,y rightBottom ), then the range of faces required for the identification experiment is:
[0146] {(x,y)|x leftTop ≤x≤x rightBottom ,y leftTop ≤y≤y rightBottom}
[0147] All the pixels represented by the above set are the required face parts.
[0148] Finally, the position of the final face area is marked on the original image and the detection data is output.
[0149] In summary, the method of the present invention has high precision and high speed. In practical applications, it can realize batch automatic detection and can also perform adaptive parameter adjustment according to different embedded devices. The final face extraction image has pixel-level accuracy and meets actual needs.
[0150] The above contents are further detailed descriptions of the present invention in combination with specific / preferred embodiments, and it cannot be determined that the specific implementation of the present invention is limited to these descriptions. For ordinary technicians in the technical field to which the present invention belongs, they can also make several substitutions or modifications to these described embodiments without departing from the concept of the present invention, and these substitutions or modifications should be regarded as belonging to the protection scope of the present invention.
[0151] Parts of the present invention that are not described in detail belong to the well-known technologies of those skilled in the art.
Claims
1. A face extraction method based on face template and sliding window, characterized in that: The following steps are involved: Step (1) Batch face image input; Step (2) convert the image into a grayscale image and use the Sobel operator to perform edge detection to obtain edge intensity features; Step (3) preprocessing the grayscale image, including mean filtering, binary image conversion, expansion, and corrosion; Step (4) calculating an integral image of the processed image to count the sum of pixels in the area; Step (5) assigning a threshold value of the face template satisfying the rule based on the face template; Step (6) calculating pixel density features based on the integral image, and then marking the face candidate area in combination with the edge strength features; Step (7) uses a sliding window to detect the candidate face area, and combines it with the face template to find the specific face position and draw the face box.
2. The face extraction method based on face template and sliding window according to claim 1, characterized in that: The image input in step (1) is a bmp format image actually taken by the device required for detection.
3. The face extraction method based on face template and sliding window according to claim 1, characterized in that: The specific method of step (2) is as follows: The feature grayscale image conversion adopts the weighted average method; the grayscale image weighted formula is as follows: I(x,y)=0.299×R(x,y)+0.587×G(x,y)+0.114×B(x,y)where I(x,y) represents the grayscale value of the pixel (x,y), and an edge intensity matrix E(x,y) is obtained by processing with the Sobel operator. Since the image is stored in a one-dimensional array, the horizontal and vertical coordinates of the pixel can be calculated according to its index index: x=index%w y=index / w Where w is the width of the image; The details are as follows: The horizontal gradient G x (x,y): G x (x,y)=(I(x+1,y-1)+2×I(x+1,y)+I(x+1,y+1))-(I(x-1,y-1)+2×I(x-1,y)+I(x-1,y+1)) The vertical gradient G y (x,y): G y (x,y)=(I(x-1,y+1)+2×I(x,y+1)+I(x+1,y+1))-(I(x-1,y-1)+2×I(x,y-1)+I(x+1,y-1)) Then the edge strength matrix is:
4. The face extraction method based on face template and sliding window according to claim 1, characterized in that: The convolution kernel used in the mean filter conversion in step (3) is a 5×5 mean filter convolution kernel, and the feature binary image conversion adopts the adaptive threshold method.
5. The face extraction method based on face template and sliding window according to claim 1, characterized in that: The steps in step (4) are specifically: The integral map IGmap is calculated according to the position of each pixel in the image and its specific value. First, the integral map is an image of the same size as the original image IMAGE. Since the pixels of the bmp format image are stored in a one-dimensional array in the structure, the order is from left to right and from top to bottom. The specific calculation process is as follows: index is the position index of the pixel, that is, the position of the pixel in the image. The length and width of the image are stored in im.h and im.w respectively, and the information of the image pixels is stored in im.color, where color is four channels: blue, green, red, and transparency: IGmap.w = im.w IGmap.h = im.h For the first pixel: IGmap.data[0]=(im.color[0].blue!=255||im.color[0].red! =255||im.color[0].green! =255)? 1:0 For the first row of pixels: IGmap.data[index] =IGmap.data[index-1]+(im.color[index].blue==0)? 1:0 For the first column of pixels: IGmap.data[index] =IGmap.data[index-im.w]+(im.color[index].blue==0)? 1:0 For other pixels: IGmap.data[index] =IGmap.data[index-1]+IGmap.data[index-im.w]-IGmap.data[index]-im.w-1]+(im.color[index].blue==0)? 1:0 The function of the integral map is to calculate the total number of pixels in a certain area. Since the bmp format image is stored in a one-dimensional array, only two points, leftTop and rightBottom, are needed to frame a square area. The specific calculation is as follows: x0 = leftTop%IGmap.w y0=leftTop / IGmap.w x1=rightBottom%IGmap.w y1 = rightBottom / IGmap.w The integral value of this area is calculated as follows: Count=IGmap.data[y1*IGmap.w+x1]-((y0>0)?IGmap.data[(y0-1)*IGmap.w+x1]:0)-(x0>0)? IGmap.data[y1*IGmap.w+(x0-1)]:0)+(x0>0&&y0>0)? IGmap.data[(y0-1)*IGmap.w+(x0-1)]:
0.
6. The face extraction method based on face template and sliding window according to claim 1, characterized in that: The steps in step (5) are specifically: The real photo taken by the equipment required for detection is used as a template. The face template is set as a square area. The required standard face part is cut out from the real photo to obtain the face template; the face template is grayed and pre-processed, and then divided into 25 5*5 sub-areas and numbered w1~w according to the row priority. 25 , use the integral image to calculate the sum of the pixels in the 25 sub-areas and assign it to w1~w 25 ;w all It is the sum of the 25 sub-regions of the face template. Based on the distribution of pixels of multiple standard faces after facial preprocessing, the threshold value that satisfies the rules of the face template is assigned as follows: w3 <BLANK (7) Among them, EYES_MIN and EYES_MAX represent the lower and upper limits of the ratio of the pixels of the two eyes, EYES_OF_FACE_MIN and EYES_OF_FACE_MAX represent the lower and upper limits of the ratio of the left eye or right eye to the overall pixel points of the face, NOSE_OF_FACE_MIN and NOSE_OF_FACE_MAX represent the lower and upper limits of the ratio of the nose to the overall pixel points of the face, MOUSE_OF_FACE_MIN and MOUSE_OF_FACE_MAX represent the lower and upper limits of the ratio of the mouth to the overall pixel points of the face; CHEEK represents the lower and upper limits of the ratio of the cheeks on both sides to the overall pixel points of the face; BLANK represents the number of pixels distributed in the blank space of the face.
7. A face extraction method based on face template and sliding window according to claim 1 or 5, characterized in that: The steps in step (6) are specifically: For the preprocessed images, the pixel density features are calculated based on the integral image, and then the face candidate areas are marked based on the multi-dimensional judgment of the edge intensity features, excluding the areas without clear edge features; Define the side length n of the preliminary sliding window. The preliminary sliding window starts from the upper left corner of the image and slides with a step length d until it covers the entire image area. The sliding window is defined as follows during the sliding process: the sliding window consists of a starting point (x, y) and a window side length n. The starting point is set to the upper left corner of the window. During each sliding scan, the edge intensity feature and pixel density feature of the preliminary sliding window area are calculated and compared with the set threshold T. E , T μ , Compare; mark the face candidate area for the area that meets any set feature threshold: store the starting point and side length of the area into the candidate face position array X; the edge strength feature and pixel density feature calculation operation of the specific area are as follows: First, the region is marked based on the edge strength feature, and the conditions are as follows: The coordinates of the upper left corner of the region are (x a ,y a ), the side length is n, then the coordinates of the lower right corner are (x a +n-1,y a +n-1); calculate the sum of edge strength within the region: Then compare the sum of edge strengths with the threshold: if S is greater than the preset threshold T E , then mark the area as a face candidate area; At the same time, the pixel density feature is calculated based on the integral image to perform density detection: the facial features, that is, the areas with high pixel density, are detected in the image and marked as possible face candidate areas; the facial features pixel density detection is as follows: Compute the average of the pixel values in a region: Calculate the variance of the pixel values (the smaller the variance value, the higher the pixel density within the window): If the mean value of pixels in the current area exceeds the mean threshold T μ , then the current region is considered to contain important facial features and is marked as a candidate face region; If the variance of the pixels in the current area is lower than the variance threshold If the pixel density is high, it is considered that the current area contains important facial features and is marked as a candidate face area.
8. The face extraction method based on face template and sliding window according to claim 7, characterized in that: The steps in step (7) are specifically: The side length of the new sliding window is defined as C, which is specifically expressed as follows: C=α*n Where n is the length of the initial sliding window; α is the scaling factor for scaling the length of the initial sliding window, which is usually set between 0.45 and 1; The step size of the new sliding window is set to Δc, and its specific value is usually an integer between 1 and 5; When searching, the new sliding window directly searches each face candidate region in order. First, a new sliding window is generated for each face candidate region, that is, a new sliding window that is smaller than the initial sliding window is used to perform a more detailed scan in the face candidate region. Specifically, the side length of the new sliding window is set to C, and within the face candidate area, the step size is set to Δc, and scanning is performed in row priority order; Each time a scan is performed, the detection area selected by the new sliding window is matched with the preset face template, and the calculation is performed based on the given 7 face templates satisfying the rules: Similarly, the detection area is divided into 25 equal blocks. If any one of the rules (1) to (5) is satisfied, it is considered that the detection area may contain a face, and the confidence of the detection area is calculated: each time a rule is satisfied, the confidence is increased in proportion to the weight corresponding to each rule, and the position coordinates of the detection area are stored; finally, the confidence ω corresponding to each detection area Y in the current face candidate area is obtained. Y , and the corresponding detection area position coordinates; After the new sliding window detection in each face candidate area is traversed once in row priority order, the side length of the new sliding window needs to be reduced by 10 pixels and traversed again until the side length of the new sliding window reaches the set minimum side length C min ; C min =180 While reducing the side length of the new sliding window, set its corresponding step size Δc: After all candidate face regions are scanned, only the coordinates of the top five detection regions with the highest confidence are extracted and identified as the five final selection regions; For the detected final selected area, if there are multiple detection areas in the final selected area that are adjacent to or repeated with the detection area corresponding to the maximum confidence, they will be merged to avoid missing some faces; The two detection windows A and B and their repetition rate O are defined as follows. The width and height of the two rectangular areas A and B are set to be W respectively. A , H A , W B , H B : W A∩B =max(0,min(x A +W A ,x B +W B )-max(x A ,x B )) H A∩B =max(0,min(y A +H A ,y B +H B )-max(y A ,y B )) Area(A∩B)=W A∩B *H A∩B Area(A∪B)=W A *H A +W B *H B -Area(A∩B) If the final overlap rate O is greater than 0.5, it is considered to be repeated and merged; and the merged area is selected; if not, the detection area with the maximum confidence is directly selected; The final selected area is marked on the original image and the detection data is output.
Citation Information
Patent Citations
Quick eye locating method based on integral projection and edge detection
CN103218605A
Improved LDP-based human face identification method
CN106778529A
Face area recognition method and device and storage medium
CN111161281A
Rapid identification photo glasses detection method based on image processing
CN114463814A
METHOD AND DEVICE OF DETECTING DROWSINESS USING INFRARED AND DEPTH IMAGE, and Non-Transitory COMPUTER READABLE RECORDING MEDIUM
KR102074519B1