A method and system for face detection based on a work card

By combining spatial domain attention enhancement processing and multi-task inference computing networks with video stream data, the problems of background interference and misjudgment in ID badge face detection are solved, the accuracy of ID badge regional feature extraction and wearing compliance judgment is improved, and a complete detection log is generated.

CN122116446APending Publication Date: 2026-05-29ANHUI YUANZE INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
ANHUI YUANZE INTELLIGENT TECH CO LTD
Filing Date
2026-03-24
Publication Date
2026-05-29

AI Technical Summary

Technical Problem

Existing face detection technology for employee badges cannot simultaneously generate a joint feature vector of the face pose angle and the badge location coordinates. Furthermore, it frequently misjudges in complex background environments and cannot effectively suppress the influence of background interference pixels, resulting in inaccurate judgment of wearing compliance.

Method used

By performing spatial domain attention enhancement processing on video stream data, the optical features of the nameplate area are amplified and background interference pixels are suppressed. A multi-task inference computing network is used to simultaneously perform face feature point localization and nameplate character region segmentation, triggering a state inversion mechanism to extract abnormal feature distribution from the intermediate layer feature map and generate structured detection logs.

Benefits of technology

It improves the accuracy of feature extraction of the employee badge area, reduces interference from the background environment, ensures the feature differentiation between the face area and the employee badge area, makes the output of wearing compliance judgment more accurate, and improves the information integrity of the detection log and the abnormal tracing path.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122116446A_ABST
    Figure CN122116446A_ABST
Patent Text Reader

Abstract

The present application relates to the technical field of intelligent video monitoring detection, in particular to a kind of based on the method and system for face detection of work card, comprising: obtaining the video stream data under target monitoring scene, the spatial domain attention enhancement processing is executed to each frame image, the optical feature of work card area is enlarged, and background environment interference pixel is inhibited.Processed image is input into multi-task inference calculation network, face feature point positioning and work card character area segmentation are simultaneously executed, and the joint feature vector containing face pose angle and work card position coordinate is output.The spatial offset of work card relative to face is calculated and the compliance of wearing is judged, and if the offset exceeds the range, state inversion mechanism is triggered, and abnormal feature distribution is extracted from network middle layer feature map, and the structured detection log containing time stamp, personnel identity mark and compliance state code is generated.The method can improve the purity of work card feature extraction, realize the feature tracing of misjudgment inducement, and optimize the accuracy and record integrity of work card wearing detection.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of intelligent video surveillance detection technology, and in particular to a method and system for face detection based on employee badges. Background Technology

[0002] Current employee badge face detection technologies employ separate face detection and badge recognition modules, with image preprocessing using generic image processing methods and lacking spatial domain attention enhancement for the badge area. The detection networks are mostly single-task structures, sequentially performing face feature point localization and badge character region segmentation, failing to simultaneously generate a joint feature vector containing face pose angles and badge position coordinates. Compliance assessment relies solely on the final detection coordinate data. When compliance issues arise, only basic state record information is generated, without extracting or analyzing feature data from the intermediate layers of the neural network.

[0003] Existing general image preprocessing methods cannot specifically amplify the optical features of the badge area. Interfering pixels in the background environment continuously affect the detection process, reducing the accuracy of badge area feature extraction. The step-by-step processing method of single-task networks causes spatial data matching deviations between the face and badge areas, resulting in errors in the calculation of the spatial offset of the badge relative to the face, and frequent misjudgments of wearing compliance. After a misjudgment occurs, it is impossible to obtain the abnormal feature distribution that caused the misjudgment from the intermediate layer feature maps of the multi-task inference computing network. The detection log can only record basic status and identification information, lacking feature-based data for tracing the source of the abnormal judgment.

[0004] This invention requires spatial domain attention enhancement processing for each frame of the video stream to amplify the optical features of the nameplate area and suppress background interference pixels. A state inversion mechanism needs to be triggered when the spatial offset exceeds the compliance range to extract the abnormal feature distribution that leads to misjudgment from the feature map of the intermediate layer of the multi-task inference computing network. Summary of the Invention

[0005] The purpose of this invention is to address the shortcomings of existing technologies by proposing a face detection method and system based on employee badges.

[0006] To achieve the above objectives, the present invention adopts the following technical solution: a face detection method based on employee badges, comprising: Acquire video stream data from the target monitoring scene, wherein the video stream data includes the face region and name tag region of the person to be detected; Spatial domain attention enhancement processing is performed on each frame of the video stream data to amplify the optical features of the nameplate area and suppress interfering pixels in the background environment. The attention-enhanced image data is input into a multi-task inference computing network, which simultaneously performs two parallel tasks: face feature point localization and name tag character region segmentation, and outputs a joint feature vector containing face pose angles and name tag position coordinates. Based on the joint feature vector, the relative spatial offset of the badge area relative to the face area is calculated, and it is determined whether the relative spatial offset is within the preset wearing compliance range. If the relative spatial offset exceeds the wearing compliance range, a state inversion mechanism is triggered. The state inversion mechanism extracts the abnormal feature distribution that leads to misjudgment from the intermediate layer feature map of the multi-task inference computing network. Based on the aforementioned abnormal feature distribution, a structured detection log is generated that includes timestamps, personnel identification, and wearing compliance status codes.

[0007] As a further aspect of the present invention, spatial domain attention enhancement processing is performed on each frame of the video stream data to amplify the optical features of the nameplate area and suppress interfering pixels in the background environment, including: The video stream data is decoded into consecutive RGB format image frames; Using a preset HSV color space threshold range, highly saturated color blocks are filtered out in the panoramic image frame to initially locate the position of the nameplate area; Based on the initially locked position, a binary region of interest mask is generated, and the region of interest mask is logically ANDed with the original image frame to remove most of the irrelevant background pixels; A channel attention module is introduced to calculate the mean and variance of the three RGB channels within the region of interest, and to dynamically adjust the weight coefficients of each channel. The adjusted channel weights are applied to the original image frame to enhance the reflective texture of the nameplate surface and the skin texture of the face, resulting in the image data after the attention enhancement processing.

[0008] As a further aspect of the present invention, the image data processed by attention enhancement is input into a multi-task inference computing network. This network simultaneously performs two parallel tasks: facial feature point localization and employee badge character region segmentation, and outputs a joint feature vector containing facial pose angles and employee badge position coordinates, including: The image data after attention enhancement processing is fed into the backbone feature extraction network to extract shallow edge texture features and deep semantic abstract features; The shallow edge texture features are diverted to the facial landmark regression branch, which outputs a set of two-dimensional feature point coordinates in a standard face coordinate system. The deep semantic abstract features are diverted to the ID card character segmentation branch, which outputs a heat map containing the ID card outline boundary. The pitch angle, yaw angle, and roll angle are calculated by fitting the coordinates of the two-dimensional feature points and combined to form the face pose angle. Perform connected component analysis on the heatmap to determine the coordinates of the four vertices of the bounding rectangle of the work badge, and normalize them to the coordinates of the work badge position. The face pose angle and the work badge location coordinates are concatenated and encapsulated into the joint feature vector.

[0009] As a further aspect of the present invention, based on the joint feature vector, the relative spatial offset of the badge area relative to the face area is calculated, and it is determined whether the relative spatial offset is within a preset wearing compliance range, including: The coordinates of the nose tip of the face and the center point of the name tag are extracted from the joint feature vector; Calculate the pixel distance difference between the center point of the work badge and the tip of the nose of the face in the horizontal and vertical directions; The pixel distance difference is converted into an actual physical distance deviation, and perspective projection correction is performed in conjunction with the face pose angle. Define a compliant spherical region in three-dimensional space, the radius of which is determined by the standard size of the work badge; Determine whether the corrected physical distance deviation vector falls completely within the compliant sphere area; If it does not fall into the category, the current joint feature vector is marked as an anomalous sample, and the subsequent state inversion mechanism is activated.

[0010] As a further aspect of the present invention, if the relative spatial offset exceeds the wearing compliance range, a state inversion mechanism is triggered. This state inversion mechanism extracts the abnormal feature distribution that leads to misjudgment from the intermediate layer feature map of the multi-task inference computing network, including: The cross-modal interaction layer responsible for fusing facial features and ID card features in the multi-task inference computing network is located. Read the feature map output by the cross-modal interaction layer and divide it into several local receptive field windows; Calculate the deviation of the feature response value from the mean baseline value within each local receptive field window; Select several local receptive field windows with the highest deviation, and map their corresponding feature response values ​​back to the original image coordinate system to form the abnormal feature distribution; Analyze the gray-level histogram of the abnormal feature distribution to distinguish whether the feature weakening is due to uneven illumination or feature loss is due to occlusion.

[0011] As a further aspect of the present invention, based on the aforementioned abnormal feature distribution, a structured detection log is generated, including a timestamp, personnel identification, and a compliance status code for wearing the garment, comprising: The abnormal feature distribution is morphologically reconstructed to generate a defect mask map that highlights the abnormal area. The defect mask map is used to identify the specific location where the name tag is obscured or the face is deflected. The defect mask image and the joint feature vector are superimposed and fused to correct the current spatial offset calculation result, and the wearing status determination result after one correction is obtained. The corrected wearing status determination result is compared with the preset identity verification database to verify whether the work badge character information and the detected facial features belong to the same subject; Based on the comparison results, a structured detection log is generated, which includes a timestamp, personnel identification, and a compliance status code for wearing the garment.

[0012] As a further aspect of the present invention, the abnormal feature distribution is morphologically reconstructed to generate a defect mask image that highlights the abnormal region. The defect mask image is used to identify the specific location of name tag occlusion or face deflection, specifically including: Gaussian smoothing filtering is applied to the abnormal feature distribution to remove high-frequency noise points and retain low-frequency blocky abnormal regions; The small protrusions in the abnormal feature distribution are eliminated by opening operation, and the void area is filled by closing operation to obtain connected abnormal patches. An adaptive threshold segmentation algorithm is used to convert connected abnormal patches into a binary mask layer; The binarized mask layer is subjected to edge refinement processing to extract the contour lines; The outline lines are superimposed with red highlight blocks to generate a visual defect mask, which is then encoded into a data structure that can be used in subsequent steps.

[0013] As a further aspect of the present invention, the defect mask image and the joint feature vector are superimposed and fused to correct the current spatial offset calculation result, thereby obtaining a corrected wearing status determination result, specifically including: The defect mask image is convolutionally encoded to generate a set of mask feature vectors; Perform a dot product operation between the mask feature vector and the joint feature vector to obtain a scalar value representing the occlusion confidence. Based on the magnitude of the occlusion confidence, the weight of the nameplate location coordinates in the calculation of the offset is reduced proportionally. The geometric relationship calculation formula is re-applied, and the weighted data is used to perform a second spatial offset calculation. The result obtained from the second calculation is compared again with the compliant spherical area to output the final corrected wearing status determination result.

[0014] As a further aspect of the present invention, comparing the corrected wearing status determination result with a preset identity verification database to verify whether the employee badge character information and the detected facial features belong to the same subject specifically includes: The optical character recognition engine is invoked to perform a secondary scan on the employee badge area to extract the name string and number string on the employee badge; Concatenate the name string and the ID string to form a unique identity retrieval key value; A hash lookup is performed in the preset identity verification database to retrieve the baseline face feature template corresponding to the identity retrieval key value; The real-time detected facial features and the benchmark facial feature template are input into the similarity measurement model to calculate the cosine similarity score between the facial features and the benchmark facial feature template. Set a similarity threshold for successful identity verification, compare the cosine similarity score with the similarity threshold, and obtain the identity verification comparison result; Based on the comparison results, a structured detection log is generated, containing a timestamp, personnel identification, and a compliance status code for wearing the garment. Specifically, this includes: Read the system clock of the current video stream to obtain the capture timestamp in milliseconds; The search key value in the comparison result is determined as the person's identity identifier; Based on the corrected wearing status determination result, an integer form of the wearing compliance status code is mapped, where different integers represent compliance, left deviation, right deviation, obstruction, or no badge status. The timestamp, the personnel identification, the compliance status code for wearing the garment, and the current monitoring point number are packaged into a log record tuple; The log record tuples are appended to the log queue in the memory buffer, waiting for batch write to disk.

[0015] As a further aspect of the present invention, the present invention also includes a face detection system based on employee badges, the system including a memory, a processor, and a computer program stored in the memory and running on the processor, wherein when the processor executes the computer program, it implements the steps of the face detection method based on employee badges as described above.

[0016] Compared with the prior art, the advantages and positive effects of the present invention are as follows: Spatial domain attention enhancement processing is performed on each frame of the video stream data to amplify the optical features of the nameplate area and suppress interfering pixels in the background environment. The representation intensity of the optical features of the nameplate area in the image data is improved, the feature response values ​​of interfering pixels in the background environment are reduced, the feature distribution of the image data is concentrated in the nameplate area, the feature distinction between the face area and the nameplate area is maintained, the feature extraction accuracy of the nameplate area is not affected by redundant background pixels, the feature purity of the input data of the subsequent multi-task inference computing network is guaranteed, the initial data basis for face feature point localization and nameplate character region segmentation remains stable, the output accuracy of nameplate position coordinates and the calculation accuracy of face pose angle are synergistically guaranteed, the spatial correlation feature extraction process between the nameplate area and the face area is not affected by complex background environment, the feature processing logic of the image preprocessing stage is adapted to the detection requirements of the subsequent multi-task network, and the calculation premise of the nameplate relative to the face spatial offset remains stable.

[0017] When the relative spatial offset of the name tag area relative to the face area exceeds the preset compliance range, a state inversion mechanism is triggered. The abnormal feature distribution that leads to misjudgment is extracted from the intermediate layer feature map of the multi-task inference computing network. The specific distribution pattern of abnormal features can be directly obtained. The information composition of the detection log can incorporate the relevant representation parameters of abnormal features. The content dimension of the structured detection log is expanded. The feature-level causes of misjudgment can be directly recorded. The detection log can be completely associated with the intrinsic feature factors of the abnormal wearing compliance judgment. The extraction operation of abnormal feature distribution is directly connected to the intermediate layer data output of the multi-task inference computing network. The generation logic of the detection log can cover the feature tracing link of the judgment of abnormality. The combination of timestamp, personnel identification and wearing compliance status code can be combined with abnormal feature distribution to form a complete detection record. The abnormal tracing path of the detection process can be improved through the extraction operation of the intermediate layer feature map. The information completeness of the detection log can be adapted to the optimization needs of subsequent detection processes. Attached Figure Description

[0018] Figure 1 This is a flowchart of a face detection method based on employee badges as described in this invention; Figure 2 A flowchart illustrating parallel processing in a multi-task inference computation network; Figure 3 To compare the distribution of employee badge offset before and after correction; Figure 4 Line graph showing the morphological processing effect; Figure 5 Performance comparison curves for log writing methods. Detailed Implementation

[0019] 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.

[0020] In the description of this invention, it should be understood that the terms "length," "width," "upper," "lower," "front," "rear," "left," "right," "vertical," "horizontal," "top," "bottom," "inner," and "outer," etc., indicating orientation or positional relationships, are based on the orientation or positional relationships shown in the accompanying drawings and are only for the convenience of describing the invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, or be constructed and operated in a specific orientation, and therefore should not be construed as a limitation of the invention. Furthermore, in the description of this invention, "a plurality of" means two or more, unless otherwise explicitly specified.

[0021] See Figure 1 The system acquires video stream data from the target monitoring scene, which includes the face and name tag regions of the person to be detected. Each frame of the video stream undergoes spatial domain attention enhancement processing, which amplifies the optical features of the name tag region and suppresses interfering pixels from the background. The attention-enhanced image data is then input into a multi-task inference computing network, which simultaneously performs two parallel tasks: face feature point localization and name tag character region segmentation. The network outputs a joint feature vector containing the face pose angle and name tag position coordinates. Based on the joint feature vector, the relative spatial offset of the name tag region relative to the face region is calculated, and it is determined whether the relative spatial offset is within a preset compliance range. If the relative spatial offset exceeds the compliance range, a state inversion mechanism is triggered. This mechanism extracts the abnormal feature distribution that led to the misjudgment from the intermediate layer feature map of the multi-task inference computing network. Based on the abnormal feature distribution, a structured detection log containing a timestamp, personnel identification, and a compliance status code is generated.

[0022] In one embodiment of the present invention, in an example scenario, video stream data of the target monitoring scene is transmitted at a rate of 30 frames per second. The resolution of the video stream data is 1920x1080 pixels. The video stream data includes the face region and name tag region of the person to be detected. Spatial domain attention enhancement processing is performed on each frame of the video stream data to amplify the optical features of the name tag region and suppress interfering pixels in the background environment. In a specific implementation, the video stream data is decoded into continuous RGB format image frames. In the example scenario, each pixel of the decoded RGB format image frame contains intensity values ​​of the red, green, and blue channels. Using a preset HSV color space threshold range, color blocks with high saturation are filtered out in the panoramic image frame to initially locate the position of the name tag region. In some embodiments, the HSV color space threshold range is set to saturation S > 0.6 and lightness V > 0.3 to identify common high-saturation colors in the nameplate area. Based on the initially locked location, a binarized region of interest (ROI) mask is generated. A logical AND operation is performed between the ROI mask and the original image frame to remove most irrelevant background pixels. In data comparison, after the logical AND operation, the number of background pixels is significantly reduced, while the pixels in the nameplate and face areas remain intact. A channel attention module is introduced to calculate the mean and variance of the three RGB channels within the ROI, dynamically adjusting the weight coefficients of each channel. This channel attention module analyzes the statistical characteristics of each channel, enhancing channels sensitive to reflective textures on the nameplate surface and skin textures on the face. The adjusted channel weights are then applied to the original image frame to enhance the reflective textures on the nameplate surface and the skin textures on the face, resulting in image data after attention enhancement processing. In a specific implementation, the channel weight coefficients are calculated using the following formula:

[0023] in: `c` represents the weight coefficient of the `c`-th channel, `m` represents the mean of the `c`-th channel within the region of interest, `v` represents the variance of the `c`-th channel within the region of interest, and `c` takes values ​​from 1 to 3, corresponding to the red, green, and blue channels, respectively. `v` represents the summation index, used to iterate through the three channels: red, green, and blue. Let represent the mean of the j-th channel within the region of interest. Let represent the variance of the j-th channel within the region of interest.

[0024] In specific implementation, please refer to Figure 2The attention-enhanced image data is input into a multi-task inference computing network, which simultaneously performs two parallel tasks: facial landmark localization and name tag character region segmentation. The attention-enhanced image data is then fed into a backbone feature extraction network to extract shallow edge texture features and deep semantic abstract features. In some embodiments, the backbone feature extraction network adopts a ResNet-50 architecture. Shallow edge texture features are derived from the first few convolutional layers of the network, while deep semantic abstract features are derived from subsequent convolutional layers. The shallow edge texture features are then routed to a facial landmark regression branch, which outputs a set of two-dimensional feature point coordinates in a standard facial coordinate system. Optionally, the facial landmark regression branch outputs the coordinates of 68 feature points, covering the facial contour, eyes, nose, and mouth. The deep semantic abstract features are then diverted to the nameplate character segmentation branch. The nameplate character segmentation branch outputs a heatmap containing the nameplate outline boundary. Based on the two-dimensional feature point coordinates, the pitch angle, yaw angle, and roll angle are fitted and calculated, and combined to form the facial pose angle. In data comparison, the calculation accuracy of the facial pose angle is guaranteed. Connectivity analysis is performed on the heatmap to determine the coordinates of the four vertices of the nameplate's bounding rectangle, and these coordinates are normalized to the nameplate position coordinates.

[0025] In one embodiment of the present invention, the relative spatial offset of the nameplate region relative to the face region is calculated based on the joint feature vector. In an example scenario, the joint feature vector includes the face pose angle and nameplate position coordinates output from the multi-task inference computing network. The nameplate position coordinates are represented in a normalized form, and the face pose angle includes three components: pitch angle, yaw angle, and roll angle. The coordinates of the face nose tip and the nameplate center point are parsed from the joint feature vector. In some embodiments, the coordinates of the face nose tip are obtained from the output of the face keypoint regression branch through a predefined face keypoint index, and the coordinates of the nameplate center point are calculated by transforming the nameplate position coordinates. The pixel distance difference between the nameplate center point and the face nose tip in the horizontal and vertical directions is calculated. It can be understood that pixel distance difference is the original offset in two-dimensional image space. Converting pixel distance difference into actual physical distance deviation and combining it with facial pose angles for perspective projection correction is crucial. In practice, the calculation of physical distance deviation considers the camera's intrinsic and extrinsic parameters, setting a compliant spherical region in three-dimensional space. The radius of this compliant spherical region is determined by the standard size of the name tag. The system then checks whether the corrected physical distance deviation vector falls completely within this compliant spherical region. During data comparison, the compliant spherical region is set based on ergonomic data. If it does not fall within the compliant spherical region, the current joint feature vector is marked as an anomalous sample, and the subsequent state inversion mechanism is activated. In some embodiments, the radius of the compliant spherical region is set to 15 centimeters to cover the reasonable wearing position of the name tag within a range of ±15 centimeters in front of the chest. Marking it as an anomalous sample means that the detection result of that frame image is deemed not to conform to the wearing specifications.

[0026] In practical implementation, a state inversion mechanism is triggered. This mechanism extracts the abnormal feature distributions that lead to misjudgments from the intermediate layer feature maps of the multi-task inference computing network. It locates the cross-modal interaction layer in the multi-task inference computing network responsible for fusing facial features and ID card features. In the example scenario, the cross-modal interaction layer is a specific network layer within the multi-task inference computing network, and its output feature map contains the fused feature information. The feature map output by the cross-modal interaction layer is read and divided into several local receptive field windows. The deviation of the feature response value within each local receptive field window from the average baseline value is calculated. Optionally, the deviation is obtained by calculating the Euclidean distance between the feature response value and the average baseline value. Several local receptive field windows with the highest deviation are selected, and their corresponding feature response values ​​are mapped back to the original image coordinate system, forming an abnormal feature distribution. In data comparison, the mapping back to the original image coordinate system is achieved through deconvolution. The gray-level histogram of the abnormal feature distribution is analyzed to distinguish whether feature weakening is due to uneven lighting or feature loss due to occlusion. It is understandable that the analysis of grayscale histograms is based on statistical characteristics, and the extraction process of the state inversion mechanism is represented by the following formula:

[0027] in: This represents the deviation of the feature response value of the k-th local receptive field window from the average baseline value. This represents the feature response value at the i-th position in the k-th local receptive field window. This represents the average baseline value at position i, and N represents the total number of feature positions within the local receptive field window. In one embodiment of the present invention, a structured detection log containing timestamps, personnel identification, and wearing compliance status codes is generated based on the abnormal feature distribution. In the example scenario, the abnormal feature distribution is extracted from the intermediate layer feature map of the multi-task inference computing network by a state inversion mechanism. Morphological reconstruction is performed on the abnormal feature distribution to generate a defect mask map that highlights the abnormal areas. The defect mask map is used to identify the specific location of the nameplate occlusion or face deflection. In some embodiments, the morphological reconstruction operations include dilation, erosion, and contour extraction. The defect mask map is superimposed and fused with the joint feature vector to correct the current spatial offset calculation result, resulting in a corrected wearing status determination result. It can be understood that the superimposition and fusion process combines the geometric information of the spatial offset calculation with the abnormal area information of the defect mask map. The corrected wearing status determination result is compared with a preset identity verification database to verify whether the nameplate character information and the detected facial features belong to the same subject. In the data comparison, the identity verification database stores the nameplate information of authorized personnel and the corresponding facial feature templates. Based on the comparison results, a structured detection log containing a timestamp, personnel identification, and wearing compliance status code is generated. In specific implementation, the timestamp is obtained from the system clock, the personnel identification is retrieved from the identity verification database, and the wearing compliance status code is mapped to a predefined integer code based on the corrected wearing status judgment result.

[0028] In practice, the morphological reconstruction of abnormal feature distributions involves performing a series of image processing operations to generate a defect mask. The size of the defect mask is the same as the size of the original input image frame, and each pixel is identified as either a normal or abnormal region. The formula for superimposing and fusing the defect mask with the joint feature vector is expressed as:

[0029] in: This represents the corrected joint eigenvector. This represents the original joint feature vector. This represents the normalized defect mask image. This represents element-wise multiplication. This represents the fusion coefficient.

[0030] In some embodiments, the normalized defect mask image The value range is between 0 and 1, where 1 represents a completely abnormal region and 0 represents a normal region. (The fusion coefficient is...) The value is set to 0.5 based on experience. It can be understood that the above formula corrects the spatial offset calculation result by reducing the weight of the feature vector components corresponding to the abnormal region. The correction process recalculates the physical distance deviation vector using the weighted feature vector and compares it with the compliant spherical region, outputting the corrected wearing status judgment result. Optionally, the corrected wearing status judgment result includes categories such as "compliant," "left offset," "right offset," "upper offset," "lower offset," or "occlusion." When comparing the corrected wearing status judgment result with the preset identity verification database, the optical character recognition module is called to extract the character information of the work badge area, and the extracted character information is matched with the information recorded in the database. In the example scenario, the identity verification database adopts a relational database structure, using the work badge number as the primary key index of the corresponding face feature template. The matching process calculates the similarity between the real-time face features and the template features in the database. The structured detection log generated based on the comparison result contains fixed fields.

[0031] See Figure 3 In the spatial offset correction stage of ID card face detection, the comparison of the ID card offset distribution before and after correction intuitively reflects the algorithm's correction efficiency. From the box plot distribution characteristics, the box range and extreme values ​​of the original horizontal and vertical offsets are significantly larger than the corresponding dimensions after correction: the interquartile range of the original horizontal offset is approximately 20 pixels, with an extreme value range covering -20 to 20 pixels; the interquartile range of the corrected horizontal offset is compressed to approximately 12 pixels, with the extreme value range narrowing to -18 to 17 pixels; the interquartile range of the original vertical offset is approximately 14 pixels, with an extreme value range of -15 to 15 pixels; the interquartile range of the corrected vertical offset is further compressed to approximately 10 pixels, with the extreme value range narrowing to -14 to 14 pixels. This convergence characteristic indicates that by superimposing and fusing the defect mask image and the joint feature vector, the spatial offset of the nameplate area relative to the face area is significantly reduced: the median is consistently close to 0 pixels, indicating that the central trend of the offset after correction is closer to the ideal position of the nameplate. The synchronous contraction of the box height and the extreme value range verifies the algorithm's ability to suppress extreme offset samples, effectively weakening the interference of abnormal factors such as uneven lighting, face deflection, or nameplate occlusion on the offset calculation, and providing a more robust feature basis for subsequent compliance determination.

[0032] In one embodiment of the present invention, morphological reconstruction is performed on the abnormal feature distribution to generate a defect mask map that highlights the abnormal areas. The defect mask map is used to identify the specific locations of name tag occlusion or face deflection. The specific process includes performing Gaussian smoothing filtering on the abnormal feature distribution to remove high-frequency noise points and retain low-frequency blocky abnormal areas. Opening operations are used to eliminate small protrusions in the abnormal feature distribution, and closing operations are used to fill in the empty areas to obtain connected abnormal patches. An adaptive threshold segmentation algorithm is used to convert the connected abnormal patches into a binary mask layer. Edge refinement processing is performed on the binary mask layer to extract the contour lines. The contour lines are superimposed with red highlight blocks to generate a visualized defect mask map, which is then encoded into a data structure that can be called by subsequent steps. In the example scenario, the abnormal feature distribution is a single-channel grayscale image. Gaussian smoothing filtering uses a 5x5 Gaussian kernel to convolve the abnormal feature distribution. Opening and closing operations use 3x3 rectangular structuring elements. The adaptive threshold segmentation algorithm uses Otsu's method to determine the segmentation threshold. Edge thinning processing uses the Zhang-Suen thinning algorithm. The final generated defect mask image is stored in the form of a three-dimensional array containing three channels: red, green, and blue. The abnormal contour region has a value of 255 in the red channel and a value of 0 in the green and blue channels.

[0033] In specific implementation, the defect mask image and the joint feature vector are superimposed and fused to correct the current spatial offset calculation result, resulting in a corrected wearing status determination. The specific process includes convolutional encoding of the defect mask image to generate a set of mask feature vectors, and performing a dot product operation between the mask feature vectors and the joint feature vectors to obtain a scalar value representing the occlusion confidence. In some embodiments, the convolutional encoding uses a 1x1 convolution kernel to process the red channel of the defect mask image, generating a mask feature vector with the same dimension as the joint feature vector. The dot product operation calculates the inner product of the two vectors. Based on the magnitude of the occlusion confidence, the weight of the nameplate position coordinates in the offset calculation is reduced proportionally. The geometric relationship calculation formula is then re-invoked, and the weighted data is used for a second spatial offset calculation. It is understandable that the reduction in weighting means that when calculating the center point coordinates of the work badge, the coordinate values ​​from the defective area are given less confidence. The result obtained from the second calculation is compared with the compliant spherical area again, and the final corrected wearing status judgment result is output. In the data comparison, the consistency rate between the corrected judgment result and the manually labeled result is higher than that of the uncorrected judgment result.

[0034] In practice, the weight adjustment of the employee badge location coordinates is based on the occlusion confidence level. The relationship between the weight adjustment coefficient and the occlusion confidence level is shown in Table 1 below. The table shows the employee badge location coordinate weight coefficients corresponding to different occlusion confidence level intervals.

[0035] Table 1: Correspondence between Occlusion Confidence and Weighting Coefficients of Employee Badge Location Coordinates

[0036] In practical implementation, the weighting coefficients defined in the table above are used for the second spatial offset calculation, and the corrected center point coordinates of the work badge are obtained. From the original work badge location coordinates With weighting coefficients The calculation formula is as follows:

[0037] in: This indicates the coordinates of the center point of the corrected employee badge. This represents the coordinates of the nose tip of the face, extracted from the joint feature vector. This represents the coordinates of the original employee badge center point, extracted from the joint feature vector. This represents the weighting coefficient for the employee badge's location coordinates. In some embodiments, both the coordinates of the tip of the face's nose and the center point of the employee badge are represented by image pixel coordinates, and the employee badge's location coordinate weighting coefficient...

[0038] Based on the calculated occlusion confidence level in the table above, the coordinates of the nameplate center point are retrieved. Re-applying the geometric relationship calculation formula means using the corrected coordinates of the nameplate center point.

[0039] The pixel distance difference between the center point of the name tag and the tip of the face's nose is recalculated and converted into a physical distance deviation vector. Optionally, the geometric relationship calculation formula involves camera model and coordinate transformation. The calculated physical distance deviation vector is compared with a preset compliance sphere area. If the physical distance deviation vector falls within the compliance sphere area, the output judgment result is "wearing in compliance". If it does not fall within the sphere area, the output is "left deviation", "right deviation", "upward deviation" or "downward deviation" based on the direction of the deviation vector. If the occlusion confidence is greater than 0.8 and the physical distance deviation vector does not fall within the compliance sphere area, the output judgment result is "occlusion".

[0040] See Figure 4In the morphological reconstruction process of defect mask generation, the optimization effects of noise suppression and abnormal region connectivity can be intuitively quantified using a dual-index line graph. Specifically, using noise ratio and abnormal region connectivity as the core evaluation indicators, the entire processing efficiency from the original image to edge refinement is fully presented: In the original image stage, the noise ratio is as high as approximately 18.5%, and the abnormal region connectivity is only 65%, reflecting the presence of a large number of high-frequency noise points and fragmented abnormal patches in the initial feature field. In the Gaussian filtering stage, through 5×5 Gaussian kernel smoothing, the noise ratio is significantly reduced to approximately 4.2%, while the abnormal region connectivity is increased to approximately 78%, achieving a balance between noise suppression and basic texture preservation. In the opening operation stage, small protrusion noise is further eliminated, reducing the noise ratio to approximately 2.1% and increasing the abnormal region connectivity to approximately 89%, effectively removing interfering small feature responses. In the closing operation stage, the internal holes of abnormal patches are filled, the noise ratio is slightly reduced to approximately 1.8%, and the abnormal region connectivity jumps to approximately 95%, completing the complete connectivity of the abnormal region. The threshold segmentation stage transforms connected anomalous patches into binary masks, further reducing the noise percentage to approximately 0.5% and increasing the connectivity of anomalous regions to approximately 98%, providing a clean binary foundation for subsequent contour extraction. The edge refinement stage extracts contour lines using the Zhang-Suen algorithm, stabilizing the noise percentage at approximately 0.3% and achieving approximately 99% connectivity in anomalous regions, ultimately realizing accurate visualization and structured encoding of anomalous region contours. The process employs progressive morphological operations to continuously reduce the noise percentage while simultaneously improving the connectivity of anomalous regions, providing a reliable feature foundation for the subsequent fusion and correction of defect masks and joint feature vectors.

[0041] In one embodiment of the present invention, identity verification and structured log generation involve comparing the corrected wearing status determination result with a preset identity verification database to verify whether the employee badge character information and the detected facial features belong to the same subject. Specifically, this includes calling an optical character recognition engine to perform a secondary scan of the employee badge area and extracting the name string and number string from the employee badge. The name string and number string are concatenated into a unique identity retrieval key value. A hash lookup is performed in the preset identity verification database to retrieve the baseline facial feature template corresponding to the identity retrieval key value. In a specific implementation, the format of the identity retrieval key value is "name_number". The preset identity verification database is stored in a hash table structure, with the key being the identity retrieval key value and the value being the corresponding baseline facial feature template vector. The real-time detected facial features and the baseline facial feature template are input into a similarity measurement model to calculate the cosine similarity score between the facial features and the baseline facial feature template. A similarity threshold for successful identity verification is set, and the relationship between the cosine similarity score and the similarity threshold is compared to obtain the identity verification comparison result. In the example scenario, the similarity measurement model calculates the cosine similarity between two feature vectors. The similarity threshold for successful identity verification is set to 0.85. When the cosine similarity score is greater than or equal to 0.85, they are determined to be the same entity; when the cosine similarity score is less than 0.85, they are determined to be different entities.

[0042] In practice, based on the comparison results, a structured detection log is generated, containing a timestamp, personnel identification, and a compliance status code for wearing the badge. This includes reading the system clock of the current video stream to obtain the millisecond acquisition timestamp, and identifying the personnel identification as the retrieval key value from the comparison results. Based on the corrected wearing status determination result, an integer-form compliance status code is mapped, where different integers represent compliance, left deviation, right deviation, obstruction, or no badge status. The timestamp, personnel identification, compliance status code, and the current monitoring point number are packaged into a log record tuple, which is then appended to the log queue in the memory buffer, awaiting batch disk write. In some embodiments, the system clock is obtained by calling the operating system's API, and the timestamp format is "YYYY-MM-DDHH:MM:SS.sss". The personnel identification is the identity retrieval key-value string extracted from the work badge area and concatenated. The monitoring point number is a unique string identifier configured during system initialization. Log record tuples are accumulated in the memory buffer. When a predetermined number is accumulated or a predetermined time interval is reached, the log record tuples are written to persistent storage in batches.

[0043] In practical implementation, the cosine similarity score The calculation formula is:

[0044] in: This represents the cosine similarity score between the detected facial features and the baseline facial feature template. This represents the real-time detected facial feature vector. This represents the baseline facial feature template vector retrieved from the identity verification database. This represents the dot product operation of vectors. Representing vectors The length of the mold, Representing vectors The modulus length. In some embodiments, the face feature vector detected in real time. Compared with the baseline face feature template vector Both are 512-dimensional floating-point vectors, extracted by a face recognition model, with cosine similarity scores. The value of cosine similarity ranges from -1 to 1, with a score closer to 1 indicating higher similarity. Cosine similarity measures the difference in direction between two feature vectors and is insensitive to the absolute length of the vectors. This helps reduce the impact of changes in lighting. A similarity threshold of 0.85 is set for successful authentication. When the cosine similarity score is greater than or equal to 0.85, the comparison result is "authentication passed"; when the cosine similarity score is less than 0.85, the comparison result is "authentication failed".

[0045] In practice, the mapping of the wearing compliance status code is based on the corrected wearing status judgment result. The correspondence between the wearing compliance status code and the judgment result is predefined. For example, when the corrected wearing status judgment result is "compliant", the mapped wearing compliance status code is integer 0; when the judgment result is "left bias", the mapped wearing compliance status code is integer 1; when the judgment result is "right bias", the mapped wearing compliance status code is integer 2; when the judgment result is "obstruction", the mapped wearing compliance status code is integer 3; and when the judgment result is "no badge", the mapped wearing compliance status code is integer 4. Optionally, in cases of failed authentication, the personnel identification field is recorded as the identity retrieval key value extracted from the work badge area. However, the compliance status code may be marked as a special exception code, such as the integer 9. The log record tuple packaging operation encapsulates the timestamp, personnel identification, compliance status code, and monitoring point number into an ordered data structure. In the example scenario, the log record tuple is temporarily stored in a memory buffer as a comma-separated string. The memory buffer is a first-in-first-out queue structure. When the number of records in the queue reaches 1000 or every 60 seconds, a batch write operation is triggered, writing all log records in the buffer to a disk file or database. In data comparison, the log recording method using a buffer queue and batch write to disk reduces frequent input / output operations to the storage system and improves the overall system throughput compared to writing each record in real time.

[0046] See Figure 5 In the performance comparison of log writing methods, the time difference between batch write to disk and real-time write strategies shows a significant non-linear variation with the increase of batch size. Specifically, the time for batch write to disk (solid line) increases slowly and linearly with the increase of batch size, reaching only about 5 seconds when the batch size is 1500 records. This reflects the dilution effect of batch aggregation on storage I / O operations, effectively reducing the average write overhead of a single log record by reducing the frequency of random disk access and merging write requests. The time for real-time write (solid line) increases sharply and linearly with the increase of batch size, reaching nearly 17.5 seconds when the batch size is 1500 records. This is essentially due to the independent disk synchronous I / O operation triggered by each log record. As the data volume increases, the frequent disk seek and flush operations cause a sharp drop in system throughput. The performance gap (filled area) continues to widen as the batch size increases. When the batch size is 1500 records, the real-time write time is about 3.5 times that of the batch disk write time, which directly verifies the performance advantage of the buffer queue + batch disk write strategy in high-concurrency log scenarios. This design transforms high-frequency small-granularity IO into low-frequency large-granularity IO by using memory temporary storage and batch disk flushing, which significantly improves the overall system throughput and resource utilization.

[0047] The above are merely preferred embodiments of the present invention and are not intended to limit the present invention in any other way. Any person skilled in the art may make changes or modifications to the above-disclosed technical content to create equivalent embodiments that can be applied to other fields. However, any simple modifications, equivalent changes, and modifications made to the above embodiments based on the technical essence of the present invention without departing from the scope of the present invention shall still fall within the protection scope of the present invention.

Claims

1. A face detection method based on employee ID cards, characterized in that, include: Acquire video stream data from the target monitoring scene, wherein the video stream data includes the face region and name tag region of the person to be detected; Spatial domain attention enhancement processing is performed on each frame of the video stream data to amplify the optical features of the nameplate area and suppress interfering pixels in the background environment. The attention-enhanced image data is input into a multi-task inference computing network, which simultaneously performs two parallel tasks: face feature point localization and name tag character region segmentation, and outputs a joint feature vector containing face pose angles and name tag position coordinates. Based on the joint feature vector, the relative spatial offset of the badge area relative to the face area is calculated, and it is determined whether the relative spatial offset is within the preset wearing compliance range. If the relative spatial offset exceeds the wearing compliance range, a state inversion mechanism is triggered. The state inversion mechanism extracts the abnormal feature distribution that leads to misjudgment from the intermediate layer feature map of the multi-task inference computing network. Based on the aforementioned abnormal feature distribution, a structured detection log is generated that includes timestamps, personnel identification, and wearing compliance status codes.

2. The face detection method based on employee badge as described in claim 1, characterized in that, Spatial domain attention enhancement processing is performed on each frame of the video stream data to amplify the optical features of the nameplate area and suppress interfering pixels in the background environment, including: The video stream data is decoded into consecutive RGB format image frames; Using a preset HSV color space threshold range, highly saturated color blocks are filtered out in the panoramic image frame to initially locate the position of the nameplate area; Based on the initially locked position, a binary region of interest mask is generated, and the region of interest mask is logically ANDed with the original image frame to remove most of the irrelevant background pixels; A channel attention module is introduced to calculate the mean and variance of the three RGB channels within the region of interest, and to dynamically adjust the weight coefficients of each channel. The adjusted channel weights are applied to the original image frame to enhance the reflective texture of the nameplate surface and the skin texture of the face, resulting in the image data after the attention enhancement processing.

3. The face detection method based on employee badge as described in claim 1, characterized in that, The attention-enhanced image data is input into a multi-task inference computing network. This network simultaneously performs two parallel tasks: facial feature point localization and nameplate character region segmentation. It outputs a joint feature vector containing facial pose angles and nameplate position coordinates, including: The image data after attention enhancement processing is fed into the backbone feature extraction network to extract shallow edge texture features and deep semantic abstract features; The shallow edge texture features are diverted to the facial landmark regression branch, which outputs a set of two-dimensional feature point coordinates in a standard face coordinate system. The deep semantic abstract features are diverted to the ID card character segmentation branch, which outputs a heat map containing the ID card outline boundary. The pitch angle, yaw angle, and roll angle are calculated by fitting the coordinates of the two-dimensional feature points and combined to form the face pose angle. Perform connected component analysis on the heatmap to determine the coordinates of the four vertices of the bounding rectangle of the work badge, and normalize them to the coordinates of the work badge position. The face pose angle and the work badge location coordinates are concatenated and encapsulated into the joint feature vector.

4. The face detection method based on employee badge as described in claim 3, characterized in that, Based on the joint feature vector, the relative spatial offset of the badge area relative to the face area is calculated, and it is determined whether the relative spatial offset is within a preset compliance range for wearing the badge, including: The coordinates of the nose tip of the face and the center point of the name tag are extracted from the joint feature vector; Calculate the pixel distance difference between the center point of the work badge and the tip of the nose of the face in the horizontal and vertical directions; The pixel distance difference is converted into an actual physical distance deviation, and perspective projection correction is performed in conjunction with the face pose angle. Define a compliant spherical region in three-dimensional space, the radius of which is determined by the standard size of the work badge; Determine whether the corrected physical distance deviation vector falls completely within the compliant sphere area; If it does not fall into the category, the current joint feature vector is marked as an anomalous sample, and the subsequent state inversion mechanism is activated.

5. The face detection method based on employee badge as described in claim 4, characterized in that, If the relative spatial offset exceeds the wearing compliance range, a state inversion mechanism is triggered. This mechanism extracts the abnormal feature distribution that leads to misjudgment from the intermediate layer feature map of the multi-task inference computing network, including: The cross-modal interaction layer responsible for fusing facial features and ID card features in the multi-task inference computing network is located. Read the feature map output by the cross-modal interaction layer and divide it into several local receptive field windows; Calculate the deviation of the feature response value from the mean baseline value within each local receptive field window; Select several local receptive field windows with the highest deviation, and map their corresponding feature response values ​​back to the original image coordinate system to form the abnormal feature distribution; Analyze the gray-level histogram of the abnormal feature distribution to distinguish whether the feature weakening is due to uneven illumination or feature loss is due to occlusion.

6. The face detection method based on employee badge as described in claim 1, characterized in that, Based on the aforementioned abnormal feature distribution, a structured detection log is generated, containing timestamps, personnel identification, and compliance status codes for wearing clothing, including: The abnormal feature distribution is morphologically reconstructed to generate a defect mask map that highlights the abnormal area. The defect mask map is used to identify the specific location where the name tag is obscured or the face is deflected. The defect mask image and the joint feature vector are superimposed and fused to correct the current spatial offset calculation result, and the wearing status determination result after one correction is obtained. The corrected wearing status determination result is compared with the preset identity verification database to verify whether the work badge character information and the detected facial features belong to the same subject; Based on the comparison results, a structured detection log is generated, which includes a timestamp, personnel identification, and a compliance status code for wearing the garment.

7. The face detection method based on employee badge as described in claim 6, characterized in that, Morphological reconstruction is performed on the distribution of the abnormal features to generate a defect mask map that highlights the abnormal areas. The defect mask map is used to identify the specific locations where name tags are obscured or faces are deflected, specifically including: Gaussian smoothing filtering is applied to the abnormal feature distribution to remove high-frequency noise points and retain low-frequency blocky abnormal regions; The small protrusions in the abnormal feature distribution are eliminated by opening operation, and the void area is filled by closing operation to obtain connected abnormal patches. An adaptive threshold segmentation algorithm is used to convert connected abnormal patches into a binary mask layer; The binarized mask layer is subjected to edge refinement processing to extract the contour lines; The outline lines are superimposed with red highlight blocks to generate a visual defect mask, which is then encoded into a data structure that can be used in subsequent steps.

8. The face detection method based on employee badge as described in claim 6, characterized in that, The defect mask image and the joint feature vector are superimposed and fused to correct the current spatial offset calculation result, resulting in a corrected wearing status determination result, specifically including: The defect mask image is convolutionally encoded to generate a set of mask feature vectors; Perform a dot product operation between the mask feature vector and the joint feature vector to obtain a scalar value representing the occlusion confidence. Based on the magnitude of the occlusion confidence, the weight of the nameplate location coordinates in the calculation of the offset is reduced proportionally. The geometric relationship calculation formula is re-applied, and the weighted data is used to perform a second spatial offset calculation. The result obtained from the second calculation is compared again with the compliant spherical area to output the final corrected wearing status determination result.

9. The face detection method based on employee badge as described in claim 6, characterized in that, The step of comparing the corrected wearing status determination result with a preset identity verification database to verify whether the employee badge character information and the detected facial features belong to the same subject specifically includes: The optical character recognition engine is invoked to perform a secondary scan on the employee badge area to extract the name string and number string on the employee badge; Concatenate the name string and the ID string to form a unique identity retrieval key value; A hash lookup is performed in the preset identity verification database to retrieve the baseline face feature template corresponding to the identity retrieval key value; The real-time detected facial features and the benchmark facial feature template are input into the similarity measurement model to calculate the cosine similarity score between the facial features and the benchmark facial feature template. Set a similarity threshold for successful identity verification, compare the cosine similarity score with the similarity threshold, and obtain the identity verification comparison result; Based on the comparison results, a structured detection log is generated, containing a timestamp, personnel identification, and a compliance status code for wearing the garment. Specifically, this includes: Read the system clock of the current video stream to obtain the capture timestamp in milliseconds; The search key value in the comparison result is determined as the person's identity identifier; Based on the corrected wearing status determination result, an integer form of the wearing compliance status code is mapped, where different integers represent compliance, left deviation, right deviation, obstruction, or no badge status. The timestamp, the personnel identification, the compliance status code for wearing the garment, and the current monitoring point number are packaged into a log record tuple; The log record tuples are appended to the log queue in the memory buffer, waiting for batch write to disk.

10. A face detection system based on employee badges, comprising a memory, a processor, and a computer program stored in the memory and running on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the face detection method based on employee badge as described in any one of claims 1 to 9.