A water gauge region extraction calibration method based on YOLOv8
By using the YOLOv8 model and distortion correction technology, the problems of low efficiency and large error in water level gauge monitoring have been solved, achieving efficient and accurate calibration of the water level gauge area, and adapting to multiple application scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- NANJING AUTOMATION INST OF WATER CONSERVANCY & HYDROLOGY MINIST OF WATER RESOURCES
- Filing Date
- 2026-02-28
- Publication Date
- 2026-06-05
AI Technical Summary
Existing water level gauge monitoring and calibration methods suffer from low efficiency, high cost, and susceptibility to errors. In particular, severe image distortion occurs in complex outdoor scenarios, affecting data accuracy and model training precision.
The YOLOv8 model is used for automatic detection, combined with distortion correction and manual fine-tuning. The water level gauge area is selected by framing the field of view with a parallelogram and zero-filling is performed to generate a normalized water level gauge image, thereby improving calibration accuracy and efficiency.
It achieves efficient and accurate extraction and calibration of the water gauge area, significantly improving calibration efficiency and data accuracy, reducing the workload and errors of manual calibration, and adapting to different scenarios and lighting conditions.
Smart Images

Figure CN122156967A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to a method for extracting and calibrating water gauge areas based on YOLOv8, belonging to the field of hydrological monitoring technology. Background Technology
[0002] As a core measurement tool in hydrological monitoring, the accuracy of water gauge readings directly determines the reliability of hydrological data. However, there are many problems with current water gauge monitoring and calibration work.
[0003] Currently, the calibration of water level gauge images mainly adopts a full manual calibration method, that is, manually marking the bounding boxes and related information of the water level gauge region image by image using image calibration tools. However, the traditional full manual calibration method is extremely inefficient. When building a large-scale dataset containing tens of thousands or even hundreds of thousands of images, manual calibration consumes a lot of manpower and time. Traditional manual calibration is affected by complex outdoor scenes such as changes in lighting, differences in shooting angles, and environmental interference, resulting in low efficiency, high cost, and susceptibility to subjective errors, making it difficult to meet the needs of large-scale calibration. Secondly, the consistency of manual calibration is difficult to guarantee. Differences in the operating habits of different calibrators may lead to deviations in the position and size of bounding boxes, affecting the quality of the dataset and thus reducing the accuracy of subsequent model training. In addition, the shooting scenes of water level gauge images are complex, such as rainy days, foggy days, and backlighting, and the water level gauge features are not obvious in some photos, further increasing the difficulty and time consumption of manual calibration. During outdoor shooting, due to the imaging characteristics of camera lenses, shooting distance and angle limitations, water level gauge images are prone to geometric distortions such as parallel edge deformation and scale distortion.
[0004] Existing technologies often directly extract regions from the original distorted images without setting up a targeted distortion correction step. This results in the distortion of key information in the extracted water gauge area, such as scales and edges, leading to significant errors in subsequent calibration and readings, which seriously affects the accuracy of hydrological data.
[0005] The existing calibration process is fragmented, lacks end-to-end intelligent tools, and suffers from poor model training sample adaptability and weak generalization ability, resulting in high model deployment and maintenance costs and failing to guarantee the efficiency and accuracy of hydrological monitoring. Summary of the Invention
[0006] The purpose of this invention is to provide a water level gauge region extraction and calibration method based on YOLOv8, which can solve the problems of low efficiency, high cost and large extraction and reading errors caused by image geometric distortion in existing manual calibration methods, thereby improving calibration efficiency and data accuracy.
[0007] To achieve the above objectives, the present invention provides the following technical solution: In a first aspect, the present invention provides a method for water level gauge region extraction and calibration based on YOLOv8, comprising: Obtain water level gauge image samples, select a portion of the water level gauge image samples for manual calibration to obtain an initial calibration sample set, and use the initial calibration sample set to train the YOLOv8 model to obtain the optimal model for detecting water level gauge regions. Obtain the water gauge image to be calibrated. For water gauge images with geometric distortion, perform distortion correction: select a parallelogram field of view that includes the entire water gauge area for distortion correction. Define the standard rectangular area of the water gauge obtained after correction as a pixel set. Perform zero-padding operation on pixel areas within the size of the original water gauge image that do not belong to the pixel set to generate a normalized water gauge image with the same size as the original water gauge image. The optimal model is used to automatically detect the water level gauge image to be calibrated, and the coordinates of the preliminary bounding box of the water level gauge region are obtained. The preliminary bounding box is then corrected to obtain the coordinates of the corrected bounding box. The coordinates of the corrected bounding box are converted into normalized coordinates in YOLO format and exported as a calibration file to obtain an automatically calibrated sample set. The initial calibration sample set is integrated with the automatic calibration sample set to form the final water gauge calibration dataset.
[0008] In conjunction with the first aspect, further obtaining water level gauge image samples includes: Collect water level photos from different scenes, shooting angles, and lighting conditions; Preprocessing of water level gauge images: The size of the water level gauge images is unified using bilinear interpolation algorithm, and Gaussian filtering is used to remove salt-and-pepper noise and Gaussian noise from the water level gauge images to obtain water level gauge image samples.
[0009] In conjunction with the first aspect, further, a portion of water level gauge image samples are manually calibrated to obtain an initial calibration sample set. This includes: selecting a portion of water level gauge image samples and importing them into an image calibration tool for manual calibration; using the rectangle calibration function to select the maximum bounding rectangle of the water level gauge, ensuring that the key information of the entire water level gauge area is completely contained within the bounding box; setting water level gauge category labels; calibrating all water level gauge areas for each water level gauge image sample; and generating a calibration file containing water level gauge category labels and bounding box coordinates to obtain the initial calibration sample set.
[0010] In conjunction with the first aspect, further, the YOLOv8 model is trained using the initial calibration sample set to obtain the optimal model for detecting water level gauge regions. This includes setting the batch size and initial learning rate; setting the learning rate to decay with cosine of the iterations and setting an early stopping mechanism; using the full intersection-over-union loss function; and stopping training when the accuracy of the validation set reaches the accuracy threshold to obtain the optimal model for detecting water level gauge regions.
[0011] In conjunction with the first aspect, furthermore, the edges of the parallelogram field of view are parallel to the top and bottom edges and the left and right edges of the water level gauge, respectively, and the pixel coordinates of the four vertices of the parallelogram field of view are respectively... , , , And satisfy .
[0012] In conjunction with the first aspect, the pixel set is further defined as follows: ; in, Represents a set of pixels. , These represent the pixel x-coordinate and pixel y-coordinate of the standard rectangular region of the water gauge after correction, respectively. , These represent the minimum and maximum values of the pixel x-coordinates of the standard rectangular region of the water level gauge after correction. , These represent the minimum and maximum values of the pixel ordinates of the standard rectangular region of the water level gauge after correction, respectively. The pixel definition of a normalized water level gauge image is: ; in, , Let x and y represent the pixel x-coordinate and pixel y-coordinate of the normalized water level gauge image, respectively. Indicates the normalized water gauge image in Pixel value at that location, This indicates the corrected water gauge image in The pixel value at that location.
[0013] In conjunction with the first aspect, further, the initial bounding box is corrected to obtain the coordinates of the corrected bounding box. This includes manually adjusting the bounding box position of the water level gauge image that is offset, missing, or mislabeled, supplementing or deleting erroneous bounding boxes, and updating the pixel coordinates of the bounding box to obtain the coordinates of the corrected bounding box.
[0014] In conjunction with the first aspect, the further transformation formula for converting the corrected bounding box coordinates to YOLO normalized coordinates is as follows: ; in, , These represent the x and y coordinates of the center point of the normalized bounding box, respectively. , These represent the width and height of the normalized bounding box, respectively. , Let represent the pixel width and pixel height of the normalized water level gauge image, respectively. , These represent the x-coordinate and y-coordinate of the top-left corner of the corrected bounding box, respectively. , These represent the x-coordinate and y-coordinate of the bottom right corner of the corrected bounding box, respectively. , These represent the pixel width and pixel height of the corrected bounding box, respectively.
[0015] Secondly, the present invention provides a water level gauge region extraction and calibration system based on YOLOv8, comprising: The data acquisition module is used to acquire water level gauge image samples, select a portion of the water level gauge image samples for manual calibration to obtain an initial calibration sample set, and use the initial calibration sample set to train the YOLOv8 model to obtain the optimal model for detecting water level gauge regions. The distortion correction module is used to acquire the water gauge image to be calibrated and to perform distortion correction on the water gauge image to be calibrated that has geometric distortion: a parallelogram field of view containing the entire water gauge area is selected for distortion correction, the standard rectangular area of the water gauge obtained after correction is defined as a pixel set, and zero-padding is performed on the pixel areas within the size of the original water gauge image that do not belong to the pixel set to generate a normalized water gauge image with the same size as the original water gauge image. The automatic calibration module is used to automatically detect the water level gauge image to be calibrated using the optimal model, obtain the coordinates of the preliminary bounding box of the water level gauge region, correct the preliminary bounding box to obtain the coordinates of the corrected bounding box, and convert the coordinates of the corrected bounding box into normalized coordinates in YOLO format and export them as a calibration file to obtain an automatic calibration sample set. The integration module is used to integrate the initial calibration sample set with the automatic calibration sample set to form the final water gauge calibration dataset.
[0016] Thirdly, the present invention provides a computer device, comprising: Storage medium: used to store computer programs; Processor: Used to execute computer programs to implement the YOLOv8-based water gauge region extraction and calibration method described in the first aspect.
[0017] Fourthly, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the YOLOv8-based water level gauge region extraction and calibration method described in the first aspect.
[0018] Fifthly, the present invention provides a computer program product, including a computer program that, when executed by a processor, implements the YOLOv8-based water level region extraction and calibration method described in the first aspect.
[0019] Compared with the prior art, the beneficial effects of the present invention are: The water level gauge region extraction and calibration method based on YOLOv8 provided by this invention replaces manual bounding box selection with automatic model detection. It only requires manual fine-tuning of a small number of images with offset, missing, or incorrectly labeled annotations. Compared to purely manual calibration, it significantly improves calibration efficiency and can meet the calibration needs of large-scale water level gauge data. Addressing the problem of water level gauge image distortion, it employs a scheme of selecting the water level gauge region using a parallelogram with a large field of view, distortion correction, and zero-padding for size alignment. This achieves accurate correction of distorted water level gauges, effectively avoiding errors caused by directly extracting regions from distorted images. This improves the accuracy of subsequent bounding box coordinates to the pixel level, providing a high-quality image foundation for accurate readings. Attached Figure Description
[0020] Figure 1 This is a flowchart of the water level gauge region extraction and calibration method based on YOLOv8 provided in an embodiment of the present invention. Detailed Implementation
[0021] The technical solution of the present invention will be further described in detail below with reference to specific embodiments.
[0022] Embodiments of the present invention are described in detail below. Examples of these embodiments are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described below with reference to the accompanying drawings are exemplary and are only used to explain the present invention, and should not be construed as limiting the present invention. Unless otherwise specified, embodiments of the present invention and the technical features thereof can be combined with each other.
[0023] This invention provides a method for water level gauge region extraction and calibration based on YOLOv8, including: Obtain water level gauge image samples, select a portion of the water level gauge image samples for manual calibration to obtain an initial calibration sample set, and use the initial calibration sample set to train the YOLOv8 model to obtain the optimal model for detecting water level gauge regions. Obtain the water gauge image to be calibrated. For water gauge images with geometric distortion, perform distortion correction: select a parallelogram field of view that includes the entire water gauge area for distortion correction. Define the standard rectangular area of the water gauge obtained after correction as a pixel set. Perform zero-padding operation on pixel areas within the size of the original water gauge image that do not belong to the pixel set to generate a normalized water gauge image with the same size as the original water gauge image. The optimal model is used to automatically detect the water level gauge image to be calibrated, and the coordinates of the preliminary bounding box of the water level gauge region are obtained. The preliminary bounding box is then corrected to obtain the coordinates of the corrected bounding box. The coordinates of the corrected bounding box are converted into normalized coordinates in YOLO format and exported as a calibration file to obtain an automatically calibrated sample set. The initial calibration sample set is integrated with the automatic calibration sample set to form the final water gauge calibration dataset.
[0024] The non-interactive symmetric revocable encryption method provided in this invention solves the problems of low efficiency, high cost, and large extraction and reading errors caused by image geometric distortion in traditional manual calibration of water level gauge images. By combining automated model detection, manual fine-tuning interaction, and large field-of-view distortion correction process, it achieves efficient and accurate extraction and calibration of the water level gauge area, significantly improving calibration efficiency and data accuracy.
[0025] Figure 1 This is a flowchart of the YOLOv8-based water level gauge region extraction and calibration method provided in this embodiment. This flowchart only illustrates the logical order of the method in this embodiment; however, different methods may be used without conflict. Figure 1 Complete the steps shown or described in the order indicated.
[0026] The YOLOv8-based water level gauge region extraction and calibration method provided in this embodiment can be applied to a terminal and can be executed by a YOLOv8-based water level gauge region extraction and calibration system. This system can be implemented by software and / or hardware and can be integrated into the terminal, such as any tablet computer or computer device with communication capabilities.
[0027] In one possible embodiment, obtaining a water level gauge image sample specifically includes the following steps: Step 1: Collect water level photos from different scenes, shooting angles, and lighting conditions; Specifically, we extensively collected water level gauge photos from various scenarios, including rivers, reservoirs, and areas prone to flooding; from different shooting angles, such as frontal views and tilted views within 30°; and under different lighting conditions, such as sunny days, cloudy days, and evenings, to ensure sample diversity.
[0028] Step 2: Preprocess the water level gauge photos: Use bilinear interpolation to unify the size of the water level gauge photos, and use Gaussian filtering to remove salt-and-pepper noise and Gaussian noise from the water level gauge photos to obtain water level gauge image samples.
[0029] Specifically, bilinear interpolation was used to uniformly scale all water level gauge photos to 640×640 pixels to ensure the consistency of the input size for training models. A Gaussian filter with a kernel size of 3×3 and a standard deviation of 0.8 was used to remove salt-and-pepper noise and Gaussian noise from the water level gauge photos, thereby improving the clarity of the water level gauge images.
[0030] In one possible embodiment, selecting a portion of water level gauge image samples for manual calibration to obtain an initial calibration sample set specifically includes: selecting a portion of water level gauge image samples and importing them into an image calibration tool for manual calibration; using the rectangle calibration function to select the maximum bounding rectangle of the water level gauge, ensuring that the key information of the entire water level gauge area is completely contained within the bounding box; setting water level gauge category labels; calibrating all water level gauge areas for each water level gauge image sample; and generating a calibration file containing water level gauge category labels and bounding box coordinates to obtain the initial calibration sample set.
[0031] Specifically, 1000 water level gauge images were selected as manual calibration samples. This number ensures a sufficient sample base for model training while controlling the workload of manual calibration. The LabelMe image calibration tool was used for manual calibration: after opening the tool and importing the samples, the rectangle annotation function was used to select the largest bounding rectangle of the water level gauge, ensuring that the key information of the entire water level gauge area was completely contained within the bounding box. The category label was set to "ruler". All water level gauge areas were calibrated for each sample. After calibration, the image calibration tool automatically generated a txt format calibration file with the same name as the sample, containing the category label, bounding box coordinates, and other information.
[0032] In one possible embodiment, training a YOLOv8 model using an initial calibration sample set to obtain the optimal model for detecting water level gauge regions specifically includes: setting the batch size and initial learning rate; setting the learning rate to decay cosine with each iteration and setting an early stopping mechanism; using full intersection-over-union loss as the loss function; stopping training when the accuracy of the validation set reaches the accuracy threshold to obtain the optimal model for detecting water level gauge regions.
[0033] Specifically, YOLOv8 was chosen as the base model to balance training speed and detection accuracy. Training parameters were configured as follows: batch size was set to 16 to accommodate standard GPU memory; the initial learning rate was set to 0.01, with the learning rate decreasing cosinely with each iteration to avoid overfitting; the number of training iterations was set to 300; and the early stopping tolerance value was set to 50, stopping training if the validation set accuracy did not improve within 50 iterations. The loss function used was Complete Intersection over Union (CIoU) loss to improve the accuracy of bounding box regression. The paths to the training and validation sets were configured in the YOLOv8 training configuration file. Model training was started, and the training set loss and validation set accuracy (mAP@0.5) were monitored in real time. Training was stopped when the validation set mAP@0.5 reached 90% or higher, and the optimal model weight file was saved.
[0034] Directly identifying the water gauge region in distorted water gauge images can lead to significant errors. This embodiment corrects geometric distortion in the water gauge image to be calibrated by utilizing the parallelism and straightness of the water gauge. A parallelogram-shaped field of view encompassing the entire water gauge region is selected for distortion correction. The corrected standard rectangular region of the water gauge is defined as a pixel set. Pixels within the original water gauge image size that do not belong to this set are zero-padded to generate a pixel set with the same dimensions as the original water gauge image. Consistent normalized water gauge image.
[0035] In one possible embodiment, the edges of the parallelogram field of view are parallel to the top, bottom, left, and right edges of the water level gauge, respectively, and the pixel coordinates of the four vertices of the parallelogram field of view are respectively... , , , And satisfy .
[0036] The pixel set is: ; in, Represents a set of pixels. , These represent the pixel x-coordinate and pixel y-coordinate of the standard rectangular region of the water gauge after correction, respectively. , These represent the minimum and maximum values of the pixel x-coordinates of the standard rectangular region of the water level gauge after correction. , These represent the minimum and maximum values of the pixel ordinates of the standard rectangular region of the water level gauge after correction.
[0037] The pixel definition of a normalized water level gauge image is: ; in, , Let x and y represent the pixel x-coordinate and pixel y-coordinate of the normalized water level gauge image, respectively. Indicates the normalized water gauge image in Pixel value at that location, This indicates the corrected water gauge image in The pixel value at that location.
[0038] In one possible embodiment, correcting the initial bounding box to obtain the coordinates of the corrected bounding box specifically includes: manually adjusting the bounding box position of the water level indicator image that is offset, missing, or mislabeled, supplementing or deleting erroneous bounding boxes, and updating the pixel coordinates of the bounding box to obtain the coordinates of the corrected bounding box.
[0039] Specifically, the water level gauge image to be calibrated is input into the optimal model for automatic detection, and the coordinates of the preliminary bounding box are output. The preliminary bounding box is displayed by a visual interactive interface. The visual interactive interface includes component buttons such as batch annotation, adding / deleting categories, automatic calibration, deleting selected boxes, and saving. It can overlay the water level gauge image with the detected bounding box.
[0040] To improve the model's recall rate, the confidence threshold is lowered to 0.3 to 0.5. This embodiment achieves a shift from "better to miss than to miss" to "better to miss than to miss," and subsequently, erroneous labels are removed through manual correction. A large number of unlabeled water level gauge images are batch-input into a visual interactive interface, which automatically identifies the water level gauge region in each image, outputs the bounding box position and category label, and generates initial automatic calibration results. The initial automatic calibration results are then filtered, retaining accurately calibrated images. For a few images with offset, missing, or incorrectly calibrated bounding boxes, the bounding box positions are manually adjusted, additional calibrations are made, or erroneous bounding boxes are deleted. The pixel coordinates of the bounding boxes are updated in real time.
[0041] In one possible embodiment, the conversion formula for converting the corrected bounding box coordinates to YOLO-formatted normalized coordinates is as follows: ; in, , These represent the x and y coordinates of the center point of the normalized bounding box, respectively. , These represent the width and height of the normalized bounding box, respectively. , Let represent the pixel width and pixel height of the normalized water level gauge image, respectively. , These represent the x-coordinate and y-coordinate of the top-left corner of the corrected bounding box, respectively. , These represent the x-coordinate and y-coordinate of the bottom right corner of the corrected bounding box, respectively. , These represent the pixel width and pixel height of the corrected bounding box, respectively.
[0042] Specifically, the coordinates of the corrected bounding box are converted into normalized coordinates in YOLO format and exported as a calibration file in txt format to obtain an automatically calibrated sample set.
[0043] In one possible embodiment, the 1000 initially manually calibrated samples and the corrected automatically calibrated samples are integrated, with a unified format and storage path, to form a complete water level gauge calibration dataset. The integrated dataset undergoes quality verification: 100 images are randomly selected to check the accuracy and consistency of the bounding boxes, ensuring that the distance between the edges of the bounding boxes and the water level gauge boundary does not exceed 5 pixels, and that there are no obvious mislabeling or omissions. After passing the verification, the dataset can be directly used for training subsequent water level gauge recognition models.
[0044] The water level gauge region extraction and calibration method based on YOLOv8 provided in this invention replaces manual bounding box selection with automatic model detection. Only minor manual adjustments are needed for a small number of images with offset, missing, or incorrectly labeled areas. Compared to purely manual calibration, this significantly improves calibration efficiency and can meet the calibration needs of large-scale water level gauge data. Addressing the issue of water level gauge image distortion, a scheme involving parallelogram-based large field-of-view bounding box selection, distortion correction, and zero-padding for size alignment achieves accurate correction of distorted water level gauges. After correction, the parallelism and straightness of the water level gauge region are well restored, effectively avoiding errors caused by directly extracting regions from distorted images. This improves the accuracy of subsequent bounding box coordinates to the pixel level, providing a high-quality image foundation for accurate readings. For water level gauge photo calibration under different scenes and lighting conditions, the number of manually calibrated samples and the model confidence threshold can be flexibly adjusted to adapt to the needs of constructing datasets of different sizes and accuracy requirements. The calibrated dataset can be directly used for training related models such as water level gauge recognition and water level measurement, showing broad application prospects.
[0045] This invention provides a YOLOv8-based water level gauge region extraction and calibration system, comprising: The data acquisition module is used to acquire water level gauge image samples, select a portion of the water level gauge image samples for manual calibration to obtain an initial calibration sample set, and use the initial calibration sample set to train the YOLOv8 model to obtain the optimal model for detecting water level gauge regions. The distortion correction module is used to acquire the water gauge image to be calibrated and to perform distortion correction on the water gauge image to be calibrated that has geometric distortion: a parallelogram field of view containing the entire water gauge area is selected for distortion correction, the standard rectangular area of the water gauge obtained after correction is defined as a pixel set, and zero-padding is performed on the pixel areas within the size of the original water gauge image that do not belong to the pixel set to generate a normalized water gauge image with the same size as the original water gauge image. The automatic calibration module is used to automatically detect the water level gauge image to be calibrated using the optimal model, obtain the coordinates of the preliminary bounding box of the water level gauge region, correct the preliminary bounding box to obtain the coordinates of the corrected bounding box, and convert the coordinates of the corrected bounding box into normalized coordinates in YOLO format and export them as a calibration file to obtain an automatic calibration sample set. The integration module is used to integrate the initial calibration sample set with the automatic calibration sample set to form the final water gauge calibration dataset.
[0046] The YOLOv8-based water level gauge region extraction and calibration system provided in this embodiment of the invention can execute the YOLOv8-based water level gauge region extraction and calibration method provided in this embodiment of the invention, and has the corresponding functional modules and beneficial effects of the method.
[0047] This invention provides a computer device, comprising: Storage medium: used to store computer programs; Processor: Used to execute computer programs to implement the YOLOv8-based water gauge region extraction and calibration method provided in this embodiment of the invention.
[0048] This invention provides a computer-readable storage medium storing a computer program thereon. When executed by a processor, the computer program implements the YOLOv8-based water level gauge region extraction and calibration method provided in this invention.
[0049] This invention provides a computer program product, including a computer program that, when executed by a processor, implements the YOLOv8-based water level gauge region extraction and calibration method provided in this invention.
[0050] Those skilled in the art will understand that embodiments of the present invention can be provided as methods, systems, or computer program products. Therefore, the present invention can take the form of a completely hardware embodiment, a completely software embodiment, or an embodiment combining software and hardware aspects. Furthermore, the present invention can take the form of a computer program product embodied on one or more computer-usable storage media (including, but not limited to, disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.
[0051] This invention is described with reference to flowchart illustrations and / or block diagrams of methods, apparatus (systems), and computer program products according to embodiments of the invention. It will be understood that each block of the flowchart illustrations and / or block diagrams, as well as combinations of blocks in the flowchart illustrations and / or block diagrams, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, special-purpose computer, embedded processor, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, generate instructions for implementing the flowchart. Figure 1 One or more processes and / or boxes Figure 1 A system that specifies functions in one or more boxes.
[0052] These computer program instructions may also be stored in a computer-readable storage medium that can direct a computer or other programmable data processing device to function in a particular manner, such that the instructions stored in the computer-readable storage medium produce an article of manufacture including an instruction set implemented in a process. Figure 1 One or more processes and / or boxes Figure 1 The function specified in one or more boxes.
[0053] These computer program instructions may also be loaded onto a computer or other programmable data processing equipment to cause a series of operational steps to be performed on the computer or other programmable equipment to produce a computer-implemented process, thereby providing instructions that execute on the computer or other programmable equipment for implementing the process. Figure 1 One or more processes and / or boxes Figure 1 The steps of the function specified in one or more boxes.
[0054] The above are merely preferred embodiments of the present invention. It should be noted that those skilled in the art can make various improvements and modifications without departing from the technical principles 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 extracting and calibrating water level gauge regions based on YOLOv8, characterized in that, include: Obtain water level gauge image samples, select a portion of the water level gauge image samples for manual calibration to obtain an initial calibration sample set, and use the initial calibration sample set to train the YOLOv8 model to obtain the optimal model for detecting water level gauge regions. Obtain the water gauge image to be calibrated. For water gauge images with geometric distortion, perform distortion correction: select a parallelogram field of view that includes the entire water gauge area for distortion correction. Define the standard rectangular area of the water gauge obtained after correction as a pixel set. Perform zero-padding operation on pixel areas within the size of the original water gauge image that do not belong to the pixel set to generate a normalized water gauge image with the same size as the original water gauge image. The optimal model is used to automatically detect the water level gauge image to be calibrated, and the coordinates of the preliminary bounding box of the water level gauge region are obtained. The preliminary bounding box is then corrected to obtain the coordinates of the corrected bounding box. The coordinates of the corrected bounding box are converted into normalized coordinates in YOLO format and exported as a calibration file to obtain an automatic calibration sample set; The initial calibration sample set is integrated with the automatic calibration sample set to form the final water gauge calibration dataset.
2. The water level gauge region extraction and calibration method based on YOLOv8 according to claim 1, characterized in that, The acquisition of water level gauge image samples includes: Collect water level photos from different scenes, shooting angles, and lighting conditions; Preprocessing of water level gauge images: The size of the water level gauge images is unified using bilinear interpolation algorithm, and Gaussian filtering is used to remove salt-and-pepper noise and Gaussian noise from the water level gauge images to obtain water level gauge image samples.
3. The method for extracting and calibrating water level gauge regions based on YOLOv8 according to claim 1, characterized in that, Manual calibration of selected water level gauge image samples yields an initial calibration sample set. This involves: importing selected water level gauge image samples into an image calibration tool for manual calibration; using the rectangle calibration function to select the maximum bounding rectangle of the water level gauge, ensuring that the key information of the entire water level gauge area is completely contained within the bounding box; setting water level gauge category labels; calibrating all water level gauge areas for each water level gauge image sample; and generating a calibration file containing water level gauge category labels and bounding box coordinates to obtain the initial calibration sample set.
4. The method for extracting and calibrating water level gauge regions based on YOLOv8 according to claim 1, characterized in that, The optimal model for detecting water level gauge regions was obtained by training the YOLOv8 model using the initial calibration sample set, including: setting the batch size and initial learning rate; setting the learning rate to decay cosine with each iteration and setting an early stopping mechanism; using the full intersection-over-union loss function; and stopping training when the accuracy of the validation set reaches the accuracy threshold.
5. The method for extracting and calibrating water level gauge regions based on YOLOv8 according to claim 1, characterized in that, The sides of the parallelogram field of view are parallel to the top, bottom, left, and right edges of the water level gauge, respectively. The pixel coordinates of the four vertices of the parallelogram field of view are respectively... , , , And satisfy .
6. The method for extracting and calibrating water level gauge regions based on YOLOv8 according to claim 1, characterized in that, The pixel set is: ; in, Represents a set of pixels. , These represent the pixel x-coordinate and pixel y-coordinate of the standard rectangular region of the water gauge after correction, respectively. , These represent the minimum and maximum values of the pixel x-coordinates of the standard rectangular region of the water level gauge after correction. , These represent the minimum and maximum values of the pixel ordinates of the standard rectangular region of the water level gauge after correction, respectively. The pixel definition of a normalized water level gauge image is: ; in, , Let x and y represent the pixel x-coordinate and pixel y-coordinate of the normalized water level gauge image, respectively. Indicates the normalized water gauge image in Pixel value at that location, This indicates the corrected water gauge image in The pixel value at that location.
7. The method for extracting and calibrating water level gauge regions based on YOLOv8 according to claim 1, characterized in that, The process of correcting the initial bounding box to obtain the coordinates of the corrected bounding box includes: manually adjusting the position of the bounding box for offset, missing or mislabeled water level gauge images, supplementing or deleting erroneous bounding boxes, and updating the pixel coordinates of the bounding box to obtain the coordinates of the corrected bounding box.
8. The method for extracting and calibrating water level gauge regions based on YOLOv8 according to claim 1, characterized in that, The formula for converting the corrected bounding box coordinates to YOLO normalized coordinates is as follows: ; in, , These represent the x and y coordinates of the center point of the normalized bounding box, respectively. , These represent the width and height of the normalized bounding box, respectively. , Let represent the pixel width and pixel height of the normalized water level gauge image, respectively. , These represent the x-coordinate and y-coordinate of the top-left corner of the corrected bounding box, respectively. , These represent the x-coordinate and y-coordinate of the bottom right corner of the corrected bounding box, respectively. , These represent the pixel width and pixel height of the corrected bounding box, respectively.
9. A water level gauge region extraction and calibration system based on YOLOv8, characterized in that, include: The data acquisition module is used to acquire water level gauge image samples, select a portion of the water level gauge image samples for manual calibration to obtain an initial calibration sample set, and use the initial calibration sample set to train the YOLOv8 model to obtain the optimal model for detecting water level gauge regions. The distortion correction module is used to acquire the water gauge image to be calibrated and to perform distortion correction on the water gauge image to be calibrated that has geometric distortion: a parallelogram field of view containing the entire water gauge area is selected for distortion correction, the standard rectangular area of the water gauge obtained after correction is defined as a pixel set, and zero-padding is performed on the pixel areas within the size of the original water gauge image that do not belong to the pixel set to generate a normalized water gauge image with the same size as the original water gauge image. The automatic calibration module is used to automatically detect the water level gauge image to be calibrated using the optimal model, obtain the coordinates of the preliminary bounding box of the water level gauge region, and correct the preliminary bounding box to obtain the coordinates of the corrected bounding box. And it is used to convert the coordinates of the corrected bounding box into normalized coordinates in YOLO format and export them as a calibration file to obtain an automatic calibration sample set; The integration module is used to integrate the initial calibration sample set with the automatic calibration sample set to form the final water gauge calibration dataset.
10. A computer device, characterized in that, include: Storage medium: used to store computer programs; Processor: for executing computer programs to implement the YOLOv8-based water gauge region extraction and calibration method as described in any one of claims 1 to 8.