Face recognition method and system and intelligent door lock
By employing techniques such as grayscale conversion, Fourier transform, and depthwise separable convolution processing, the problem of face recognition in smart door locks under complex lighting and non-frontal poses has been solved, improving recognition accuracy and robustness, reducing false recognition rate, and adapting to the real-time performance and environmental adaptability of smart door locks.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- SHENZHEN AIJIA WULIAN TECHNOLOGY CO LTD
- Filing Date
- 2026-03-04
- Publication Date
- 2026-05-19
AI Technical Summary
Existing smart door lock facial recognition technology has a low recognition rate under complex lighting conditions and is not robust enough to non-frontal poses, failing to effectively capture spatial relationship changes in the facial features, resulting in a high false recognition rate.
By employing grayscale conversion and histogram equalization, Fourier transform and high-frequency component amplification, depthwise separable convolution processing, spatial location correlation matrix quantization, and multi-frame stable matching mechanism, and through adaptive edge enhancement filter and depthwise separable convolution structure, edge texture is restored and the relationship between facial features under side profile pose is captured.
It improves the accuracy and robustness of facial recognition, reduces the false recognition rate, adapts to the real-time and environmental adaptability requirements of smart door locks, and meets the computing power constraints of embedded devices.
Smart Images

Figure CN122067293A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of facial recognition technology, and in particular to a facial recognition method and system, and a smart door lock. Background Technology
[0002] As a crucial entry point for smart homes, smart door locks present numerous challenges for the application of facial recognition technology. In real-world scenarios, motion blur caused by a user rapidly approaching the lock can severely reduce the edge sharpness of facial images. Traditional spatial sharpening methods struggle to precisely control the enhancement frequency band, easily introducing noise or over-enhancing.
[0003] Existing facial recognition methods show a significant drop in recognition rate under complex lighting conditions such as outdoor backlighting and low light at night. At the same time, when users naturally approach the door lock, their faces often turn to the side at a degree of ±30 degrees. Traditional convolutional neural networks are not robust enough to non-frontal poses and cannot effectively capture changes in the spatial relationship of facial features. Summary of the Invention
[0004] The main objective of this invention is to provide a face recognition method and system, and a smart door lock. This invention effectively reduces the false recognition rate, ensures door lock security, and meets the real-time performance, security, and environmental adaptability requirements of smart door locks.
[0005] To achieve the above objectives, the present invention provides a face recognition method, comprising the following steps: A first face image is acquired, and grayscale conversion and histogram equalization are performed on the first face image to obtain a second face image; The second face image is subjected to two-dimensional discrete Fourier transform and high-frequency component amplification to obtain a third face image, and the third face image is subjected to convolution processing to obtain a first feature map. Calculate the correlation matrix between spatial locations in the first feature map, and perform feature aggregation based on the correlation matrix to obtain the second feature map; The second feature map is subjected to feature encoding to obtain a face feature vector; The cosine similarity between the face feature vector and the pre-stored authorized user feature vector is calculated, and the cosine similarity is compared with a target threshold. When the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, an unlock signal is output.
[0006] Optionally, in a first implementation of the first aspect of the present invention, the step of acquiring a first face image and performing grayscale conversion and histogram equalization on the first face image to obtain a second face image includes: The first face image is captured by the camera in the smart door lock, and the face region is detected and located in the first face image, and the face rectangular region is cropped. The rectangular area of the face is scaled to a preset standard size to obtain a color image of the face; The red, green and blue channels of the face color image are weighted and summed according to preset weighting coefficients and then merged into a single channel to obtain a single-channel face grayscale image. The number of pixels at each gray level in the single-channel grayscale face image is counted, the cumulative distribution function is calculated, and the original grayscale value is mapped to the new grayscale value to complete the grayscale redistribution, thus obtaining the second face image.
[0007] Optionally, in a second implementation of the first aspect of the present invention, the step of performing a two-dimensional discrete Fourier transform and high-frequency component amplification on the second face image to obtain a third face image, and then performing convolution processing on the third face image to obtain a first feature map, includes: A two-dimensional discrete Fourier transform is performed on the gray values of each pixel in the second face image to obtain a first spectral distribution, which includes a low-frequency overall brightness component and a high-frequency edge texture component. The cutoff frequency is calculated based on the lens focal length and sensor size of the camera, and an adaptive edge enhancement filter is constructed by combining a preset enhancement coefficient and an exponential parameter. The adaptive edge enhancement filter is then multiplied point-by-point with the first spectral distribution to amplify the high-frequency edge texture components, thereby obtaining a second spectral distribution. Perform an inverse Fourier transform on the second spectral distribution to obtain the third face image; The third face image is subjected to depthwise separable convolution processing to obtain the first feature map.
[0008] Optionally, in a third implementation of the first aspect of the present invention, the step of calculating the cutoff frequency based on the lens focal length and sensor size of the camera, constructing an adaptive edge enhancement filter by combining a preset enhancement coefficient and an exponential parameter, and performing a point-by-point multiplication operation between the adaptive edge enhancement filter and the first spectral distribution to amplify the high-frequency edge texture component to obtain a second spectral distribution includes: Based on the lens focal length and sensor size of the camera, the cutoff frequency is obtained by calculating the square root of the sum of the squares of the width and height of the second face image and then dividing it by a preset frequency division coefficient. Based on the cutoff frequency, preset enhancement coefficient, and exponential parameter, the power ratio of the frequency distance between each frequency coordinate point in the first spectrum distribution is calculated as the enhancement weight to obtain an adaptive edge enhancement filter. The enhancement weights at each frequency point in the adaptive edge enhancement filter are multiplied point by point with the complex values at the corresponding frequency points in the first spectral distribution to amplify the high-frequency edge texture components, thus obtaining the second spectral distribution.
[0009] Optionally, in a fourth implementation of the first aspect of the present invention, the step of performing depthwise separable convolution processing on the third face image to obtain a first feature map includes: Independent spatial convolution operations are performed on each channel of the third face image using a depth convolution kernel of a preset size, and downsampling is performed according to a preset stride to obtain the depth convolution feature map of each channel. A predetermined number of pointwise convolutional kernels are used to perform a cross-channel weighted summation linear combination operation on the depth convolutional feature maps of each channel to obtain local texture feature maps, and the local texture feature maps are used as the first feature maps for encoding the face edge direction and texture pattern.
[0010] Optionally, in a fifth implementation of the first aspect of the present invention, the step of calculating the correlation matrix between spatial locations in the first feature map and performing feature aggregation based on the correlation matrix to obtain a second feature map includes: Flatten the spatial dimension of the first feature map into a one-dimensional sequence and retain the feature vectors corresponding to each spatial position to obtain the feature vector sequence. The correlation matrix is obtained by performing a dot product operation on the feature vectors at any two spatial locations in the feature vector sequence, dividing by the square root of the feature dimension as a scaling factor, calculating the exponential function value for each spatial location, normalizing and summing the results. Based on the association weights of each spatial location in the association matrix, the corresponding feature vectors in the feature vector sequence are weighted, summed, and aggregated to reshape them into a three-dimensional tensor form, thus obtaining the second feature map.
[0011] Optionally, in a sixth implementation of the first aspect of the present invention, the step of performing feature encoding on the second feature map to obtain a face feature vector includes: Perform local convolution operation on the second feature map to obtain local detail features; perform max pooling followed by convolution operation on the second feature map to obtain medium receptive field features; and perform adaptive global average pooling operation on the second feature map to obtain global structural features. The intermediate receptive field features and the global structural features are respectively upsampled to the same spatial size as the local detail features and then concatenated along the channel dimension to obtain the face feature vector.
[0012] Optionally, in the seventh implementation of the first aspect of the present invention, the step of calculating the cosine similarity between the face feature vector and the pre-stored authorized user feature vector, and comparing the cosine similarity with a target threshold, and outputting an unlock signal when the cosine similarity of N consecutive frames all exceeds the target threshold and matches the same user, includes: Traverse the pre-stored authorized user feature vectors and perform an inner product operation with the face feature vectors to obtain the cosine similarity of each authorized user; The maximum similarity value and the corresponding user index are selected from the cosine similarity of each authorized user, and the maximum similarity value is compared with the target threshold to determine whether the current frame matches the authorized user, thereby obtaining the current frame matching information containing the matching result and the user index; The matching information of the current frame is stored in a circular buffer of length N, and it is determined whether N consecutive frames are all successfully matched and have the same user index. When the conditions are met, a high-level signal is sent to the door lock motor control module to trigger the unlocking action.
[0013] The present invention also provides a face recognition system, comprising: The acquisition module is used to acquire a first face image and perform grayscale conversion and histogram equalization on the first face image to obtain a second face image; The transformation module is used to perform a two-dimensional discrete Fourier transform and high-frequency component amplification on the second face image to obtain a third face image, and to perform convolution processing on the third face image to obtain a first feature map. The association module is used to calculate the association matrix between spatial locations in the first feature map, and perform feature aggregation based on the association matrix to obtain the second feature map; The feature encoding module is used to encode the features of the second feature map to obtain a face feature vector; The output module is used to calculate the cosine similarity between the face feature vector and the pre-stored authorized user feature vector, and compare the cosine similarity with a target threshold. When the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, an unlock signal is output.
[0014] The present invention also provides a smart door lock, which is used to implement the steps of the method described in any of the above-mentioned embodiments.
[0015] In summary, this invention employs a Fourier frequency-domain adaptive edge enhancement filter to precisely compensate for motion blur and illumination degradation issues in smart door lock scenarios. It selectively amplifies high-frequency components in the frequency domain and dynamically calculates the cutoff frequency based on lens parameters. Compared to traditional spatial domain sharpening methods, this approach precisely controls the enhancement frequency band to avoid noise amplification and effectively restores edge degradation caused by rapid user approach. A depthwise separable convolutional structure is used to decompose standard convolution into depthwise convolution and pointwise convolution, significantly reducing the number of parameters and computational complexity while retaining feature extraction capabilities, meeting the computational constraints of embedded devices. By constructing a spatial location correlation matrix to quantify the semantic relevance of feature vectors at each location, global context-aware modeling is achieved, enabling the network to capture long-distance spatial dependencies of facial features under side-face poses and exhibiting robustness to ±30-degree deviations. A multi-scale feature fusion strategy integrates local details, intermediate receptive fields, and global structural information, generating semantically rich feature representations through weighted concatenation. The multi-frame stable matching mechanism requires that consecutive frames identify the same user and that the similarity exceeds a threshold, which effectively reduces the false recognition rate and ensures door lock security, adapting to the real-time, security and environmental adaptability requirements of smart door locks. Attached Figure Description
[0016] Figure 1 This is a schematic diagram of the steps of a face recognition method in one embodiment of the present invention; Figure 2 This is a structural block diagram of a face recognition system according to an embodiment of the present invention.
[0017] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0018] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0019] Reference Figure 1 This embodiment provides a face recognition method, including the following steps: S1, acquire the first face image, and perform grayscale conversion and histogram equalization on the first face image to obtain the second face image; The system utilizes a high-resolution fixed-focus camera integrated into the smart lock. Upon detecting a user entering a pre-defined sensing range, the image acquisition module is activated, continuously capturing the first face image at a rate of 30 frames per second. Based on a preset face detection and localization algorithm, the acquired face image is analyzed to identify the face region within the image. The face region boundaries are then marked with rectangular bounding boxes, achieving face region localization. The image processing module crops the original image based on the face bounding boxes, extracting a sub-image containing only the face region and performing a scaling transformation to uniformly scale it to a preset standard resolution size, such as 128×128 pixels. Pixel matrices for the red, green, and blue color channels are extracted from the standard-sized color face image. The three channels are then weighted and summed according to the weighting coefficients of human eye perception of brightness across different wavelengths. The weights for the red, green, and blue channels are set to 0.299, 0.587, and 0.114, respectively. The resulting grayscale image retains the texture details and contrast variations of the original color image to the greatest extent possible, resulting in a single-channel grayscale face image. Histogram equalization is performed on a single-channel grayscale face image. Statistical analysis is conducted on the pixel grayscale levels throughout the image to construct a histogram from grayscale level 0 to 255. The number of pixels corresponding to each grayscale value is calculated, and the frequency distribution of each grayscale level is accumulated to form the cumulative distribution function of the grayscale image. Then, according to the normalization mapping rule, each original grayscale value is mapped to a new grayscale value through the cumulative distribution function, completing the brightness redistribution process of the image. This enhances the image contrast and reduces grayscale deviation caused by uneven local illumination, resulting in a second face image.
[0020] S2, perform two-dimensional discrete Fourier transform and high-frequency component amplification on the second face image to obtain the third face image, and perform convolution processing on the third face image to obtain the first feature map; Specifically, a two-dimensional discrete Fourier transform is performed on the grayscale values of each pixel in the second face image to convert the image from the spatial domain to the frequency domain, generating a first spectral distribution map. This spectrum map decomposes the image signal into low-frequency and high-frequency components. The low-frequency component is concentrated in the center of the spectrum, corresponding to the overall brightness information and contour structure of the image, while the high-frequency component is distributed in the peripheral region of the spectrum, mainly carrying information about edges, textures, and detail changes in the image. The corresponding frequency cutoff value is calculated based on the lens focal length and CMOS image sensor size parameters in the actual camera hardware parameters. The cutoff frequency is used to define the high-frequency enhancement domain, focusing the enhancement operation on the frequency range corresponding to the facial features. A frequency-domain adaptive edge enhancement filter is constructed using a set of enhancement coefficients and exponential adjustment parameters optimally set experimentally. The filter forms a gain curve on the frequency coordinate plane that selectively enhances the high-frequency region and suppresses the low-frequency region, achieving frequency-selective modulation. The adaptive edge enhancement filter is then multiplied point-by-point with the first spectral distribution map, directly amplifying the high-frequency texture components in the frequency domain while keeping the low-frequency components essentially unchanged, generating a second spectral distribution map. A two-dimensional inverse Fourier transform is performed on the second spectral distribution map to restore the frequency domain image to the spatial domain image, resulting in the third face image. The third face image is then input into the first feature extraction stage of a lightweight neural network for depthwise separable convolution processing. The convolution structure consists of two parts: depthwise convolution and pointwise convolution. A 3×3 convolution kernel is used to independently perform spatial convolution operations on each channel of the image to extract edge directions and local texture features. Then, a 1×1 convolution kernel is used to perform linear combination along the channel dimension to achieve cross-channel feature fusion, outputting the first feature map.
[0021] S3, calculate the correlation matrix between spatial locations in the first feature map, and perform feature aggregation based on the correlation matrix to obtain the second feature map; It should be noted that the first feature map is flattened into a one-dimensional sequence according to its two-dimensional spatial structure. The local feature vectors at each spatial position (x, y) are arranged sequentially into a one-dimensional vector sequence of length M×N, where each vector element retains the original feature dimension d, forming a set of feature vectors with a total length of M×N and each dimension d. A dot product operation is performed on the feature vectors corresponding to each pair of positions i and j in the feature vector sequence. The dot product result serves as a preliminary measure of the similarity between positions i and j. The dot product result is divided by the square root of the feature dimension d as a scaling factor to obtain a numerically stable similarity score. After completing the scaled dot product calculation for all position pairs, the similarity score for each row corresponding to position i is taken as an exponential function and normalized within that row. That is, the softmax normalization function is used to ensure that the sum of the association weights of each position to all other positions is 1, forming an association matrix of dimension (M×N)×(M×N). Each row in the matrix represents the distribution of the association strength between the current spatial position and all other positions. Based on the weight distribution of the correlation matrix, a weighted summation operation is performed on the feature vectors at all positions in the original feature vector sequence. That is, for each position i, its feature vector is weighted and superimposed with the feature vectors at all other positions j according to the correlation weight, resulting in a new aggregated feature vector. The aggregated feature vector sequence is then reshaped into a three-dimensional tensor according to the original two-dimensional spatial structure, that is, restored to the feature map form with the same spatial distribution but incorporating information from the entire image, resulting in the second feature map.
[0022] S4, perform feature encoding on the second feature map to obtain the face feature vector; Specifically, a local convolution operation is performed on the second feature map. A standard convolution method with a kernel size of 3×3 and a stride of 1 is used to directly spatially filter the input feature map, extracting fine-grained features corresponding to areas such as the corners of the eyes, nostrils, and mouth, while maintaining the same spatial resolution as the original feature map, resulting in a local detail feature map. Simultaneously, to capture medium-scale structural information, such as the geometric relationships between the eyes and nose, and between the eyebrows, max pooling is first performed on the second feature map to compress it spatially, reducing the spatial resolution and increasing the receptive field coverage. Then, a convolution operation is applied to the pooled result to extract medium-scale feature patterns, resulting in a medium receptive field feature map. In the third path, an adaptive global average pooling operation is directly performed on the second feature map, compressing the two-dimensional feature map of each channel into a single value, forming a 1×1×C feature vector. The global structural feature map extracts the macroscopic semantic features of the entire face by summarizing the activation response values of all spatial locations, including the overall facial contour, illumination distribution trends, and compositional balance. Perform interpolation upsampling on the medium receptive field feature map to restore its spatial dimensions to match the local detail features. Figure 1To achieve this, for example, bilinear interpolation is used to upsample the 16×16 feature map to 32×32, while the global structural features are expanded into a 32×32×C tensor through copy broadcasting, ensuring that the three feature maps maintain spatial consistency. After spatial size matching, the local detail feature map, the intermediate receptive field feature map, and the global structural feature map are concatenated along the channel dimension to form a fused feature map with multiple channel dimensions. Global average pooling is then used to compress all spatial locations of this fused feature map, resulting in a unified-dimensional face feature vector.
[0023] S5 calculates the cosine similarity between the face feature vector and the pre-stored authorized user feature vector, and compares the cosine similarity with the target threshold. When the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, an unlock signal is output.
[0024] The process involves taking the facial feature vector identified in the current frame as input and sequentially iterating through all pre-stored sets of authorized user feature vectors in the Flash memory. Each user's feature vector in these sets has been normalized to a magnitude of 1, simplifying the cosine similarity calculation to a standard inner product operation. For each authorized user feature vector, a dot product operation is performed with the current frame's feature vector to obtain a set of cosine similarity values corresponding to each user, forming a similarity score sequence. The element with the highest similarity value from the similarity score sequence is selected as the candidate result for the most likely matching authorized user in the current frame, and its corresponding user index is recorded. The maximum similarity value is compared with a preset target threshold. If the similarity value equals or exceeds the threshold, the frame is considered to have successfully matched an authorized user, and the matching result is marked as true, while the current matched user index is recorded; otherwise, it is marked as an unmatched or invalid frame. The frame matching result and user index information are encapsulated as matching state units into the current frame matching information and written into a circular buffer of length N to record the continuous recognition status of the current and previous frames. As the recognition process progresses, the oldest data item in the buffer is continuously updated, retaining only the recognition results of the most recent N frames. When all matching flags in N consecutive frames in the buffer are true, and the corresponding user indices are completely identical (meaning all N frames have matched successfully and point to the same authorized user), the current user authentication is deemed valid and the recognition is stable. At this point, the control module triggers the GPIO interface to output a high-level signal and continuously outputs the high-level signal for a specified duration (e.g., 500 milliseconds) to drive the door lock motor to rotate and release the bolt, thus unlocking the door.
[0025] In one example, a first face image is acquired, and grayscale conversion and histogram equalization are performed on the first face image to obtain a second face image, including: The first face image is captured by the camera in the smart door lock, and the face region is detected and located in the first face image, and the face rectangular area is cropped. The rectangular area of the face is scaled to a preset standard size to obtain a color image of the face; The red, green and blue channels of a color face image are weighted and summed according to preset weighting coefficients and then merged into a single channel to obtain a single-channel grayscale face image. The number of pixels at each gray level in a single-channel grayscale face image is counted, the cumulative distribution function is calculated, and the original grayscale values are mapped to new grayscale values to complete the grayscale redistribution, thus obtaining the second face image.
[0026] In this example, a high-performance fixed-focus camera integrated into the smart lock system captures a first face image containing the user's face at a frequency of 30 frames per second after the user approaches the lock and enters a preset sensing range (e.g., 0.5 to 1.5 meters). The first face image has a typical color format and contains complete background information. The captured image is processed by a preset face detection algorithm. The algorithm is based on models such as convolutional neural networks, Haar features, or multi-task cascaded networks to locate and identify the face region in the image and output bounding box coordinates to describe the rectangular region where the face is located. Based on the bounding box, a cropping operation is performed on the original image to extract the rectangular region where the face is located, remove irrelevant information from the background, obtain the target feature region, and uniformly scale the target feature region image to a preset standard size, such as 128×128 pixels. Pixel matrices for the red, green, and blue channels of the scaled color face image are extracted separately. A weighted summation method is used to merge the RGB three channels into a single-channel grayscale image. Each channel is assigned a weight coefficient according to the human eye's sensitivity to different spectral brightness levels: the weight coefficient for the red channel is set to 0.299, for the green channel to 0.587, and for the blue channel to 0.114. After proportional weighting, a single-channel grayscale face image is obtained. Histogram equalization is performed on the grayscale image, and the number of pixels corresponding to each gray level (0 to 255) in the entire image is counted to construct a grayscale distribution histogram. Based on the grayscale distribution histogram, the cumulative probability distribution function for each gray level is calculated, and the number of pixels at each level is accumulated and normalized. Each original grayscale value is mapped to a new grayscale value according to the cumulative distribution function, making the pixel grayscale of the entire image more evenly distributed within the range of 0 to 255, achieving contrast enhancement and brightness balance, thus obtaining the second face image.
[0027] In one example, a two-dimensional discrete Fourier transform and high-frequency component amplification are performed on the second face image to obtain a third face image. The third face image is then convolved to obtain a first feature map, including: A two-dimensional discrete Fourier transform is performed on the gray values of each pixel in the second face image to obtain a first spectral distribution, which includes a low-frequency overall brightness component and a high-frequency edge texture component. The cutoff frequency is calculated based on the lens focal length and sensor size of the camera. An adaptive edge enhancement filter is constructed by combining the preset enhancement coefficient and exponential parameters. The adaptive edge enhancement filter is then multiplied point by point with the first spectral distribution to amplify the high-frequency edge texture components and obtain the second spectral distribution. The third face image is obtained by performing an inverse Fourier transform on the second spectral distribution; The third face image is subjected to depthwise separable convolution to obtain the first feature map.
[0028] In this example, the grayscale value of each pixel in the second face image is used as the input matrix. A two-dimensional discrete Fourier transform maps the entire image from the spatial domain to the frequency domain, yielding a first spectral distribution. The central region of the first spectral distribution primarily concentrates low-frequency components, corresponding to global information such as overall brightness and contour structure of the face image. The outer periphery of the spectrum represents high-frequency components, corresponding to local textures, microstructures, and edge details at locations such as the corners of the eyes, lip lines, and the edges of the nose. To enhance the response intensity of the high-frequency components in the frequency domain, the cutoff frequency is calculated based on the camera's imaging parameters. Specifically, the upper limit of the spatial resolution is calculated based on the lens's focal length and the diagonal size of the CMOS image sensor, resulting in the cutoff frequency value used to define the high-frequency starting interval for enhancement. Based on this, and combining enhancement coefficients and exponential parameters determined through empirical setting or simulation optimization, a frequency-selective adaptive edge enhancement filter is constructed. This filter exhibits frequency response characteristics of preserving the central low-frequency region, enhancing the edge high-frequency region, and providing a smooth transition in the transition region. The enhancement filter is multiplied pointwise with the first spectral distribution to perform directional amplification of the high-frequency components in the frequency domain image while preserving low-frequency information, generating a second spectral distribution. A two-dimensional inverse Fourier transform is applied to the second spectral distribution to restore it from the frequency domain back to the spatial domain, generating the enhanced third face image. This third face image is then input into a feature extraction module based on depthwise separable convolution. The feature extraction module applies spatial convolution operations to each channel to extract local texture information, and then uses 1×1 pointwise convolution to fuse information between channels, extracting a first feature map with high representational power while maintaining extremely low parameter count.
[0029] Before calculating the power ratio of the frequency distance between each frequency coordinate point in the first spectrum distribution based on the cutoff frequency, preset enhancement coefficient, and exponential parameter as the enhancement weight, the process includes motion blur detection and dynamic adjustment of the enhancement coefficient: The absolute value of the grayscale difference between adjacent pixels in the second face image is calculated along the horizontal and vertical directions, and the proportion of pixels with a value greater than a preset gradient threshold is counted to obtain horizontal edge sharpness index and vertical edge sharpness index; the weighted average of the horizontal and vertical edge sharpness indices is compared with a preset blur determination threshold; when the value is lower than the preset blur determination threshold, motion blur is determined to exist, and the sharpness deviation is calculated to obtain a motion blur degree quantization value; based on the motion blur degree quantization value, an enhancement coefficient adjustment factor is calculated through a piecewise linear mapping function, and the preset enhancement coefficient is multiplied by the enhancement coefficient adjustment factor to obtain an adaptive enhancement coefficient; simultaneously, the exponential parameter is adjusted according to the motion blur degree quantization value so that its value decreases as the blur degree increases to expand the enhancement frequency band range, resulting in an adaptive exponential parameter; the adaptive enhancement coefficient and adaptive exponential parameter replace the original preset enhancement coefficient and exponential parameter to construct an adaptive edge enhancement filter, so that the filter response characteristics are dynamically adjusted with the degree of motion blur.
[0030] In one example, the cutoff frequency is calculated based on the camera's lens focal length and sensor size. An adaptive edge enhancement filter is then constructed using preset enhancement coefficients and exponential parameters. This adaptive edge enhancement filter is then multiplied point-by-point with the first spectral distribution to amplify the high-frequency edge texture components, resulting in a second spectral distribution, including: Based on the lens focal length and sensor size of the camera, the cutoff frequency is obtained by calculating the square root of the sum of the squares of the width and height of the second face image and then dividing it by the preset frequency division coefficient. Based on the cutoff frequency, preset enhancement coefficient, and exponential parameter, the power ratio of the frequency distance between each frequency coordinate point in the first spectrum distribution is calculated as the enhancement weight to obtain an adaptive edge enhancement filter. The enhancement weights at each frequency point in the adaptive edge enhancement filter are multiplied point by point with the complex values at the corresponding frequency points in the first spectral distribution to amplify the high-frequency edge texture components, thus obtaining the second spectral distribution.
[0031] In this example, based on the lens focal length and sensor size parameters in the camera configuration, and combined with the spatial dimensions of the second face image (width and height), the diagonal length of the image plane is calculated in pixels. The maximum frequency amplitude range in the frequency domain is obtained by summing the squares of the image width and height and then taking the square root. The maximum frequency amplitude is divided by a preset frequency division coefficient, for example, a certain proportion of the image size, to obtain the cutoff frequency. The cutoff frequency defines the starting boundary of high-frequency enhancement in the spectrum, and the frequency domain region above the cutoff frequency is the main target for high-frequency information enhancement. Based on the cutoff frequency and the preset enhancement coefficient and exponential control parameters optimized from recognition performance experiments, the frequency distance (u,v) of each frequency coordinate point (u,v) in the spectrum is calculated, i.e., the Euclidean distance from that point to the center of the spectrum. The distance value is substituted into the power operation model to construct the frequency enhancement weight expression. The weight factor reflects the degree of deviation of the frequency coordinate from the cutoff frequency. The greater the deviation from the center, i.e., the higher the frequency, the larger the corresponding enhancement factor value, achieving selective enhancement of high-frequency components. The enhancement weights for all frequency points are calculated one by one as described above to form an adaptive edge enhancement filter, which exhibits a frequency response surface in the frequency domain characterized by low-frequency preservation, progressive high-frequency enhancement, and a smooth transition region. The adaptive edge enhancement filter is then multiplied point-by-point with the first spectral distribution map; that is, for each frequency coordinate point, its corresponding enhancement weight value is directly multiplied by the complex value of that point in the first spectral distribution. This directly amplifies the high-frequency texture components of the original image in the frequency domain, resulting in the second spectral distribution.
[0032] Before performing an inverse Fourier transform on the second spectral distribution to obtain the third face image, the process includes a virtual reconstruction and constraint optimization step based on complementary frequency-spatial dual-domain sparse frequency components: The reliability of the frequency components in the second spectral distribution is assessed; the ratio of the complex amplitude of each frequency point to the mean amplitude of its neighboring frequency points is calculated as a local contrast index; and the variance of each frequency point in the historical N-frame spectrum is calculated as a time stability index. Frequency points with local contrast indices below a preset contrast threshold or time stability indices above a preset variance threshold are marked as sparse observation frequency points with degradation or noise contamination. The remaining frequency points are marked as reliable observation frequency points, thus obtaining a frequency domain observation quality mask that distinguishes between sparse and reliable frequency regions. For frequency points marked as sparse observations, a frequency-spatial dual-domain complementary virtual reconstruction model is established to complete the degraded frequency components. First, local image patches corresponding to the frequency positions are extracted from the second face image in the spatial domain, and the spatial gradient features and texture statistical features of these patches are calculated. Then, a frequency response pattern that best matches these spatial features is queried using a pre-established frequency-spatial mapping database. This database is constructed by simultaneously acquiring spatial image patch features and corresponding frequency components from 5000 high-quality face samples. The obtained frequency response patterns are used to virtually estimate the complex values of the sparse observation frequency points. These virtually estimated frequency components serve as supplementary observation information provided by the frequency-domain virtual sensor, resulting in a model that includes the true frequency components. A hybrid spectral representation of reliable frequency observations and virtual reconstructed frequency observations is proposed. Constraint optimization is applied to the virtual reconstructed frequency components in the hybrid spectral representation to ensure the rationality of the reconstruction. Three constraints are established: spectral continuity constraint (the amplitude gradient between the virtual reconstructed frequency point and its neighboring reliable frequency points does not exceed a preset smoothing threshold); spatial consistency constraint (the mean square error between the spatial features corresponding to the virtual reconstructed frequency and the actual observed spatial image patch features is minimized); and temporal stability constraint (the variation amplitude of the virtual reconstructed frequency between adjacent frames is limited). A non-convex optimization problem is constructed with the objective of minimizing the weighted sum of the deviations between the virtual reconstructed frequency and the constraints. The Lagrange multiplier method is used to transform the constraints into penalty terms, and the gradient is iterated. The descent algorithm optimizes the complex real and imaginary parts of the virtual reconstructed frequency to bring the objective function to converge, resulting in optimized virtual frequency components that satisfy multi-domain constraints. These optimized virtual frequency components are then filled into the corresponding sparse observation frequency points in the second spectral distribution, while the original reliable observation frequency points are preserved. Fusion weights are assigned to the virtual and real frequency points based on the frequency domain observation quality mask. The weights of the virtual frequency points are set based on their constraint optimization objective function values; the smaller the objective function value, the higher the reconstruction quality and the greater the weight. Through weighted fusion, a complete spectral distribution enhanced by frequency domain observation is obtained. Compared to the original second spectral distribution, the frequency components in the sparse and degraded regions are virtually reconstructed and completed, resulting in the final spectral distribution enhanced by the dual-domain virtual sensor.Through theoretical derivation and experimental verification, reasonable value ranges for key parameters were determined. Specifically, the preset contrast threshold ranged from 0.3 to 0.7 to identify significantly degraded frequency points; the preset variance threshold ranged from 1.5 to 2.5 times the standard deviation of frequency amplitude to detect unstable frequency components; the sample size of the frequency-spatial mapping database ranged from 3000 to 8000 samples to ensure mapping accuracy; the smoothing threshold for spectral continuity constraints ranged from 0.5 to 1.5 times the mean of the neighborhood frequency gradient; and the initial value of the Lagrange multiplier ranged from 0.1 to 1.0 and was adaptively adjusted during iteration. The optimal configuration is determined by evaluating the spectral reconstruction quality on a test set containing motion blur and noise contamination. The final spectral distribution enhanced by dual-domain virtual sensors is reconstructed into a spatial image using inverse Fourier transform, virtually completing the image in sparse observation areas of the frequency domain. Compared to directly performing an inverse transform on the original second spectral distribution, this method guides frequency domain virtual reconstruction with spatial information. It leverages the complementary relationship between the frequency and spatial domains, providing virtual sensor supplementation from the other domain when observations in one domain are insufficient. This allows for the recovery of relatively complete spectral information even when motion blur causes high-frequency attenuation or noise contamination causes frequency distortion.
[0033] In one example, a depthwise separable convolution is performed on a third face image to obtain a first feature map, including: Independent spatial convolution operations are performed on each channel of the third face image using a depth convolution kernel of a preset size, and downsampling is performed according to a preset stride to obtain the depth convolution feature map of each channel. A predetermined number of pointwise convolutional kernels are used to perform a cross-channel weighted summation linear combination operation on the depth convolutional feature maps of each channel to obtain local texture feature maps, which are then used as the first feature maps for encoding the direction of face edges and texture patterns.
[0034] In this example, a pre-defined depthwise convolution kernel is used to perform independent spatial convolution operations on each channel of the third-person face image. The depthwise convolution kernel is 3×3 pixels in size, and its scope is limited to the two-dimensional spatial dimension and does not involve the channel dimension. This allows each convolution kernel to perceive the gray-level changes of the local neighborhood of the feature map only in its own channel, thus effectively responding to the directional edges and texture configurations of areas such as eyelids, bridge of the nose, and corners of the mouth in the image. During the depthwise convolution operation, the image is downsampled according to the set stride parameter. For example, if the stride is set to 2, the spatial size of the feature map will be downsampled from 128×128 to 64×64 to compress the data volume, expand the receptive field, and enhance the extraction strength of local structural patterns, outputting the depthwise convolution feature map corresponding to each channel. Pointwise convolution operation is introduced, using a 1×1 convolution kernel to process the depthwise convolution feature map. With the spatial coordinates kept fixed, the feature response values of all channels at each position are linearly weighted and summed, compressing and combining the information of multiple channels into a high-dimensional semantic expression in a single feature channel. The number of pointwise convolutional kernels is set according to the required number of output channels. For example, setting 64 1×1 convolutional kernels will result in 64 channels for the output feature map. Through the mechanism of combining depthwise convolution and pointwise convolution, a local texture feature map with a spatial dimension of 64×64 and 64 channels is generated. This local texture feature map is then used as the first feature map input to the context modeling module.
[0035] Before weighted summation and aggregation of corresponding feature vectors in the feature vector sequence based on the association weights of each spatial location in the association matrix, the process includes a pose deviation detection and adaptive enhancement step for the association matrix weight region: For each spatial location feature vector in the first feature map, the projection intensity on preset left face direction vector, frontal face direction vector, and right face direction vector is calculated, and the direction with the largest projection intensity is selected as the dominant pose direction to obtain the face pose deviation category; based on the three projection intensity values corresponding to the face pose deviation category, the ratio of the largest projection intensity to the second largest projection intensity is calculated as the pose confidence, and the pose confidence is mapped to a deviation angle estimate using the arctangent function to obtain the pose deviation angle that quantifies the degree of face lateral deviation; based on the face pose deviation category, the pose deviation is determined on the first feature map... Visible and occluded region masks are defined, where the right half of the feature map corresponding to the left face category is the visible region, the left half of the feature map corresponding to the right face category is the visible region, and the entire image corresponding to the frontal category is the visible region, resulting in a binary mask that distinguishes between visible and occluded regions. The association weights corresponding to spatial locations belonging to the visible region in the association matrix are multiplied by a region enhancement factor greater than 1 to amplify them, while the association weights corresponding to spatial locations belonging to the occluded region are multiplied by a region suppression factor less than 1 to attenuate them. The adjusted association weights are then re-normalized to obtain a pose-adaptive association matrix. Based on the adjusted association weights at each spatial location in the pose-adaptive association matrix, the corresponding feature vectors in the feature vector sequence are weighted and aggregated, making the aggregation process more focused on the visible feature regions after pose shift.
[0036] In one example, the correlation matrix between spatial locations in the first feature map is calculated, and feature aggregation is performed based on the correlation matrix to obtain the second feature map, including: Flatten the spatial dimension of the first feature map into a one-dimensional sequence and retain the feature vectors corresponding to each spatial location to obtain the feature vector sequence. The correlation matrix is obtained by performing a dot product operation on the feature vectors at any two spatial locations in the feature vector sequence, dividing by the square root of the feature dimension as a scaling factor, calculating the exponential function value for each spatial location, normalizing and summing the results. Based on the association weights of each spatial location in the association matrix, the corresponding feature vectors in the feature vector sequence are weighted, summed, and aggregated to reshape them into a three-dimensional tensor form, thus obtaining the second feature map.
[0037] In this example, the two-dimensional spatial structure of the first feature map is flattened into a one-dimensional feature vector sequence. Assuming the spatial dimension of the first feature map is H×W and the channel dimension is C, the flattened sequence contains H×W feature vectors, each with dimension C. To construct the semantic association between positions, a dot product operation is performed on the feature vectors corresponding to any two positions i and j in the feature vector sequence. The dot product result is then divided by the square root of the feature dimension C to obtain a normalized similarity score. This normalization process prevents gradient explosion and numerical instability caused by dimensional expansion. After calculating the scaled dot product between all position pairs, an exponential function is performed on the scaled similarity score between each position and all other positions, and softmax normalization is applied. This yields a spatial position association matrix of size (H×W)×(H×W). Each element in the matrix represents the normalized feature similarity weight between the source and target positions, and the sum of the weights in each row is 1, thus achieving probabilistic modeling of the association weights of all adjacent positions. A global feature aggregation operation is performed based on the association matrix. Specifically, for each source location, the association weights between it and all target locations are used as weighting coefficients. A weighted summation operation is then performed on the feature vectors of all target locations, fusing the global semantic context into the representation of each location and outputting an enhanced global context feature vector sequence. The aggregated feature vector sequence is then reshaped according to the spatial dimension H×W of the original feature map, restoring it to a three-dimensional tensor form, thus forming the context-enhanced second feature map.
[0038] Before performing a cross-channel weighted summation linear combination operation on the depth convolution feature maps of each channel using a preset number of pointwise convolution kernels, the process includes a hybrid frequency-spatial adaptive channel enhancement and selective activation optimization step: The frequency domain energy distribution is calculated for each channel's depth convolution feature map of the edge enhancement image. After obtaining the spectrum of each channel through Fast Fourier Transform, the ratio of high-frequency energy proportion to low-frequency energy proportion is calculated. When the ratio is higher than a preset high-frequency dominance threshold, the channel is marked as an edge texture-dominant channel requiring active spatial domain enhancement processing; when the ratio is lower than a preset low-frequency dominance threshold, the channel is marked as an overall brightness-dominant channel requiring only passive pass-through. This yields the frequency domain energy characteristic labels for each channel. Active and passive channel assignment labels are used. For the edge texture dominant channel marked as active enhancement, additional spatial oriented gradient enhancement convolution operations are performed on its depth convolution feature map. Horizontal and vertical convolution kernels are used to extract directional edge information and then weighted and fused. This consumes additional computational resources but yields a more refined edge feature representation, resulting in the active enhancement channel feature map. For the overall brightness dominant channel marked as passive transfer, its depth convolution feature map is directly retained without additional processing to save computational energy, resulting in the passive transfer channel feature map. The active enhancement channel feature map and the passive transfer channel feature map are then recombine in the original channel order, and adaptive labels are assigned to each channel based on its frequency domain energy characteristics. Channel weight coefficients are used, where the weight coefficient of the edge texture-dominant channel is linearly mapped to a larger weight value based on its high-frequency energy proportion, and the weight coefficient of the overall brightness-dominant channel is mapped to a smaller weight value. The feature maps of each channel are multiplied by their corresponding weight coefficients and then concatenated to obtain a hybrid-enhanced multi-channel deep convolutional feature map. A non-convex optimization problem is established with the objective function of minimizing the computational energy consumption of the single-frame feature extraction stage, and with the dual constraints of recognition accuracy not being lower than a preset accuracy threshold and feature extraction time not exceeding a preset time limit. This optimization problem is decomposed into two sub-problems: an active channel number optimization sub-problem and a frequency domain energy threshold optimization sub-problem. An alternating iterative optimization algorithm is used to solve these sub-problems respectively: [The text abruptly ends here, likely due to an incomplete translation or a missing section.] When the dominant threshold and the preset low-frequency dominant threshold are used, the optimal number of active channels is determined by enumeration search to minimize energy consumption. When the number of active channels is fixed, the preset high-frequency dominant threshold and the preset low-frequency dominant threshold are adjusted by gradient descent to optimize the allocation strategy. This process is iterated until the objective function converges, resulting in the energy-efficient active and passive channel allocation strategy and frequency domain decision threshold. The reasonable range of key parameters is determined through theoretical analysis and experimental verification. The proportion of active enhancement channels to the total number of channels ranges from 15% to 40% to balance computational cost and feature quality. The preset high-frequency dominant threshold ranges from 1.5 to 3.0 (frequency-to-energy ratio), and the preset low-frequency dominant threshold ranges from 0.3 to 0.The frequency-energy ratio is 8. The number of directions of the active enhancement convolution kernel ranges from 2 to 4 to capture the main edge directions. The parameter range was determined through energy consumption-precision Pareto front analysis on 1000 sets of door lock scene images of different qualities. The multi-channel depth convolution feature map with hybrid enhancement is input into the subsequent pointwise convolution for cross-channel integration. This enables the depth-separable convolution process to achieve a frequency-domain guided hybrid enhancement strategy. Active computational enhancement is applied to key edge channels, while passive pass-through is used in redundant brightness channels, achieving an optimal trade-off between feature quality and computational energy consumption.
[0039] In one example, feature encoding is performed on the second feature map to obtain a face feature vector, including: Perform local convolution operation on the second feature map to obtain local detail features; perform max pooling followed by convolution operation on the second feature map to obtain medium receptive field features; and perform adaptive global average pooling operation on the second feature map to obtain global structural features. The intermediate receptive field features and global structural features are restored to the same spatial size as the local detail features by upsampling algorithm and then concatenated by channel dimension to obtain the face feature vector.
[0040] In this example, a local convolution operation is performed on the second feature map using a standard 3×3 convolution kernel. This performs fine-grained spatial filtering on the image without changing its spatial dimensions, resulting in a detailed feature response map with a pixel-level local neighborhood as the receptive field. The convolution kernel parameters are optimized during training to respond to highly discriminative local feature regions in the face image, such as eye corner texture, lip edges, and nose contours. The local detailed feature map output by this processing path has a complete spatial structure and high resolution. Simultaneously, in the second path, max pooling is first performed on the second feature map to compress the spatial dimension. A 2×2 window is used for downsampling, compressing the spatial size of the original feature map to half its original size, expanding the receptive field and improving the coverage of medium-scale regional structures. A convolution operation is then applied to the pooling result to extract medium-scale feature expressions of the relative structures between facial features, such as the symmetry between eyebrows and the vertical arrangement of eyes and nose. This results in a medium-scale receptive field feature map with a smaller spatial size but a wider semantic coverage. An adaptive global average pooling operation is performed on the second feature map through the third path, averaging the response values of all spatial locations within each channel and compressing them into a 1×1×C vector form. This yields macroscopic information representations of overall facial structure, contour layout, and illumination distribution. The global structural features possess strong pose invariance and overall consistency, making them suitable as a discrimination criterion at the whole-image level. After completing the three-path feature extraction, the intermediate receptive field feature map and the global structural feature map are restored to the same spatial dimensions as the local detail feature map. The intermediate receptive field feature map is proportionally restored to its original dimensions using bilinear interpolation upsampling, for example, from 16×16 to 32×32. The global structural features are expanded from single-point vectors into spatially uniform tensors through channel broadcast replication, ensuring their spatial dimensions match those of the local detail features. Figure 1 The local detail feature map, medium receptive field feature map, and global structural feature map are concatenated along the channel dimension to form a fused multi-scale feature map. Global average pooling is then performed on the fused feature map to compress the channel responses of all spatial locations into a vector representation of a uniform dimension, generating a face feature vector.
[0041] In one example, a cosine similarity is calculated between the facial feature vector and the pre-stored authorized user feature vector. This cosine similarity is then compared to a target threshold. When the cosine similarity exceeds the target threshold for N consecutive frames and matches the same user, an unlock signal is output, including: Traverse the pre-stored feature vectors of authorized users and perform an inner product operation with the face feature vectors to obtain the cosine similarity of each authorized user; Select the maximum similarity value and the corresponding user index from the cosine similarity of each authorized user, and compare the maximum similarity value with the target threshold to determine whether the current frame matches an authorized user, thus obtaining the current frame matching information containing the matching result and the user index; The matching information of the current frame is stored in a circular buffer of length N, and it is determined whether N consecutive frames are all successfully matched and have the same user index. When the conditions are met, a high-level signal is sent to the door lock motor control module to trigger the unlocking action.
[0042] In this example, after processing the face image of the current frame and fusing multi-scale features, a set of face feature vectors after L2 normalization is obtained. The vector dimensions are fixed, and the values are distributed on a unit sphere, providing a good foundation for similarity measurement. All authorized user feature vectors stored in non-volatile memory (such as a Flash chip) are sequentially traversed, with a pre-stored set of N vectors, each representing the face identity features of a registered user. The inner product operation is used to calculate the similarity between the face feature vector of the current frame and each authorized user feature vector. Since both are unit vectors, the inner product value is the cosine similarity, ranging from -1 to 1. After normalization, it can be converted into a real value between 0 and 1. After completing all traversal calculations, a set of face similarity values corresponding to each authorized user is obtained. The maximum similarity value and its corresponding user index are selected as the optimal matching result for the current frame recognition. The maximum similarity value is compared with a preset target threshold, which is determined by algorithm training and false recognition rate verification experiments, for example, set to 0.87. When the facial similarity value is greater than or equal to the target threshold, the current frame is considered a successful match, and the matching flag is recorded as true. Simultaneously, the matching user index for the current frame is recorded. If the similarity does not reach the threshold, the match is considered a failure, and the matching flag is false. The matching information, including the matching status and user index, is encapsulated into a structure and written into a circular buffer of length N. This buffer maintains the recognition results of the most recent N frames, overwriting the oldest data with each frame update to maintain the continuity and real-time nature of frame-level recognition information. After each recognition, it is checked whether all records in the buffer satisfy the condition of a true matching status and whether the corresponding user index is completely consistent. Only when N consecutive frames are successfully matched and the matched users remain consistent is the current user authentication confirmed, and the user is considered to have unlocking privileges. After this condition is met, a high-level signal is sent to the motor driver in the door lock control module. The high-level signal is maintained for a certain duration (e.g., 500 milliseconds) to drive the motor to rotate, thereby releasing the door lock mechanism and realizing the physical unlocking action.
[0043] Before calculating the cosine similarity between the face feature vector and the pre-stored authorized user feature vector, the process includes a feature vector stabilization and fusion step with multi-frame temporal consistency constraints: maintaining a feature vector temporal buffer queue of length M and storing the face feature vector of the current frame as the latest feature vector at the end of the queue; filling empty slots with zero vectors when the queue is not full, resulting in a temporal feature sequence containing feature vectors of the current frame and M-1 historical frames; calculating the cosine similarity of the feature vectors of adjacent frames in the temporal feature sequence as an inter-frame consistency measure, and assigning time weights to historical frames using an exponential decay function so that older frames have smaller weights, obtaining the temporal weighting coefficients of each historical frame; and performing a multiplication of the temporal weighting coefficients of each historical frame with the corresponding inter-frame consistency measure. The contribution weight of this frame to the fusion result is assigned, and the feature vectors of each frame in the temporal feature sequence are weighted, then normalized using the second norm to obtain a temporally stable face feature vector. The cosine similarity between the temporally stable face feature vector and the face feature vector of the current frame is calculated as a temporal consistency index. When the temporal consistency index is lower than a preset consistency threshold, it is determined that the current frame is abnormal. The weight of the temporally stable face feature vector is increased, the weight of the face feature vector of the current frame is decreased, and the feature vector is re-fused to obtain the final face feature vector optimized by temporal constraints. The final face feature vector is used as the face feature vector for subsequent similarity calculation with the pre-stored authorized user feature vector, so that the feature representation maintains stability in the temporal dimension and suppresses abnormal fluctuations in a single frame.
[0044] Reference Figure 2 This embodiment provides a face recognition system, including: Acquisition module 1 is used to acquire a first face image and perform grayscale conversion and histogram equalization on the first face image to obtain a second face image; Transformation module 2 is used to perform two-dimensional discrete Fourier transform and high-frequency component amplification on the second face image to obtain the third face image, and to perform convolution processing on the third face image to obtain the first feature map. The association module 3 is used to calculate the association matrix between spatial locations in the first feature map and perform feature aggregation based on the association matrix to obtain the second feature map; Feature encoding module 4 is used to encode the features of the second feature map to obtain the face feature vector; Output module 5 is used to calculate the cosine similarity between the face feature vector and the pre-stored authorized user feature vector, and compare the cosine similarity with the target threshold. When the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, an unlock signal is output.
[0045] In this embodiment, the specific implementation of each unit in the above system embodiment is described in the above method embodiment, and will not be repeated here.
[0046] An embodiment of the present invention also provides a smart door lock, which is used to implement the above method when performing operations.
[0047] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, system, article, or method that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, system, article, or method. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, system, article, or method that includes that element.
[0048] The above description is only a preferred embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A face recognition method, characterized in that, include: A first face image is acquired, and grayscale conversion and histogram equalization are performed on the first face image to obtain a second face image; The second face image is subjected to two-dimensional discrete Fourier transform and high-frequency component amplification to obtain a third face image, and the third face image is subjected to convolution processing to obtain a first feature map. Calculate the correlation matrix between spatial locations in the first feature map, and perform feature aggregation based on the correlation matrix to obtain the second feature map; The second feature map is subjected to feature encoding to obtain a face feature vector; The cosine similarity between the face feature vector and the pre-stored authorized user feature vector is calculated, and the cosine similarity is compared with a target threshold. When the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, an unlock signal is output.
2. The face recognition method according to claim 1, characterized in that, The process of acquiring a first face image and performing grayscale conversion and histogram equalization on the first face image to obtain a second face image includes: The first face image is captured by the camera in the smart door lock, and the face region is detected and located in the first face image, and the face rectangular region is cropped. The rectangular area of the face is scaled to a preset standard size to obtain a color image of the face; The red, green and blue channels of the face color image are weighted and summed according to preset weighting coefficients and then merged into a single channel to obtain a single-channel face grayscale image. The number of pixels at each gray level in the single-channel grayscale face image is counted, the cumulative distribution function is calculated, and the original grayscale value is mapped to the new grayscale value to complete the grayscale redistribution, thus obtaining the second face image.
3. The face recognition method according to claim 2, characterized in that, The process of performing a two-dimensional discrete Fourier transform and high-frequency component amplification on the second face image to obtain a third face image, and then performing convolution processing on the third face image to obtain a first feature map, includes: A two-dimensional discrete Fourier transform is performed on the gray values of each pixel in the second face image to obtain a first spectral distribution, which includes a low-frequency overall brightness component and a high-frequency edge texture component. The cutoff frequency is calculated based on the lens focal length and sensor size of the camera, and an adaptive edge enhancement filter is constructed by combining a preset enhancement coefficient and an exponential parameter. The adaptive edge enhancement filter is then multiplied point-by-point with the first spectral distribution to amplify the high-frequency edge texture components, thereby obtaining a second spectral distribution. Perform an inverse Fourier transform on the second spectral distribution to obtain the third face image; The third face image is subjected to depthwise separable convolution processing to obtain the first feature map.
4. The face recognition method according to claim 3, characterized in that, The process of calculating the cutoff frequency based on the lens focal length and sensor size of the camera, constructing an adaptive edge enhancement filter by combining a preset enhancement coefficient and exponential parameters, and then performing a point-by-point multiplication operation between the adaptive edge enhancement filter and the first spectral distribution to amplify the high-frequency edge texture components to obtain a second spectral distribution includes: Based on the lens focal length and sensor size of the camera, the cutoff frequency is obtained by calculating the square root of the sum of the squares of the width and height of the second face image and then dividing it by a preset frequency division coefficient. Based on the cutoff frequency, preset enhancement coefficient, and exponential parameter, the power ratio of the frequency distance between each frequency coordinate point in the first spectrum distribution is calculated as the enhancement weight to obtain an adaptive edge enhancement filter. The enhancement weights at each frequency point in the adaptive edge enhancement filter are multiplied point by point with the complex values at the corresponding frequency points in the first spectral distribution to amplify the high-frequency edge texture components, thus obtaining the second spectral distribution.
5. The face recognition method according to claim 4, characterized in that, The step of performing depthwise separable convolution processing on the third face image to obtain a first feature map includes: Independent spatial convolution operations are performed on each channel of the third face image using a depth convolution kernel of a preset size, and downsampling is performed according to a preset stride to obtain the depth convolution feature map of each channel. A predetermined number of pointwise convolutional kernels are used to perform a cross-channel weighted summation linear combination operation on the depth convolutional feature maps of each channel to obtain local texture feature maps, and the local texture feature maps are used as the first feature maps for encoding the face edge direction and texture pattern.
6. The face recognition method according to claim 1, characterized in that, The step of calculating the correlation matrix between spatial locations in the first feature map and performing feature aggregation based on the correlation matrix to obtain the second feature map includes: Flatten the spatial dimension of the first feature map into a one-dimensional sequence and retain the feature vectors corresponding to each spatial position to obtain the feature vector sequence. The correlation matrix is obtained by performing a dot product operation on the feature vectors at any two spatial locations in the feature vector sequence, dividing by the square root of the feature dimension as a scaling factor, calculating the exponential function value for each spatial location, normalizing and summing the results. Based on the association weights of each spatial location in the association matrix, the corresponding feature vectors in the feature vector sequence are weighted, summed, and aggregated to reshape them into a three-dimensional tensor form, thus obtaining the second feature map.
7. The face recognition method according to claim 1, characterized in that, The step of encoding the second feature map to obtain a face feature vector includes: Perform local convolution operation on the second feature map to obtain local detail features; perform max pooling followed by convolution operation on the second feature map to obtain medium receptive field features; and perform adaptive global average pooling operation on the second feature map to obtain global structural features. The intermediate receptive field features and the global structural features are respectively upsampled to the same spatial size as the local detail features and then concatenated along the channel dimension to obtain the face feature vector.
8. The face recognition method according to claim 1, characterized in that, The step of calculating the cosine similarity between the facial feature vector and the pre-stored authorized user feature vector, and comparing the cosine similarity with a target threshold, and outputting an unlock signal when the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, includes: Traverse the pre-stored authorized user feature vectors and perform an inner product operation with the face feature vectors to obtain the cosine similarity of each authorized user; The maximum similarity value and the corresponding user index are selected from the cosine similarity of each authorized user, and the maximum similarity value is compared with the target threshold to determine whether the current frame matches the authorized user, thereby obtaining the current frame matching information containing the matching result and the user index; The matching information of the current frame is stored in a circular buffer of length N, and it is determined whether N consecutive frames are all successfully matched and have the same user index. When the conditions are met, a high-level signal is sent to the door lock motor control module to trigger the unlocking action.
9. A face recognition system, characterized in that, The steps for implementing the face recognition method according to any one of claims 1 to 8 include: The acquisition module is used to acquire a first face image and perform grayscale conversion and histogram equalization on the first face image to obtain a second face image; The transformation module is used to perform a two-dimensional discrete Fourier transform and high-frequency component amplification on the second face image to obtain a third face image, and to perform convolution processing on the third face image to obtain a first feature map. The association module is used to calculate the association matrix between spatial locations in the first feature map, and perform feature aggregation based on the association matrix to obtain the second feature map; The feature encoding module is used to encode the features of the second feature map to obtain a face feature vector; The output module is used to calculate the cosine similarity between the face feature vector and the pre-stored authorized user feature vector, and compare the cosine similarity with a target threshold. When the cosine similarity of N consecutive frames exceeds the target threshold and matches the same user, an unlock signal is output.
10. A smart door lock, characterized in that, The smart door lock is used to implement the steps of the face recognition method according to any one of claims 1 to 8.