A face extraction method based on face template and sliding window
By combining face templates and sliding window methods with feature point detection, the problems of low efficiency and unstable accuracy of face recognition on embedded devices are solved, achieving efficient face recognition with low resource consumption.
Patent Information
- Application Number
- CN202411512411.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-28
- Publication Date
- 2025-12-12
- Estimated Expiration
- 2044-10-28
AI Technical Summary
Existing technologies for face recognition on embedded devices suffer from low computational efficiency, unstable recognition accuracy, and insufficient resource utilization, making it difficult to achieve efficient face recognition on lightweight devices.
We employ a face template and sliding window-based approach. This approach reduces computation through initial filtering and combines sliding window detection with template matching. By utilizing feature points for local sliding window detection, we improve the robustness of the detection.
It significantly improves processing speed and recognition accuracy, reduces memory and computing resource consumption, and is suitable for implementing efficient face recognition on embedded devices.
Smart Images

Figure CN119723630B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application belongs to the technical field of computer vision, and particularly relates to a face extraction method based on a face template and a sliding window. BACKGROUND
[0002] In the field of face extraction, with the advent of deep learning, a large number of excellent recognition technologies have emerged, bringing revolutionary progress and development to the field of computer vision. The advantage lies in that a large amount of data can be quickly and accurately recognized through the training of a neural network.
[0003] However, deep learning, OpenCV and other methods 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 devices has shown a trend of lightness, but smaller network size and light memory resources often have difficulty achieving excellent recognition performance. The existing technology still has problems of low calculation efficiency and unstable recognition accuracy in actual application, and the resource occupation is not fully optimized. Therefore, the present application provides a face extraction method based on a face template and a sliding window, which significantly improves the processing speed and recognition accuracy by optimizing the feature detection algorithm and introducing the concept of face template, and greatly reduces the occupation of memory and calculation resources, making it more suitable for efficient face recognition on embedded devices. SUMMARY
[0004] In view of the deficiencies in the prior art, the present application provides a face extraction method based on a face template and a sliding window.
[0005] The innovation of the method lies in that it can reduce unnecessary calculations based on the existing methods, combine sliding window detection and template matching by customizing a face template, perform local sliding window detection through feature points, and consider multiple features (edge distribution, distribution density) to improve the robustness of detection.
[0006] A face extraction method based on a face template and a sliding window, comprising the following steps:
[0007] Step (1) batch face picture input.
[0008] Step (2) convert the picture to a gray image and perform edge detection using a sobel operator to obtain edge intensity features.
[0009] Step (3) pre-process the gray image, including mean filtering, binary image conversion, dilation and erosion.
[0010] Step (4) calculate the integral image of the processed picture to count the pixel points in the region.
[0011] Step (5) assigns a threshold value to the face template that satisfies the rules based on the face template.
[0012] Step (6) calculates the pixel density feature based on the integral image, and then combines the edge intensity feature to mark the face candidate region.
[0013] Step (7) uses a sliding window to detect the face candidate region, and combines it with the face template to find the specific face position and draw a face box.
[0014] Further, the input picture of step (1) uses a bmp format picture actually taken by the detection device.
[0015] Further, step (2) has the following specific method:
[0016] The feature grayscale conversion uses a weighted average method. The grayscale 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 point (x,y), and an edge intensity matrix E(x,y) is obtained by processing with a sobel operator. Since the picture is stored in a one-dimensional array, the horizontal and vertical coordinates of the pixel point can be calculated according to the index:
[0019] x = index % w
[0020] y = index / w
[0021] Where w is the width of the picture.
[0022] Specifically:
[0023] 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] 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] The edge intensity matrix is then:
[0030]
[0031] Furthermore, the convolution kernel used in step (3) for mean filtering transformation is a 5×5 mean filtering convolution kernel, and the feature binary map transformation adopts an adaptive thresholding method.
[0032] Furthermore, the specific steps in step (4) are as follows:
[0033] The integral image (IGmap) is calculated based on the position and value of each pixel in the image. The advantage of using an integral image is that it can calculate the sum of pixels within any rectangular region in constant time. First, the integral image is an image of roughly the same size as the original image (IMAGE). Since the pixels of a BMP format image are stored in a one-dimensional array within the structure, in left-to-right and top-to-bottom order, the specific calculation process is as follows: `index` represents the pixel's position index within the image; the image's length and width are stored in `im.h` and `im.w` respectively, and the image pixel information is stored in `im.color`, where `color` is a four-channel image (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 purpose of an integral image is to calculate the total number of pixels in a given region. Since BMP images are stored as a one-dimensional array, only two points (leftTop, rightBottom) are needed to define a rectangular 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 for this region 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] Further, the steps in step (5) are specifically:
[0067] A real photo taken by the detection required device is used as a template, and the face template is defined as a square region. The standard face part required is obtained by cutting the real photo, and the face template is equally divided into 25 sub-regions of 5*5 after being grayscaled and pretreated, and numbered as w1-w 25 25 in row priority. The pixel point sum of the 25 sub-regions is calculated by using the integral graph, and the pixel point sum is assigned to w1-w 25 25. w all is the sum of the 25 sub-regions of the face template; based on the pixel point distribution of the multiple standard face faces after pretreatment, the threshold value of the face template satisfying the rule is assigned, and the specific assignment is as follows:
[0068]
[0069] w3<BLANK (7)
[0070] wherein EYES_MIN and EYES_MAX represent the lower limit and upper limit of the ratio of the pixel points of the two eyes, EYES_OF_FACE_MIN and EYES_OF_FACE_MAX represent the lower limit and upper limit of the ratio of the pixel points of the left eye or the right eye to the whole face, NOSE_OF_FACE_MIN and NOSE_OF_FACE_MAX represent the lower limit and upper limit of the ratio of the pixel points of the nose to the whole face, MOUSE_OF_FACE_MIN and MOUSE_OF_FACE_MAX represent the lower limit and upper limit of the ratio of the pixel points of the mouth to the whole face, CHEEK represents the lower limit and upper limit of the ratio of the pixel points of the two cheeks to the whole face, and BLANK represents the number of pixel point distribution of the blank part of the face.
[0071] Further, the steps in step (6) are specifically:
[0072] For the pretreated picture, the pixel density feature is calculated based on the integral graph, and then the multi-dimensional judgment of the edge intensity feature is combined to mark the face candidate region and exclude the region without clear edge feature.
[0073] The edge length n of the primary sliding window is defined, and the primary sliding window starts from the top-left corner of the picture and slides with a step d until the whole picture area is covered. The definition of the sliding window during the sliding process is as follows: the sliding window is composed of a starting point (x, y) and the window edge length n, and the starting point is set as the top-left corner vertex of the window, which is considered that the pixel points are stored in a structure body image with row priority in the storage stage. Therefore, the starting point and the edge length are defined, and the pixel point coordinates contained in the window can be calculated. In each sliding scan, the edge intensity feature and the pixel density feature of the primary sliding window area are calculated and compared with the set threshold T E 、T μ 、 The region is marked as a face candidate region if it meets any of the set feature thresholds: the starting point and the edge length of the region are stored in the candidate face position array X. The calculation operation of the edge intensity feature and the pixel density feature of the specific region is as follows:
[0074] First, the region is marked based on the edge intensity feature, and the condition is as follows:
[0075] The top-left coordinates of the region are (x a ,y a ), and the edge length is n, so the bottom-right coordinates are (x a +n-1,y a +n-1). The edge intensity sum in the region is calculated:
[0076]
[0077] Then, the edge intensity sum is compared with the threshold: if S is greater than the preset threshold T E , the region is marked as a face candidate region.
[0078] Meanwhile, the pixel density feature is detected based on the integral image calculation: the five organs (eyes, nose, etc.) in the picture, i.e., the regions with high pixel density, are detected and marked as possible face candidate regions. The specific five organ pixel density detection is as follows:
[0079] The average value of the pixel values in the region is calculated:
[0080]
[0081] The variance of the pixel values is calculated (the smaller the variance value, the higher the pixel density in the window):
[0082]
[0083] If the average value of the pixel points in the current region exceeds the average value threshold T μIf the variance of the pixel points in the current region is lower than the variance threshold value
[0084] If the variance of the pixel points in the current region is lower than the variance threshold value If the variance of the pixel points in the current region is lower than the variance threshold value
[0085] In summary, the work of the preliminary sliding window is to find the candidate face position by calculating the edge intensity features and the pixel density features contained in the window region.
[0086] Further, the step in step (7) is specifically:
[0087] The side length of the new sliding window is defined as C, and the formula is as follows:
[0088] C = a * n
[0089] Wherein, n represents the side length of the preliminary sliding window. a represents a scaling factor for scaling the side length of the preliminary sliding window, and is usually set to be between 0.45 and 1.
[0090] The step length of the new sliding window is set to be Δ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, for each face candidate region (recorded by the preliminary sliding window scanning), a new sliding window is generated, i.e. a new sliding window smaller than the preliminary sliding window is used to scan the face candidate region more carefully.
[0092] Specifically, the side length of the new sliding window is set to be C, and in the face candidate region (the square region with a side length of n framed by the preliminary sliding window), the step length is set to be Δc, and scanning is performed in row priority order.
[0093] Each time of scanning will match the detection region framed by the new sliding window with the preset face template, and based on the given 7 face templates, the rules are calculated: the detection region is equally divided into 25 squares, if any of rules (1) to (5) is satisfied, it is considered that the detection region may contain a face, and the confidence of the detection region is calculated: each time a rule is satisfied, the confidence is increased in proportion according to the weight corresponding to each rule, and the detection region position coordinates are stored. Finally, the confidence ω of each detection region Y corresponding to the current face candidate region is obtained Y , and the corresponding detection region position coordinates.
[0094] And the new sliding window detection in each face candidate region needs to reduce the side length of the new sliding window by 10 pixels and re-traverse until the side length of the new sliding window reaches the set minimum side length C after traversing once in row priority order min .
[0095] C min =180
[0096] While reducing the side length of the new sliding window, set its corresponding step length Δc:
[0097]
[0098] After scanning all face candidate regions, only the top five detection region position coordinates with the highest confidence are extracted and identified as five final selected regions.
[0099] For the detected final selected regions, if multiple detection regions in the final selected region are adjacent to or repeated with the detection region corresponding to the maximum confidence, they are merged to avoid missing parts of the face.
[0100] Two detection windows A, B and their repetition rate O are defined as follows (set the width and height of the two rectangular regions A, B as W 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 last overlap rate O is greater than 0.5, it is determined to be repeated, and merging is performed. The selected region after merging is selected. If not, the detection region with the maximum confidence is directly selected.
[0109] The finally determined selected region is marked on the original image, and the detection data is output.
[0110] The present application has the following beneficial effects:
[0111] The present application introduces a combination of face template and adaptive sliding window detection technology, and uses the matching degree of the detection region and the face template to enhance the accuracy of detection. The present application uses a local sliding window based on feature points, avoids detection of invalid regions and invalid features, and predicts the approximate position of the face by detecting edge intensity features and pixel density features, and searches for the specific position of the face in combination with the face template. The present application fuses a variety of feature sliding windows, considers face edges and feature point information of facial features during the detection process, performs detailed search on the periphery of the region that meets multiple features, and enhances robustness. In the sliding window traversal search process, the present application intelligently skips part of the region according to the result of the last traversal search, avoids redundant calculation and invalid regions, and saves computing resources. The present application merges multiple windows with high detection repetition, can accurately retain all facial information, and avoids incomplete facial retention. In summary, the present application can process images in batches. A variety of preprocessing methods are used to extract effective face features of the picture. The present application does not need to introduce a neural network, and uses a lightweight sliding window search to extract faces from the preprocessed picture. BRIEF DESCRIPTION OF DRAWINGS
[0112] Figure 1 Method execution flowchart of the embodiment of the present application. DETAILED DESCRIPTION
[0113] The specific implementation scheme of the present application will be further described below with reference to the accompanying drawings.
[0114] The present application mainly proposes a face extraction method based on face template and sliding window, Figure 1 is the specific implementation step of the present application:
[0115] Step (1) input face picture image. The size of the bmp format picture is 1280*960, read its information, and keep 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 picture image into a grayscale picture using the weighted average method and performs edge detection using the Sobel operator to calculate an edge intensity matrix E (the E matrix has the same size as the original picture, i.e., 1280*960).
[0117] Step (3) pre-processes the grayscale picture.
[0118] First, a mean filtering operation is performed. A mean filtering convolution kernel KERNELS
[25] is introduced, which is a 5*5 convolution kernel composed of all 1s, and is used to perform convolution operation with the picture image to remove noise. In the second step, an adaptive threshold method is used to binarize the image to retain key edge information. Then, through one inflation and one corrosion operation, key feature information of the picture is highlighted. The pre-processing operation is only performed on the RGB channel of the picture.
[0119] Step (4) calculates an integral image for the processed picture. The integral image has the same size as the original picture image, and stores information related to the region pixel point and the pixel point in the internal. The input is a pre-processed binary image image, and the output is an integral image structure IGmap, which includes the h and w of the picture, and the pixel point and information array data corresponding to each pixel point. The value of each pixel point (x, y) has the following meaning:
[0120] x=index%w
[0121] y=index / w
[0122]
[0123] where index represents the one-dimensional index of the pixel point in IGmap, n (x,y) represents the value of the pixel point in the integral image, and B(x, y) represents the value of the pixel point in the binary image (in the binary image, black pixels take 1, and otherwise take 0)
[0124] Step (5) introduces a face template. In this embodiment, a real photo taken by the detection device is introduced as the template. The standard face part needed is intercepted and segmented into 5*5 25 blocks and numbered. The threshold value that satisfies the rule of the face template is assigned by analyzing the pixel point distribution of the pre-processed standard face, and the specific assignment is as follows:
[0125]
[0126]
[0127] w3<3
[0128] Step (6) For a picture of 1280*960, define the side length n=400 pixels of the sliding window, the sliding window starts from the top left corner of the picture, and the step d is 20. At each sliding scan, calculate the edge intensity feature and pixel density feature of the preliminary sliding window region, and compare them with the set threshold T E 、T μ 、 until the entire picture area is covered. Mark the face candidate area for any region that meets any set feature threshold.
[0129] Set the edge intensity threshold T E to 810000, which is used to compare the edge intensity matrix E(x,y) calculated using the Sobel operator in the grayscale stage:
[0130]
[0131] If the threshold is met (i.e. S>T E ) during the window sliding process, record the starting point (x,y) and the side length n of the current window in the candidate face position array X.
[0132] Set the mean threshold T μ to 50, which is used to compare the mean μ of the pixels in the current sliding window:
[0133]
[0134] If the mean 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 the side length n of the current window are recorded in the candidate face position array X.
[0135] Set the variance threshold to 500, which is used to compare the variance σ 2 of the pixels in the current sliding window:
[0136]
[0137] If the variance of the pixels in the current window is lower than the threshold, it indicates that the pixel density is higher, and it is determined that the current window contains important facial features (eyes, nose, mouth, etc.), and the starting point (x,y) and the side length n of the current window are recorded in the candidate face position array X.
[0138] In step (7), further screening is performed on each face candidate region using a new sliding window, and combined with the face template to find the specific face position, and the method of drawing the face frame is as follows:
[0139] The new sliding window scans each face candidate region in detail.The length of the new sliding window is set as C.Under the control of the scale factor alpha, the length of the new sliding window starts from 400 pixels.After each traversal, the length is reduced by 10 pixels until the length is reduced to 180 pixels.The step is also reduced according to the length of the new sliding window in proportion, from a step of 5 to a step of 1.Then after scanning each face candidate region, the scanning of the next face candidate region is performed until the end.
[0140] When the new sliding window scans, the detection region framed is compared with the face template with added threshold to meet the rules: the detection region is equally divided into 25 squares, and whether the first five rules of the face template meeting rules are met is calculated.If the rules are met, the position coordinates of the detection region are recorded, and the confidence is calculated according to all the face template meeting rules.
[0141] The confidence ω calculation process needs to use the set seven rules and the confidence calculation formula:
[0142]
[0143] w3<3 (7)
[0144]
[0145] After the scanning work is completed, the position coordinates of the five detection regions with the largest confidence are selected as the five final selected regions.According to the merging rule, the final face region is selected.The final face region needs to contain two coordinates (x leftTop ,y leftTop ) and (x rightBottom ,y rightBottom ), and the range of the face required in the experiment is determined as:
[0146] {(x,y)|x leftTop ≤x≤x rightBottom , y leftTop ≤y≤y rightBottom}
[0147] All the pixel points represented by the above set are the face part required.
[0148] Finally, the position of the final face region is marked on the original image, and the detection data is output.
[0149] In summary, the method has high precision and fast speed, can realize batch automatic detection in practical application, can also be adaptively adjusted according to different embedded devices, and finally obtained face extraction picture has pixel level precision and meets the actual demand.
[0150] The above further describes the present application in connection with specific / preferred embodiments, and cannot be deemed to limit the specific implementation of the present application to these descriptions. For those skilled in the art to which the present application belongs, without departing from the concept of the present application, they can make several substitutions or modifications to the described embodiments, and these substitutions or modifications shall be deemed to belong to the protection scope of the present application.
[0151] The part of the present application not described in detail belongs to the technology known to those skilled in the art.
Claims
1. A face extraction method based on face template and sliding window, characterized in that, Comprise the following steps: Step (1) batch face picture input; Step (2) the picture is converted to a gray image, and the edge intensity feature is obtained by using a sobel operator for edge detection; The edge intensity matrix is: G = Gx + Gy x (x, y) is the gradient in the horizontal direction; G y (x, y) is the gradient in the vertical direction; Step (3) pre-processing the gray image, including mean filtering, binary image conversion, dilation, and corrosion; Step (4) calculate the integral image of the processed image, which is used to count the sum of the pixel points in the region; Step (5) based on the face template, the threshold value of the face template that meets the rules is assigned; A real photo taken by a detection required device is used as a template, the face template is set as a square region, and a standard face part required is obtained by cutting the standard face part from the real photo; the face template is equally divided into 25 sub-regions of 5*5 after being grayed and preprocessed, and is numbered as w1~ w 25 25 sub-regions according to row priority, wherein the sum of the 25 sub-regions is S 25 ; ; based on the pixel point distribution of the preprocessed standard face, a threshold value satisfying a rule of the face template is valued, and the threshold value is specifically as follows: Where EYES_MIN and EYES_MAX represent the lower and upper limits of the ratio of the two eye pixel points, 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 face pixel points, NOSE_OF_FACE_MIN and NOSE_OF_FACE_MAX represent the lower and upper limits of the ratio of the nose to the overall face pixel points, MOUSE_OF_FACE_MIN and MOUSE_OF_FACE_MAX represent the lower and upper limits of the ratio of the mouth to the overall face pixel points; CHEEK represents the upper limit of the ratio of the two cheeks to the overall face pixel points; BLANK represents the number of pixel points distributed in the blank area of the face; Step (6) based on the integral image, calculate the pixel density feature, and then mark the face candidate region in combination with the edge intensity feature; For the pre-processed image, based on the integral image, calculate the pixel density feature, and then mark the face candidate region in combination with the multi-dimensional judgment of the edge intensity feature, and exclude the region without clear edge feature; The edge length n of the preliminary sliding window is defined, and the preliminary sliding window starts from the top left corner of the picture and slides with a step length d until the entire picture area is covered. The definition of the sliding window during the sliding process is as follows: the sliding window is composed of a starting point (x, y) and a window edge length n, and the starting point is set as the top left corner vertex of the window. At each sliding scan, the edge intensity feature and the pixel density feature of the preliminary sliding window area are calculated and compared with the set threshold , , . For the region that meets any set feature threshold, the face candidate region is marked: the starting point and the edge length of the region are stored in the candidate face position array X. The calculation operation of the edge intensity feature and the pixel density feature of the specific region is as follows: First, based on the edge intensity feature, mark the region, with the following conditions: The upper-left corner coordinate of the region is (x a , y a ), and the side length is n, so the right-bottom corner coordinate is (x a + n-1, y a + n-1); the total sum of edge strength in the region is calculated: Then compare the edge intensity sum with a threshold value: if S is greater than a preset threshold value then mark the region as a face candidate region; At the same time, based on the integral image, calculate the pixel density feature for density detection: detect the features in the image, i.e. the areas with high pixel density, and mark them as possible face candidate regions; the specific method for detecting the features with high pixel density is as follows: Calculate the average value of the pixel value in the region: Calculate the variance of the pixel value: If the average value of the pixel points in the current region exceeds the average value threshold it is considered that the current region contains important facial features, and the region is marked as a face candidate region; If the variance of the pixel points in the current region is lower than the variance threshold , indicating that the pixel points are densely distributed, it is determined that the current region contains important facial features, and the region is marked as a face candidate region. Step (7) use a sliding window to detect the face candidate region, and combine it with the face template to find the specific face position and draw a face box; The side length of the new sliding window is defined as , which is specifically expressed in the following formula: wherein n represents a length of the preliminary sliding window; and a represents a scale factor for scaling the length of the preliminary sliding window, and is set to be between 0.45 and 1. The step of the new sliding window is set as , which is an integer value between 1 and 5. When searching for a new sliding window, search each face candidate region in order; first, generate a new sliding window for each face candidate region, i.e. use a new sliding window smaller than the initial sliding window to scan the face candidate region more carefully; Specifically, a new sliding window side length is set as C, and in the face candidate region, a step length is set as , and scanning is performed in row priority order. The detection area framed by the new sliding window is matched with the preset face template each time of scanning, and the given 7 face templates satisfy the rules to calculate: the detection area is also equally divided into 25 blocks, if any of 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 according to the weight corresponding to each rule, and the detection area position coordinates are stored; finally, the confidence corresponding to each detection area Y of the current face candidate area is obtained and the corresponding detection area position coordinates.
2. The face extraction method based on face template and sliding window according to claim 1, characterized in that, Step (1) the input image uses a bmp format image actually taken by the detection device required. 3.The face extraction method based on face template and sliding window according to claim 1, characterized in that, Step (2) the specific method is as follows: The feature gray image conversion uses the weighted average method; the gray image weighted formula is as follows: Where I(x, y) represents the gray value of the pixel point (x, y), and an edge intensity matrix E(x, y) is obtained by processing it with a sobel operator; since the image is stored in one-dimensional array, the horizontal and vertical coordinates of the pixel point can be calculated according to the index: Where w is the width of the image; The specific method is as follows: Gradient G in horizontal direction x (x, y): Gradient G in vertical direction y (x, y): 。 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 filtering conversion of step (3) is a 5x5 mean filtering convolution kernel, and the feature binary image conversion uses an 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 image IGmap is calculated according to the position and specific value of each pixel point in the picture; first, the integral image is a picture with a size comparable to the original picture IMAGE; since the pixel points 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: where index is the position index of the pixel point, that is, the position of the pixel point in the picture; the length and width of the picture are stored in im.h and im.w, respectively, and the pixel information of the picture is stored in im.color, where color is a four-channel: blue, green, red, and transparency: For the first pixel point: For the first row of pixel points: For the first column of pixel points: For other pixel points: The integral image is used to calculate the total number of pixel points in a certain block region; since the bmp format picture is stored in a one-dimensional array, only two points leftTop and rightBottom are needed to frame a square region; the specific calculation is as follows: The integral value of the region is calculated as follows: 。 6. The face extraction method based on face template and sliding window according to claim 1 or 5, characterized in that, After the new sliding window detection in each face candidate region is traversed in row priority order, the side length of the new sliding window needs to be reduced by 10 pixels and re-traversed until the side length of the new sliding window reaches the set minimum side length ; In reducing the side length of the new sliding window while setting its corresponding step length : After scanning all the face candidate regions, only the top five detection region coordinates with the highest confidence are extracted, and they are identified as the five final selected regions; For the detected final selected region, if there are multiple detection regions in the final selected region that are adjacent to or repeated with the detection region corresponding to the maximum confidence, they are merged to avoid missing parts of the face; Two detection windows A, B and its repetition rate O are defined as follows, set the width and height of two rectangular regions A, B region are respectively : If the final overlap rate O is greater than 0.5, it is determined to be repeated and merged; and the merged region is selected; if not, the detection region with the maximum confidence is directly selected; Mark the final selected region on the original image and output the detection data.
Citation Information
Patent Citations
Quick eye locating method based on integral projection and edge detection
CN103218605A
Rapid identification photo glasses detection method based on image processing
CN114463814A