Water meter pointer reading recognition and correction method based on machine vision

Through machine vision and U-YOLOV8 object detection model combined with image processing technology, the artificial error and environmental interference problems in water meter pointer reading recognition are solved, and efficient and accurate automatic reading recognition and correction are achieved, which is suitable for industrial automation verification in the water meter industry.

CN120356192APending Publication Date: 2025-07-22HANGZHOU QUANREN ELECTRONIC TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311778779.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2023-12-22
Publication Date
2025-07-22

AI Technical Summary

Technical Problem

The prior art has problems such as large errors in the recognition of water meter pointer readings, low efficiency and inaccurate identification due to changes in environmental factors, which is difficult to meet the needs of industrial automation.

Method used

Using a machine vision-based method, the U-YOLOV8 object detection model is used to predict the water meter dial image, combined with image processing and mathematical geometry technology, the final reading is obtained through angle mapping and correction, and computer technology, machine vision and deep learning technology are integrated to reduce manual intervention.

Benefits of technology

It realizes the recognition of the water meter dial pointer reading with high accuracy, strong interference resistance and fast recognition speed, almost completely replaces manual inspection and improves the convenience of industrial automation verification.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120356192A_ABST
    Figure CN120356192A_ABST
Patent Text Reader

Abstract

The invention discloses a water meter pointer reading recognition and correction method based on machine vision, which comprises the following steps of: fixing a camera at the upper end of a water meter dial plate to capture an image of the whole water meter dial plate in real time, and transmitting the captured digital image to a U-YOLOV8 target detection model to predict; and then image processing and angle calculation are carried out on the predicted target image, and the final water meter reading is obtained through angle mapping and correction. According to the invention, a computer technology, a machine vision image processing technology and a traditional artificial intelligence deep learning technology are integrated, the water meter dial pointer reading can be accurately and rapidly read, manual detection is almost completely replaced, and the workload of manual detection is effectively reduced; recognition and correction of the water meter dial pointer reading are completed through the characteristics of high accuracy, high anti-interference performance, wide application range, high recognition speed and the like, and great convenience is brought to industrial automatic verification in the water meter industry.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of intelligent recognition of instrument readings, and particularly relates to a method for identifying and correcting water meter pointer readings based on machine vision. Background Art

[0002] With the rapid development of industrial automation in China and the increasingly widespread application of water meters, a traditional water resource measurement method, in the people's livelihood field, there comes the contradiction that the astronomical number of water meter usages and the industrial intelligent detection requirements cannot be met.

[0003] On the industrial production line, relying on the traditional method of human eye reading will introduce errors and uncertainties caused by manual fatigue, and on the other hand, the efficiency of traditional human eye reading is inversely proportional to the input in industrial automation. Existing digital image algorithms and image processing processes based on machine vision can accurately identify water meters under relatively stable environmental factors, including but not limited to illumination, water bubbles, stains, reflections, etc. Once these environmental factors change, the problem of inaccurate readings will occur, which will greatly affect production efficiency and is not suitable for industrial application and promotion. Summary of the Invention

[0004] In order to solve the drawbacks and instabilities brought by manual reading of the dial and traditional machine vision processing in the verification process of existing mechanical and intelligent water meters, the present invention proposes a method for identifying and correcting water meter pointer readings based on machine vision, which can complete the reading of the pointer readings on the water meter dial with the characteristics of high accuracy, strong anti-interference ability, wide application range, fast recognition speed, etc., bringing great convenience to the industrial automation verification of the water meter industry.

[0005] In order to achieve the above object, the present invention adopts the following technical solutions.

[0006] A method for identifying and correcting water meter pointer readings based on machine vision, comprising the following steps: Step S1: Input the captured water meter dial image into the target detection model to obtain the prediction result, and preprocess the prediction result; Step S2: Obtain the low-range pointer reading and the high-range pointer digital area image from the preprocessed prediction result, and perform grayscale processing and binaryzation processing on the high-range pointer digital area image in sequence; Step S3: Extract the red pointer part from the binaryzation-processed high-range pointer digital area image, and then perform morphological processing on the red pointer part image to obtain the pointer contour; Step S4: Extract the black scale circle part from the binaryzation-processed high-range pointer digital area image, and then calculate the maximum circumscribed rectangle of the black scale circle part image to obtain the center point; Step S5: Determine the pointer direction based on the pointer contour and the center point, calculate the geometric angle, and obtain the theoretical pointer reading through angle mapping. Step S6: Correct the theoretical pointer reading calculated for the high-range based on the pointer reading predicted for the low-range.

[0007] The present invention provides a method for identifying and correcting water meter pointer readings based on machine vision. The camera is fixed at the upper end of the water meter dial. After powering on, the entire water meter dial image is captured in real time. The captured digital image is transmitted to the background recognition service. The recognition service first calls the custom-trained U-YOLOV8 object detection model to predict the captured image, then performs image processing and angle calculation on the predicted target image, and then obtains the final water meter reading through angle mapping and correction. Finally, the reading is transmitted to the computer client for data processing. The present invention integrates computer technology, machine vision image processing technology, and traditional artificial intelligence deep learning technology, and can effectively and accurately read the pointer readings of the water meter dial, and almost completely replaces manual detection and effectively reduces the workload of manual detection. Specifically, the present invention uses the U-YOLOV8 object detection model that has been very mature in the field of image processing, trains with more than 5000 real pictures, predicts the target of the captured image, and does not require other image preprocessing operations. Then, combined with image processing technology, mathematical geometry technology, and special angle mapping and correction methods, a very accurate dial reading result is obtained.

[0008] Preferably, in step S1, a camera is used to capture the water meter dial image, and the captured water meter dial image is input into the custom-trained U-YOLOV8 object detection model to obtain the model prediction result. The model prediction result includes the pointer area frames of each range; data extraction, classification, screening, and sorting preprocessing are performed on the model prediction result to obtain the preprocessed result.

[0009] The client software captures the water meter dial image and sends the captured image to the local background recognition service through the http protocol. The background recognition service receives the transmitted image through the http protocol, then uses the custom-trained U-YOLOV8 object detection model for prediction, and then performs preprocessing on the prediction result.

[0010] Preferably, in step S2, the predicted pointer reading of the low-range and the rectangular frame coordinates of the pointer digital area of the high-range are obtained from the preprocessed result; according to the rectangular frame coordinates of the pointer digital area of the high-range, the pointer digital area of the high-range is cropped from the water meter dial image to obtain the high-range pointer digital area image, and then Gaussian filtering and binarization processing are sequentially performed on the high-range pointer digital area image.

[0011] Obtain the predicted pointer reading of the low-range x0.001 from the preprocessed result; obtain the rectangular frame coordinates of the pointer digit regions for ranges x0.01 and x0.1 from the preprocessed result; separately take screenshots of the pointer digit regions for ranges x0.01 and x0.1 from the dial image, and then sequentially perform Gaussian filtering on the intercepted images to achieve image grayscale processing for the purpose of image denoising; perform binarization on the filtered images. The initial parameter threshold for binarization of the red pointer part is 70, and the initial parameter threshold for binarization of the black scale circle part is 100, which need to be manually configured according to the actual environment.

[0012] Preferably, in step S3, convert the binarized high-range pointer digit region image into the HSV model, i.e., the hue, saturation, value model, set the red pixel parameters with reference to the HSV table, extract the red pointer part image, and perform morphological processing on the red pointer part image, including closing operation and erosion, to obtain the pointer contour. First extract the red pointer part from the binarized image, and then perform image morphological processing to obtain the red pointer contour.

[0013] Preferably, in step S4, convert the binarized high-range pointer digit region image into the HSV model, set the black pixel parameters with reference to the HSV table, extract the black scale circle part image, perform the minimum bounding rectangle operation on the black scale circle part image, calculate the width and height of the minimum bounding rectangle, and obtain the center point. Then extract the black scale circle part, i.e., extract the black pixels, from the binarized image, and perform the minimum bounding rectangle operation to obtain the center point of the black scale circle.

[0014] Preferably, in step S5, according to the pointer contour and the center point, use the Euclidean distance formula to calculate the distance from each point on the pointer contour to the center point, find the coordinate point with the maximum distance, which is the pointer vertex, and connect the center point and the pointer vertex, which is the pointer pointing direction.

[0015] Preferably, in step S5, with the center point as the connection point, connect the due north direction starting from the center point and the pointer vertex respectively, calculate the included angle between the line connecting the center point and the pointer vertex and the two lines in the due north direction starting from the center point, and obtain the theoretical pointer reading through the mapping relationship between the angle and the scale.

[0016] Preferably, in step S6, the pointer reading predicted by the low-range is used to correct the theoretical pointer reading calculated by the high-range. The correction methods include: when the pointer reading of the low-range is 0, 1, 2, or 3, the theoretical pointer reading of the high-range is corrected upward, i.e., the theoretical pointer reading of the high-range + 1; when the pointer reading of the low-range is 7, 8, or 9, the theoretical pointer reading of the high-range is corrected downward, i.e., the theoretical pointer reading of the high-range - 1. The angles calculated by the pointer reading predicted by the low-range x0.001 and the high-ranges x0.01 and x0.1 are corrected according to the correction rules. The correction method is as follows: Upward correction reference: offset_scale = 3.6 * (5 - low_flow); Upward correction condition: B < high_r and (high_r - B) < offset_scale; Downward correction reference: offset_scale = 3.6 * (low_flow - 4); Downward correction condition: B > low_r and (B - low_r) < offset_scale; Wherein, low_flow is the pointer reading of the low-range x0.001 or x0.01, offset_scale is the reference angle threshold, B is the theoretical reading mapped by the current pointer angle, high_r is the maximum value of the angle range mapped by the theoretical reading, and low_r is the minimum value of the angle range mapped by the theoretical reading.

[0017] Preferably, it further includes: adding the pointer readings of each range after correction according to the range unit to obtain the final water meter pointer reading. The pointer readings of the ranges x0.001, x0.01, and x0.1 are predicted, calculated, and corrected in sequence to obtain the pointer readings of each range, that is: when calculating the pointer reading of the range x0.01, it is necessary to calculate, map, and correct according to the reading of x0.001 and the theoretical reading of x0.01, and then when calculating the pointer reading of the range x0.1, it is necessary to calculate, map, and correct according to the corrected reading of x0.01 and the theoretical reading of x0.1. The pointer readings of each range are added to obtain the final reading.

[0018] Therefore, the advantages of the present invention are: (1) The present invention integrates computer technology, machine vision image processing technology, and traditional artificial intelligence deep learning technology, can effectively and accurately read the pointer readings of the water meter dial, and almost completely replaces manual detection and effectively reduces the manual detection workload; (2) The present invention uses the U-YOLOV8 object detection model that is already very mature in the field of image processing, trains it with more than 5000 real pictures, predicts the objects in the captured pictures, and does not require other image preprocessing operations. Then, combined with image processing technology, mathematical geometry technology, and special angle mapping and correction methods, very accurate dial reading results are obtained; (3) The reading of the water meter dial pointer is completed with the characteristics of high accuracy, strong anti-interference ability, wide application range, and fast recognition speed, bringing great convenience to the industrial automation verification of the water meter industry. BRIEF DESCRIPTION OF THE DRAWINGS

[0019] Figure 1 is a flowchart of a method for identifying and correcting the pointer reading of a water meter based on machine vision in the embodiment.

[0020] Figure 2 is the original water meter dial image in the embodiment.

[0021] Figure 3 is the image after prediction by the object detection model in the embodiment.

[0022] Figure 4 is a flowchart for extracting the red pointer part in the embodiment.

[0023] Figure 5 is a flowchart for extracting the black scale circle part in the embodiment.

[0024] Figure 6 is the image of the connecting line between the center point and the vertex of the pointer in the x0.01 range pointer area in the embodiment.

[0025] Figure 7 is the image of the connecting line between the center point and the vertex of the pointer in the x0.1 range pointer area in the embodiment.

[0026] Figure 8 is the actual reading diagram after using angle mapping and correction in the embodiment. DETAILED DESCRIPTION OF THE EMBODIMENTS

[0027] The following further describes the present invention in conjunction with the drawings and the specific embodiments.

[0028] Embodiment 1.

[0029] A method for identifying and correcting the pointer reading of a water meter based on machine vision includes the following steps: Step S1: Input the captured water meter dial image into the object detection model to obtain the prediction result, and preprocess the prediction result; Step S2: Obtain the low-range pointer reading and the high-range pointer digital area image from the preprocessed prediction result, and perform grayscale conversion and binarization processing on the high-range pointer digital area image in sequence; Step S3: Extract the red pointer part from the binarized high-range pointer digital area image, and then perform morphological processing on the red pointer part image to obtain the pointer contour; Step S4: Extract the black scale circle part from the binarized high-range pointer digital area image, and then calculate the maximum circumscribed rectangle of the black scale circle part image to obtain the center point; Step S5: Determine the pointer direction according to the pointer contour and the center point, calculate the geometric angle, and obtain the theoretical pointer reading through angle mapping; Step S6: Correct the theoretical pointer reading calculated for the high range according to the pointer reading predicted for the low range.

[0030] This embodiment provides a method for identifying and correcting water meter pointer readings based on machine vision. The camera is fixed at the upper end of the water meter dial. After powering on, the entire water meter dial image is captured in real time. The captured digital image is transmitted to the background recognition service. The recognition service first calls the custom-trained U-YOLOV8 object detection model to predict the captured image, then performs image processing and angle calculation on the predicted target image, and then obtains the final water meter reading through angle mapping and correction. Finally, the reading is transmitted to the computer client for data processing. This embodiment integrates computer technology, machine vision image processing technology, and traditional artificial intelligence deep learning technology, and can effectively and accurately read the pointer readings of the water meter dial, and almost completely replaces manual detection and effectively reduces the workload of manual detection. Specifically, this embodiment uses the U-YOLOV8 object detection model that is already very mature in the field of image processing, trains with more than 5000 real pictures, predicts the target of the captured picture, and does not require other image preprocessing operations. Then, combined with image processing technology, mathematical geometry technology, and special angle mapping and correction methods, a very accurate dial reading result is obtained.

[0031] In step S1, a camera is used to capture the water meter dial image, and the captured water meter dial image is input into the custom-trained U-YOLOV8 object detection model to obtain the model prediction result. The model prediction result includes the pointer area frames of each range; data extraction, classification, screening, and sorting preprocessing are performed on the model prediction result to obtain the preprocessed result.

[0032] The client software captures the water meter dial image and sends the captured image to the local background recognition service through the http protocol. The background recognition service receives the transmitted image through the http protocol, then uses the custom-trained U-YOLOV8 object detection model for prediction, and then performs preprocessing on the prediction result.

[0033] In step S2, obtain the predicted pointer readings of the low-range and the rectangular frame coordinates of the pointer digital area of the high-range from the preprocessed results; according to the rectangular frame coordinates of the pointer digital area of the high-range, take a screenshot of the pointer digital area of the high-range from the water meter dial image to obtain the high-range pointer digital area image, and then sequentially perform Gaussian filtering and binarization processing on the high-range pointer digital area image.

[0034] Obtain the predicted pointer readings of the low-range x0.001 from the preprocessed results; obtain the rectangular frame coordinates of the pointer digital areas of the ranges x0.01 and x0.1 from the preprocessed results; respectively take screenshots of the pointer digital areas of the ranges x0.01 and x0.1 from the dial image, and then sequentially perform Gaussian filtering on the intercepted images to achieve image grayscale processing and the purpose of image denoising; perform binarization on the filtered images. The initial parameter threshold of the binarization threshold for the red pointer part is 70, and the initial parameter threshold of the binarization threshold for the black scale circle part is 100, which need to be manually configured according to the actual environment.

[0035] In step S3, convert the binarized high-range pointer digital area image into the HSV model, that is, the hue, saturation, and value model, set the red pixel parameters with reference to the HSV table, extract the red pointer part image, and perform morphological processing on the red pointer part image, including closing operation and erosion, to obtain the pointer contour. First extract the red pointer part from the binarized image, and then perform image morphological processing to obtain the red pointer contour.

[0036] In step S4, convert the binarized high-range pointer digital area image into the HSV model, set the black pixel parameters with reference to the HSV table, extract the black scale circle part image, perform the minimum bounding rectangle operation on the black scale circle part image, calculate the width and height of the minimum bounding rectangle, and obtain the center point. Then extract the black scale circle part, that is, extract the black pixels, from the binarized image, and then perform the minimum bounding rectangle operation to obtain the center point of the black scale circle.

[0037] In step S5, according to the pointer contour and the center point, use the Euclidean distance formula to calculate the distance from each point on the pointer contour to the center point, find the coordinate point with the maximum distance, which is the pointer vertex, and connect the center point and the pointer vertex, which is the pointer pointing direction.

[0038] In step S5, with the center point as the connection point, respectively connect the due north starting from the center point and the pointer vertex, calculate the included angle between the line connecting the center point and the pointer vertex and the two lines in the due north direction starting from the center point, and obtain the theoretical pointer reading through the mapping relationship between the angle and the scale.

[0039] In step S6, the theoretical pointer reading calculated for the high range is corrected according to the pointer reading predicted for the low range. The correction methods are as follows: when the pointer reading of the low range is 0, 1, 2, or 3, the theoretical pointer reading of the high range is corrected upward, i.e., the theoretical pointer reading of the high range + 1; when the pointer reading of the low range is 7, 8, or 9, the theoretical pointer reading of the high range is corrected downward, i.e., the theoretical pointer reading of the high range - 1. The angles calculated from the pointer readings predicted by the low range x0.001 and the high ranges x0.01 and x0.1 are corrected according to the correction rules in sequence. The correction method is as follows: upward correction reference: offset_scale = 3.6 * (5 - low_flow); Upward correction condition: B < high_r and (high_r - B) < offset_scale; Downward correction reference: offset_scale = 3.6 * (low_flow - 4); Downward correction condition: B > low_r and (B - low_r) < offset_scale; where low_flow is the pointer reading of the low range x0.001 or x0.01, offset_scale is the reference angle threshold, B is the theoretical reading mapped by the current pointer angle, high_r is the maximum value of the angle range mapped by the theoretical reading, and low_r is the minimum value of the angle range mapped by the theoretical reading.

[0040] It also includes: accumulating the pointer readings of each range after correction according to the range unit to obtain the final water meter pointer reading. The pointer readings of the ranges x0.001, x0.01, and x0.1 are predicted, calculated, and corrected in sequence to obtain the pointer readings of each range, that is: when calculating the pointer reading of the range x0.01, it is necessary to calculate, map, and correct according to the reading of x0.001 and the theoretical reading of x0.01, and then when calculating the pointer reading of the range x0.1, it is necessary to calculate, map, and correct according to the corrected reading of x0.01 and the theoretical reading of x0.1, and accumulate the pointer readings of each range to obtain the final reading.

[0041] Embodiment 2.

[0042] This embodiment provides a method for identifying and correcting water meter pointer readings based on machine vision, as Figure 1 shown, including the following steps:

[0043] Step a, the client software captures the water meter dial image and sends the captured image to the local background recognition service through the http protocol.

[0044] Step b, the background recognition service receives the transmitted image through the http protocol, and then uses the custom-trained U-YOLOV8 object detection model for prediction. The method for predicting the image is as follows: results = model_meter.predict(frame, imgsz = 640) Among them, model_meter is the loaded trained prediction model, predict is the prediction function of the network model, frame is the received water meter dial image, imgsz is the image size, and results is the result returned after model prediction.

[0045] Step c, perform data extraction, classification, and screening on the prediction result results. The specific method is: low_pointer, w_pointers = data_process(results) Among them, data_process is the data processing function, results is the prediction result, low_pointer is the prediction data of the lowest bit pointer area type 'p', and w_pointers is the prediction data of the high bit pointer area category 'area_p'.

[0046] Step d, process low_pointer to obtain the reading low_flow of the lowest bit range x0.001 pointer: names = results.nameslow_flow = int(names[int(low_pointer[5])][1:]) Among them, names are the model prediction target parameters, which is a list of prediction categories with a length of 11: ['p0', 'p1', 'p2', 'p3', 'p4', 'p5', 'p6', 'p7', 'p8', 'p9', 'area_p']. low_pointer is also a list structure. low_pointer[5] represents the index of the prediction result, which is then converted to an integer using the int() function. names[int(low_pointer[5])] locates through the prediction result index in the names label, finds the element in the prediction category, then uses slicing to obtain the represented value, and finally uses the int() function to convert it to an integer, that is, the reading of the lowest bit pointer.

[0047] Step e, process the pointer regions of the high-order x0.01 and x0.1 ranges step by step. Use w_pointers to obtain the position coordinates of the pointer regions of the two ranges respectively, including top, left, bottom, and right. Then intercept the corresponding position regions from the dial image to form independent pointer region images. The main method is as follows: pointer_boxes = restore_boxes(w_pointers) top_boxes = get_pointer_position(pointer_boxes) top, left, bottom, right = get_rect(top_boxes[1], frame) frame_rect = frame[top:bottom, left:right] Among them, the restore_boxes function reorganizes the result data of the predicted pointer region again, mainly to handle the phenomenon of multiple repeated predictions for the same pointer region, ensuring that there is only one predicted region. The get_pointer_position function obtains the four coordinate data in each predicted region, and the get_rect function converts the four coordinates into four integer relative position points on the frame dial image. Finally, each pointer region image is intercepted by slicing frame[top:bottom, left:right].

[0048] Step f, perform grayscale operation on each pointer region image to remove some noise. The main method is: blur = GaussianBlur(img, kernel=(3, 3), sigmaX=1) Among them, GaussianBlur is the Gaussian filtering function, img is the target pointer region image, kernel is the Gaussian kernel size, sigmaX is the Gaussian kernel size in the X-axis direction, and blur is the image after Gaussian filtering to remove noise.

[0049] Step g, perform binarization on the filtered image. The main method is as follows: dst = threshold(blur, p_threshold, 255, THRESH_BINARY) Among them, threshold is the binarization processing function, blur is the filtered image, p_threshold is the lower limit of the binarization threshold, 255 is the upper limit of the threshold, THRESH_BINARY is the binarization method, and dst is the target image after binarization.

[0050] Step h, extract the image of the red pointer part in dst using the HSV model. The implementation method is: hsv = cvtColor(img, COLOR_BGR2HSV) low_hsv = np.array([0, 40, 50]) high_hsv = np.array([10, 255, 255]) mask = inRange(hsv, lowerb = low_hsv, upperb = high_hsv).

[0051] Step i, perform morphological processing on the extracted image of the red pointer part mask. The implementation method is: closed = morphologyEx(mask, MORPH_CLOSE, kernel=(3, 3)) m_img = erode(closed, kernel=(3, 3), iterations = 1).

[0052] Step j, extract the image of the black scale circle part in the pointer area. The implementation method is: hsv = cvtColor(img, COLOR_BGR2HSV) low_hsv = np.array([0, 0, 0]) high_hsv = np.array([180, 255, 46]) mask = inRange(hsv, lowerb = low_hsv, upperb = high_hsv).

[0053] Step k, find the center point and the vertex of the pointer. The implementation method is: cx, cy = get_center_pointer(img, circle_threshold) distances = sqrt(sum((mask – array([cx, cy])) ** 2, axis = 1)) top_pt = mask[argmax(distances)] Among them, the get_center_pointer() function obtains the center point of the scale circle in the pointer area. circle_threshold is the binarization threshold parameter. The sqrt() function is used for mathematical square root calculation. The sum() function calculates the sum of the squares of each x and y. In this step, the distance from each coordinate point on the center pointer contour of the mask to the center point (cx, cy) is calculated. The Euclidean distance calculation method is used for distance calculation to obtain the distance set distances. Then, the index of the coordinate point with the maximum distance is obtained through the argmax() function. Then, the specific coordinate point, that is, the vertex of the center pointer, is found from the mask contour points.

[0054] Step l: Determine the due north coordinate (cx, 0) through the center point (cx, cy). Then, with the center point as the connection point, calculate the included angle through the vertex top_pt of the center pointer. After angle conversion and mapping, the theoretical reading is obtained. The implementation method is: B = cal_ang((cx, 0), (cx, cy), top_pt) angle_flow = get_angle_flow(B) Among them, cal_ang is the angle calculation function. Through three coordinate points on the image, with the middle point as the connection point, the included angle B between the line connecting the center point and the due north coordinate and the line connecting the center point and the pointer vertex is calculated. The get_angle_flow() function is to calculate and map the theoretical reading of the pointer through the angle.

[0055] Step m: Since there are various deviations in the installation of the dial pointer, angle deviation correction is also required to determine the final reading. The implementation method is: flow = get_correct_flow(B, low_flow, angle_flow) Among them, B is the calculated angle, low_flow is the predicted or calculated low reading, angle_flow is the calculated current range reading, and get_correct_flow is the reading correction function. This function judges the angle range where B is located through the mapping list, finds the element index, and obtains the scale value corresponding to the current angle. Then, the current reading is corrected up and down through the low reading low_flow. The correction method is: offset_scale = 3.6 * (5 - low_flow) low_r, high_r = get_low_high_angle(B) flow = fix_up(low_r, high_r, B, offset_scale, fix_ups) Among them, offset_scale is the angle deviation threshold, indicating that correction will only be performed when this threshold condition is met. get_low_high_angle() is the function to obtain the high and low angle ranges corresponding to the current pointer angle, and the fix_up() function is the correction function. fix_ups is a list of values that need to be corrected manually, indicating at which readings of the low pointer the high pointer should be corrected.

[0056] Step n, after obtaining the readings for each pointer area, integrate the readings of each range to obtain the final water meter reading. The implementation method is as follows: p_flows = [0, 0, 0] p_flows[2] = low_flowflow1 = get_real_flow(top_boxes[1], frame, p_flows[2], 'x0.01') p_flows[1] = flow1 flow2 = get_real_flow(top_boxes[0], frame, p_flows[1], 'x0.1') p_flows[0] = flow2 Among them, p_flows initializes the readings of the three ranges of the water meter. After step-by-step prediction, angle calculation, and correction for each pointer range area graph, they are integrated into p_flows.

[0057] Step m, for each element in the p_flows list, concatenate the element values in ascending order of the index to obtain the final water meter pointer reading.

[0058] Embodiment 3.

[0059] Take Figure 2 as an example to perform automatic extraction and correction of the water meter dial pointer reading.

[0060] A method for identifying and correcting water meter pointer readings based on machine vision is as follows: 1. First, load the camera image. The width and height of the image are both fixed at 640 * 480: frame = imread(img_path) frame is the image data after reading. imread() is the image reading function, and img_path is the computer image storage path; 2. Input frame into the trained U-YOLOV8 object detection model for prediction: results = model_meter.predict(frame, imgsz = 640) As Figure 3 shown in the result image after prediction, results are the results after model prediction, including information such as target region coordinates, classification, labels, confidence, etc. model_meter is the loaded and trained object detection model, and predict() is the prediction method, which predicts the image data frame of the specified size imgsz; 3. Obtain the pointer region target coordinate points of each range with the highest confidence from the prediction results, and then sort them from largest to smallest by the x-axis, and use them as the pointer region targets of the x0.1, x0.01, and x0.001 ranges respectively; 4. Intercept the target image from the original image frame through the target coordinate points of each range region: top, left, bottom, right = get_rect(top_box, frame) frame_rect = frame[top:bottom, left:right] top, left, bottom, right are the integer conversions of the coordinate points top_box in the prediction results into azimuth points, which are the upper left, lower left, lower right, and upper right respectively. In order to intercept from the original image data, frame_rect is the pointer region image data intercepted from the original image frame; 5. First, upsample the intercepted image frame_rect once, and then perform Gaussian filtering and binarization in sequence; 6. As Figure 4 shown in the flowchart for extracting the red pointer part, convert the binarized image into the HSV model, extract the red pointer part, and perform closing operation and dilation operation on the extracted region to remove external noise points to obtain the complete contour p of the red pointer. The implementation method is as follows: hsv = cvtColor(img, COLOR_BGR2HSV) low_hsv = np.array([0, 40, 50]) high_hsv = np.array([10, 255, 255]) mask = inRange(hsv, lowerb = low_hsv, upperb = high_hsv) closed = morphologyEx(mask, MORPH_CLOSE, kernel=(3, 3)) m_img = erode(closed, kernel=(3, 3), iterations=1); 7. As Figure 5 shown in the flowchart for extracting the black scale circle part, the binary image is converted to the HSV model, the black scale circle part is extracted to obtain the mask image, the contour cnt is found through the mask, and then the bounding rectangle r of the contour is calculated. The implementation method is as follows: hsv = cvtColor(img, COLOR_BGR2HSV) low_hsv = np.array([0, 40, 50]) high_hsv = np.array([10, 255, 255]) mask = inRange(hsv, lowerb=low_hsv, upperb=high_hsv) cnt = findContours(mask) x_r, y_r, w_r, h_r = boundingRect(cnt); 8. Calculate the center coordinate point of the pointer scale circle rectangle through the bounding rectangle r of the maximum contour: x, y = (w_r / 2) + x_r, (h_r / 2) + y_r. w_r and h_r are the width and height of the maximum bounding rectangle respectively. (w_r / 2) and (h_r / 2) can obtain the midpoint of the rectangle frame, and then adding x_r and y_r respectively and mapping to the image coordinate points, which is the center point coordinate c_pt; 9. Use the Euclidean distance formula to calculate the distance from each coordinate point on the red pointer contour p to the center point c_pt, and take the point with the maximum distance, which is the pointer vertex to be found. Then connect the two points, which is the pointer pointing direction. As Figure 6 、 7 shown, the method for finding the point with the maximum distance is as follows: distances = sqrt(sum((p - array([c_pt[0], c_pt[1]])) ** 2, axis = 1)) top_pt = p[argmax(distances)] draw_line(frame_rect, (c_pt[0], c_pt[1]), (top_pt[0], top_pt[1])) p is the contour coordinate point of the extracted red center pointer area, distances is the set of distances from each point to the center point of the scale circle, top_pt is the coordinate point with the maximum distance, and draw_line is the function to draw the line connecting the center point and the pointer vertex; 10. Calculate the angle between the line connecting the center point and the pointer vertex and the two lines in the due north direction starting from the center point. Through a custom correction rule, correct the angle, and then use the mapping relationship between the angle and the scale to obtain the pointer reading: flow = get_correct_flow(B, low_flow, angle_flow, per_scale) B is the actual angle calculated for the current pointer direction, low_flow is the predicted low reading, angle_flow is the theoretical reading obtained from B, and per_scale is the fixed coefficient unit angle 3.6. After correcting the angle reading through the correction function get_correct_flow, the final result flow is obtained; 11. Calculate the pointer readings sequentially from the low position to the high position, and then integrate them to obtain the final reading: p_flows[2] = low_flow p_flows[1] = get_real_flow(p_flows[2]) p_flows[0] = get_real_flow(p_flows[1]) The final reading of the water meter = p_flows[0] * 100 + p_flows[1] * 10 + p_flows[2], in units of L, as Figure 8 shown is the actual reading after using angle mapping and correction.

[0061] This embodiment provides a method for identifying and correcting the pointer readings of a water meter based on machine vision. First, a camera with a resolution of 640*480 is used to capture the pointer digital area of the water meter dial. Then, the captured image is input into the U-YOLOV8 object detection model for object prediction, and multiple pointer area targets and coordinate data are predicted. Then, the pointer area image is intercepted through the predicted box coordinates, and the pointer area image is processed by image processing, such as Gaussian filtering, binarization, HSV model extraction of the black scale circle / red pointer part, closing operation, erosion, maximum circumscribed rectangle, etc. Through geometric calculation, the center point coordinates of the pointer scale circle and the center red pointer contour points are obtained. The distance from each contour point to the center point is calculated by the Euclidean distance, and the point with the maximum distance is the vertex of the red pointer, so as to determine the pointer direction. The pointer reading corresponding to each range is obtained through angle calculation and numerical mapping, and then the angle and the theoretical reading of the current pointer are corrected according to the correction rules to obtain the final accurate reading. Finally, the readings of each range are accumulated according to the range unit to obtain the final water meter pointer reading.

[0062] The above content is only the specific implementation manner of this application, but the protection scope of this application is not limited thereto. Any person skilled in the art within the technical scope disclosed by this application can easily think of changes or substitutions, which should be covered by the protection scope of this application. Therefore, the protection scope of this application shall be subject to the protection scope of the claims.

Claims

1. A method for identifying and correcting water meter pointer readings based on machine vision, characterized in that, It includes the following steps: Step S1: Input the captured water meter dial image into the target detection model to obtain the prediction result, and preprocess the prediction result; Step S2: Obtain the low-range pointer reading and the high-range pointer digital area image from the preprocessed prediction result, and perform grayscale conversion and binarization on the high-range pointer digital area image in sequence; Step S3: Extract the red pointer part from the binarized high-range pointer digital area image, and then perform morphological processing on the red pointer part image to obtain the pointer contour; Step S4: Extract the black scale circle part from the binarized high-range pointer digital area image, and then calculate the maximum circumscribed rectangle of the black scale circle part image to obtain the center point; Step S5: Determine the pointer direction according to the pointer contour and the center point, calculate the geometric angle, and obtain the theoretical pointer reading through angle mapping; Step S6: Correct the theoretical pointer reading calculated for the high range according to the pointer reading predicted for the low range.

2. The method for identifying and correcting water meter pointer readings based on machine vision according to claim 1, characterized in that, In step S1, a camera is used to capture the water meter dial image, and the captured water meter dial image is input into the custom-trained U-YOLOV8 target detection model to obtain the model prediction result. The model prediction result includes the pointer area boxes for each range; data extraction, classification, screening, and sorting preprocessing are performed on the model prediction result to obtain the preprocessed result.

3. The method for identifying and correcting the water meter pointer reading based on machine vision according to claim 1, characterized in that, In step S2, obtain the predicted pointer reading for the low range and the coordinate of the high-range pointer digital area rectangle box from the preprocessed result; according to the coordinate of the high-range pointer digital area rectangle box, capture the high-range pointer digital area from the water meter dial image to obtain the high-range pointer digital area image, and then perform Gaussian filtering and binarization on the high-range pointer digital area image in sequence.

4. A method for identifying and correcting water meter pointer readings based on machine vision according to claim 1 or 3, characterized in that, In step S3, convert the binarized high-range pointer digital area image to the HSV model, set the red pixel parameters with reference to the HSV table, extract the red pointer part image, and perform morphological processing on the red pointer part image, including closing operation and erosion, to obtain the pointer contour.

5. A method for identifying and correcting water meter pointer readings based on machine vision according to claim 1 or 3, characterized in that, In step S4, convert the binarized high-range pointer digital area image to the HSV model, set the black pixel parameters with reference to the HSV table, extract the black scale circle part image, perform the maximum circumscribed rectangle operation on the black scale circle part image, calculate the width and height of the maximum circumscribed rectangle, and obtain the center point.

6. A method for identifying and correcting water meter pointer readings based on machine vision according to claim 1, characterized in that, In step S5, according to the pointer contour and the center point, use the Euclidean distance formula to calculate the distance from each point on the pointer contour to the center point, find the coordinate point with the maximum distance, which is the pointer vertex, and connect the center point and the pointer vertex, which is the pointer direction.

7. A method for identifying and correcting water meter pointer readings based on machine vision according to claim 1 or 6, characterized in that In step S5, with the center point as the connection point, connect the due north starting from the center point and the pointer vertex respectively, calculate the included angle between the line connecting the center point and the pointer vertex and the two lines in the due north direction starting from the center point, and obtain the theoretical pointer reading through the mapping relationship between the angle and the scale.

8. A method for identifying and correcting water meter pointer readings based on machine vision according to claim 1, characterized in that, In step S6, the theoretical pointer reading calculated for the high range is corrected according to the pointer reading predicted for the low range. The correction methods include: when the pointer reading of the low range is 0, 1, 2, or 3, the theoretical pointer reading of the high range is corrected upward, that is, the theoretical pointer reading of the high range + 1; when the pointer reading of the low range is 7, 8, or 9, the theoretical pointer reading of the high range is corrected downward, that is, the theoretical pointer reading of the high range - 1.

9. A method for identifying and correcting water meter pointer readings based on machine vision according to claim 1 or 8, characterized in that, It also includes: The pointer readings of each range after correction are accumulated in range units to obtain the final water meter pointer reading.