A facial image optimization recognition method for smart door locks
By analyzing the horizontal and vertical gradient images of the face image, combining comprehensive gradient information to screen the face edges and performing linear enhancement, the problem of poor face recognition effect in smart door locks is solved, and fast and accurate face area recognition and optimization are achieved .
Patent Information
- Application Number
- CN202411095711.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-12
- Publication Date
- 2024-11-12
- Estimated Expiration
- 2044-08-12
Smart Images

Figure CN118629080B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of electronic device data recognition, and in particular to a facial image optimization recognition method for a smart door lock. Background Art
[0002] Face recognition unlocking is an important function of smart door locks. The position of smart door locks is fixed on the door, so it is easily affected by light, causing the collected facial images to be overexposed or too dark, further affecting the smart door lock's recognition of the face. Therefore, optimization and enhancement of facial images is one of the important functions that smart door locks must achieve.
[0003] For the scenario of smart door locks recognizing faces, it is necessary to extract the face area in the image before image enhancement, and then perform targeted enhancement on the face area to avoid the errors and complex calculations caused by global enhancement. However, in the prior art, neural networks or cloud computing are usually used to identify the face area in the image. This method relies on high-speed networks and costly computing models, which is not applicable to smart door locks. Therefore, it is impossible to quickly and accurately determine the face area, and it is impossible to optimize and enhance the face area image, resulting in poor face recognition results for smart door locks. Summary of the invention
[0004] In order to solve the technical problem that the face area cannot be quickly and accurately identified in the smart door lock scenario, thereby affecting the image enhancement quality, the purpose of the present invention is to provide a face image optimization recognition method for a smart door lock. The technical solution adopted is as follows:
[0005] The present invention proposes a method for optimizing facial image recognition for a smart door lock, the method comprising:
[0006] Acquire a face image of a front-facing face collected by the smart door lock; obtain a horizontal gradient image and a vertical gradient image of the face image;
[0007] Arrange and combine the edges in the horizontal gradient image to obtain a horizontally arranged edge group, and obtain the horizontal confidence of each edge according to the distance between the edges in the horizontally arranged edge group; arrange and combine the edges in the vertical gradient image to obtain a vertically arranged edge group, and obtain the vertical confidence of each edge according to the distance between the edges in the vertically arranged edge group;
[0008] Obtaining a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image; obtaining a response degree of each edge according to the gradient information on the edge in the comprehensive gradient image; obtaining a face edge confidence of each edge according to the transverse confidence corresponding to each edge in the transverse gradient image, the longitudinal confidence corresponding to each edge in the longitudinal gradient image, and the response degree;
[0009] Filtering out a face edge according to the face edge confidence, and obtaining a face region in the face image according to the face edge;
[0010] Determine linear enhancement parameters according to the brightness change degree of the face area and the overall brightness within the face area, enhance and optimize the face image according to the linear enhancement parameters; and perform face recognition based on the enhanced and optimized face image.
[0011] Furthermore, obtaining the transverse gradient image and the longitudinal gradient image of the face image includes:
[0012] The face image is processed by a transverse Sobel operator to obtain an initial transverse gradient image; the face image is processed by a longitudinal Sobel operator to obtain an initial longitudinal gradient image; and the transverse gradient image corresponding to the initial transverse gradient image and the longitudinal gradient image corresponding to the initial longitudinal gradient image are respectively processed by the Otsu threshold method.
[0013] Furthermore, the distance acquisition method includes:
[0014] In the transverse gradient image, an average horizontal coordinate of each edge is obtained, and the difference between the average horizontal coordinates of the edges is used as the distance;
[0015] In the longitudinal gradient image, the average longitudinal coordinate of each edge is obtained, and the difference between the average longitudinal coordinates of the edges is used as the distance.
[0016] Furthermore, the method for obtaining the lateral confidence includes:
[0017] Select four edges to arrange and combine to obtain the horizontal arrangement edge group, and use a horizontal combination confidence formula to obtain the horizontal combination confidence of the horizontal arrangement edge group. The horizontal combination confidence formula includes:
[0018]
[0019] in, is the horizontal combined confidence of the horizontally arranged edge groups; , , , are respectively serial numbers of the four edges in the horizontally arranged edge group arranged in sequence in the horizontal order; For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between
[0020] The maximum horizontal combined confidence of all the horizontally arranged edge groups corresponding to each edge is used as the horizontal confidence of the corresponding edge.
[0021] Furthermore, the method for obtaining the longitudinal confidence includes:
[0022] Select six edges to arrange and combine to obtain the vertically arranged edge group, and use a vertical combination confidence formula to obtain the vertical combination confidence of the vertically arranged edge group. The vertical combination confidence formula includes:
[0023]
[0024] in, is the vertical combined confidence of the vertically arranged edge groups; , , , , , are respectively serial numbers of the six edges in the longitudinally arranged edge group arranged in sequence in longitudinal order; For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between
[0025] The maximum longitudinal combined confidence of all the longitudinally arranged edge groups corresponding to each edge is used as the longitudinal confidence of the corresponding edge.
[0026] Further, obtaining a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image comprises:
[0027] Respectively obtaining a horizontal edge binary image corresponding to the horizontal gradient image and a vertical edge binary image corresponding to the vertical gradient image; merging the horizontal edge binary image and the vertical edge binary image to obtain an edge binary image;
[0028] A comprehensive gradient value is obtained according to the gradient value of each pixel point in the horizontal gradient image and the vertical gradient image, and the pixel value of each edge pixel point in the edge binary image is set to the comprehensive gradient value to obtain the comprehensive gradient image.
[0029] Further, obtaining the response degree of each edge according to the gradient information on the edge in the comprehensive gradient image includes:
[0030] The comprehensive gradient value of each edge pixel in the comprehensive gradient image is normalized to obtain an initial response degree; and the average initial response degree of the edge pixels on each edge in the comprehensive gradient image is used as the response degree.
[0031] Furthermore, the method for obtaining the face edge confidence comprises:
[0032] Obtain the average horizontal confidence of all corresponding edges in the horizontal gradient image for each edge in the integrated gradient image; obtain the average vertical confidence of all corresponding edges in the vertical gradient image for each edge in the integrated gradient image; and take the average value among the average horizontal confidence, the average vertical confidence and the response degree as the face edge confidence.
[0033] Furthermore, the linear enhancement parameter acquisition method includes:
[0034] The linear enhancement parameters include a first linear enhancement parameter and a second linear enhancement parameter;
[0035] The average grayscale value in the face area is used as the overall brightness, and the average value of the grayscale value difference between all two adjacent pixels in the face area is used as the brightness change degree; the average overall brightness and the average brightness change degree of the historical face areas in the smart door lock database are obtained; the difference between the average overall brightness and the overall brightness of the face area is used as the first linear enhancement parameter; the difference between the brightness change degree of the face area and the average brightness change degree is used as the second linear enhancement parameter.
[0036] Further, the image enhancement optimization of the face image of the current frame according to the linear enhancement parameters includes:
[0037] The original grayscale value of the pixel point in the face area is multiplied by the second linear enhancement parameter and then added to the first linear enhancement parameter to obtain the enhanced grayscale value of each pixel point in the face area.
[0038] The present invention has the following beneficial effects:
[0039] The present invention takes into account that each part of the face has a distinct proportion, so the face image is divided into a horizontal gradient image and a vertical gradient image and the distance ratio between the edges in the two gradient images is analyzed respectively. According to the existing known face ratio information, the horizontal confidence or vertical confidence of each edge is analyzed by the horizontally arranged edge group or the vertically arranged edge group obtained by permutation and combination. Further considering the gradient information of the edge itself, the larger the gradient information, the stronger the reference of the corresponding edge, so the response degree is obtained and the face edge confidence is obtained by combining the horizontal confidence and the vertical confidence. According to the face edge confidence, the face edge with strong reference can be accurately screened out and the face area in the face image can be determined. The smart door lock can quickly and accurately identify the face area according to the local algorithm, reducing the cost of the recognition algorithm. Further analyze the brightness characteristics in the face area, eliminate the influence of light on the face image through the linear enhancement coefficient, realize accurate face area recognition and face image optimization, and then enable the smart door lock to effectively identify face information. BRIEF DESCRIPTION OF THE DRAWINGS
[0040] In order to more clearly illustrate the technical solutions and advantages in the embodiments of the present invention or the prior art, the drawings required for use in the embodiments or the prior art descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0041] Figure 1 An embodiment of the present invention provides a method for optimizing facial image recognition for a smart door lock. DETAILED DESCRIPTION
[0042] In order to further explain the technical means and effects adopted by the present invention to achieve the predetermined invention purpose, the following is a detailed description of the face image optimization recognition method for a smart door lock proposed by the present invention, its specific implementation method, structure, features and effects, in combination with the accompanying drawings and preferred embodiments. In the following description, different "one embodiment" or "another embodiment" does not necessarily refer to the same embodiment. In addition, specific features, structures or characteristics in one or more embodiments may be combined in any suitable form.
[0043] Unless defined otherwise, all technical and scientific terms used herein have the same meaning as commonly understood by one of ordinary skill in the art to which this invention belongs.
[0044] An embodiment of a method for optimizing facial image recognition for a smart door lock:
[0045] The following is a detailed description of a specific scheme of a facial image optimization recognition method for a smart door lock provided by the present invention in conjunction with the accompanying drawings.
[0046] See also Figure 1 , which shows a flow chart of a method for optimizing facial image recognition for a smart door lock provided by an embodiment of the present invention, the method comprising:
[0047] Step S1: Acquire a face image of a frontal face collected by a smart door lock; obtain a horizontal gradient image and a vertical gradient image of the face image.
[0048] In the scenario of face recognition in smart door locks, the camera is fixed at a certain position on the door lock. Therefore, in order to realize face recognition, the user needs to face the camera directly so that the camera can collect the face image facing the face. Because there is a lot of useless information in the face image, such as clothes, background, etc., in order to improve the efficiency of image optimization, it is necessary to identify the face area and perform targeted enhancement on the face area to eliminate the influence of bad lighting.
[0049] In order to accurately identify the face area, existing technologies often use technologies such as neural networks or cloud computing models that are costly and network-dependent. For smart door locks, this technology is not only costly, but also not applicable in some scenarios. Therefore, in order to realize local face recognition of smart door locks, it is necessary to determine the face area based on the edge information in the collected face image.
[0050] Because there are multiple edge information in a face image, in order to achieve accurate analysis of the edge information, an embodiment of the present invention obtains a transverse gradient image and a longitudinal gradient image of the face image, that is, the transverse edge is stronger in the transverse gradient image, and the longitudinal edge is stronger in the longitudinal gradient image.
[0051] Preferably, obtaining a transverse gradient image and a longitudinal gradient image of a face image comprises:
[0052] The face image is processed by the transverse Sobel operator to obtain an initial transverse gradient image; the face image is processed by the longitudinal Sobel operator to obtain an initial longitudinal gradient image; the Otsu threshold method is used to process the face image to obtain a transverse gradient image corresponding to the initial transverse gradient image and a longitudinal gradient image corresponding to the initial longitudinal gradient image, that is, the transverse gradient image and the longitudinal gradient image are both binary images after being processed by the Otsu threshold algorithm to facilitate subsequent edge extraction.
[0053] It should be noted that the structure of the Sobel operator and the method of image processing are technical means well known to those skilled in the art, and the specific algorithm operation will not be repeated here. The Otsu threshold algorithm is also an existing technology well known to those skilled in the art, and will not be repeated or limited here.
[0054] Step S2: Arrange and combine the edges in the horizontal gradient image to obtain a horizontally arranged edge group, and obtain the horizontal confidence of each edge according to the distance between the edges in the horizontally arranged edge group; arrange and combine the edges in the vertical gradient image to obtain a vertically arranged edge group, and obtain the vertical confidence of each edge according to the distance between the edges in the vertically arranged edge group.
[0055] Considering that the human face has obvious proportions, for example, the length of the face is divided into three equal parts, from the forehead hairline to the brow bone, the brow bone to the nose bottom, and the nose bottom to the chin. The lengths of these three parts are almost the same, and the dividing line of each part is an obvious face edge. However, there is a large amount of irrelevant edge information and face edge information in the face image, so the face edge can be accurately identified based on the proportions of each part of the face, eliminating the interference of irrelevant edges.
[0056] In order to accurately analyze edge features based on the proportion of facial parts, the horizontal gradient image and the vertical gradient image are processed separately, and the edges in the horizontal gradient image are arranged and combined to obtain a horizontally arranged edge group. If a certain horizontally arranged edge group meets the face proportion in the prior knowledge, it means that the edge corresponding to the combination is more likely to be a face edge. Therefore, the horizontal confidence of each edge can be obtained according to the distance between the edges in the horizontally arranged edge group. Similarly, the edges in the vertical gradient image are processed in the same way to obtain the vertical confidence of each edge. According to the horizontal confidence and vertical confidence, whether the upper edge of the face meets the face proportion can be accurately analyzed from two directions.
[0057] It should be noted that the edges in the transverse gradient image can be directly distinguished according to existing technologies, such as region growing, chain coding, scanning and other methods, which are not limited or elaborated here.
[0058] Preferably, in one embodiment of the present invention, the method for obtaining the distance between edges includes:
[0059] Because the face image is an image of the face in the front view, the horizontal and vertical coordinates of the edges that make up the face area should be uniform coordinates. Therefore, for the edges in the horizontal gradient image, the average horizontal coordinate of each edge is obtained, and the difference between the average horizontal coordinates of the edges is used as the distance; for the edges in the vertical gradient image, the average vertical coordinate of each edge is obtained, and the difference between the average vertical coordinates of the edges is used as the distance. By using the difference between the average coordinates of the edges in different directions to represent the distance, the subsequent analysis of the face proportions can be facilitated, making the confidence of the face edges with reference significance higher.
[0060] Preferably, in one embodiment of the present invention, the confidence is specifically analyzed with reference to the proportion of "three sections and five eyes" of the human face. Three sections and five eyes refers to dividing the human face into three equal parts from top to bottom and into five equal parts from left to right. The three equal parts refer to: from the forehead hairline to the brow bone, from the brow bone to the nose bottom, and from the nose bottom to the chin. The five equal parts refer to: taking the length of the eye shape as the unit, the human face is divided into five parts from the left hairline to the right hairline. In the division results of three equal parts and five equal parts, there are obvious edges between each part, such as the left hairline edge to the cheekbone edge, the cheekbone edge to the nose wing edge, etc. in the five equal parts, so four edges can be selected in the horizontal gradient image for arrangement and combination to obtain a horizontal arrangement edge group, and it is considered that these four edges divide the human face into three parts horizontally; six edges are selected in the vertical gradient image for arrangement and combination to obtain a vertical arrangement edge group, and it is considered that these six edges divide the human face into five parts vertically.
[0061] The horizontal combination confidence formula is further used to obtain the horizontal combination confidence of the horizontally arranged edge group. The horizontal combination confidence formula includes:
[0062]
[0063] in, is the horizontal combined confidence of the horizontally arranged edge groups; , , , are the serial numbers of the four edges in the horizontally arranged edge group arranged in the horizontal order; For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between.
[0064] It can be seen from the horizontal combination confidence formula that It represents the ratio of twice the width of the middle part to the width of the upper and lower parts. The closer the ratio is to 1, the more the width ratio of the three parts divided by the four edges conforms to the equal division relationship. Therefore, the ratio is subtracted by 1 and then subtracted by 1, that is, when the ratio is 1, the horizontal combination confidence is also 1.
[0065] The vertical combination confidence formula is used to obtain the vertical combination confidence of the vertically arranged edge group, and the vertical combination confidence formula includes:
[0066]
[0067] in, is the vertical combined confidence of the vertically arranged edge groups; , , , , , are respectively serial numbers of the six edges in the longitudinally arranged edge group arranged in sequence in longitudinal order; For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between.
[0068] Similar to the horizontal combination confidence formula, the vertical combination confidence formula It expresses the ratio of three times the average length of the two middle parts to the length of the front, middle and back parts. The closer the ratio is to 1, the more the combination conforms to the equal division relationship.
[0069] Because each edge corresponds to multiple horizontally arranged edge groups or vertically arranged edge groups, the maximum horizontal combined confidence of all horizontally arranged edge groups corresponding to each edge is used as the horizontal confidence of the corresponding edge, and the maximum vertical combined confidence of all vertically arranged edge groups corresponding to each edge is used as the vertical confidence of the corresponding edge. That is, if an edge meets the edge division relationship of three courts and five eyes, it must have a greater confidence and representation.
[0070] Step S3: obtaining a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image; obtaining the response degree of each edge according to the gradient information on the edge in the comprehensive gradient image; obtaining the face edge confidence of each edge according to the transverse confidence corresponding to each edge in the transverse gradient image, the longitudinal confidence corresponding to each edge in the longitudinal gradient image and the response degree.
[0071] In step S3, the confidence is mainly determined by analyzing the position and shape of the edge. However, the face image also contains a large number of noise edges such as hair. Such edges may also meet the division edges of the face ratio. Therefore, in order to eliminate such edges, it is necessary to further obtain a comprehensive gradient image based on the horizontal gradient image and the vertical gradient image, that is, the comprehensive gradient image contains the comprehensive gradient information of each pixel point. The larger the comprehensive gradient, the less the corresponding edge belongs to the noise edge and the stronger the edge feature. Therefore, the response degree of each edge can be obtained according to the gradient information on the edge in the comprehensive gradient image, and the face edge confidence of each edge is determined by combining the response degree and the confidence.
[0072] Preferably, in one embodiment of the present invention, obtaining a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image comprises:
[0073] The horizontal edge binary image corresponding to the horizontal gradient image and the vertical edge binary image corresponding to the vertical gradient image are obtained respectively; the horizontal edge binary image and the vertical edge binary image are merged to obtain the edge binary image. It should be noted that the merging to obtain the binary image is to add the two images. If the pixel value at a certain place is greater than 1, it is set to 1, that is, the two images are logically ORed. Then, an edge binary image containing only 0 and 1 is obtained, where 0 represents a non-edge point, which is black; 1 represents an edge point, which is white. It should be noted that because the edge binary image is obtained by merging two edge binary images in different directions, there will be a situation where multiple edges in the horizontal edge binary image or the vertical edge binary image are merged into one edge on the edge binary image. That is, one edge in the edge binary image may correspond to multiple horizontal edge binary images or multiple vertical edge binary images.
[0074] The comprehensive gradient value is obtained according to the gradient value of each pixel in the horizontal gradient image and the vertical gradient image, and the pixel value of each edge pixel in the edge binary image is set to the comprehensive gradient value to obtain the comprehensive gradient image. It should be noted that the calculation method of the comprehensive gradient value is a technical means well known to those skilled in the art. The comprehensive gradient value can be obtained by calculating the square root of the sum of the gradient values in two different directions, which will not be described in detail here.
[0075] Because the magnitude of the gradient value represents the strength of the edge degree represented by the corresponding edge point, in a preferred embodiment of the present invention, the comprehensive gradient value of each edge pixel point in the comprehensive gradient image is normalized to obtain the initial response degree; the average initial response degree of the edge pixel points on each edge in the comprehensive gradient image is taken as the response degree. That is, the greater the response degree, the more the corresponding edge is a real edge that can be referenced.
[0076] In one embodiment of the present invention, the normalization operation uses maximum and minimum value normalization. In other embodiments of the present invention, other normalization methods may also be used, which are not limited or elaborated herein.
[0077] Preferably, in one embodiment of the present invention, the method for obtaining the face edge confidence comprises:
[0078] Get the average horizontal confidence of all corresponding edges in the horizontal gradient image for each edge in the integrated gradient image; get the average vertical confidence of all corresponding edges in the vertical gradient image for each edge in the integrated gradient image; take the average of the average horizontal confidence, the average vertical confidence and the response degree as the face edge confidence. That is, the face edge confidence is expressed by the formula: ;in represents the face edge confidence, Indicates the number of edges corresponding to this edge in the horizontal gradient image. Indicates the edge corresponding to the first lateral confidence of the strip edge, Indicates the number of edges corresponding to this edge in the longitudinal gradient image, The edge corresponds to the first The longitudinal confidence of the strip edge, is the response degree of the edge. That is, the greater the confidence and the greater the response degree, the more the edge can be used to divide the face area and the stronger the representation.
[0079] Step S4: Filter out the face edge according to the face edge confidence, and obtain the face area in the face image according to the face edge.
[0080] Because the greater the confidence of the face edge, the more the corresponding edge is a reference face edge, so in one embodiment of the present invention, a confidence threshold is set, and the edge with a face edge confidence greater than the confidence threshold is regarded as the face edge. Further, the maximum and minimum coordinates on the face edge are combined to determine the coordinates of four points, and the face bounding box is obtained from the four point coordinates, that is, the area corresponding to the face bounding box in the face image is the face area.
[0081] In one embodiment of the present invention, because the confidence value range of the face edge is between 0 and 1, the confidence threshold is set to 0.7.
[0082] Step S5: Determine linear enhancement parameters according to the brightness change degree of the face area and the overall brightness in the face area, and optimize the face image enhancement according to the linear enhancement parameters; perform face recognition based on the enhanced and optimized face image.
[0083] After the accurate face area is identified, the face area can be enhanced in a targeted manner. Because the main influence on image quality in the smart door lock scene is caused by light, in order to determine how to enhance the face area, it is necessary to analyze the brightness characteristics in the face area. Therefore, the linear enhancement parameters are determined according to the brightness change degree and overall brightness in the face area. According to the linear enhancement parameters, targeted enhancement of the face area can be achieved.
[0084] Preferably, in one embodiment of the present invention, the linear enhancement parameter acquisition method includes:
[0085] The linear enhancement parameters include a first linear enhancement parameter and a second linear enhancement parameter;
[0086] The average grayscale value in the face area is used as the overall brightness, and the average value of the grayscale value difference between all two adjacent pixels in the face area is used as the degree of brightness change. The average overall brightness and the average brightness change degree of the historical face area in the smart door lock database are obtained; the difference between the average overall brightness and the overall brightness of the face area is used as the first linear enhancement parameter; the difference between the brightness change degree of the face area and the average brightness change degree is used as the second linear enhancement parameter. That is, the first linear enhancement parameter has a sign and has a negative value, while the second linear enhancement parameter is always a positive value. Therefore, it can be determined whether the face area needs to increase or decrease the brightness based on the first linear enhancement parameter. Therefore, in a preferred embodiment of the present invention, the image enhancement optimization of the face image of the current frame according to the linear enhancement parameter includes:
[0087] The original grayscale value of the pixel in the face area is multiplied by the second linear enhancement parameter and then added to the first linear enhancement parameter to obtain the enhanced grayscale value of each pixel in the face area. That is, the calculation formula of the enhanced grayscale value is:
[0088] ;
[0089] in, Indicates The first The enhanced pixel value of each pixel is For the The degree of brightness change of the face area in the frame face image, is the average brightness change of the historical face area in the smart door lock database, For the The first The original gray value of the pixel, is the average overall brightness of the historical face area in the smart door lock database, No. The overall brightness of the face area in a frame face image.
[0090] It can be seen from the enhanced gray value formula that the enhancement effect of the enhanced gray value is controlled by the first linear enhancement parameter, and the second linear enhancement parameter is used as the enhancement degree of the original gray value to achieve linear enhancement of the face area.
[0091] The face image after enhancement and optimization can be used to enable the smart door lock to accurately recognize the face. The face area recognition method provided by the embodiment of the present invention does not rely on the high-cost neural network or cloud computing model, so that the smart door lock can recognize and enhance the face area through the local algorithm, ensuring the working efficiency of the smart door lock.
[0092] In summary, the embodiments of the present invention process the horizontal gradient image and the vertical gradient image of the face image separately based on the characteristics of face proportions, analyze the distance between the edges, and obtain the horizontal confidence or vertical confidence of each edge. The response degree of each edge is determined according to the comprehensive gradient information of each pixel point in the comprehensive gradient image, and the face edge confidence is obtained by combining the horizontal confidence and the vertical confidence to identify the face area. The brightness features in the face area are analyzed and linear enhancement optimization is performed. The embodiments of the present invention realize effective face image optimization in the smart door lock scenario by quickly and accurately identifying the face area. The optimized face image can enable the smart door lock to quickly and effectively identify face information.
[0093] An embodiment of a method for recognizing a face region of a face image for a smart door lock:
[0094] For the scenario of smart door locks recognizing faces, it is necessary to extract the face area in the image before image enhancement, and then perform targeted enhancement on the face area to avoid the errors and complex calculations caused by global enhancement. However, in the prior art, neural networks or cloud computing are usually used to identify the face area in the image. This method relies on high-speed networks and costly computing models, which is not applicable to smart door locks. Therefore, it is impossible to quickly and accurately determine the face area. Therefore, an embodiment of the present invention proposes a face area recognition method for smart door locks using face images, which specifically includes:
[0095] Step S1: Acquire a face image of a frontal face collected by a smart door lock; obtain a horizontal gradient image and a vertical gradient image of the face image.
[0096] Step S2: Arrange and combine the edges in the horizontal gradient image to obtain a horizontally arranged edge group, and obtain the horizontal confidence of each edge according to the distance between the edges in the horizontally arranged edge group; arrange and combine the edges in the vertical gradient image to obtain a vertically arranged edge group, and obtain the vertical confidence of each edge according to the distance between the edges in the vertically arranged edge group.
[0097] Step S3: obtaining a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image; obtaining the response degree of each edge according to the gradient information on the edge in the comprehensive gradient image; obtaining the face edge confidence of each edge according to the transverse confidence corresponding to each edge in the transverse gradient image, the longitudinal confidence corresponding to each edge in the longitudinal gradient image and the response degree.
[0098] Step S4: Filter out the face edge according to the face edge confidence, and obtain the face area in the face image according to the face edge.
[0099] The embodiment of the present invention takes into account that each part of the face has obvious proportions, and therefore divides the face image into a horizontal gradient image and a vertical gradient image, and analyzes the distance ratio between the edges in the two gradient images respectively. According to the existing known face ratio information, the horizontal confidence or vertical confidence of each edge is analyzed by the horizontally arranged edge group or the vertically arranged edge group obtained by permutation and combination. Further considering the gradient information of the edge itself, the larger the gradient information, the stronger the reference of the corresponding edge. Therefore, the response degree is obtained and the face edge confidence is obtained by combining the horizontal confidence and the vertical confidence. According to the face edge confidence, the face edges with strong reference can be accurately screened out and the face area in the face image can be determined. This enables the smart door lock to quickly and accurately identify the face area according to the local algorithm, reducing the cost of the recognition algorithm.
[0100] Since the specific implementation process of steps S1 to S4 of the face area recognition method for a smart door lock using a face image has been described in detail in the above-mentioned embodiment of the face image optimization recognition method for a smart door lock, it will not be repeated here.
[0101] It should be noted that the sequence of the above embodiments of the present invention is only for description and does not represent the advantages and disadvantages of the embodiments. The processes depicted in the accompanying drawings do not necessarily require the specific order or continuous order shown to achieve the desired results. In some embodiments, multitasking and parallel processing are also possible or may be advantageous.
[0102] The various embodiments in this specification are described in a progressive manner, and the same or similar parts between the various embodiments can be referenced to each other, and each embodiment focuses on the differences from other embodiments.
Claims
1. A facial image optimization recognition method for smart door locks, characterized in that: The method comprises: Acquire a face image of a front-facing face collected by the smart door lock; obtain a horizontal gradient image and a vertical gradient image of the face image; Arrange and combine the edges in the horizontal gradient image to obtain a horizontally arranged edge group, and obtain the horizontal confidence of each edge according to the distance between the edges in the horizontally arranged edge group; arrange and combine the edges in the vertical gradient image to obtain a vertically arranged edge group, and obtain the vertical confidence of each edge according to the distance between the edges in the vertically arranged edge group; Obtaining a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image; obtaining a response degree of each edge according to the gradient information on the edge in the comprehensive gradient image; obtaining a face edge confidence of each edge according to the transverse confidence corresponding to each edge in the transverse gradient image, the longitudinal confidence corresponding to each edge in the longitudinal gradient image, and the response degree; Filtering out a face edge according to the face edge confidence, and obtaining a face region in the face image according to the face edge; Determine a linear enhancement parameter according to the brightness change degree of the face area and the overall brightness of the face area, and enhance and optimize the face image according to the linear enhancement parameter; perform face recognition according to the enhanced and optimized face image; The step of obtaining the transverse gradient image and the longitudinal gradient image of the face image comprises: Processing the face image using a transverse Sobel operator to obtain an initial transverse gradient image; processing the face image using a longitudinal Sobel operator to obtain an initial longitudinal gradient image; respectively processing using the Otsu threshold method to obtain the transverse gradient image corresponding to the initial transverse gradient image and the longitudinal gradient image corresponding to the initial longitudinal gradient image; The linear enhancement parameter acquisition method comprises: The linear enhancement parameters include a first linear enhancement parameter and a second linear enhancement parameter; The average grayscale value in the face area is used as the overall brightness, and the average grayscale value difference between all two adjacent pixels in the face area is used as the brightness change degree; the average overall brightness and the average brightness change degree of the historical face area in the smart door lock database are obtained; the difference between the average overall brightness and the overall brightness of the face area is used as the first linear enhancement parameter; the difference between the brightness change degree of the face area and the average brightness change degree is used as the second linear enhancement parameter; The image enhancement optimization of the face image of the current frame according to the linear enhancement parameters includes: The original grayscale value of the pixel point in the face area is multiplied by the second linear enhancement parameter and then added to the first linear enhancement parameter to obtain the enhanced grayscale value of each pixel point in the face area.
2. The method for optimizing facial image recognition for smart door locks according to claim 1, characterized in that: The distance acquisition method comprises: In the transverse gradient image, an average horizontal coordinate of each edge is obtained, and the difference between the average horizontal coordinates of the edges is used as the distance; In the longitudinal gradient image, the average longitudinal coordinate of each edge is obtained, and the difference between the average longitudinal coordinates of the edges is used as the distance.
3. The method for optimizing facial image recognition for smart door locks according to claim 1, characterized in that: The method for obtaining the lateral confidence comprises: Select four edges to arrange and combine to obtain the horizontal arrangement edge group, and use a horizontal combination confidence formula to obtain the horizontal combination confidence of the horizontal arrangement edge group. The horizontal combination confidence formula includes: in, is the horizontal combination confidence of the horizontally arranged edge group; , , , are respectively serial numbers of the four edges in the horizontally arranged edge group arranged in sequence in the horizontal order; For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between The maximum horizontal combined confidence of all the horizontally arranged edge groups corresponding to each edge is used as the horizontal confidence of the corresponding edge.
4. The method for optimizing facial image recognition for smart door locks according to claim 3 is characterized in that: The method for obtaining the longitudinal confidence comprises: Select six edges to arrange and combine to obtain the vertically arranged edge group, and use a vertical combination confidence formula to obtain the vertical combination confidence of the vertically arranged edge group. The vertical combination confidence formula includes: in, is the vertical combined confidence of the vertically arranged edge groups; , , , , , are respectively serial numbers of the six edges in the longitudinally arranged edge group arranged in sequence in longitudinal order; For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between For the edge and edge The distance between The maximum longitudinal combined confidence of all the longitudinally arranged edge groups corresponding to each edge is used as the longitudinal confidence of the corresponding edge.
5. The method for optimizing facial image recognition for smart door locks according to claim 1, characterized in that: The obtaining of a comprehensive gradient image according to the transverse gradient image and the longitudinal gradient image comprises: Respectively obtaining a horizontal edge binary image corresponding to the horizontal gradient image and a vertical edge binary image corresponding to the vertical gradient image; merging the horizontal edge binary image and the vertical edge binary image to obtain an edge binary image; A comprehensive gradient value is obtained according to the gradient value of each pixel point in the horizontal gradient image and the vertical gradient image, and the pixel value of each edge pixel point in the edge binary image is set to the comprehensive gradient value to obtain the comprehensive gradient image.
6. The method for optimizing facial image recognition for smart door locks according to claim 5, characterized in that: The step of obtaining the response degree of each edge according to the gradient information on the edge in the comprehensive gradient image comprises: The comprehensive gradient value of each edge pixel in the comprehensive gradient image is normalized to obtain an initial response degree; and the average initial response degree of the edge pixels on each edge in the comprehensive gradient image is used as the response degree.
7. The method for optimizing facial image recognition for smart door locks according to claim 1, characterized in that: The method for obtaining the face edge confidence comprises: Obtain the average horizontal confidence of all corresponding edges in the horizontal gradient image for each edge in the integrated gradient image; obtain the average vertical confidence of all corresponding edges in the vertical gradient image for each edge in the integrated gradient image; and take the average value among the average horizontal confidence, the average vertical confidence and the response degree as the face edge confidence.
