Unmanned aerial vehicle-based water conservancy construction worker safety helmet color recognition and classification statistical method and system

By improving the YOLOv8 model and ByteTrack algorithm, the problems of blind spots in monitoring, low recognition accuracy, and inaccurate statistics at water conservancy construction sites have been solved. This has enabled efficient and accurate color recognition and classification statistics of safety helmets for construction workers, covering the entire area without blind spots and improving the digital level of water conservancy safety supervision.

CN122289969APending Publication Date: 2026-06-26NANJING HYDRAULIC RES INST +1
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
NANJING HYDRAULIC RES INST
Filing Date
2026-02-10
Publication Date
2026-06-26

AI Technical Summary

Technical Problem

Water conservancy construction sites suffer from problems such as blind spots in monitoring, low recognition accuracy, low efficiency, and inaccurate statistics. In particular, the loss of detection features of small targets from a high-altitude perspective and environmental interference lead to false detections and missed detections, making it impossible to achieve real-time and accurate work type classification statistics.

Method used

An improved YOLOv8 model is used in conjunction with the CBAM attention mechanism and the P2 detection layer to detect and classify safety helmets by color. The ByteTrack algorithm is used for target tracking, and global motion compensation and spatial logic are combined for identity verification and counting to achieve end-to-end safety helmet color recognition and classification statistics.

Benefits of technology

It significantly improves the detection accuracy of small targets, enhances the anti-interference capability in complex environments, realizes accurate deduplication and counting and refined management in dynamic scenarios, covers the entire domain without blind spots, reduces regulatory costs, and improves the level of digitalization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122289969A_ABST
    Figure CN122289969A_ABST
Patent Text Reader

Abstract

This invention discloses a method and system for color recognition and classification statistics of safety helmets used in water conservancy engineering construction based on unmanned aerial vehicles (UAVs). The method includes: acquiring aerial video data of a water conservancy engineering construction site taken by a UAV along a preset flight path; performing defogging and illumination compensation on the acquired video frames, and segmenting the original image into multiple overlapping sub-images; inputting the sub-images into an improved YOLOv8 model for safety helmet detection and color classification; tracking the detected targets using the ByteTrack algorithm, assigning a unique ID to each target, and introducing a global motion compensation module during the tracking process to offset the influence of the UAV's own motion; performing identity verification based on a temporal buffer and classification and counting based on spatial logic; mapping the safety helmet color to a preset job type, and outputting the number of workers on duty for each job type and / or early warning information. This invention enables efficient and refined management in complex environments during water conservancy engineering construction.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the fields of computer vision, intelligent monitoring and drone application technology, specifically to a method and system for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on drones. Background Technology

[0002] Water conservancy construction projects (such as dam construction and river management) are typically characterized by vast work areas, significant terrain elevation differences, and dispersed personnel movement, making on-site safety supervision exceptionally difficult. According to safety production regulations, personnel with different responsibilities must wear different colored safety helmets (e.g., yellow for ordinary workers, red for safety officers, blue for technicians, and white for supervisors or visitors). Traditional supervision mainly relies on manual patrols and fixed-point camera monitoring, which has the following significant drawbacks: 1. Blind spots (incomplete coverage): Fixed-point cameras have numerous blind spots, failing to cover the entire narrow water conservancy work area. 2. Low efficiency: Manual statistics are inefficient and cannot provide real-time information on the distribution of different job types (such as managers, ordinary workers, and special operations personnel). 3. Low recognition accuracy, including: tiny targets (unclear visibility): When drones take aerial photos, construction workers and safety helmets occupy a very small percentage of the image (usually less than 32×32 pixels). Conventional target detection algorithms compress high-resolution images, resulting in significant loss of tiny target features and a high false negative rate. Environmental interference (misreading): Environmental factors such as water surface reflection and water mist can easily cause false detections or missed detections. Inaccurate statistics (inaccurate counting): Counting methods based on single-frame images cannot distinguish between personnel movement and repeated appearances, resulting in duplicate or missed counts of personnel, making it impossible to achieve accurate on-duty statistics for different job types.

[0003] Therefore, there is an urgent need for an automated system that can adapt to the complex environment of water conservancy projects, flexibly and accurately identify the identity of construction personnel and classify and count them. Summary of the Invention

[0004] Purpose of the invention: In view of the technical problems of "unclear visibility", "misreading", "inaccurate counting" and "incomplete visibility" in the complex environment of water conservancy construction, the purpose of this invention is to provide a method and system for color recognition and classification statistics of safety helmets of water conservancy construction workers based on drones.

[0005] Technical Solution: To achieve the above-mentioned objectives, this invention provides a method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs), comprising the following steps:

[0006] Aerial data of aerial photography collected by drones from above the construction site of a water conservancy project, following a preset flight path;

[0007] The acquired video frames are dehazed and illumination compensated, and the original image is cut into multiple overlapping sub-images;

[0008] The subgraph is input into the improved YOLOv8 model for safety helmet detection and color classification. The improved YOLOv8 model embeds the CBAM attention mechanism module in the backbone network and adds a P2 detection layer for small targets in the detection head. The model is trained end-to-end using a safety helmet dataset with labeled colors. Different colored safety helmets correspond to different types of work and include sample data with labeled no safety helmets.

[0009] The ByteTrack algorithm is used to track detected targets, each target is assigned a unique ID, and a global motion compensation module is introduced during the tracking process to counteract the influence of the UAV's own motion; identity verification is based on a temporal buffer and classification and counting are based on spatial logic.

[0010] Based on the color mapping of safety helmets to preset job types, output the number of employees on duty for each job type and / or early warning information.

[0011] Furthermore, the process of dehazing and illumination compensation of the acquired video frames includes: performing dehazing using a dark channel prior algorithm or an AOD-Net dehazing network, and performing illumination compensation using an MSRCR algorithm.

[0012] Furthermore, when the original image is cut into multiple overlapping sub-images, an overlapping sliding window is used to perform sliding cropping on the original image, with an overlap rate of 10% to 30%. After the sub-images are input into the improved YOLOv8 model for helmet detection and color classification, the target coordinates are converted back to the global coordinates of the original image based on the offset of the sub-images in the original image, and the global NMS algorithm is used to remove duplicate targets.

[0013] Furthermore, in the improved YOLOv8 model, after C2f feature extraction is completed in Stage 3 of the backbone network, a CBAM attention mechanism module is connected in series; the P2 detection layer is constructed by splicing and fusing the P2 feature map output by the backbone network after a 2x upsampling operation on the P3 feature map processed in the neck network, and is used to detect small targets with a pixel size of less than 32×32.

[0014] Furthermore, the target bounding box and category information output by the improved YOLOv8 model are input into the ByteTrack algorithm. The ByteTrack algorithm uses Kalman filtering to predict the target's position in the next frame and combines it with the Hungarian algorithm for IOU matching to assign a unique tracking ID to each construction worker appearing in the video. The global motion compensation module performs motion compensation on the target position predicted by the Kalman filter by calculating the homography matrix of the two frames.

[0015] Furthermore, the identity verification based on the time-series buffer includes: when the same ID is detected as the same color category in a consecutive preset number of frames, and the detection confidence is higher than a preset threshold, the ID is marked as a valid target and its job attribute is locked.

[0016] Furthermore, the classification and counting based on spatial logic includes: for IDs marked as valid targets, executing counting judgment lines and / or area judgment statistical logic according to actual regulatory needs; wherein the counting judgment line logic is: determining whether the trajectory center point of the valid target ID crosses a preset virtual tripwire in a specified direction, and if it does, triggering traffic accumulation counting; the area judgment logic is: determining whether the anchor point coordinates of the valid target ID are located inside a preset polygonal area, and if they are inside, counting them as the real-time on-duty personnel.

[0017] Furthermore, when performing classification and counting based on spatial logic, event deduplication is implemented for violation events, and independent intrusion events are counted. When the ID of the same valid target intrudes into the preset area, it is counted once. The count is only accumulated when the ID leaves the preset area and re-enters.

[0018] This invention provides a UAV-based system for color recognition and classification statistics of safety helmets used in water conservancy engineering construction workers. The system includes:

[0019] The data acquisition module is used to acquire aerial video data of the construction site of the water conservancy project by the UAV following the preset route.

[0020] The preprocessing module is used to perform dehazing and illumination compensation on the acquired video frames, and to cut the original image into multiple overlapping sub-images;

[0021] The neural network inference module is used to input the subgraph into the improved YOLOv8 model for safety helmet detection and color classification. The improved YOLOv8 model embeds the CBAM attention mechanism module in the backbone network and adds a P2 detection layer for small targets in the detection head. The model is trained end-to-end using a safety helmet dataset with labeled colors. Different colored safety helmets correspond to different types of work and include sample data with labeled no safety helmets.

[0022] The multi-target tracking and deduplication module uses the ByteTrack algorithm to track detected targets, assigns a unique ID to each target, and introduces a global motion compensation module during the tracking process to offset the influence of the UAV's own motion; it performs identity verification based on a temporal buffer and classification and counting based on spatial logic.

[0023] The results output module is used to map the safety helmet color to a preset job type and output the number of employees on duty for each job type and / or warning information.

[0024] The present invention also provides a computer program product, including a computer program, which, when executed by a processor, implements the steps of the method for color recognition and classification statistics of safety helmets for construction workers in water conservancy projects based on unmanned aerial vehicles.

[0025] Beneficial effects: Compared with the prior art, the significant advantages of this invention are:

[0026] 1. Significantly improves the accuracy of small target detection from the high-altitude perspective of UAVs. This invention employs a dual approach of image slicing of the original image and adding a P2 small target detection layer to collaboratively address the problem of feature loss of small targets at high altitudes from both data and model perspectives. This overcomes the feature loss problem caused by the small pixel ratio of construction workers and safety helmets in traditional target detection algorithms under UAV high-altitude overhead scenarios, significantly reducing the false negative rate and effectively solving the problem of "not being able to see clearly".

[0027] 2. Enhance the anti-interference capability and robustness of water conservancy projects in complex environments. This invention combines defogging and illumination compensation preprocessing for water conservancy environments with the addition of a CBAM attention mechanism to the model backbone network. This enables the system to focus on the shape and color features of the safety helmet, effectively resisting interference from water mist, reflections, and complex backgrounds, thus improving the accuracy of safety helmet color recognition and solving the problem of "misreading".

[0028] 3. Achieving accurate deduplication and refined management in dynamic scenarios. This invention stabilizes target tracking in swaying drone scenarios by introducing the ByteTrack algorithm with global motion compensation; combined with the logic of high-confidence judgment of continuous frames, it achieves accurate deduplication of work types. This invention can stably track the movement trajectory of the same construction worker, avoiding duplicate counting caused by personnel movement or brief obstruction; at the same time, through color-work type mapping, it achieves refined classification and statistics of on-site personnel structure (such as real-time monitoring of the ratio of special operation personnel to general workers), making up for the shortcomings of traditional monitoring that can only view images but cannot output data. On the basis of solving the problem of "inaccurate counting", it further realizes refined management.

[0029] 4. Achieve efficient, blind-spot-free monitoring of water conservancy construction. This invention utilizes the mobility of drones combined with automated recognition algorithms to replace traditional manual inspections and fixed-point monitoring. It can easily cover visual blind spots in traditional monitoring, such as the backwater surface of dams, deep foundation pits, and the center of river channels, solving the problem of "not being able to see everything." Moreover, the detection speed is fast (reaching real-time frame rate), which can greatly reduce the manpower cost of supervision and improve the digital level of water conservancy safety supervision. Attached Figure Description

[0030] Figure 1 This is a general flowchart of an embodiment of the present invention.

[0031] Figure 2 This is a detailed method flowchart illustrating an embodiment of the present invention.

[0032] Figure 3 This is a schematic diagram of the improved YOLOv8 model structure in an embodiment of the present invention. Detailed Implementation

[0033] The technical solution of the present invention will be further described below with reference to the accompanying drawings and specific embodiments.

[0034] like Figure 1 As shown in the figure, the present invention discloses a method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs), which mainly includes the following steps:

[0035] S1. Human-machine aerial photography data acquisition: Acquire aerial photography data by drones that take an aerial view of the water conservancy project construction site along a preset flight path.

[0036] S2. Image preprocessing: Dehaze and compensate for illumination on the acquired video frames, and cut the original image into multiple overlapping sub-images.

[0037] S3. Improved YOLOv8 model inference: The subgraph is input into the improved YOLOv8 model for safety helmet detection and color classification. The improved YOLOv8 model embeds the CBAM attention mechanism module in the backbone network and adds a P2 detection layer for small targets in the detection head. The model is trained end-to-end using a safety helmet dataset with labeled colors. Different colored safety helmets correspond to different types of work and include sample data with labeled no safety helmets.

[0038] S4. Multi-target tracking and deduplication statistics: The ByteTrack algorithm is used to track detected targets, each target is assigned a unique ID, and a global motion compensation module is introduced during the tracking process to offset the influence of the UAV's own motion; identity verification is performed based on a time-series buffer and classification and counting are performed based on spatial logic.

[0039] S5. Job Mapping and Data Output: Based on the color of the safety helmet, map it to the preset job type and output the number of employees on duty for each job type.

[0040] The following is combined Figure 2 The steps of this embodiment will be described in detail.

[0041] In practical applications, step S1 utilizes an industrial-grade drone equipped with a high-resolution gimbal camera to automatically cruise along a pre-set inspection route for water conservancy projects. During flight, the drone collects real-time overhead video streams of the construction site and transmits the collected video streams to edge computing terminals or ground workstations.

[0042] It is important to note that, given the significant elevation differences in the terrain of water conservancy projects, the drones employ a terrain-following flight mode to maintain a constant altitude relative to the ground, ensuring that the collected data on personnel targets are generally consistent in scale.

[0043] In step S2, the edge computing terminal or ground workstation preprocesses the acquired video frames to eliminate environmental interference. Specifically, image preprocessing for water conservancy environments includes:

[0044] S21. Dehazing: For water vapor and morning fog on the water surface, the dark channel prior algorithm or AOD-Net dehazing network is used to enhance the image by dehazing and improve the image clarity.

[0045] S22. Illumination compensation: The MSRCR (Multi-scale Retina Enhancement with Color Restoration) algorithm is used to prevent misjudgment of helmet color due to reflection.

[0046] S23. Slicing Processing: In order to solve the problem of people being too small from a high-altitude perspective, the high-resolution original image (such as 4K) is sliced ​​into multiple overlapping sub-images (such as 640x640), which are then input into the network for detection, and finally the coordinates are mapped and restored.

[0047] In this embodiment, considering that photos taken by drones are typically 4K (3840×2160) or even higher resolution, the YOLOv8 model usually requires the input image to be uniformly scaled to a fixed size (e.g., 640×640 pixels) for inference. During compression, a safety helmet that is only 30×30 pixels in the original image becomes 5×5 pixels after scaling. At this size, the shape, edge, and color features of the safety helmet are almost completely lost, turning into several blurry noise points. The convolutional neural network cannot extract effective features, leading to missed detections. Therefore, this invention adopts an overlapping sliding window slicing mechanism, which cuts the large image into smaller images for separate detection to maintain the original resolution of the target. The specific process is as follows:

[0048] Step 1: Overlapping sliding window slices. In this embodiment, instead of directly scaling the original image, a fixed-size window (e.g., 640×640) is used to perform sliding cropping on the 4K original image. To prevent targets located at the cutting edge from being "cut in half" (becoming unrecognizable), an overlapping area must be maintained between adjacent slices (overlap rate of 10%~30%, for example, set to 20%).

[0049] Step 2: Independent Inference. Each 640×640 sub-image is directly input into the improved YOLOv8 model for prediction. At this stage, the sub-images do not need to be scaled. A 30×30 safety helmet in the original image remains 30×30 when input into the model. The relative pixel ratio is greatly increased, and features are clearly visible.

[0050] Step 3: Coordinate Mapping and Restoration. After the improved YOLOv8 model outputs the target coordinates (x, y) in the subgraph, it converts the target coordinates back to the global coordinates (X, Y) of the original graph based on the offset (Ox, Oy) of the subgraph in the original graph. Formula: X = x + Ox, Y = y + Oy.

[0051] Step 4: Non-maximum suppression. Due to overlapping regions, the same safety helmet may be detected in two adjacent slices, resulting in two overlapping boxes on the original image. This embodiment uses the global non-maximum suppression (NMS) algorithm to filter boxes with excessive overlap (i.e., Intersection over Union (IOU), retaining only the one with the highest confidence, thus removing duplicate detection targets.

[0052] In this embodiment, by image slicing processing and improving the YOLOv8 model, the problem of feature loss of small targets at high altitudes is solved in a coordinated manner from both data and model levels. This overcomes the feature loss problem caused by the small pixel ratio of construction workers and safety helmets in the high-altitude top-down scenario of UAVs, which is a problem of traditional target detection algorithms.

[0053] In step S3, an improved YOLOv8 detection model is constructed, such as... Figure 3 As shown, the following targeted improvements were made to the YOLOv8 infrastructure:

[0054] I. Introduction of an Attention Mechanism: A CBAM (Convolutional Block Attention Module) is embedded at the end of the C2f module (double convolutional CSP bottleneck module) of the YOLOv8 backbone network. This enhances the model's focus on the key features of the safety helmet and suppresses the weights of complex background noise such as steel bars and stones. Figure 3As shown, in this embodiment, the CBAM attention mechanism module is embedded between Stage 3 (outputting P4 features for detecting medium-sized targets) and Stage 4 (outputting P5 features for detecting large targets) of the backbone network. That is, after C2f feature extraction is completed in Stage 3 of the backbone network, a CBAM attention mechanism module is connected in series. This setup allows the feature map to have its feature weights recalibrated through the channel and spatial attention mechanisms of CBAM before being fed into the neck network for multi-scale fusion, or before entering the SPPF layer. This effectively suppresses environmental noise such as water surface light spots and enhances semantic focus on the safety helmet target.

[0055] II. Adding a Tiny Target Detection Layer: Addressing the issue of extremely small target pixel proportions from the high-altitude perspective of UAVs, this embodiment extends the original neck network structure. Specifically, in addition to the existing P3, P4, and P5 feature fusion layers, a top-down high-resolution fusion path is added. The system upsamples the processed P3 feature map (8x downsampling scale) in the neck network by 2x, making its size consistent with the P2 feature map output by the backbone network (4x downsampling scale). Subsequently, the two are concatenated along the channel dimension. The concatenated feature map is input into the subsequent C2f module for feature fusion and extraction, and finally output to the P2 detection head. This P2 detection head is specifically designed for inference on the 4x downsampled high-resolution feature map, enabling accurate capture of extremely small human targets smaller than 32x32 pixels in the image, significantly reducing the false negative rate.

[0056] The improved YOLOv8 model training strategy involves end-to-end training using a dataset of color-coded safety helmets (red, yellow, blue, white, and none), where "none" represents a person not wearing a helmet, which can also be interpreted as a head. The trained improved YOLOv8 model outputs the identified bounding boxes, color categories, and confidence scores based on the input sub-image (a slice of the original image). For each sub-image, after helmet detection and color classification, the target coordinates are converted back to global coordinates in the original image based on the sub-image's offset from the original image, and a global NMS algorithm is used to remove duplicate targets.

[0057] In step S4, for each frame of the acquired drone video stream, the detected safety helmet target bounding box and category information (i.e., color) are input into the tracking algorithm to achieve dynamic statistics. Specifically, in this embodiment, the ByteTrack multi-target tracking algorithm is used. This algorithm uses Kalman filtering to predict the target's position in the next frame and combines it with the Hungarian algorithm for IOU matching to assign a unique tracking ID to each construction worker appearing in the video.

[0058] This invention takes into account that the native ByteTrack algorithm assumes the camera is stationary or that the motion is smooth. However, in this application scenario, the drone, operating at high altitudes, is affected by wind, resulting in shaking, pitch, or rapid displacement. This can cause a significant deviation between the target position predicted by the Kalman filter and the actual position, leading to ID switching (losing track of the drone). Therefore, this invention adds a global motion compensation module before the Kalman filter prediction step.

[0059] Specifically, the global motion compensation module first uses a feature point matching (such as ORB features) or ECC (enhanced correlation coefficient) algorithm to calculate the homography matrix of the two frames of images to obtain the translation and rotation of the background; then, the target coordinates predicted by Kalman filtering are reverse-mapped according to the homography matrix to cancel the motion components of the UAV itself, thereby obtaining the true displacement of the target relative to the ground.

[0060] For example, a scenario where Kalman filter predictions are corrected using translation and rotation (i.e., homography matrix) could be: At time T: The drone sees a worker at coordinates (100, 100). The Kalman filter predicts the worker will move to (105, 100) at time T+1. At time T+1: The drone suddenly translates to the right. Although the worker didn't actually move, in the T+1 view, due to the camera movement, the worker might appear at (50, 100). Conflict: Kalman prediction: (105, 100) (this is the prediction based on the coordinates at time T). Actual detection: (50, 100) (this is the observation in the coordinates at time T+1). Consequence: The predicted and detected values ​​differ too much; ByteTrack will consider these to be two different people, leading to ID switching (loss of tracking). By using the homography matrix of the two frames, we can know that the camera has shifted 55 pixels to the right. We can then use this shift to transform the Kalman prediction from (105,100) to around (50,100), so that the prediction and detection values ​​match.

[0061] In step S4, multi-target tracking and deduplication statistics include two logical levels: target identity verification (de-jittering) and business counting.

[0062] S41, First Level: Identity Verification Based on Timing Buffer (De-jitter Mechanism). A timing state buffer is established for the tracking trajectory output by ByteTrack. The system performs validity verification on each ID: only when the same ID is detected as the same color category in N consecutive frames (e.g., N=5), and the detection confidence is higher than a preset threshold (e.g., 0.6), is the ID marked as a valid target and its job attribute locked. This step is used to eliminate false detections due to water surface reflection and classification flicker caused by motion blur.

[0063] S42, Second Level: Spatial Logic-Based Classification Counting. For IDs already marked as valid targets, perform one or more of the following statistical logic based on actual regulatory requirements:

[0064] Logic A (Counting Decision Line): Determines whether the center point of the trajectory of a valid ID has crossed the preset virtual tripwire (LineCrossing) in the specified direction. If it has crossed, it triggers the cumulative counting of traffic (such as counting the total number of people entering the venue).

[0065] Logic B (Region Determination Logic): Determine whether the anchor point coordinates of a valid ID are located inside a preset polygonal region (ROI). If they are inside, count the number of people currently on duty (e.g., count the number of people currently on the work surface).

[0066] Deduplication strategy: For IDs that have already been counted (in logic A) or IDs that are within the region (in logic B), use unique tracking IDs for indexing to prevent duplicate accumulation caused by the target's brief stay or occlusion.

[0067] In practical applications, event deduplication is crucial for tracking violation counts. For example, when calculating "How many violations occurred today?", without deduplication, a drone recording at 30 FPS (30 frames per second) might show "300 violations" if a worker accidentally enters a danger zone and stays there for 10 seconds. To prevent data absurdity, event deduplication logic is needed to count independent intrusion events. Specifically, the same ID crossing from the "safe zone" to the "danger zone" counts as one violation. It's only counted as a second violation if the ID leaves the area and re-enters. Thus, the report could display: "1 violation, 10 seconds of stay."

[0068] In this embodiment, the confidence level refers to the classification probability value output by the detector head in the improved YOLOv8 model. The specific judgment logic related to the confidence level can be as follows:

[0069] (1) Detection stage: The improved YOLOv8 model is used to extract features and infer from each sub-image of the current video frame to obtain a set of detection results including target bounding boxes, category labels and classification confidence.

[0070] (2) Tracking phase: The ByteTrack algorithm assigns a unique tracking ID to each target based on the detection results and associates the target with the classification confidence of the current frame.

[0071] (3) Statistical screening stage: The system sets a high confidence counting threshold (e.g., T=0.7). The system only recognizes the identity of the target as valid and triggers the counter of the corresponding job type to increment when the classification confidence of the target associated with a specific ID is greater than T in N consecutive frames (e.g., N=5) and the classification category remains consistent.

[0072] In this embodiment, the improved high-precision classification capability of YOLOv8 is used as a verification condition for the existence of ByteTrack, which effectively filters out low-quality prediction boxes (such as the inertial prediction of Kalman filter when the target is occluded) and background false detections that may occur during the tracking process, ensuring the authenticity of the people count.

[0073] In step S5, based on the identified safety helmet color, it is automatically mapped to the job type according to preset rules, and statistical results are output in real time (for each image in the video). The mapping rules can be as follows: yellow—general worker; white—management / supervisory personnel; red—safety officer; blue—special operations personnel; no safety helmet—violation personnel. The output format can be: generating a statistical report containing the real-time number of workers on duty for each job type and the number of violations, and displaying a flashing red box alarm for violators on the monitoring interface.

[0074] The effectiveness and advantages of the present invention will be illustrated below with several application examples.

[0075] Application Example 1: High-altitude small target detection and statistics at the dam main body pouring site

[0076] 1. Application Scenario Description: This embodiment is applied to the concrete pouring site of the main dam of a large hydropower station. The construction surface has a large vertical height difference, and the river surface is shrouded in heavy fog in the morning. The drone needs to cruise at an altitude of more than 50 meters above the ground. The pixels of people in the captured images are extremely small (average less than 20x20 pixels), and the background contains a large amount of steel mesh and reflections from the wet concrete surface.

[0077] 2. System Configuration and Parameter Settings:

[0078] Drone platform: DJI M300RTK drone, equipped with H20T zoom camera.

[0079] Algorithm model: The improved YOLOv8-Small version is used.

[0080] Color mapping rules: Yellow—pouring worker; White—supervisor / management personnel; Red—safety officer.

[0081] 3. Specific implementation process:

[0082] In step S1, the drone is set to "ground-following flight" mode, maintaining a height of 60 meters relative to the work surface, and recording video in 4K resolution.

[0083] In step S2, the ground station receives the video stream and first performs defogging on each frame of the image to remove interference from water vapor on the river surface; then it cuts the large 3840x2160 image into six overlapping sub-images of 640x640 (overlap rate 15%).

[0084] In step S3, the sub-image is input into the improved YOLOv8 model. The model uses the P2 detector head to accurately capture the tiny yellow safety helmets moving in the steel mesh, and uses the CBAM attention mechanism module to filter out the reflections of water accumulation on the concrete surface.

[0085] In step S4, the system identifies 15 yellow safety helmets (workers) and 2 white safety helmets (supervisors) in the current screen.

[0086] In step S5, the digital twin screen displays: "Dam section A3 area: 15 general workers, 2 managers, personnel configuration is compliant."

[0087] 4. Implementation results: Compared with traditional manual counting, the detection accuracy of this embodiment in foggy weather has been improved from 75% to 93%, effectively solving the problem of missed detection at high altitudes.

[0088] Application Example 2: Electronic Fences and Violation Warnings in Hazardous Areas of River Management Projects

[0089] 1. Application Scenario Description: This embodiment is applied to urban river dredging and slope protection projects. The site environment is open, but there are potential hazards in deep water areas. The key requirements are to prevent non-specialized personnel from entering the edge of deep water and to track the on-duty time of each type of worker.

[0090] 2. System Configuration and Parameter Settings:

[0091] Drone platform: The lightweight Mavic 3 Enterprise is used for low-altitude fixed-point hovering shooting.

[0092] Algorithm model: The improved YOLOv8-Nano version is used (in pursuit of inference speed, achieving 30 FPS in real time).

[0093] Tracking Algorithm: Enable ByteTrack multi-target tracking, set the ID survival threshold in the ByteTrack algorithm to 30 frames, and the deduplication logic threshold to 5 frames.

[0094] Color mapping rules: Blue - Special operations personnel (permitted); Yellow - General laborers (prohibited); No hat - Serious violation.

[0095] Area settings: Manually draw a polygon on the monitoring screen and set the area within 5 meters of the center of the river as the "red restricted area".

[0096] 3. Specific implementation steps:

[0097] Steps S1 to S3 are similar to those in the above embodiment. In step S4, the model detects personnel in the scene in real time. When a person wearing a yellow safety helmet is assigned ID 1024 by ByteTrack and moves into the "red restricted area," the algorithm's pseudocode is: Class(ID_1024) == 'yellow' AND Position(ID_1024) in ROI_Red. The judgment result is "violation of boundary." The system immediately triggers an audible and visual alarm, automatically captures a close-up image of the person, uploads it to the cloud database, and records the time of the violation.

[0098] In step S5, at the end of each workday, the system automatically generates a report based on the ID's survival time: "Today, special operations personnel (blue hats) accumulated 120 hours of effective working time, and general workers accidentally entered the danger zone 3 times."

[0099] 4. Implementation Results: This embodiment realizes intelligent dynamic management and control of the construction site. It not only counts the number of people, but also realizes safety early warning through logical judgment, with a false alarm rate of less than 2%.

[0100] This invention discloses a UAV-based system for color recognition and classification statistics of safety helmets used in water conservancy engineering construction workers. The system is used to implement the aforementioned UAV-based method for color recognition and classification statistics of safety helmets used in water conservancy engineering construction workers. The system includes:

[0101] The data acquisition module is used to acquire aerial video data of the construction site of the water conservancy project by the UAV following the preset route.

[0102] The preprocessing module is used to perform dehazing and illumination compensation on the acquired video frames, and to cut the original image into multiple overlapping sub-images;

[0103] The neural network inference module is used to input the subgraph into the improved YOLOv8 model for safety helmet detection and color classification. The improved YOLOv8 model embeds the CBAM attention mechanism module in the backbone network and adds a P2 detection layer for small targets in the detection head. The model is trained end-to-end using a safety helmet dataset with labeled colors. Different colored safety helmets correspond to different types of work and include sample data with labeled no safety helmets.

[0104] The multi-target tracking and deduplication module uses the ByteTrack algorithm to track detected targets, assigns a unique ID to each target, and introduces a global motion compensation module during the tracking process to offset the influence of the UAV's own motion; it performs identity verification based on a temporal buffer and classification and counting based on spatial logic.

[0105] The results output module is used to map the safety helmet color to a preset job type and output the number of employees on duty for each job type and / or warning information.

[0106] This invention also discloses a computer program product, including a computer program that, when executed by a processor, implements the steps of the method for color recognition and classification statistics of safety helmets for construction workers in water conservancy projects based on unmanned aerial vehicles (UAVs). The program code for implementing the method of this invention can be written in any combination of one or more programming languages. This program code can be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, such that when executed by the processor or controller, the program code causes the steps of the method of this invention to be implemented.

[0107] The UAV-based system for color recognition and classification statistics of safety helmets for water conservancy construction workers provided in this embodiment, as well as the computer program product, have the same beneficial effects as the UAV-based method for color recognition and classification statistics of safety helmets for water conservancy construction workers described above, and will not be repeated here.

[0108] It should be noted that the various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the systems or apparatus disclosed in the embodiments, since they correspond to the methods disclosed in the embodiments, the descriptions are relatively simple, and relevant parts can be referred to the method section. Any aspects not described in detail in this invention are well-known techniques to those skilled in the art.

[0109] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the principle of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs), characterized in that, Includes the following steps: Aerial data of aerial photography collected by drones from above the construction site of a water conservancy project, following a preset flight path; The acquired video frames are dehazed and illumination compensated, and the original image is cut into multiple overlapping sub-images; The subgraph is input into the improved YOLOv8 model for safety helmet detection and color classification. The improved YOLOv8 model embeds the CBAM attention mechanism module in the backbone network and adds a P2 detection layer for small targets in the detection head. The model is trained end-to-end using a safety helmet dataset with labeled colors. Different colored safety helmets correspond to different types of work and include sample data with labeled no safety helmets. The ByteTrack algorithm is used to track detected targets, each target is assigned a unique ID, and a global motion compensation module is introduced during the tracking process to counteract the influence of the UAV's own motion; identity verification is based on a temporal buffer and classification and counting are based on spatial logic. Based on the color mapping of safety helmets to preset job types, output the number of employees on duty for each job type and / or early warning information.

2. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 1, characterized in that, The process of dehazing and illumination compensation of the acquired video frames includes: using a dark channel prior algorithm or an AOD-Net dehazing network for dehazing, and using an MSRCR algorithm for illumination compensation.

3. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 1, characterized in that, When the original image is cut into multiple overlapping sub-images, an overlapping sliding window is used to perform sliding cropping on the original image, with an overlap rate of 10% to 30%. After the sub-images are input into the improved YOLOv8 model for safety helmet detection and color classification, the target coordinates are converted back to the global coordinates of the original image based on the offset of the sub-image in the original image, and the global NMS algorithm is used to remove duplicate targets.

4. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 1, characterized in that, In the improved YOLOv8 model, after C2f feature extraction is completed in Stage 3 of the backbone network, a CBAM attention mechanism module is connected in series. The P2 detection layer is constructed by splicing and fusing the P2 feature map output by the backbone network after a 2x upsampling operation on the P3 feature map processed in the neck network. It is used to detect small targets with a pixel size of less than 32×32.

5. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 1, characterized in that, The target bounding box and category information output by the improved YOLOv8 model are input into the ByteTrack algorithm. The ByteTrack algorithm uses Kalman filtering to predict the target's position in the next frame and combines it with the Hungarian algorithm for IOU matching to assign a unique tracking ID to each construction worker appearing in the video. The global motion compensation module performs motion compensation on the target position predicted by Kalman filtering by calculating the homography matrix of the two frames.

6. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 1, characterized in that, The identity verification based on the time-series buffer includes: when the same ID is detected as the same color category in a consecutive preset number of frames, and the detection confidence is higher than a preset threshold, the ID is marked as a valid target and its job attribute is locked.

7. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 6, characterized in that, The spatial logic-based classification and counting includes: for IDs marked as valid targets, executing counting judgment lines and / or area judgment statistical logic according to actual regulatory needs; wherein the counting judgment line logic is: determining whether the trajectory center point of the valid target ID crosses a preset virtual tripwire in a specified direction, and if it does, triggering traffic accumulation counting; the area judgment logic is: determining whether the anchor point coordinates of the valid target ID are located inside a preset polygonal area, and if they are inside, counting them as the real-time on-duty personnel.

8. The method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to claim 1, characterized in that, When performing classification and counting based on spatial logic, event deduplication is implemented for violation events, and independent intrusion events are counted. When the ID of the same valid target intrudes into the preset area, it is counted once. The count is only accumulated when the ID leaves the preset area and re-enters.

9. A system for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs), characterized in that, The system is used to implement the method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles (UAVs) according to any one of claims 1-8. The system includes: The data acquisition module is used to acquire aerial video data of the construction site of the water conservancy project by the UAV following the preset route. The preprocessing module is used to perform dehazing and illumination compensation on the acquired video frames, and to cut the original image into multiple overlapping sub-images; The neural network inference module is used to input the subgraph into the improved YOLOv8 model for safety helmet detection and color classification. The improved YOLOv8 model embeds the CBAM attention mechanism module in the backbone network and adds a P2 detection layer for small targets in the detection head. The model is trained end-to-end using a safety helmet dataset with labeled colors. Different colored safety helmets correspond to different types of work and include sample data with labeled no safety helmets. The multi-target tracking and deduplication module uses the ByteTrack algorithm to track detected targets, assigns a unique ID to each target, and introduces a global motion compensation module during the tracking process to offset the influence of the UAV's own motion; it performs identity verification based on a temporal buffer and classification and counting based on spatial logic. The results output module is used to map the safety helmet color to a preset job type and output the number of employees on duty for each job type and / or warning information.

10. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by the processor, it implements the steps of the method for color recognition and classification statistics of safety helmets for water conservancy engineering construction workers based on unmanned aerial vehicles, as described in any one of claims 1-8.