Scale-free oil level gauge reading method and device based on image segmentation algorithm, electronic equipment and storage medium
Through the scaleless oil level meter reading method based on image segmentation algorithm, the range and needle area of the oil level meter are extracted using the yolov8 segmentation algorithm and attention mechanism, combined with post-processing analysis, the identification of oil level meter readings in complex industrial scenarios of substations is solved. Light impact problems achieve high-precision reading recognition.
Patent Information
- Application Number
- CN202410967429.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-18
- Publication Date
- 2024-11-05
AI Technical Summary
In the complex industrial scenarios of substations, the reading of the oil level gauge is easily affected by ambient light, resulting in misidentification and false detection, and the reading of the unscaled oil level gauge cannot be effectively identified.
Using the scaleless oil level meter reading method based on image segmentation algorithm, the image segmentation model is constructed by acquiring and preprocessing the oil level meter image dataset, and feature extraction is performed using the yolov8 segmentation algorithm and attention mechanism, combining Dice loss loss function and condition Image segmentation was performed at random, the range area and needle area were extracted, and post-processing analysis was performed to calculate the readings.
It improves the accuracy and reliability of oil level gauge readings, reduces errors, and improves the accuracy of oil level gauge readings without scales, and is suitable for complex industrial scenarios.
Smart Images

Figure CN118898837A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of instrument reading recognition of specific computer models, and more specifically, relates to a scale-free oil level gauge reading method, device, electronic equipment and storage medium based on an image segmentation algorithm. Background Art
[0002] With the rapid development of my country's industry, the continuously growing demand for industrial production has brought tremendous pressure to our work, and the requirements for industrial automation are becoming more and more urgent. As one of the most important equipment in the substation, the transformer's oil level gauge and other related meter readings are an important part of the substation inspection. Although the application of digital instruments is relatively mature, considering the influence of environmental factors such as electromagnetic interference, it is not suitable to use digital instruments in substation scenarios. Most substations in operation do not have remote transmission functions for meters such as substation oil level gauges due to historical and cost reasons. Therefore, substation inspections mainly rely on manual inspections to ensure the safe and stable operation of power equipment. The manual reading method of the oil level gauge is a huge workload and will bring subjective errors, so it is necessary to use machine vision to realize the automatic reading of the oil level gauge.
[0003] Chinese patent document CN111368906A discloses a method for identifying readings of a pointer-type oil level gauge based on deep learning, comprising: collecting an image of an oil level gauge instrument, constructing a data set required for training and training a YOLOv3 model; using the YOLOv3 model to identify an image of a pointer-type oil level gauge whose indication is to be calculated; fitting an ellipse where the center point of a scale number Bounding Box on the dial is located and obtaining the center of the circle; connecting the center of the circle with the center point of the Bounding Box to determine the area of the scale to be detected in that direction; performing corner point detection in all segmented rectangular detection areas, obtaining the midpoint of the side length of each scale close to the center of the circle and fitting a new center of the circle; performing straight line detection after preprocessing the image of the pointer-type oil level gauge to be identified, obtaining the pointer equation and the projection point of the new center of the circle on the straight line equation; and finally calculating the reading.
[0004] Since most existing methods are easily affected by ambient lighting and involve recognition requirements during the day and at night, and are prone to missed recognition and false detection, the present invention designs a scale-free oil level gauge reading method based on image segmentation algorithm to solve the problem of difficulty in reading scale-free oil level gauges in complex industrial scenarios of substations. Summary of the invention
[0005] The present invention aims to overcome at least one defect of the above-mentioned prior art and provide a method for reading a scale-free oil level gauge based on an image segmentation algorithm.
[0006] The invention also discloses a device loaded with a scale-free oil level gauge reading method based on an image segmentation algorithm.
[0007] The detailed technical scheme of the present invention is as follows:
[0008] A method for reading a scale-free oil level gauge based on an image segmentation algorithm, the method comprising:
[0009] S1, obtaining a scale-free oil level gauge image dataset, and preprocessing the oil level gauge images in the scale-free oil level gauge image dataset to construct a scale-free oil level gauge segmentation dataset;
[0010] S2, constructing a scale-free oil level gauge image segmentation model, and using the scale-free oil level gauge segmentation dataset to train the scale-free oil level gauge image segmentation model;
[0011] S3, using the trained non-scale oil level gauge image segmentation model to perform reasoning on the non-scale oil level gauge image to be identified, so as to obtain the range area and the needle area in the oil level gauge;
[0012] S4. Based on the obtained range area and needle area of the oil level gauge, combined with post-processing analysis, the reading of the scale-free oil level gauge to be identified is obtained.
[0013] Preferably, in S1, the oil level gauge image in the scale-free oil level gauge image dataset is preprocessed to construct a scale-free oil level gauge segmentation dataset, specifically comprising:
[0014] The open source annotation tool labelme is used to annotate the unlabeled oil level gauge image dataset without scale. The annotation includes the scale value area, the fan-shaped area where the oil level gauge center point connection line is located, and the pointer area, to construct the initial oil level gauge segmentation dataset without scale.
[0015] The labeled oil level gauge images in the initial scale-free oil level gauge segmentation dataset are randomly extracted, and data augmentation is performed on the images using a data enhancement algorithm to obtain a final scale-free oil level gauge segmentation dataset.
[0016] Preferably, in S2, a scale-free oil level gauge image segmentation model is constructed based on the yolov8 segmentation algorithm and in combination with an attention mechanism, wherein the attention mechanism includes channel attention, and the channel attention mechanism is:
[0017] For the input feature map X1, its dimension is [h,w,c], where h is the height of the feature map X1, w is the width of the feature map X1, and c is the number of channels of the feature map X1;
[0018] Using global average pooling, the two-dimensional feature [h, w] of each channel is compressed into a real number, that is, the input feature map X1 is compressed from [h, w, c] to [1, 1, c];
[0019] Generate a normalized weight value for each feature channel through two fully connected layers;
[0020] The obtained normalized weight is weighted to the features of each channel, and each channel is multiplied by the corresponding normalized weight, that is, [h,w,c]*[1,1,c]=[h,w,c], and finally the weighted feature map X2 is obtained.
[0021] Preferably, according to the present invention, in S2, the attention mechanism further includes spatial attention, and the spatial attention mechanism is:
[0022] For the input feature map X2, it is pooled, which are average pooling and maximum pooling;
[0023] Using a 1*1 convolution operation, we get a [h,w,1] feature map with a channel number of 1. This feature map is passed through a Sigmoid function and is element-wise multiplied with the original input feature map X2 to get a weighted feature map X3.
[0024] Preferably, in S2, in the training stage of the scaleless oil level gauge image segmentation model, a Dice loss function is used as a training loss function; in the post-processing stage of the scaleless oil level gauge image segmentation model, a conditional random field is used to perform image segmentation to obtain the minimum energy value after segmentation, thereby obtaining a global image segmentation result;
[0025] Among them, the Dice loss function is:
[0026]
[0027] In formula (1), X represents the pixel label of the real segmented image, Y represents the pixel category of the segmented image predicted by the model, |X∩Y| refers to the intersection between X and Y, |X| and |Y| represent the number of elements in X and Y respectively, and the numerator is multiplied by 2 to ensure that the denominator is in the range of [0, 1] after repeated calculation.
[0028] Preferably, according to the present invention, S4 specifically includes:
[0029] S41, extracting key point information in the range area using a corner detection algorithm;
[0030] S42, extracting the minimum circumscribed rectangle of the needle area, and calculating the pixel distances between the coordinates of the center points of the two short sides of the minimum circumscribed rectangle and the coordinates of the corner point C where the center point of the meter is located, taking the coordinates of the center point of the short side corresponding to the larger pixel distance as the needle head coordinate point, and taking the coordinates of the center point of the short side corresponding to the smaller pixel distance as the needle tail coordinate point;
[0031] S43. Connect the corner point S where the minimum scale is located and the corner point C where the center point of the meter is located to make a first straight line L1, connect the needle coordinate point and the corner point C where the center point of the meter is located to make a second straight line L2, connect the corner point M where the maximum scale is located and the corner point C where the center point of the meter is located to make a third straight line L3, and calculate the reading of the scaleless oil level gauge based on the angle θ1 between the first straight line L1 and the second straight line L2 and the angle θ2 between the third straight line L3 and the second straight line L2.
[0032] According to a preferred embodiment of the present invention, in S43, the reading of the scaleless oil level gauge is calculated based on the angle θ1 between the first straight line L1 and the second straight line L2 and the angle θ2 between the third straight line L3 and the second straight line L2 as follows:
[0033]
[0034] In formula (2), P represents the reading of the oil level gauge without scale.
[0035] In another aspect of the present invention, a device for implementing a scale-free oil level gauge reading method based on an image segmentation algorithm is provided, the device comprising:
[0036] An acquisition module, used for acquiring a scale-free oil level gauge image dataset, and preprocessing the oil level gauge images in the scale-free oil level gauge image dataset to construct a scale-free oil level gauge segmentation dataset;
[0037] A construction module, used for constructing a scale-free oil level gauge image segmentation model, and using the scale-free oil level gauge segmentation data set to train the scale-free oil level gauge image segmentation model;
[0038] A recognition module, used for performing reasoning on the image of the oil level gauge without scale to be recognized by using the trained image segmentation model of the oil level gauge without scale, so as to obtain the range area and the needle area in the oil level gauge;
[0039] The post-processing module is used to obtain the reading of the non-scale oil level gauge to be identified based on the range area and the needle area of the oil level gauge obtained in combination with post-processing analysis.
[0040] In another aspect of the present invention, there is also provided an electronic device, comprising:
[0041] at least one processor; and
[0042] A memory storing instructions, which, when executed by the at least one processor, enable the at least one processor to perform the scale-free oil level gauge reading method based on the image segmentation algorithm as described above.
[0043] In another aspect of the present invention, a machine-readable storage medium is provided, which stores executable instructions. When the instructions are executed, the machine executes the scale-free oil level gauge reading method based on the image segmentation algorithm as described above.
[0044] Compared with the prior art, the present invention has the following beneficial effects:
[0045] (1) The present invention provides a method for reading a scaleless oil level gauge based on an image segmentation algorithm. The method detects the range area and the needle area in the scaleless oil level gauge, performs oil level gauge reading in combination with corresponding post-processing, and utilizes the powerful feature extraction capability of deep learning to greatly improve the accuracy and reliability of key point prediction.
[0046] (2) The present invention designs a new image segmentation model, and improves the algorithm based on the original yolov8 segmentation model, including adding an attention mechanism, adopting the Dice loss function, and using the conditional random field method to replace the non-maximum suppression algorithm, which greatly improves the accuracy of the segmentation algorithm and the smoothness of the boundary.
[0047] (3) The present invention designs a method based on image segmentation algorithm and its post-processing method for reading the oil level gauge without a scale, which greatly improves the reading accuracy of the oil level gauge without a scale. BRIEF DESCRIPTION OF THE DRAWINGS
[0048] Figure 1 The present invention is a flowchart of a method for reading a scale-free oil level gauge based on an image segmentation algorithm.
[0049] Figure 2 Schematic diagram of the network structure of the attention mechanism in Example 1 of the present invention.
[0050] Figure 3 It is a schematic diagram of post-processing analysis based on the range area and the needle area in Example 1 of the present invention.
[0051] Figure 4 It is a schematic diagram of fitting circles and straight lines based on key points of the oil level gauge in Example 1 of the present invention. DETAILED DESCRIPTION
[0052] The present disclosure is further described below in conjunction with the accompanying drawings and embodiments.
[0053] It should be noted that the following detailed descriptions are exemplary and are intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meanings as those commonly understood by those skilled in the art to which the present disclosure belongs.
[0054] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is also intended to include the plural form. In addition, it should be understood that when the terms "comprising" and / or "including" are used in this specification, it indicates the presence of features, steps, operations, devices, components and / or combinations thereof.
[0055] In the absence of conflict, the embodiments in the present disclosure and the features in the embodiments may be combined with each other.
[0056] In view of the deficiencies in the prior art, the present invention provides a method for reading a scaleless oil level gauge based on an image segmentation algorithm. The method of the present invention is applied to a substation station monitoring to shoot a video of the oil level gauge pointer installed on the oil storage tank in real time. After extracting a number of video frames at a certain time interval from the captured video stream and sending them to the scaleless oil level gauge image segmentation algorithm adopted by the present invention, the image segmentation algorithm detects the range area and the needle area on the scaleless oil level gauge at a certain moment. Combined with post-processing analysis, the pointer reading information at the current moment is calculated, and the pointer reading information is obtained in real time.
[0057] The scale-free oil level gauge reading method and device based on image segmentation algorithm of the present invention will be further described below in conjunction with specific embodiments.
[0058] Embodiment 1,
[0059] Ginseng Figure 1 This embodiment provides a method for reading a scale-free oil level gauge based on an image segmentation algorithm, the method comprising:
[0060] S1. Acquire a scale-free oil level gauge image dataset, and preprocess the oil level gauge images in the scale-free oil level gauge image dataset to construct a scale-free oil level gauge segmentation dataset.
[0061] Specifically, the surveillance camera installed in the substation can be used to shoot the scaleless oil level gauge video, and then the video stream transmitted by the camera can be decoded into RGB format video frames, and then the decoded video frames are extracted at a certain time interval, which can be set to 60 minutes. Finally, all the collected video frame images are aggregated to produce a scaleless oil level gauge image dataset.
[0062] In this embodiment, the images in the scaleless oil level gauge image dataset are preprocessed to construct a scaleless oil level gauge segmentation dataset, which can specifically include: firstly, using the open source labeling tool labelme to label the unlabeled scaleless oil level gauge image dataset, including the scale value area, the fan-shaped area where the oil level gauge center point connection line is located, and the pointer area, to construct an initial version of the scaleless oil level gauge segmentation dataset.
[0063] Then, the initial version of the scale-free oil level gauge segmentation dataset is augmented with image enhancement algorithms, including Gaussian noise, glass noise, gamma transform, mean filter, motion blur, image sharpening, histogram equalization, principal component analysis, perspective transformation, etc. The enhancement method can be to randomly select the labeled oil level gauge images in the dataset and randomly select one or two of the above data enhancement algorithms for data enhancement, and collect the enhanced dataset to construct the final version of the scale-free oil level gauge segmentation dataset.
[0064] Finally, the final version of the scale-free oil level gauge segmentation dataset is randomly allocated into training set, test set and validation set in a ratio of 7:2:1, which are used for subsequent model training, testing and validation respectively, and there is no overlap between the datasets.
[0065] S2. Construct a scale-free oil level gauge image segmentation model, and use the scale-free oil level gauge segmentation dataset to train the scale-free oil level gauge image segmentation model.
[0066] In this embodiment, the scaleless oil level gauge image segmentation model adopts an improved version of the yolov8 segmentation algorithm, and its improvements specifically include:
[0067] 1) The yolov8 segmentation algorithm is improved by using the attention mechanism to enhance the effectiveness of feature extraction. The attention mechanism mainly includes channel attention and spatial attention.
[0068] Specific reference Figure 2 , the channel attention mechanism is as follows: for the input feature map X1, its dimension is [h, w, c], where h is the height of the feature map X1, w is the width of the feature map X1, and c is the number of channels of the feature map X1; first, global average pooling is used to compress the two-dimensional features [h, w] of each channel into a real number, that is, the input feature map X1 is compressed from [h, w, c] to [1, 1, c]; then a normalized weight value is generated for each feature channel through two fully connected layers; finally, the obtained normalized weight is weighted to the features of each channel, and the corresponding normalized weight is multiplied channel by channel, that is, [h, w, c]*[1, 1, c] = [h, w, c], and finally the weighted feature map X2 is obtained.
[0069] The spatial attention mechanism is as follows: for the input feature map X2, it is first pooled, namely average pooling and maximum pooling; then a 1*1 convolution operation is used to obtain a [h,w,1] feature map with a channel number of 1. This feature map is passed through a Sigmoid function and element-wise multiplied with the original input feature map X2 to obtain a weighted feature map X3.
[0070] 2) The conventional yolov8 segmentation algorithm uses a loss function based on target detection. In combination with the application scenario of this embodiment, a loss function Dice loss that is more suitable for segmentation tasks is used here. It is a metric function used to evaluate the similarity of two samples. The value range is between 0 and 1. The larger the value, the more similar it is. It is used to improve the accuracy of segmentation and the smoothness of the boundary. The Dice loss loss function is defined as:
[0071]
[0072] In formula (1), X represents the pixel label of the real segmented image, Y represents the pixel category of the segmented image predicted by the model, |X∩Y| refers to the intersection between X and Y, |X| and |Y| represent the number of elements in X and Y respectively, and the numerator is multiplied by 2 to ensure that the denominator is in the range of [0, 1] after repeated calculation.
[0073] The intersection method of Dice loss can be understood as a mask operation. Therefore, no matter how large the image is, the loss calculated for the fixed-size positive sample area is the same, and the supervisory contribution to the network does not change with the size of the image. This feature allows Dice loss to better solve the problem of imbalance between positive and negative samples. The positive and negative samples in this embodiment can be understood as the target area (i.e., image area) annotated in the data set is a positive sample, and the non-annotated area (i.e., background area) is a negative sample.
[0074] 3) In terms of model post-processing, the conventional yolov8 segmentation algorithm uses non-maximum suppression to remove the overlapping bounding boxes after the prediction results. In combination with the application scenario of this embodiment, the conditional random field method is used here to replace the non-maximum suppression algorithm to suppress the false detection area. The conditional random field can globally normalize all features and obtain the global optimal solution. The energy function is minimized to obtain the global image segmentation result.
[0075] The conditional random field mainly refers to the use of conditional probability to determine the probability that the current pixel belongs to a certain category under the condition of the grayscale value of the current pixel and the pixels in the surrounding area. However, this conditional probability does not refer to the probability of a certain pixel point, but refers to the conditional probability that the categories of all pixels on the image have been determined. Applying the conditional random field for image segmentation can obtain the minimum energy after segmentation, thereby obtaining the global image segmentation result. This method not only takes into account the similarity and spatial relationship between pixels, but also can use multiple features to describe each pixel, and achieve more accurate image segmentation by interacting and fusing these features.
[0076] Based on the above process, a scaleless oil level gauge image segmentation model is constructed, and then the model is trained using the constructed scaleless oil level gauge segmentation dataset until the set training conditions are met. The model training process is a conventional technology and will not be described in detail here.
[0077] S3. Use the trained non-scale oil level gauge image segmentation model to infer the non-scale oil level gauge image to be identified, so as to obtain the range area and the needle area in the oil level gauge.
[0078] That is, the image of the oil level gauge without scale to be identified is input into the trained oil level gauge without scale image segmentation model for algorithm reasoning, and finally the following is obtained: Figure 3 The image shows the range area (range) and the pointer area (pointer) of the oil level gauge.
[0079] S4. Based on the obtained range area and needle area of the oil level gauge, combined with post-processing analysis, the reading of the scale-free oil level gauge to be identified is obtained.
[0080] Combination Figure 3 and Figure 4 As shown, based on the range area (range) and pointer area (pointer) of the oil level gauge output by the non-scale oil level gauge image segmentation model, post-processing analysis is performed, specifically including:
[0081] S41. Extract key point information in the range area using a corner detection algorithm.
[0082] In this embodiment, the Harris corner point detection algorithm can be used to detect key point information such as the corner point S where the minimum scale of the range is located, the corner point M where the maximum scale is located, and the corner point C where the center point of the meter is located.
[0083] S42. Extract the minimum circumscribed rectangle of the needle area, and calculate the pixel distances between the coordinates of the center points of the two short sides of the minimum circumscribed rectangle and the coordinates of the corner point C where the center point of the meter is located. The coordinates of the center point of the short side corresponding to the larger pixel distance are used as the needle head coordinate point, and the coordinates of the center point of the short side corresponding to the smaller pixel distance are used as the needle tail coordinate point.
[0084] Among them, the pixel distance between the coordinates of the center points of the two short sides of the minimum circumscribed rectangle of the pointer area (pointer) and the coordinates of the corner point C where the center point of the meter is located can be solved using the Euclidean distance calculation formula, and then the needle head coordinate point and the needle tail coordinate point are determined based on the calculation results.
[0085] S43. Connect the corner point S where the minimum scale is located and the corner point C where the center point of the meter is located to make a first straight line L1, connect the needle coordinate point and the corner point C where the center point of the meter is located to make a second straight line L2, connect the corner point M where the maximum scale is located and the corner point C where the center point of the meter is located to make a third straight line L3, and calculate the reading of the scaleless oil level gauge based on the angle θ1 between the first straight line L1 and the second straight line L2 and the angle θ2 between the third straight line L3 and the second straight line L2.
[0086] Ginseng Figure 4 As shown, according to the above steps, the coordinate position information of the corner point S where the minimum scale is located, the corner point M where the maximum scale is located, the corner point C where the center point of the meter is located, and the coordinate point of the needle and the coordinate point of the needle tail are obtained respectively; then, according to the above coordinate position information, straight lines are constructed respectively to obtain the angle θ1 between the corner point S where the minimum scale is located and the straight line where the needle coordinate point is located, and the angle θ2 between the corner point M where the maximum scale is located and the straight line where the needle coordinate point is located; finally, the reading of the scaleless oil level gauge is calculated according to the angle θ1 and the angle θ2, and the calculation formula is:
[0087]
[0088] In formula (2), P represents the reading of the oil level gauge without scale.
[0089] In summary, the scaleless oil level gauge reading method based on image segmentation algorithm of the present invention detects the range area and the needle area in the scaleless oil level gauge, and performs oil level gauge reading in combination with corresponding post-processing. The present invention avoids the cumbersome image processing flow, simplifies the meter reading processing process, and improves the accuracy of the scaleless oil level gauge meter reading to a certain extent.
[0090] The present invention does not require any prior knowledge. It uses the improved yolov8 segmentation algorithm to detect the range area and the pointer area, and combines post-processing to extract the maximum scale point, the minimum scale point, the meter center point, the pointer needle and other information to achieve the final accurate reading. It has been verified by experiments that the accuracy within 1 small scale error is greater than 95%.
[0091] The present invention does not require tilt correction for the pointer-type instrument. When the pointer-type instrument is tilted but the dial can be clearly seen, the present invention can be directly applied without adding redundant processing.
[0092] Embodiment 2,
[0093] This embodiment provides a device for implementing a method for reading a scale-free oil level gauge based on an image segmentation algorithm, the device comprising:
[0094] An acquisition module, used for acquiring a scale-free oil level gauge image dataset, and preprocessing the oil level gauge images in the scale-free oil level gauge image dataset to construct a scale-free oil level gauge segmentation dataset;
[0095] A construction module, used for constructing a scale-free oil level gauge image segmentation model, and training the scale-free oil level gauge image segmentation model using the scale-free oil level gauge segmentation dataset;
[0096] A recognition module, used for reasoning the image of the oil level gauge without scale to be recognized by using the trained image segmentation model of the oil level gauge without scale, so as to obtain the range area and the needle area in the oil level gauge;
[0097] The post-processing module is used to obtain the reading of the scale-free oil level gauge to be identified based on the range area and the needle area of the oil level gauge obtained in combination with post-processing analysis.
[0098] Embodiment 3,
[0099] This embodiment also provides an electronic device, including:
[0100] at least one processor; and
[0101] A memory storing instructions, which, when executed by the at least one processor, enable the at least one processor to perform the scale-free oil level gauge reading method based on the image segmentation algorithm as described above.
[0102] In this embodiment, the electronic device may include, but is not limited to: personal computers, server computers, workstations, desktop computers, laptop computers, notebook computers, mobile computing devices, smart phones, tablet computers, cellular phones, personal digital assistants (PDAs), handheld devices, messaging devices, wearable computing devices, consumer electronic devices, and the like.
[0103] Embodiment 4,
[0104] This embodiment also provides a machine-readable storage medium storing executable instructions, which, when executed, enable the machine to execute the scale-free oil level gauge reading method based on the image segmentation algorithm as described above.
[0105] Specifically, a system or device equipped with a readable storage medium can be provided, on which software program codes that implement the functions of any of the above-mentioned embodiments are stored, and a computer or processor of the system or device can read and execute instructions stored in the readable storage medium.
[0106] In this case, the program code itself read from the machine-readable medium can realize the function of any one of the above embodiments, and thus the machine-readable code and the machine-readable storage medium storing the machine-readable code constitute part of this specification.
[0107] Examples of readable storage media include floppy disks, hard disks, magneto-optical disks, optical disks (such as CD-ROM, CD-R, CD-RW, DVD-ROM, DVD-RAM, DVD-RW, DVD-RW), magnetic tapes, non-volatile memory cards, and ROMs. Alternatively, the program code may be downloaded from a server computer or a cloud via a communication network.
[0108] Those skilled in the art will appreciate that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented 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.
[0109] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices (systems), and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0110] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1A function specified in one or more boxes.
[0111] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0112] Obviously, the above embodiments of the present invention are merely examples for clearly illustrating the technical solution of the present invention, and are not intended to limit the specific implementation methods of the present invention. Any modifications, equivalent substitutions, and improvements made within the spirit and principles of the claims of the present invention shall be included in the protection scope of the claims of the present invention.
Claims
1. A method for reading a scale-free oil level gauge based on an image segmentation algorithm, characterized in that: The method comprises: S1, obtaining a scale-free oil level gauge image dataset, and preprocessing the oil level gauge images in the scale-free oil level gauge image dataset to construct a scale-free oil level gauge segmentation dataset; S2, constructing a scale-free oil level gauge image segmentation model, and using the scale-free oil level gauge segmentation dataset to train the scale-free oil level gauge image segmentation model; S3, using the trained non-scale oil level gauge image segmentation model to perform reasoning on the non-scale oil level gauge image to be identified, so as to obtain the range area and the needle area in the oil level gauge; S4. Based on the obtained range area and needle area of the oil level gauge, combined with post-processing analysis, the reading of the scale-free oil level gauge to be identified is obtained.
2. The method for reading a scale-free oil level gauge based on an image segmentation algorithm according to claim 1, characterized in that: In S1, the oil level gauge images in the scale-free oil level gauge image dataset are preprocessed to construct a scale-free oil level gauge segmentation dataset, specifically including: The open source annotation tool labelme is used to annotate the unlabeled oil level gauge image dataset without scale. The annotation includes the scale value area, the fan-shaped area where the oil level gauge center point connection line is located, and the pointer area, to construct the initial oil level gauge segmentation dataset without scale. The labeled oil level gauge images in the initial scale-free oil level gauge segmentation dataset are randomly extracted, and data augmentation is performed on the images using a data enhancement algorithm to obtain a final scale-free oil level gauge segmentation dataset.
3. The method for reading a scale-free oil level gauge based on an image segmentation algorithm according to claim 1, characterized in that: In S2, a scale-free oil level gauge image segmentation model is constructed based on the yolov8 segmentation algorithm and combined with the attention mechanism. The attention mechanism includes channel attention, and the channel attention mechanism is: For the input feature map X1, its dimension is [h,w,c], where h is the height of the feature map X1, w is the width of the feature map X1, and c is the number of channels of the feature map X1; Using global average pooling, the two-dimensional feature [h, w] of each channel is compressed into a real number, that is, the input feature map X1 is compressed from [h, w, c] to [1, 1, c]; Generate a normalized weight value for each feature channel through two fully connected layers; The obtained normalized weight is weighted to the features of each channel, and each channel is multiplied by the corresponding normalized weight, that is, [h,w,c]*[1,1,c]=[h,w,c], and finally the weighted feature map X2 is obtained.
4. The method for reading a scale-free oil level gauge based on an image segmentation algorithm according to claim 3 is characterized in that: In S2, the attention mechanism also includes spatial attention, and the spatial attention mechanism is: For the input feature map X2, it is pooled, which are average pooling and maximum pooling; Using a 1*1 convolution operation, we get a [h,w,1] feature map with a channel number of 1. This feature map is passed through a Sigmoid function and is element-wise multiplied with the original input feature map X2 to get a weighted feature map X3.
5. The method for reading a scale-free oil level gauge based on an image segmentation algorithm according to claim 1, characterized in that: In S2, in the training stage of the scaleless oil level gauge image segmentation model, the Dice loss function is used as the training loss function; in the post-processing stage of the scaleless oil level gauge image segmentation model, the conditional random field is used to perform image segmentation to obtain the minimum energy value after segmentation, and obtain the global image segmentation result; Among them, the Dice loss function is: In formula (1), X represents the pixel label of the real segmented image, Y represents the pixel category of the segmented image predicted by the model, |X∩Y| refers to the intersection between X and Y, |X| and |Y| represent the number of elements in X and Y respectively, and the numerator is multiplied by 2 to ensure that the denominator is in the range of [0, 1] after repeated calculation.
6. The method for reading a scale-free oil level gauge based on an image segmentation algorithm according to claim 1, characterized in that: The S4 specifically includes: S41, extracting key point information in the range area using a corner detection algorithm; S42, extracting the minimum circumscribed rectangle of the needle area, and calculating the pixel distances between the coordinates of the center points of the two short sides of the minimum circumscribed rectangle and the coordinates of the corner point C where the center point of the meter is located, taking the coordinates of the center point of the short side corresponding to the larger pixel distance as the needle head coordinate point, and taking the coordinates of the center point of the short side corresponding to the smaller pixel distance as the needle tail coordinate point; S43. Connect the corner point S where the minimum scale is located and the corner point C where the center point of the meter is located to make a first straight line L1, connect the needle coordinate point and the corner point C where the center point of the meter is located to make a second straight line L2, connect the corner point M where the maximum scale is located and the corner point C where the center point of the meter is located to make a third straight line L3, and calculate the reading of the scaleless oil level gauge based on the angle θ1 between the first straight line L1 and the second straight line L2 and the angle θ2 between the third straight line L3 and the second straight line L2.
7. The method for reading a scale-free oil level gauge based on an image segmentation algorithm according to claim 6, characterized in that: In S43, the reading of the scaleless oil level gauge is calculated based on the angle θ1 between the first straight line L1 and the second straight line L2 and the angle θ2 between the third straight line L3 and the second straight line L2: In formula (2), P represents the reading of the oil level gauge without scale.
8. A device for realizing a scale-free oil level gauge reading method based on an image segmentation algorithm, characterized in that: The device comprises: An acquisition module, used for acquiring a scale-free oil level gauge image dataset, and preprocessing the oil level gauge images in the scale-free oil level gauge image dataset to construct a scale-free oil level gauge segmentation dataset; A construction module, used for constructing a scale-free oil level gauge image segmentation model, and training the scale-free oil level gauge image segmentation model using the scale-free oil level gauge segmentation dataset; A recognition module, used for reasoning the image of the oil level gauge without scale to be recognized by using the trained image segmentation model of the oil level gauge without scale, so as to obtain the range area and the needle area in the oil level gauge; The post-processing module is used to obtain the reading of the scale-free oil level gauge to be identified based on the range area and the needle area of the oil level gauge obtained in combination with post-processing analysis.
9. An electronic device, characterized in that: The electronic device comprises: at least one processor; and A memory storing instructions, which, when executed by the at least one processor, enable the at least one processor to perform the scale-free oil level gauge reading method based on an image segmentation algorithm as described in any one of claims 1 to 7.
10. A machine-readable storage medium, characterized in that: The machine-readable storage medium stores executable instructions, which, when executed, enable the machine to perform the scale-free oil level gauge reading method based on an image segmentation algorithm according to any one of claims 1 to 7.
