Safety helmet wearing detection method in construction scene, equipment and medium
By building the YOLOX object detection model, extracting image features, generating anchor boxes, and performing feature point positioning and denoising processing, the robustness and accuracy of safety helmet wear detection in complex detection environments are solved, and rapid automatic identification and Improved safety management efficiency.
Patent Information
- Application Number
- CN202411550270.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-01
- Publication Date
- 2025-02-25
AI Technical Summary
In complex detection environments, existing safety helmet wear detection methods have problems such as poor robustness, poor accuracy in detection of small objects, and high demand for computing resources.
Construct the YOLOX object detection model, divide the image into a grid, build a sliding window to extract the feature information in the grid image, generate an anchor box, and obtain the amplitude of each direction of the anchor box through the descriptor, and locate and filter feature points. Eliminate stitching gaps and denoising the image.
Improve the accuracy and robustness of detection, optimize the training process of the model, improve the generalization ability and processing speed of the model, realize the rapid automatic identification of whether workers at the construction site wear safety helmets, and improve the safety management efficiency. Reduce safety accidents caused by not wearing a safety helmet.
Smart Images

Figure CN119516578A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of image processing, and in particular to a method, device and medium for detecting the wearing of a safety helmet in a construction scene. Background Art
[0002] Construction sites are high-risk environments, and wearing helmets correctly is an effective measure to reduce head injuries. Image recognition technology can automatically monitor whether workers are wearing helmets in accordance with safety regulations, thereby improving the safety of the construction site. By automatically identifying whether all personnel on the construction site are wearing helmets correctly, violations can be discovered in a timely manner and measures can be taken to prevent accidents, thereby reducing the incidence of accidents on the construction site.
[0003] Currently, the image recognition methods for helmet wearing are mainly based on deep learning technology, especially convolutional neural network (CNN) and Transformer architecture. The following are some of the main methods and their shortcomings:
[0004] 1. Based on head detection + helmet wearing detection:
[0005] This method first trains a general head detection model (regardless of whether a person is wearing a helmet or not), then expands the detection frame and crops the head area, and then trains a helmet wearing classifier to complete the classification and recognition of people wearing helmets.
[0006] Disadvantages: This method uses a two-stage method for detection and recognition, so the speed is relatively slow. In addition, the head detection model does not distinguish whether a helmet is worn or not, and only detects the head detection frame, which may be affected by the performance of the face detector, especially when the person is facing away, the detection effect may be poor.
[0007] 2. Helmet detection based on deep learning:
[0008] Existing technologies have conducted in-depth research on helmet detection based on YOLOv8 / v7 / v6 / v5, using YOLOv8 as the core and integrating YOLOv7, YOLOv6, and YOLOv5 algorithms to compare performance indicators. Existing technologies support helmet detection using images, videos, and real-time cameras, and can upload different training models for inference and prediction.
[0009] Disadvantages: It requires a lot of computing resources in practical applications, especially when processing high-resolution images. In addition, the detection ability for small objects may need to be further optimized to improve the recognition performance in complex scenes.
[0010] In general, although existing helmet wearing image recognition methods have made significant progress in accuracy and real-time performance, they suffer from poor robustness in complex environments, poor detection accuracy for small targets, and high demand for computing resources.
[0011] 3. Safety helmet detection based on YOLO series algorithms:
[0012] YOLO (You Only Look Once) series algorithms, such as YOLOv5, YOLOv6, YOLOv7, YOLOv8, etc., dominate many real-time object detection tasks due to their excellent real-time performance and accuracy. These algorithms significantly improve the efficiency and accuracy of object detection by adopting unique architectures, training techniques, and data processing methods.
[0013] Disadvantages: Although the YOLO series of algorithms perform well in real-time and accuracy, they still face challenges in terms of robustness in complex environments, real-time performance optimization of the model, and accuracy in detecting small targets. In addition, different versions of the YOLO algorithm need to be adjusted and optimized for specific scenarios to adapt to different detection requirements, resulting in the complexity of applications in different scenarios. Summary of the invention
[0014] The technical problem to be solved by the present invention is that in a complex detection environment, the robustness is poor and the detection accuracy of small targets is poor. The purpose is to provide a method, device and medium for detecting the wearing of a safety helmet in a construction scene, construct a YOLOX target detection model, divide the image into grids, construct a sliding window to extract feature information in the grid image, reduce the amount of calculation and alleviate the imbalance problem of positive and negative samples, generate an anchor frame based on the extracted features, obtain the amplitude of the anchor frame in each direction through the descriptor, obtain the gradient amplitude in the neighborhood in the interpolation direction, locate the feature points based on the gradient amplitude and filter the anchor frame, so as to accurately locate the target object and improve the detection accuracy, obtain more accurate recognition data by eliminating the splicing gap, denoise the image to improve the image quality, improve the accuracy of image recognition, especially the feature recognition of specific targets in a complex environment, optimize the training process of the model, improve the generalization ability and processing speed of the model, and realize the rapid and automatic recognition of whether the workers in the construction site are wearing safety helmets, improve the efficiency of safety management, and reduce the safety accidents caused by not wearing safety helmets.
[0015] The present invention is achieved through the following technical solutions:
[0016] The first aspect of the present invention provides a method for detecting the wearing of a safety helmet in a construction scenario, comprising the following specific steps:
[0017] Acquire image data of the construction site, and perform enhancement and annotation operations on the image data;
[0018] Build a YOLOX object detection model to extract key features and descriptors based on image data;
[0019] Generate an anchor frame based on the extracted features, obtain the amplitude of the anchor frame in each direction through the descriptor, and obtain the gradient amplitude in the neighborhood in the interpolation direction;
[0020] Feature points are located based on gradient amplitude, and anchor boxes are selected based on the location data;
[0021] The maximum cross-correlation matching deviation is used to stitch and eliminate cracks on the selected anchor frames to obtain a stitched image;
[0022] The spliced image is denoised, and the detection result is obtained based on the denoised image data.
[0023] Furthermore, the extracting of key features based on image data specifically includes:
[0024] Build a sliding window and select the starting position of the window;
[0025] Starting from the starting position, the image data is traversed using sliding windows of different sizes;
[0026] During the traversal process, local extreme points are found in spaces of different scales, and the positions and scales of key points are determined based on the local extreme points to obtain key features.
[0027] Furthermore, descriptors are extracted based on the image data, specifically including:
[0028] With the key point as the center, a neighborhood is constructed, and the gradient histograms in multiple directions are randomly calculated in the neighborhood;
[0029] Select multiple pixel pairs in the neighborhood based on the gradient histogram and construct a description operator;
[0030] The description operators are compared pairwise, and the comparison results of all pixel pairs are concatenated to form a binary string of fixed length to obtain the descriptor.
[0031] Furthermore, the step of obtaining the magnitude of the anchor frame in each direction through the descriptor to obtain the gradient magnitude in the neighborhood in the interpolation direction specifically includes:
[0032] Get the extracted features, generate a feature map of size n, divide the feature map into multiple grids, and get the anchor box;
[0033] Based on the gradient histograms randomly obtained in multiple directions in the neighborhood of the key point, the gradient amplitude of the anchor box in different directions is calculated;
[0034] RPN is used to predict a target score for each anchor box, where the target score indicates the possibility of whether the anchor box contains the target object.
[0035] This layer maps the feature vector at each position of the feature map to a target score vector;
[0036] According to the target score vector obtained by mapping, the gradient histograms of multiple directions randomly obtained in the neighborhood of the key point are obtained, and the gradient amplitudes of the anchor box in different directions are calculated;
[0037] The calculated gradient magnitude is integrated into the descriptor corresponding to each anchor box to obtain the gradient magnitude in the neighborhood in the interpolation direction.
[0038] Furthermore, the feature point positioning based on the gradient amplitude and the anchor frame screening based on the positioning data specifically include:
[0039] The feature points are located based on the gradient amplitude, the direction of the feature points is obtained, and the offset of the anchor frame is calculated based on the direction of the feature points;
[0040] Calculate the intersection-over-union ratio of each anchor box and the true bounding box, set the intersection-over-union ratio threshold, and determine whether the anchor box overlaps the true bounding box by more than the threshold;
[0041] Calculate the confidence score and perform non-maximum suppression on the anchor box based on the judgment result;
[0042] Get the offset threshold and confidence score threshold of the anchor box, determine the matching degree between the anchor box and the predicted box, and filter the anchor box according to the matching results.
[0043] Furthermore, the determining of the matching degree between the anchor box and the prediction box and screening the anchor box according to the matching result specifically includes:
[0044] If the matching degree is greater than a set threshold, the initial prediction box is determined to be a foreground;
[0045] If the matching degree is less than the set threshold, the initial prediction frame is determined to be the background;
[0046] The Hungarian algorithm is used to perform similarity matching between the initial prediction box whose confidence is lower than the set threshold and the initial prediction box judged as the foreground, and the Hungarian algorithm is used to perform similarity matching between the initial prediction box whose confidence is higher than the set threshold and the initial prediction box judged as the background.
[0047] Furthermore, the method of using the maximum cross-correlation matching deviation to stitch and eliminate cracks on the selected anchor frames to obtain a stitched image specifically includes:
[0048] According to the process of window sliding on the image, a moving relationship function between the window and the image is generated;
[0049] Based on the moving relationship between the window and the image,
[0050] The maximum cross-correlation matching deviation is used to compare the similarity of the selected anchor boxes;
[0051] According to the similarity comparison result, the function response value is calculated by combining the movement relationship function between the window and the image;
[0052] The corner points of the anchor frames screened out based on the function response values are determined, and stitching and crack elimination are performed based on the corner points to obtain a stitched image.
[0053] Furthermore, the denoising process of the spliced image specifically includes:
[0054] Load the stitched image and perform grayscale and normalization processing;
[0055] According to the location information of the detection target output by the YOLOX target detection model, multiple thresholds are set and the grayscale image is threshold segmented to obtain multiple binary images;
[0056] Traverse the noise points in each binary image, count the number and position of the noise points, and remove the noise points at different positions according to the number threshold;
[0057] Output the denoised stitched image.
[0058] A second aspect of the present invention provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, a method for detecting the wearing of a safety helmet in a construction scenario is implemented.
[0059] A third aspect of the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for detecting the wearing of a safety helmet in a construction scenario.
[0060] Compared with the prior art, the present invention has the following advantages and beneficial effects:
[0061] A YOLOX target detection model is constructed. By dividing the image into grids and constructing a sliding window to extract feature information from the grid image, the amount of calculation is reduced and the imbalance problem of positive and negative samples is alleviated. Anchor frames are generated based on the extracted features, and the amplitudes of the anchor frames in various directions are obtained through descriptors. The gradient amplitude in the neighborhood in the interpolation direction is obtained. Feature points are located based on the gradient amplitude and anchor frames are screened. The target object can be accurately located to improve the accuracy of detection. More accurate recognition data can be obtained by eliminating splicing gaps, and the image is denoised to improve image quality. The accuracy of image recognition is improved, especially for feature recognition of specific targets in complex environments. The training process of the model is optimized, and the generalization ability and processing speed of the model are improved. It can realize rapid and automatic recognition of whether workers on construction sites are wearing safety helmets, improve safety management efficiency, and reduce safety accidents caused by not wearing safety helmets. BRIEF DESCRIPTION OF THE DRAWINGS
[0062] In order to more clearly illustrate the technical solutions of the exemplary embodiments of the present invention, the following briefly introduces the drawings required for use in the embodiments. It should be understood that the following drawings only illustrate certain embodiments of the present invention and should not be regarded as limiting the scope. For those of ordinary skill in the art, other relevant drawings can be obtained based on these drawings without creative work. In the drawings:
[0063] Figure 1 Flow chart of the helmet wearing detection method in an embodiment of the present invention. DETAILED DESCRIPTION
[0064] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with embodiments and drawings. The exemplary embodiments of the present invention and their description are only used to explain the present invention and are not intended to limit the present invention.
[0065] As a possible implementation, Figure 1 As shown, this embodiment provides a method for detecting the wearing of a safety helmet in a construction scenario, comprising the following specific steps:
[0066] Acquire image data from the construction site, and perform enhancement and annotation operations on the image data; build a YOLOX target detection model, and extract key features and descriptors based on image data; generate anchor frames based on the extracted features, obtain the amplitude of the anchor frames in each direction through the descriptors, and obtain the gradient amplitude in the neighborhood in the interpolation direction; locate feature points based on the gradient amplitude, and filter anchor frames based on the positioning data; use the maximum cross-correlation matching deviation to splice and eliminate cracks on the filtered anchor frames to obtain a spliced image; denoise the spliced image, and obtain the detection result based on the denoised image data. This embodiment constructs a YOLOX target detection model, divides the image into grids, constructs a sliding window to extract feature information in the grid image, reduces the amount of calculation and alleviates the imbalance problem of positive and negative samples, generates an anchor frame based on the extracted features, obtains the amplitude of the anchor frame in each direction through the descriptor, obtains the gradient amplitude in the neighborhood in the interpolation direction, locates feature points based on the gradient amplitude and filters the anchor frame, can accurately locate the target object, improve the accuracy of detection, obtain more accurate recognition data by eliminating splicing gaps, and denoise the image to improve image quality, thereby improving the accuracy of image recognition, especially the feature recognition of specific targets in complex environments, optimizing the training process of the model, improving the generalization ability and processing speed of the model, and can realize rapid and automatic recognition of whether workers on construction sites are wearing safety helmets, thereby improving safety management efficiency and reducing safety accidents caused by not wearing safety helmets.
[0067] In some possible embodiments, image data of the construction site is collected, and data that does not meet the pixel threshold is eliminated to ensure that the image contains images of workers in various lighting conditions and at different angles. The image is enhanced, including data enhancement operations such as flipping, rotating, and scaling the image to improve the generalization ability of the model. Annotation tools are used to annotate the heads of workers in the image and distinguish whether they are wearing helmets.
[0068] In some possible embodiments, a target detection model is constructed using the YOLOX algorithm framework, which can quickly and accurately identify the head features of workers in an image. The image is scanned through the constructed sliding window, and the Backbone and Neck structures of the YOLOX model are used to extract image features. The model is trained using annotated data sets, and the model parameters are adjusted through optimization algorithms to improve recognition accuracy.
[0069] In some possible embodiments, YOLOX is an improved version based on the YOLO series, which introduces the Anchor-free method, reduces the amount of calculation, alleviates the imbalance problem of positive and negative samples, and avoids the adjustment of anchor parameters. The network architecture of YOLOX includes an input end, BackBone, Neck, and Head. BackBone is used to extract image features, usually using Darknet53. Neck is used for feature fusion, and the PAFPN structure is commonly used. The Head part predicts the results, adopts the Decoupled Head and Anchor-free design, and improves the expression ability of the model. The process of building a YOLOX target detection model and using a sliding window to extract features from image data includes: first, through the BackBone and Neck structures, the model can extract high-level features of the image. These feature maps are then used for target detection. In the feature extraction stage, the sliding window technology is used to extract the local features of the image. By constructing a sliding window, a window is slid on the feature map, the window starting position is selected, and the image data is traversed using sliding windows of different sizes starting from the starting position. In the traversal process, local extreme points are found in the space of different scales, and the position and scale of the key points are determined based on the local extreme points to obtain the key features. With the key point as the center, a neighborhood is constructed, and the gradient histograms of multiple directions are randomly calculated in the neighborhood; multiple pixel pairs are selected in the neighborhood based on the gradient histogram to construct a description operator; the description operators are compared pairwise, and the comparison results of all pixel pairs are connected in series to form a fixed-length binary string to obtain a descriptor.
[0070] The above content describes the detection and description of local features in an image by the SIFT (Scale Invariant Feature Transform) algorithm, which can extract key features in the image and generate corresponding descriptors. These descriptors remain invariant to rotation, scale scaling, brightness changes, etc., so that they can be used to match and identify the same object or feature in different images. Specifically, by finding local extreme points in space at different scales, the SIFT algorithm can detect points of interest in the image, which are usually corner points, edge points or other feature points with obvious texture. Based on the local extreme points, the SIFT algorithm can determine the exact position and scale of the key points. By constructing a neighborhood centered on the key point and calculating the gradient histogram in the neighborhood, the SIFT algorithm can assign one or more directions to each key point so that the feature descriptor remains invariant to the rotation of the key point. By selecting multiple pixel pairs in the neighborhood and constructing a description operator based on the gradient histogram, the SIFT algorithm generates a unique feature descriptor that can represent the local image structure around the key point. By comparing the description operators pairwise and concatenating the comparison results to form a fixed-length binary string, the SIFT algorithm obtains a compact and unique descriptor, which helps to quickly match and identify feature points in practical applications.
[0071] In some possible embodiments, the amplitude of each direction of the anchor frame is obtained through the descriptor to obtain the gradient amplitude in the neighborhood in the interpolation direction, specifically including: obtaining the extracted features, generating a feature map of size n, dividing the feature map into multiple grids, obtaining anchor frames, generating anchor frames at the center positions of these grids according to predefined sizes and proportions, these anchor frames cover different sizes and shapes, and can cover targets of various sizes and proportions; based on the gradient histograms of multiple directions randomly obtained in the neighborhood of the key point, the gradient amplitudes of the anchor frames in different directions are calculated; using RPN to predict a target score for each anchor frame, the target score indicates the possibility of whether the anchor frame contains the target object; this layer maps the feature vector of each position of the feature map to a target score vector; according to the mapped target score vector, the gradient histograms of multiple directions randomly obtained in the neighborhood of the key point are obtained, and the gradient amplitudes of the anchor frames in different directions are calculated; the calculated gradient amplitudes are integrated into the descriptors corresponding to each anchor frame to obtain the gradient amplitudes in the neighborhood in the interpolation direction. The above process combines the target detection framework of deep learning with the gradient calculation in traditional computer vision, aiming to improve the accuracy and robustness of target detection. In this way, the local feature information of the image and the powerful feature extraction capability of the deep learning model can be effectively utilized.
[0072] In some possible embodiments, feature point positioning is performed based on the gradient amplitude, and anchor boxes are filtered based on the positioning data, specifically including:
[0073] Feature point positioning based on gradient amplitude, that is, in the gradient amplitude image, the local maximum point is identified as a potential feature point, and the direction of the feature point is obtained;
[0074] Calculate the offset of the anchor box based on the direction of the feature point: Generate an anchor box based on the position of the feature point. The anchor box is usually a set of bounding boxes aligned with the feature point position. They can have different sizes and aspect ratios. The calculated offset can be used to adjust the position of the anchor box to align it more accurately with the target object.
[0075] Calculate the intersection-over-union ratio of each anchor box and the true bounding box, set the intersection-over-union ratio threshold, and determine whether the anchor box overlaps the true bounding box by more than the threshold;
[0076] Calculate the confidence score and perform non-maximum suppression on the anchor box based on the judgment result, that is, obtain the offset threshold and confidence score threshold of the anchor box, judge the matching degree between the anchor box and the predicted box, and filter the anchor box according to the matching result.
[0077] The anchor box that is most likely to contain the target object can be effectively screened out from a large number of candidate anchor boxes, thereby improving the accuracy and efficiency of target detection.
[0078] The initial prediction box is adjusted based on the offset and confidence of the bounding box, specifically including: adjusting the position and size of the initial prediction box using the predicted offset; calculating the intersection-over-union ratio of the adjusted initial prediction box and the anchor box, and calculating the confidence score based on the intersection-over-union ratio; obtaining the intersection-over-union ratio threshold and the confidence score threshold, judging the matching degree between the anchor box and the prediction box, and filtering the anchor box according to the matching results, specifically including:
[0079] If the matching degree is greater than a set threshold, the initial prediction box is determined to be a foreground;
[0080] If the matching degree is less than the set threshold, the initial prediction frame is determined to be the background;
[0081] The Hungarian algorithm is used to perform similarity matching between the initial prediction box whose confidence is lower than the set threshold and the initial prediction box judged as the foreground, and the Hungarian algorithm is used to perform similarity matching between the initial prediction box whose confidence is higher than the set threshold and the initial prediction box judged as the background.
[0082] In some possible embodiments, the confidence score is calculated, and the anchor box is non-maximum suppressed in combination with the judgment result, specifically including: sorting all the initial prediction boxes according to the confidence score; wherein the confidence score refers to the probability that the YOLOX target detection model predicts that the box contains the target object; selecting the initial prediction box with the highest confidence from the sorted list as the selected prediction box; calculating the intersection and union ratio of the unselected initial prediction box and the selected prediction box, and judging whether the intersection and union ratio of the unselected initial prediction box and the selected prediction box exceeds the preset threshold; if it exceeds, it is considered that the unselected initial prediction box and the selected prediction box represent the same target, and the unselected initial prediction box is added as the selected prediction box; if it does not exceed, the unselected initial prediction box is removed; traversing the highest confidence in the selected initial prediction box, repeatedly counting the intersection and union ratio of the unselected initial prediction box and the selected prediction box, selecting or removing the initial prediction box according to the intersection and union ratio, and obtaining a collection of selected prediction boxes as the optimized prediction box. After the above steps are processed, the remaining collection of prediction boxes is the optimized prediction result. These boxes are considered to be the boxes that are most likely to contain the target object, and they do not overlap with each other. By performing non-maximum suppression on the adjusted initial prediction box, redundant predictions in target detection can be reduced and the accuracy of detection can be improved.
[0083] In some possible embodiments, the selected anchor frames are stitched and cracks are eliminated by using the maximum cross-correlation matching deviation to obtain a stitched image, specifically including: generating a movement relationship function between the window and the image according to a process in which the window slides on the image;
[0084] Based on the movement relationship between the window and the image, the maximum cross-correlation matching deviation is used to compare the similarity of the selected anchor boxes;
[0085] According to the similarity comparison results, combined with the movement relationship function between the window and the image, the function response value is calculated; the corner points of the selected anchor frame are determined based on the function response value, and the stitching and crack elimination are performed based on the corner points to obtain the stitched image. The aggregation of corner points can be avoided, making the corner points more evenly distributed in the image. By calculating the geometric transformation between the images, such as translation, rotation, and scaling, according to the matching relationship of the feature points, the images are aligned. The aligned images are color corrected and fused to create a seamless panoramic image.
[0086] In some possible embodiments, the denoising process is performed on the spliced image, specifically including:
[0087] Image stitching and denoising is a multi-step process involving image preprocessing, threshold segmentation, noise point removal and final image output, including:
[0088] Load the spliced image. After loading the image, in order to simplify the processing flow, the image is usually converted to a grayscale image, because the grayscale image only has a single brightness information, which reduces the complexity brought by the color information. Normalize the image. Normalization is to scale the pixel values of the image to a specific range, usually [0,1]. This helps the subsequent threshold segmentation and denoising. According to the location information of the detection target output by the YOLOX target detection model, set multiple thresholds and perform threshold segmentation on the grayscale image to obtain multiple binary images. The YOLOX target detection model can be used to detect the target in the image and output the location information of the target. This information can be used to guide the subsequent threshold segmentation to ensure that the target area remains intact in the segmented binary image. According to the location information of the target, multiple thresholds can be set for segmentation, and each threshold corresponds to a binary image. The purpose of threshold segmentation is to separate the foreground and background of the image to prepare for subsequent noise removal. In a binary image, noise usually appears as isolated white or black dots. By counting the number and location of these noise points, they can be identified. According to the set number threshold, it can be determined which noise points need to be removed. For example, if the number of white dots in an area is less than a threshold, then these white dots can be considered as noise and removed. After the noise dots are removed, a clean binary image can be obtained, and a more accurate image detection result can be obtained based on the processed image.
[0089] As a possible implementation, this embodiment provides an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the program, a method for detecting the wearing of a safety helmet in a construction scenario is implemented.
[0090] As a possible implementation, this embodiment provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements a method for detecting the wearing of a safety helmet in a construction scenario.
[0091] The specific implementation methods described above further illustrate the objectives, technical solutions and beneficial effects of the present invention in detail. It should be understood that the above description is only a specific implementation method of the present invention and is not intended to limit the scope of protection of the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present invention should be included in the scope of protection of the present invention.
Claims
1. A method for detecting the wearing of a safety helmet in a construction scenario, characterized in that: The specific steps include: Acquire image data of the construction site, and perform enhancement and annotation operations on the image data; Build a YOLOX object detection model to extract key features and descriptors based on image data; Generate an anchor frame based on the extracted features, obtain the amplitude of the anchor frame in each direction through the descriptor, and obtain the gradient amplitude in the neighborhood in the interpolation direction; Feature points are located based on gradient amplitude, and anchor boxes are selected based on the location data; The maximum cross-correlation matching deviation is used to stitch and eliminate cracks on the selected anchor frames to obtain a stitched image; The spliced image is denoised, and the detection result is obtained based on the denoised image data.
2. The method for detecting the wearing of a safety helmet in a construction scene according to claim 1, characterized in that: The extracting of key features based on image data specifically includes: Build a sliding window and select the starting position of the window; Starting from the starting position, the image data is traversed using sliding windows of different sizes; During the traversal process, local extreme points are found in spaces of different scales, and the positions and scales of key points are determined based on the local extreme points to obtain key features.
3. The method for detecting the wearing of a safety helmet in a construction scene according to claim 2, characterized in that: Extract descriptors based on image data, including: With the key point as the center, a neighborhood is constructed, and the gradient histograms in multiple directions are randomly calculated in the neighborhood; Select multiple pixel pairs in the neighborhood based on the gradient histogram and construct a description operator; The description operators are compared pairwise, and the comparison results of all pixel pairs are concatenated to form a binary string of fixed length to obtain the descriptor.
4. The method for detecting the wearing of a safety helmet in a construction scene according to claim 3, characterized in that: The step of obtaining the magnitude of each direction of the anchor frame through the descriptor to obtain the gradient magnitude in the neighborhood in the interpolation direction specifically includes: Get the extracted features, generate a feature map of size n, divide the feature map into multiple grids, and get the anchor box; Based on the gradient histograms randomly obtained in multiple directions in the neighborhood of the key point, the gradient amplitude of the anchor box in different directions is calculated; RPN is used to predict a target score for each anchor box, where the target score indicates the possibility of whether the anchor box contains the target object. This layer maps the feature vector at each position of the feature map to a target score vector; According to the target score vector obtained by mapping, the gradient histograms of multiple directions randomly obtained in the neighborhood of the key point are obtained, and the gradient amplitudes of the anchor box in different directions are calculated; The calculated gradient magnitude is integrated into the descriptor corresponding to each anchor box to obtain the gradient magnitude in the neighborhood in the interpolation direction.
5. The method for detecting the wearing of a safety helmet in a construction scene according to claim 1, characterized in that: The method of locating feature points based on gradient amplitude and filtering anchor frames based on the positioning data specifically includes: The feature points are located based on the gradient amplitude, the direction of the feature points is obtained, and the offset of the anchor frame is calculated based on the direction of the feature points; Calculate the intersection-over-union ratio of each anchor box and the true bounding box, set the intersection-over-union ratio threshold, and determine whether the anchor box overlaps the true bounding box by more than the threshold; Calculate the confidence score and perform non-maximum suppression on the anchor box based on the judgment result; Get the offset threshold and confidence score threshold of the anchor box, determine the matching degree between the anchor box and the predicted box, and filter the anchor box according to the matching results.
6. The method for detecting the wearing of a safety helmet in a construction scene according to claim 5, characterized in that: The determining of the matching degree between the anchor frame and the prediction frame and screening the anchor frame according to the matching result specifically includes: If the matching degree is greater than a set threshold, the initial prediction box is determined to be a foreground; If the matching degree is less than the set threshold, the initial prediction frame is determined to be the background; The Hungarian algorithm is used to perform similarity matching between the initial prediction box whose confidence is lower than the set threshold and the initial prediction box judged as the foreground, and the Hungarian algorithm is used to perform similarity matching between the initial prediction box whose confidence is higher than the set threshold and the initial prediction box judged as the background.
7. The method for detecting the wearing of a safety helmet in a construction scene according to claim 1, characterized in that: The method uses the maximum cross-correlation matching deviation to stitch and eliminate cracks on the selected anchor frames to obtain a stitched image, specifically including: According to the process of window sliding on the image, a moving relationship function between the window and the image is generated; Based on the movement relationship between the window and the image, the maximum cross-correlation matching deviation is used to compare the similarity of the selected anchor boxes; According to the similarity comparison result, the function response value is calculated by combining the movement relationship function between the window and the image; The corner points of the anchor frames screened out based on the function response values are determined, and stitching and crack elimination are performed based on the corner points to obtain a stitched image.
8. The method for detecting the wearing of a safety helmet in a construction scene according to claim 1, characterized in that: The denoising process of the spliced image specifically includes: Load the stitched image and perform grayscale and normalization processing; According to the location information of the detection target output by the YOLOX target detection model, multiple thresholds are set and the grayscale image is threshold segmented to obtain multiple binary images; Traverse the noise points in each binary image, count the number and position of the noise points, and remove the noise points at different positions according to the number threshold; Output the denoised stitched image.
9. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the method for detecting the wearing of a safety helmet in a construction scenario as described in any one of claims 1 to 8 is implemented.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for detecting the wearing of a safety helmet in a construction scenario as described in any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Pavement defect analysis and detection method and system
CN120563521A