Liquid level image generation method and device, electronic equipment and medium
Patent Information
- Application Number
- CN202611196332.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2026-08-07
- Publication Date
- 2026-11-03
- Estimated Expiration
- 2046-08-07
AI Technical Summary
Deep learning-based liquid level recognition models suffer from low training accuracy in substations due to a lack of extreme abnormal liquid level samples, which affects the accuracy of liquid level recognition.
The initial acquisition image is obtained by generating a method, and after geometric correction, the liquid level block image is cropped. Then, liquid level block images with different positions are generated in the target image. The images are filled in with the position information to amplify the sample liquid level images for training the preset model.
It improved the efficiency and accuracy of sample liquid level image generation, enhanced the model's ability to identify liquid level height, and reduced the false alarms and missed alarms during model operation in the field.
Smart Images

Figure CN122761101B_ABST
Abstract
Description
Technical Field
[0001] This application belongs to the field of computer vision technology, and in particular relates to a method, apparatus, electronic device and medium for generating liquid level images. Background Technology
[0002] In the unmanned operation and maintenance system of intelligent substations, real-time online monitoring of water tank levels and oil levels in oil filling equipment is a core safety control aspect. Liquid level identification based on deep learning-based target detection models is currently the mainstream trend.
[0003] However, deep learning-based object detection models rely on a large number of sample images with different liquid levels and lighting conditions. In actual operation, substation equipment is at normal water / oil levels for extended periods, making it extremely difficult to collect abnormal samples in reality. This affects the training accuracy of the model and consequently, the accurate identification of liquid levels. Summary of the Invention
[0004] This application provides a method, apparatus, electronic device, and medium for generating liquid level images, which can effectively increase the amount of sample data and facilitate model training.
[0005] In a first aspect, embodiments of this application provide a method for generating a liquid level image, comprising: An initial acquisition image is obtained, and a target image and a first liquid level block image are obtained based on the initial acquisition image; wherein, the initial acquisition image is an image containing a glass tube containing liquid, the target image represents a vertical glass tube image, and the first liquid level block image represents an image block containing liquid level extracted from the target image; Based on the first liquid level block image, a second liquid level block image is generated in the target image; wherein, the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position; Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a liquid level height different from that in the initial acquisition image, and the sample liquid level image is used to train a preset model, and the preset model is used to identify the liquid level height in the image.
[0006] Secondly, embodiments of this application provide an apparatus for generating a liquid level image, the apparatus comprising: An image acquisition module is used to acquire an initial image and obtain a target image and a first liquid level block image based on the initial image; wherein, the initial image is an image of a glass tube containing liquid, the target image represents a vertical glass tube image, and the first liquid level block image represents an image block containing liquid level extracted from the target image; An image block generation module is used to generate a second liquid level block image in the target image based on the first liquid level block image; wherein the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position. The sample generation module is used to determine the filling region in the target image based on the position information of the first liquid level block image and the position information of the second liquid level block image in the target image, and to fill the filling region to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a liquid level height different from that in the initial acquisition image, and the sample liquid level image is used to train a preset model, and the preset model is used to identify the liquid level height in the image.
[0007] Thirdly, embodiments of this application provide an electronic device, including: a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the method described in the first aspect.
[0008] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when executed by a processor, implements the method described in the first aspect.
[0009] Fifthly, embodiments of this application provide a computer program product that, when run on an electronic device, causes the electronic device to execute the method described in the first aspect above.
[0010] In this embodiment, an initial acquisition image is obtained, which is an image containing a glass tube. The glass tube in the initial acquisition image may be tilted. Based on the initial acquisition image, a target image and a first liquid level block image can be obtained. The target image represents the vertical glass tube image, and the first liquid level block image represents an image block containing liquid levels extracted from the target image. Geometric correction is performed on the initial acquisition image to improve the processing accuracy of subsequent liquid level blocks. Based on the first liquid level block image, a second liquid level block image is generated in the target image. The second liquid level block image is the same size as the first liquid level block image but in a different position, and both contain liquid levels. That is, there are two liquid levels in the target image. Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled so that the target image only contains the liquid level of the second liquid level block, thereby obtaining a sample liquid level image. The liquid level height in the sample liquid level image differs from that in the initially acquired image, thus amplifying the sample liquid level image and improving its generation efficiency. The sample liquid level image can then be used to train a pre-defined model, enabling the model to accurately identify the liquid level height in the image and improving the recognition accuracy. Attached Figure Description
[0011] To more clearly illustrate the technical solutions in the embodiments of this application, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0012] Figure 1 This is a system architecture diagram provided in the embodiments of this application; Figure 2 This is a schematic flowchart of the liquid level image generation method provided in the embodiments of this application; Figure 3 This is a schematic flowchart of the method for generating liquid level images provided in the embodiments of this application; Figure 4 This is a schematic flowchart of the method for generating liquid level images provided in the embodiments of this application; Figure 5 This is a schematic diagram of the filling area under the liquid level rising condition provided in the embodiments of this application; Figure 6 This is a schematic diagram of the filling area under the liquid level drop condition provided in the embodiments of this application; Figure 7 This is a schematic diagram of the transition region provided in the embodiments of this application; Figure 8This is a schematic diagram illustrating the variation of the one-dimensional cosine attenuation mask provided in the embodiments of this application; Figure 9 This is a schematic flowchart of the method for generating liquid level images provided in the embodiments of this application; Figure 10 This is a schematic diagram of the initial acquired image provided in an embodiment of this application; Figure 11 This is a schematic diagram of the structure of the liquid level image generation device provided in the embodiments of this application; Figure 12 This is a schematic diagram of the structure of the electronic device provided in the embodiments of this application. Detailed Implementation
[0013] In the following description, specific details such as particular system architectures and techniques are set forth for illustrative purposes and not for limitation, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application may also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods have been omitted so as not to obscure the description of this application with unnecessary detail.
[0014] It should be understood that, when used in this application specification and the appended claims, the term "comprising" indicates the presence of the described features, integrals, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or a collection thereof.
[0015] It should also be understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0016] As used in this application specification and the appended claims, the term "if" may be interpreted, depending on the context, as "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if detected [the described condition or event]" may be interpreted, depending on the context, as meaning "once determined," "in response to determination," "once detected [the described condition or event]," or "in response to detection [the described condition or event]."
[0017] Furthermore, in the description of this application and the appended claims, the terms "first," "second," "third," etc., are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.
[0018] References to "one embodiment" or "some embodiments" as described in this specification mean that one or more embodiments of this application include a specific feature, structure, or characteristic described in connection with that embodiment. Therefore, the phrases "in one embodiment," "in some embodiments," "in other embodiments," "in still other embodiments," etc., appearing in different parts of this specification do not necessarily refer to the same embodiment, but rather mean "one or more, but not all, embodiments," unless otherwise specifically emphasized. The terms "comprising," "including," "having," and variations thereof mean "including but not limited to," unless otherwise specifically emphasized.
[0019] The liquid level image generation method provided in this application embodiment can be applied to terminal devices such as mobile phones, tablets, wearable devices, vehicle-mounted devices, augmented reality (AR) / virtual reality (VR) devices, laptops, ultra-mobile personal computers (UMPCs), netbooks, robots, and personal digital assistants (PDAs). This application embodiment does not impose any restrictions on the specific type of terminal device.
[0020] Before providing a further detailed description of the embodiments of this application, the nouns and terms used in the embodiments of this application are explained, and the nouns and terms used in the embodiments of this application shall be interpreted as follows: Glass tube: A transparent observation window that can be used to visually display the liquid level in the transformer tank. Real-time monitoring of the liquid level is crucial to ensuring the safe operation of the equipment.
[0021] Liquid level: refers to the vertical height of the liquid surface in the glass tube relative to a certain reference surface. The liquid level is an important indicator for the safe operation of the transformer. For example, if the liquid level is too low, it may cause insulation failure and lead to faults. If the liquid level is too high or expands rapidly, it may cause oil leakage or bursting.
[0022] In the unmanned operation and maintenance system of intelligent substations, real-time online monitoring of water tank levels and oil levels in oil-filled equipment is a core safety control aspect. On the one hand, the fire pump room and domestic fire water supply system within the substation fall under the category of auxiliary environmental monitoring, and the water tank level needs to be strictly monitored throughout the entire process. Too low a water level will directly cause the fire-fighting water supply system to fail, making it impossible to guarantee fire-fighting water in case of fire; too high a water level can easily cause water overflow, soaking electrical equipment such as cables and secondary cabinets in the underground machine room, leading to short circuits and grounding faults. On the other hand, the oil level status of oil-filled primary high-voltage equipment such as the main transformer oil conservator, high-voltage bushings, and oil-immersed instrument transformers must be monitored in real time to prevent equipment leakage and oil shortage, which can lead to internal partial discharge, accelerated insulation deterioration, winding overheating, and in severe cases, internal short circuits, oil tank spraying, and fires.
[0023] Using fixed infrared night vision cameras within substations for visual liquid level identification is a mainstream trend. However, deep learning-based target detection models rely on a large number of labeled samples with varying liquid levels and lighting conditions. In actual operation, substation equipment is typically at normal water / oil levels, making it extremely difficult to collect extreme anomalies such as "extremely high / low water levels" or "severe oil shortages." Manually synthesizing samples is not only labor-intensive and time-consuming but also subject to limitations such as lighting variations, infrared night vision reflections, image tilt, and harsh edge transitions. The generated images deviate significantly from the actual on-site conditions, resulting in poor robustness of the trained model. This leads to frequent false alarms and missed alarms during on-site operation, completely failing to meet the high reliability and low alarm error requirements of unmanned power systems.
[0024] The system architecture used in the embodiments of this application Figure 1 This is a system architecture diagram of the liquid level image generation method according to an embodiment of this application. It includes a terminal 140, an Internet 130, a gateway 120, a server 110, etc.
[0025] Terminal 140 can take various forms, including desktop computers, laptops, PDAs (personal digital assistants), mobile phones, in-vehicle terminals, home theater terminals, and dedicated terminals. Furthermore, it can be a single device or a collection of multiple devices. Terminal 140 can communicate with the Internet 130 via wired or wireless means to exchange data.
[0026] Server 110 refers to a computer system that can provide certain services to terminal 140. Compared to ordinary terminal 140, server 110 has higher requirements in terms of stability, security, and performance. Server 110 can be a single high-performance computer in a network platform, a cluster of multiple high-performance computers, a portion of a single high-performance computer (e.g., a virtual machine), or a combination of portions of multiple high-performance computers (e.g., virtual machines).
[0027] Gateway 120, also known as an internetwork connector or protocol converter, is a computer system or device that acts as a translator, enabling network interconnection at the transport layer. It bridges the gap between two systems using different communication protocols, data formats, languages, or even completely different architectures. Gateways can also provide filtering and security functions. Messages sent from terminal 140 to server 110 are forwarded to the corresponding server 110 via gateway 120. Messages sent from server 110 to terminal 140 are also forwarded to the corresponding terminal 140 via gateway 120.
[0028] General Description of Embodiments in this Application According to one embodiment of this application, a method for generating liquid level images is provided, proposing an enhanced dataset of full-range water / oil levels that can be automatically generated by collecting a very small number of initial samples at a fixed location, and realizing a closed-loop solution for automated operation and maintenance.
[0029] Figure 2 This is a flowchart illustrating the method for generating liquid level images, as shown below. Figure 2 As shown, a method for generating a liquid level image according to an embodiment of this application may include: Step 210: Obtain the initial acquisition image. Based on the initial acquisition image, obtain the target image and the first liquid level block image. The initial acquisition image is an image of a glass tube containing liquid. The target image represents the vertical glass tube image. The first liquid level block image represents an image block containing liquid level extracted from the target image. Step 220: Generate a second liquid level block image in the target image based on the first liquid level block image; wherein, the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position; Step 230: Based on the position information of the first liquid level block image and the second liquid level block image in the target image, determine the filling region in the target image and fill the filling region to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a different liquid level height than the initially acquired image, and the sample liquid level image is used to train the preset model, which is used to identify the liquid level height in the image.
[0030] Steps 210-230 are described in detail below.
[0031] In step 210, the initial image acquired is the original image of the glass tube captured by the on-site acquisition equipment, containing the complete glass tube body and the liquid inside. This image can fully represent all real-world operating conditions, including the glass tube's tilt shape, original liquid level, on-site infrared illumination, and tube wall texture. The glass tube is a tubular visual component used to visually display the internal liquid level in substation liquid level and oil level monitoring scenarios. The component contains a liquid area that can be raised and lowered. The liquid is a medium contained inside the glass tube whose height dynamically changes with the equipment's operating conditions, and can include various media such as water from fire-fighting tanks and insulating oil from oil-filled equipment.
[0032] A reference image of the visible liquid level at the substation at different times can be acquired as the initial acquisition image. Based on the initial acquisition image, a target image and a first liquid level block image can be obtained. The target image is an image representing a glass tube, and the glass tube is vertical. The glass tube in the initial acquisition image may be tilted at different angles. By geometrically correcting the initial acquisition image, the glass tube can be made vertical, thus obtaining the target image. For example, the verticalized initial acquisition image can be used as the target image, or the glass tube in the verticalized initial acquisition image can be cropped to obtain the target image. That is, the target image can be an image of the glass tube after geometric rotation correction of the initial acquisition image, with the central axis of the tube parallel to the vertical direction. The first liquid level block image is a local image segment extracted from the target image, and the first liquid level block image contains the liquid level. For example, it can be a rectangular frame containing the liquid level.
[0033] For example, the initial image acquisition can be achieved using fixed infrared night vision cameras at the substation site or imaging equipment mounted on a mobile inspection robot. After acquisition, the tilt angle of the glass tube is calculated, and the image is corrected through inverse rotation transformation to obtain the target image. Alternatively, a local pixel segment can be cropped based on the marked liquid surface boundary to obtain the first liquid level block image. During the correction transformation, the inverse transformation matrix can also be stored simultaneously for subsequent restoration of the tilt shape of the original image.
[0034] In step 220, the second liquid level block image is a liquid level material image block that reuses the complete pixel size of the first liquid level block image, only adjusting its placement coordinates within the target image. By changing the placement position, it is possible to simulate the image of different liquid levels across the entire range, that is, to simulate the new liquid surface imaging area after the liquid in the glass tube rises or falls, facilitating the construction of multi-condition sample liquid level images.
[0035] Since the glass tube in the target image is vertical, the first liquid level block image can be shifted vertically to obtain the second liquid level block image. While generating the second liquid level block image, the first liquid level block image is retained in the target image; that is, two liquid levels can appear in the target image.
[0036] The operation of generating the second liquid level block image can be performed by randomly selecting vertical coordinates within the pixel range of the glass tube defined by the target image. In this embodiment, the second liquid level block image cannot exceed the range of the glass tube.
[0037] In step 230, the location information is spatial representation data such as the boundary coordinates and center coordinates of the corresponding liquid level block image in the pixel coordinate system of the target image. It can be used to quantify and distinguish the spatial difference between the original liquid level area and the newly generated liquid level area, that is, the spatial relationship between the first liquid level block image and the second liquid level block image.
[0038] Based on these two sets of location information, the boundary range of the filling area can be accurately defined, providing a precise pixel interval basis for subsequent texture filling processing. For example, the area between the horizontal central axis of the first liquid level block image and the horizontal central axis of the second liquid level block image can be determined as the filling area. The filling area is the pixel interval corresponding to the pipe wall between the original liquid level area and the newly generated liquid level area inside the target image, carrying the simulated content of the pipe wall texture exposed after the liquid level rises and falls.
[0039] By performing texture interpolation and noise superposition on the filled area, the natural imaging effect of the pipe wall at different liquid levels under real working conditions can be restored, eliminating blank and distorted areas caused by liquid level block displacement. The filling process involves performing pixel reconstruction operations such as pipe wall texture interpolation and imaging noise superposition on the filled area. Based on the real pipe wall pixels in the original image, a continuous and natural pipe wall image is generated, filling the blank areas caused by the displacement of the liquid level block, weakening the traces of artificial synthesis, and improving the distribution consistency between the sample liquid level image and the real scene shooting image.
[0040] For example, for different operating conditions, pipe wall pixels near the first liquid level block image can be selected as texture interpolation references. A continuously gradient pipe wall substrate is generated through one-dimensional linear interpolation. Low-intensity random noise is superimposed within the substrate pixels to replicate the particle imaging features of the infrared camera, thus completing pixel coverage of all blank areas. After filling, an edge smoothing and blending operation can be performed on the second liquid level block image to eliminate the splicing boundary between the liquid level block and the filled pipe wall.
[0041] The sample liquid level image is determined based on the filled image. This sample liquid level image is a completely new image obtained after liquid level block displacement, pixel reconstruction of the filled area, and edge smoothing and fusion. The sample liquid level image contains a complete glass tube, and the liquid height inside the image differs significantly from the initial acquired image. By determining the sample liquid level image, the training dataset of the preset model, namely the substation liquid level recognition model, can be expanded to identify the liquid level height in images. The sample liquid level image can supplement extreme working condition samples with extremely high and low liquid levels that are difficult to collect on-site, enriching the liquid level height range and light interference types covered by the training data.
[0042] For example, the sample liquid level image can be used to restore the image coordinates and screen angle based on the pre-stored inverse transformation matrix, thus restoring the tilt shape of the glass tube inherent in the initial acquired image. Simultaneously, the coordinates of all tubes and liquid surfaces are normalized to generate a corresponding annotation file. The images and annotation files are stored as a set as model training material. Multiple sets of second liquid level block images with different vertical coordinates can be cyclically generated to produce multiple sets of sample liquid level images with differentiated liquid level heights, expanding the dataset coverage.
[0043] The preset model in this embodiment is an image liquid level recognition network model built based on deep learning. After training, it can receive real-time images captured by on-site cameras, automatically extract the coordinates of key points on the glass tube and liquid surface, and calculate the actual liquid level height. Depending on the different business scenarios of the substation, the identified key point coordinates are dynamically compared mathematically with preset safety thresholds. For example, in the substation pump room scenario, an alarm is issued when the identified water tank level coordinates trigger the upper or lower limit; in the substation oil filling equipment inspection scenario, inspection robots or fixed cameras periodically read the oil levels of the main transformer oil tank, bushings, and current transformers, and an alarm is issued when the oil level continuously drops or triggers the "oil shortage" threshold. In continuous frame recognition, geometric constraints and temporal filtering can also be added. For example, geometric constraints can be that the position and distance of the liquid surface points in the left and right frames must conform to the physical dimensions of the glass tube; otherwise, it is considered a false alarm and filtered out. Temporal filtering can be performed if the liquid level changes continuously in physical form; if the jump between two consecutive frames is too large, smoothing filtering or rejection is performed.
[0044] By standardizing and correcting the pipe body using a single on-site captured image and extracting real liquid level data, the liquid level data is reused to adjust the placement position to simulate various liquid level heights. Based on the difference in liquid level position, the blank filling interval of the pipe wall is accurately defined and gradient filling is completed based on the real pipe wall texture of the original image. It can automatically generate a training dataset covering the full range of liquid level heights with only a few on-site captured labeled samples, supplementing extreme abnormal liquid level samples that are difficult to collect on-site. This significantly reduces the workload of manual labeling and manual image synthesis, improves the pixel distribution fit between the generated samples and the real on-site working conditions, and thus optimizes the recognition robustness of the preset model, reduces the false alarms and missed alarms during the model's on-site operation, and matches the control requirements of high-reliability liquid level monitoring in unattended substation operation and maintenance systems.
[0045] In this embodiment, an initial acquisition image is obtained, which is an image containing a glass tube. The glass tube in the initial acquisition image may be tilted. Based on the initial acquisition image, a target image and a first liquid level block image can be obtained. The target image represents the vertical glass tube image, and the first liquid level block image represents an image block containing liquid levels extracted from the target image. Geometric correction is performed on the initial acquisition image to improve the processing accuracy of subsequent liquid level blocks. Based on the first liquid level block image, a second liquid level block image is generated in the target image. The second liquid level block image is the same size as the first liquid level block image but in a different position, and both contain liquid levels. That is, there are two liquid levels in the target image. Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled so that the target image only contains the liquid level of the second liquid level block, thereby obtaining a sample liquid level image. The liquid level height in the sample liquid level image differs from that in the initially acquired image, thus amplifying the sample liquid level image and improving its generation efficiency. The sample liquid level image can then be used to train a pre-defined model, enabling the model to accurately identify the liquid level height in the image and improving the recognition accuracy.
[0046] Figure 3 This is a flowchart illustrating the method for generating liquid level images, as shown below. Figure 3 As shown, a method for generating a liquid level image according to an embodiment of this application may include: Step 310: Obtain the initial acquisition image. Based on the initial acquisition image, obtain the target image and the first liquid level block image. The initial acquisition image is an image containing a glass tube containing liquid. The target image represents the vertical glass tube image. The first liquid level block image represents an image block containing liquid level extracted from the target image. Step 320: Determine a random point on the left side of the glass tube wall of the target image, and set the random point as the upper left corner coordinate point of the second liquid level block image; Step 330: Generate the second liquid level block image based on the coordinates of the upper left corner of the first liquid level block image and the second liquid level block image; Step 340: Based on the position information of the first liquid level block image and the second liquid level block image in the target image, determine the filling region in the target image and fill the filling region to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a different liquid level height than the initially acquired image, and the sample liquid level image is used to train the preset model, and the preset model is used to identify the liquid level height in the image.
[0047] Steps 310 and 340 have been described in detail above and will not be repeated here. Steps 320 and 330 will be described in detail below.
[0048] In step 320, the left glass tube wall is the pixel area of the left side of the tube wall within the target image after vertical correction. The left glass tube wall is the effective constraint area defining the vertical arrangement of the second liquid level block image, and limits the effective spatial boundary for selecting the vertical coordinates of the liquid level block.
[0049] Both the first and second liquid level block images are rectangular frames. A random point is selected based on the pixel range corresponding to the left glass tube wall, and this random point is determined as the upper left corner coordinate point of the rectangle of the second liquid level block image. Determining the upper left corner coordinate point of the second liquid level block image on the left glass tube wall ensures that the second liquid level block image falls completely within the imaging range of the glass tube, avoiding the liquid level block from shifting outwards from the tube body and producing invalid composite images.
[0050] In step 330, the upper left corner coordinate point is the pixel coordinate corresponding to the upper left corner of the pixel area of the rectangular liquid level block image. Only the upper left corner coordinate point needs to be adjusted to completely translate the entire liquid level block image without changing all the pixel content inside the liquid level block image, thus simplifying the generation process of the second liquid level block image.
[0051] That is, by reusing the complete pixel content of the first liquid level block image and combining it with the coordinates of the upper left corner of the second liquid level block image, the second liquid level block image is constructed.
[0052] For example, when performing the second liquid level block image generation operation, all liquid imaging pixel content contained in the first liquid level block image can be completely copied without changing the pixel information such as the liquid surface texture, imaging grayscale, and noise characteristics inside the liquid level block. Only the upper left corner pixel of the copied image block is shifted to the coordinate position corresponding to the determined random point, so as to obtain a second liquid level block image with the same size as the first liquid level block image but with a different vertical position.
[0053] In this embodiment, by selecting random points as the upper left corner coordinate reference of the second liquid level block image with the left glass tube wall in the target image as a constraint, and reusing the pixel content of the first liquid level block image in combination with the coordinate reference to generate a second liquid level block image with different positions, it is possible to controllably generate liquid level materials with different vertical heights within a regular vertical tube image, ensuring batch synthesis of sample liquid level images.
[0054] In one embodiment, determining random points on the left glass tube wall of the target image includes: determining random range information on the left glass tube wall of the target image based on the height information of the first liquid level block image; wherein the random range information characterizes the range within which random points are allowed to be generated; and determining random points on the left glass tube wall of the target image based on the random range information.
[0055] Specifically, the height information is the spatial dimension representation information corresponding to the vertical pixel span of the first liquid level block image itself. The height information of the first liquid level block image is the same as that of the second liquid level block image. The height information of the first liquid level block image can be used to constrain the vertical boundary interval of the random points. Based on the vertical dimension of the first liquid level block image itself, it can prevent the second liquid level block image from exceeding the vertical imaging boundary of the glass tube after the random points are selected.
[0056] That is, the random range information can be determined based on the height information of the first liquid level block image. The random range information is a vertical pixel value interval marked on the left glass tube wall based on the height information of the first liquid level block image. It limits the effective pixel area that random points can generate, and filters out invalid coordinate intervals that would cause the second liquid level block image to go beyond the glass tube body image. This ensures that all random points generated based on this interval can produce a second liquid level block image that is completely inside the glass tube.
[0057] For example, after extracting the height information corresponding to the first liquid level block image, the coordinates of the endpoint of the bottom longitudinal section of the left glass tube wall can be determined. Based on the endpoint coordinates and height information, the boundary of the random range information can be determined. For instance, the coordinates of the bottom endpoint at the distance from the height information can be used as one boundary of the random range information. Alternatively, the coordinates of the top longitudinal section of the left glass tube wall can be determined, and these coordinates can be used as another boundary of the random range information. The range between these two boundaries constitutes the random range information. Based on the generated random range information, a random point determination operation is then performed.
[0058] In this embodiment, by using the height information of the first liquid level block image to define the effective value range of random points on the left glass tube wall to form random range information, and then generating random points based on the random range information, the coordinate boundary can be pre-constrained by relying on the size of the liquid level block itself, avoiding the second liquid level block image from exceeding the imaging range of the glass tube due to the random point values, reducing the invalid image removal operation after subsequent image synthesis, and improving the computational efficiency and image effectiveness of batch generating sample liquid level images.
[0059] In this embodiment, an initial acquisition image is obtained, which is an image containing a glass tube. The glass tube in the initial acquisition image may be tilted. Based on the initial acquisition image, a target image and a first liquid level block image can be obtained. The target image represents the vertical glass tube image, and the first liquid level block image represents an image block containing liquid levels extracted from the target image. Geometric correction is performed on the initial acquisition image to improve the processing accuracy of subsequent liquid level blocks. Based on the first liquid level block image, a second liquid level block image is generated in the target image. The second liquid level block image is the same size as the first liquid level block image but in a different position, and both contain liquid levels. That is, there are two liquid levels in the target image. Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled so that the target image only contains the liquid level of the second liquid level block, thereby obtaining a sample liquid level image. The liquid level height in the sample liquid level image differs from that in the initially acquired image, thus amplifying the sample liquid level image and improving its generation efficiency. The sample liquid level image can then be used to train a pre-defined model, enabling the model to accurately identify the liquid level height in the image and improving the recognition accuracy.
[0060] Figure 4 This is a flowchart illustrating the method for generating liquid level images, as shown below. Figure 4 As shown, a method for generating a liquid level image according to an embodiment of this application may include: Step 410: Obtain the initial acquisition image. Based on the initial acquisition image, obtain the target image and the first liquid level block image. The initial acquisition image is an image of a glass tube containing liquid. The target image represents the vertical glass tube image. The first liquid level block image represents an image block containing liquid level extracted from the target image. Step 420: Generate a second liquid level block image in the target image based on the first liquid level block image; wherein, the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position; Step 430: Determine the liquid level offset based on the position information of the first liquid level block image and the second liquid level block image in the target image; wherein, the liquid level offset represents the direction of liquid level movement from the first liquid level block image to the second liquid level block image. Step 440: Based on the liquid level offset, the position information of the first liquid level block image in the target image, and the position information of the second liquid level block image in the target image, determine the filling area in the target image, and fill the filling area to obtain the sample liquid level image.
[0061] Steps 410 and 420 have been described in detail above and will not be repeated here. Steps 430 and 440 will be described in detail below.
[0062] In step 430, the position information is the complete spatial coordinate representation data of the corresponding liquid level block image in the target image pixel coordinate system after vertical correction, including the upper and lower boundaries of the liquid level block image, the pixel coordinates corresponding to the center point, etc. The position information can quantitatively record the spatial distribution of the two liquid level block images within the glass tube imaging area, providing the original pixel reference for calculating the liquid level movement amplitude and direction.
[0063] The first and second liquid level block images each have their own positional information. By comparing these two sets of positional information, the liquid level rise or fall can be distinguished, that is, whether the liquid level is rising or falling from the first liquid level block image to the second liquid level block image. If the first liquid level block image is below the second liquid level block image, it indicates that the liquid level is rising; conversely, the liquid level is falling.
[0064] The liquid level offset is a spatial difference parameter calculated based on the positional information of two sets of liquid level block images. It can distinguish whether the liquid level moves upward or downward during the conversion from the first liquid level block image to the second liquid level block image. For example, taking the lower left corner of the target image as the image origin, and including the upper left corner of the liquid level block image in the positional information, the difference between the ordinate value new_y of the upper left corner of the second liquid level block image and the ordinate value y_patch_top of the upper left corner of the first liquid level block image is calculated as the liquid level offset. If offset > 0, it indicates that the liquid level is rising; if offset < 0, it indicates that the liquid level is falling. If the liquid level offset is 0, no processing is performed on the target image.
[0065] In step 440, the filling region is the pixel range within the target image that needs to be filled in the vertical space of the first and second liquid level block images. The filling regions corresponding to different liquid level offsets have different vertical start and end boundaries, and the boundary range of the filling region can be defined by the position information of the two liquid level block images and the liquid level offset.
[0066] In other words, the positional information of the two liquid level block images is compared and calculated to obtain a liquid level offset that can distinguish the direction of liquid level movement. Then, the liquid level offset and the positional information of the two liquid level block images are combined to delineate the filling area within the target image that needs texture restoration. Using the direction of liquid level movement as a precondition for dividing the filling area avoids the texture distortion problem caused by uniform interval filling and provides accurate pixel interval boundaries for subsequent differentiated one-dimensional linear interpolation filling operations.
[0067] For example, when determining the filling region based on the liquid level offset and two sets of position information, the corresponding vertical start and end boundaries can be selected from the first and second liquid level block images according to the movement direction represented by the liquid level offset. The area between the selected vertical start and end boundaries is then used as the filling region. For instance, if the liquid level offset corresponds to a rising liquid level condition, the pixel interval between the center vertical coordinate of the second liquid level block image and the lower vertical coordinate of the first liquid level block image is defined as the filling region; if the liquid level offset corresponds to a falling liquid level condition, the pixel interval between the upper vertical coordinate of the first liquid level block image and the center vertical coordinate of the second liquid level block image is defined as the filling region. After the region is defined, the complete pixel boundary data corresponding to the filling region is output and directly supplied to the subsequent filling processing stage.
[0068] In this embodiment, by comparing the position information of two sets of liquid level block images, the direction of liquid level movement can be distinguished. Then, by combining the liquid level offset with the two sets of position information, the filling area can be delineated. Different filling pixel intervals can be matched according to different physical scenarios of liquid level rise and fall, avoiding texture filling distortion caused by uniform interval division and improving the accuracy of filling area boundary division.
[0069] In one embodiment, determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the position information of the second liquid level block image in the target image includes: determining the coordinates of the center point of the liquid level in the second liquid level block image based on the position information of the second liquid level block image in the target image; determining the horizontal edge where the center point coordinates are located in the target image; and determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located.
[0070] Specifically, the position information of the second liquid level block image in the target image can include the coordinates of the four vertices of the second liquid level block image, as well as the coordinates of the center point of the liquid level in the second liquid level block image. The liquid level is displayed as a downward-curving arc in the image, and the coordinates of the center point are the coordinates of the lowest point of the arc. Alternatively, the vertical upper and lower boundary coordinates of the liquid level block can be read from the complete position information of the second liquid level block image, and the vertically centered pixel can be used as the coordinates of the center point of the liquid surface.
[0071] Determine the tangent line to the center point coordinates. This tangent line is a horizontal straight line, which defines the horizontal edge containing the center point coordinates. The horizontal edge is a horizontal line segment within the target image that is parallel to the horizontal pixel coordinate axis and passes through the center point coordinates. This segment can be used as the pixel boundary for the filling area later.
[0072] The horizontal edge where the center point coordinates are located can be used as one boundary of the filling area. Then, based on the liquid level offset and the position information of the first liquid level block image, the other boundary of the filling area can be determined, thus defining the complete filling area. For example, based on the liquid level movement direction corresponding to the liquid level offset, a certain edge in the first liquid level block image can be selected as the other boundary of the filling area.
[0073] In this embodiment, by extracting the coordinates of the center point of the liquid surface from the position information of the second liquid level block image and generating the corresponding horizontal edge, and combining the liquid level offset with the position information of the first liquid level block image to delineate the filling area, it is possible to accurately distinguish the liquid imaging area and the pipe wall section to be repaired, match the differentiated filling range corresponding to the rise and fall of the liquid level, improve the matching degree between the boundary division of the filling area and the real exposed pipe wall area, and reduce the problem of misalignment and distortion of the pipe wall texture in the synthesized image.
[0074] In one embodiment, determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located includes: if the liquid level offset indicates that the movement direction of the liquid level is upward, then determining the bottom horizontal edge of the first liquid level block image based on the position information of the first liquid level block image in the target image; and determining the region between the bottom horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located as the filling region.
[0075] Specifically, the liquid level offset may indicate that the liquid level is moving upwards or downwards. For the case where the liquid level is moving upwards, the bottom horizontal edge of the first liquid level block image is determined. The bottom horizontal edge is the bottom edge of the rectangle, that is, the bottom edge of the rectangle corresponding to the first liquid level block image is determined.
[0076] The positional information of the first liquid level block image can include the coordinates of the lower left and lower right corners of the rectangle. Based on the coordinates of the lower left and lower right corners, the location of the bottom horizontal edge of the first liquid level block image can be obtained. The horizontal edge where the center point coordinates are located is one boundary of the filled area, and the bottom horizontal edge of the first liquid level block image is the other boundary of the filled area. That is, the area between the bottom horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located is the filled area.
[0077] Figure 5 This is a schematic diagram of the filling area under the condition of rising liquid level. Figure 5 The dashed rectangle in the image represents the first liquid level block image, the solid rectangle represents the second liquid level block image, and the area filled with the liquid texture is the filling area.
[0078] In this embodiment, by extracting the bottom horizontal edge of the first liquid level block image when the liquid level rises, the pixel interval between the bottom horizontal edge and the horizontal edge where the center point coordinates are located is defined as the filling area. This can accurately adapt to the independent repair interval of the liquid level rise scenario, avoid the texture filling misalignment problem caused by sharing the same interval under different rising and falling conditions, and improve the matching accuracy between the filling area and the real blank area of the pipe wall.
[0079] In one embodiment, determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located includes: if the liquid level offset indicates that the movement direction of the liquid level is downward, then determining the top horizontal edge of the first liquid level block image based on the position information of the first liquid level block image in the target image; and determining the region between the top horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located as the filling region.
[0080] Specifically, the liquid level offset may indicate that the liquid level is moving upwards or downwards. For the case where the liquid level is moving downwards, the top horizontal edge of the first liquid level block image is determined. The top horizontal edge is the top edge of the rectangle, that is, the top edge of the rectangle corresponding to the first liquid level block image is determined.
[0081] The positional information of the first liquid level block image can include the coordinates of the top left and top right corners of the rectangle. Based on the coordinates of the top left and top right corners, the position of the top horizontal edge of the first liquid level block image can be obtained. The horizontal edge where the center point coordinates are located is one boundary of the filled area, and the top horizontal edge of the first liquid level block image is the other boundary of the filled area. That is, the area between the top horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located is the filled area.
[0082] Figure 6 This is a schematic diagram of the filling area under the condition of liquid level drop. Figure 6 The dashed rectangle in the image represents the first liquid level block image, the solid rectangle represents the second liquid level block image, and the area filled with air texture is the filled area.
[0083] In this embodiment, by extracting the top horizontal edge of the first liquid level block image when the liquid level is dropping, and defining the pixel interval between the top horizontal edge and the horizontal edge where the center point coordinates are located as the filling area, it is possible to accurately adapt to the independent repair interval of the liquid level dropping scenario, avoid the texture filling misalignment problem caused by sharing the same interval under different lifting and lowering conditions, and improve the matching accuracy between the filling area and the real blank area of the pipe wall.
[0084] In one embodiment, filling the filling area to obtain a sample liquid level image includes: determining the average pixel value of a preset number of pixels above the bottom horizontal edge of the first liquid level block image, as the first pixel average, and determining the average pixel value of a preset number of pixels below the bottom horizontal edge of the first liquid level block image, as the second pixel average; filling the filling area based on the first pixel average and the second pixel average using a preset one-dimensional linear interpolation algorithm to obtain a filled target image; and determining the sample liquid level image based on the filled target image.
[0085] Specifically, for the case where the liquid level moves upward, using the bottom horizontal edge of the first liquid level block image as a reference, the pixel values of all pixels located in a predetermined number of rows above the bottom horizontal edge of the first liquid level block image are determined, and the average value of these pixel values is calculated as the first pixel mean. For example, the pixel mean of the five rows above the bottom horizontal edge of the first liquid level block image can be calculated.
[0086] Using the bottom horizontal edge of the first liquid level block image as a reference, determine the pixel values of all pixels located in a predetermined number of rows below the bottom horizontal edge of the first liquid level block image, and calculate the average of these pixel values as the second pixel mean. For example, the pixel mean of the five rows below the bottom horizontal edge of the first liquid level block image can be calculated.
[0087] The mean value of the first pixel can be used as the upper reference in a one-dimensional linear interpolation algorithm, and the mean value of the second pixel can be used as the lower reference. The upper and lower references are the two endpoints that define the interpolation interval in a one-dimensional linear interpolation algorithm, and will not be explained in detail here.
[0088] One-dimensional linear interpolation is a pixel reconstruction algorithm that performs a smooth transition of pixel grayscale along the vertical dimension of the filled region. It distributes the average values of the first and second pixels to each row of pixels in the filled region according to their vertical position weights, achieving a natural transition of the pipe wall texture. The calculation formula for one-dimensional linear interpolation can be: fill roll =(1 α)×top ref +α×bot ref α∈[0,1]; Among them, fill roll The pixel values to be filled, α is the weight, and top ref For reference only, bot ref For reference below.
[0089] The filled target image is a vertically standardized glass tube image after the one-dimensional linear interpolation texture of the filled region has been laid. Subsequent post-processing can be performed, such as liquid level block edge blending, illumination noise perturbation, and inverse geometric transformation. That is, the final sample liquid level image can be obtained from the filled target image.
[0090] For example, when performing a one-dimensional linear interpolation algorithm to complete the filling process, a gradually varying weight α can be assigned row by row along the vertical direction of the filling area. The weight value changes continuously between two sets of pixel mean values as the vertical position changes. The gray level of each row of pixels is obtained by weighted fusion of the first pixel mean and the second pixel mean. Low-intensity random noise can also be superimposed on the base pixels generated by interpolation to simulate infrared imaging particle noise. After reconstructing all pixels in the filling area, the filled target image is output.
[0091] In this embodiment, two sets of pixel averages are obtained by extracting the upper and lower pipe wall pixels with the bottom horizontal edge of the first liquid level block image as the boundary. Based on the two sets of pixel averages, a one-dimensional linear interpolation algorithm is used to perform gradient filling on the filling area corresponding to the liquid level rise condition to obtain the filled target image. Then, a sample liquid level image is generated from the filled target image. This can reuse the original pipe wall texture of the original image to construct a continuous and natural gradient pipe wall image, avoid the synthesis artifacts caused by blank filling and fixed texture tiling, and improve the consistency between the generated sample and the real infrared imaging of the substation site.
[0092] In one embodiment, filling the filling area to obtain a sample liquid level image includes: determining the average pixel value of a preset number of pixels above the top horizontal edge of the first liquid level block image, which is the third pixel average, and determining the average pixel value of a preset number of pixels below the top horizontal edge of the first liquid level block image, which is the fourth pixel average; filling the filling area based on the third pixel average and the fourth pixel average using a preset one-dimensional linear interpolation algorithm to obtain a filled target image; and determining the sample liquid level image based on the filled target image.
[0093] Specifically, for the case where the liquid level moves downwards, using the top horizontal edge of the first liquid level block image as a reference, the pixel values of all pixels located in a predetermined number of rows above the top horizontal edge of the first liquid level block image are determined, and the average of these pixel values is calculated as the third pixel mean. For example, the pixel mean of the five rows above the top horizontal edge of the first liquid level block image can be calculated.
[0094] Using the top horizontal edge of the first liquid level block image as a reference, determine the pixel values of all pixels located in a predetermined number of rows below the top horizontal edge of the first liquid level block image, and calculate the average of these pixel values as the fourth pixel mean. For example, the pixel mean of the five rows below the top horizontal edge of the first liquid level block image can be calculated.
[0095] The mean value of the third pixel can be used as the upper reference in a one-dimensional linear interpolation algorithm, and the mean value of the fourth pixel can be used as the lower reference. The upper and lower references are the two endpoint values that define the interpolation interval in a one-dimensional linear interpolation algorithm, and will not be explained in detail here.
[0096] The one-dimensional linear interpolation algorithm is a pixel reconstruction operation that performs a smooth transition of pixel grayscale along the vertical dimension of the filled region. It distributes the mean values of the third and fourth pixels to each row of pixels in the filled region according to their vertical position weights, thus achieving a natural transition of the pipe wall texture. The calculation formula for the one-dimensional linear interpolation algorithm is the same as above.
[0097] The filled target image is a vertically standardized glass tube image after the one-dimensional linear interpolation texture of the filled region has been laid. Subsequent post-processing can be performed, such as liquid level block edge blending, illumination noise perturbation, and inverse geometric transformation. That is, the final sample liquid level image can be obtained from the filled target image.
[0098] For example, when performing a one-dimensional linear interpolation algorithm to complete the filling process, a gradually varying weight α can be assigned row by row along the vertical direction of the filling area. The weight value changes continuously between two sets of pixel mean values as the vertical position changes. The gray level of each row of pixels is obtained by weighted fusion of the first pixel mean and the second pixel mean. Low-intensity random noise can also be superimposed on the base pixels generated by interpolation to simulate infrared imaging particle noise. After reconstructing all pixels in the filling area, the filled target image is output.
[0099] In this embodiment, two sets of pixel mean values are obtained by extracting the upper and lower pipe wall pixels with the top horizontal edge of the first liquid level block image as the boundary. Based on the two sets of pixel mean values, a one-dimensional linear interpolation algorithm is used to perform gradient filling on the filling area corresponding to the liquid level drop condition to obtain the filled target image. Then, a sample liquid level image is generated from the filled target image. This can reuse the original pipe wall texture of the original image to construct a continuous and natural gradient pipe wall image, avoid the synthesis artifacts caused by blank filling and fixed texture tiling, and improve the consistency between the generated sample and the real infrared imaging of the substation site.
[0100] In one embodiment, determining a sample liquid level image based on the filled target image includes: determining a transition region based on the height information of the second liquid level block image; wherein the transition region represents the area in the second liquid level block image that needs to be blended with the background of the glass tube; for each row of pixels in the transition region, determining a one-dimensional cosine attenuation mask corresponding to each row of pixels; and, based on the one-dimensional cosine attenuation mask corresponding to each row of pixels, smoothing the transition region in the filled target image based on a preset Alpha fusion algorithm based on bidirectional cosine attenuation weights to obtain the sample liquid level image.
[0101] Specifically, the height information of the second liquid level block image is the same as that of the first liquid level block image, both representing the size corresponding to the vertical pixel span of the image block. Based on the height information of the second liquid level block image, the range of the transition region can be determined. The transition region represents the area in the second liquid level block image that needs to be blended with the background of the glass tube, specifically the vertical pixel intervals near the tube wall background at the top and bottom edges of the second liquid level block image where pixel smoothing fusion needs to be performed. This embodiment limits the fusion operation to a narrow range at the edges of the liquid level block to avoid damaging the liquid texture in the middle of the liquid level area during the fusion operation.
[0102] A height reference value can be preset, and the transition region can be determined based on the height reference value and the height information of the second liquid level block image. For example, based on the height information h of the second liquid level block image, half of the height information, i.e., h / 2, can be determined. h / 2 can be multiplied by a random value within a preset range to obtain a height value to be compared, with the preset range being 0.2 to 0.8. The height reference value and the height value to be compared are compared, and the smaller value is selected as the height of the transition region. Alternatively, a height reference value can be omitted, and the result of multiplying h / 2 by a random value within a preset range can be directly used as the height of the transition region. Based on the height of the transition region, a transition region can be determined from the top and bottom horizontal edges of the second liquid level block image, respectively; that is, two transition regions can be determined, one near the top horizontal edge and one near the bottom horizontal edge.
[0103] In other words, the top horizontal edge of the second liquid level block image is used as one boundary of the transition region, and the corresponding other boundary is found downwards based on the height of the transition region; the bottom horizontal edge of the second liquid level block image is used as one boundary of the transition region, and the corresponding other boundary is found upwards based on the height of the transition region. Figure 7 This is a schematic diagram of the transition region. Figure 7 The black part in the image is the transition area, and the left and right sides of the transition area are the glass tube walls.
[0104] The one-dimensional cosine decay mask is a sequence of weight parameters generated along the vertical pixels of the transition region, with values smoothly varying according to a cosine law. It serves as the pixel weight benchmark for the Alpha fusion algorithm. The mask value near the middle region of the liquid level block is close to 1, while the mask value near the outer edge of the transition region smoothly decays to 0, thereby achieving a smooth transition from the liquid level pixels to the pipe wall texture without hard segmentation lines. Figure 8 This is a schematic diagram illustrating the changes in a one-dimensional cosine attenuation mask. Figure 8 The area between the middle dashed lines is Figure 7 The region between the two transition regions. For the transition region of the top horizontal edge, mask = sin([0, π / 2]), starting from the top horizontal edge, smoothly increases from 0 to 1; for the transition region of the bottom horizontal edge, mask = sin([π / 2, 0]), starting from the bottom horizontal edge, smoothly increases from 0 to 1.
[0105] The Alpha fusion algorithm based on bidirectional cosine attenuation weights is a pixel reconstruction operation rule that uses a one-dimensional cosine attenuation mask to weight and mix the liquid level pixels in the transition region with the background pixels of the pipe wall. By using mask weights to distinguish between the liquid body and the transition edge, the algorithm fully preserves the original texture of the liquid while weakening the stitching marks. That is, the target image after filling is a vertically standardized glass tube image after the one-dimensional linear gradient pipe wall texture of the filled region has been repaired.
[0106] For example, when performing smoothing processing using the Alpha fusion algorithm based on bidirectional cosine decay weights, for each row of pixels in the transition region, the liquid pixels of the second liquid level block image and the background pixels of the pipe wall in the filled target image are weighted and fused using the corresponding row's one-dimensional cosine decay mask. After weighting, the pixel grayscale values are range-limited, and the smoothed pixels are backfilled into the corresponding positions in the filled target image, ultimately obtaining a sample liquid level image with no obvious stitching marks at the edges. The calculation formula for the Alpha fusion algorithm is: blended = patch × mask + bg × (1 mask); Where, blended represents the smoothed pixels, patch represents the liquid pixels in the second liquid level block image, and bg represents the background pixels of the pipe wall.
[0107] In this embodiment, the transition region of the liquid level block edge is defined by the height information of the second liquid level block image. A one-dimensional cosine attenuation mask is generated for each row of pixels in the transition region. An Alpha fusion algorithm based on bidirectional cosine attenuation weight is used to smooth the transition region to obtain a sample liquid level image. This can eliminate the hard segmentation line between the liquid level block and the repair pipe wall while completely preserving the original texture features of the liquid surface, thereby improving the visual realism of the synthesized image and reducing the texture distortion artifacts caused by artificially synthesized images.
[0108] In one implementation, based on the one-dimensional cosine attenuation mask corresponding to each row of pixels, and based on a preset Alpha fusion algorithm with bidirectional cosine attenuation weights, the transition region in the filled target image is smoothed to obtain a sample liquid level image. This includes: based on the one-dimensional cosine attenuation mask corresponding to each row of pixels, and based on a preset Alpha fusion algorithm with bidirectional cosine attenuation weights, the transition region in the filled target image is smoothed to obtain a smoothed image; the smoothed image is then subjected to inverse rotation processing to obtain a sample liquid level image; wherein the tilt angle of the glass tube in the sample liquid level image is the same as the tilt angle of the glass tube in the initial acquired image.
[0109] Specifically, the smoothed image is a vertically standardized glass tube image obtained by performing bidirectional cosine alpha smoothing fusion on the transition region of the filled target image, with no obvious splicing boundary between the liquid level block and the tube wall. The glass tube inside the image still maintains its corrected vertical shape, and the transition texture between the liquid and the tube wall has been naturally smoothed. Only the tilt shape of the tube body differs from the initial image acquired on site.
[0110] The glass tube was only made vertical after the initial image acquisition was rotated. Therefore, the smoothed image can be subjected to a corresponding inverse rotation to put the glass tube back in a tilted state. The inverse rotation is a geometric restoration operation performed based on the inverse transformation matrix stored during the previous image correction. Its function is to undo the rotational deformation caused by the previous vertical correction of the glass tube, restore the vertical glass tube in the smoothed image to the tilted shape of the initial image acquisition, and simultaneously map all pixel coordinates of the tube body and liquid surface to match the actual imaging perspective captured by the substation's on-site camera.
[0111] After obtaining the smoothed image, random brightness enhancement can be applied to simulate various lighting conditions in the field. Random Gaussian noise can also be superimposed to replicate the grainy noise in the camera image, improving the model's robustness to complex disturbances. Finally, inverse rotation processing is performed to obtain the sample liquid level image.
[0112] In this embodiment, the transition region is smoothed by using an Alpha fusion algorithm with a one-dimensional cosine attenuation mask and a two-way cosine attenuation weight to obtain a smoothed image. Then, the smoothed image is subjected to inverse rotation processing to restore the original tilt angle of the glass tube to obtain a sample liquid level image. This allows for the synthesis of a distortion-free liquid level texture within a regular vertical image, and the restoration of the tilt geometry of the tube in the actual on-site shooting. This results in a sample that simultaneously possesses a natural tube wall gradient texture, a soft liquid surface transition effect, and a realistic shooting perspective, significantly reducing the distribution difference between the synthesized image and the actual image at the substation site.
[0113] In this embodiment, the coordinates of the left and right points of the liquid level in the smoothed image can be calculated, that is, the coordinates of the left and right intersection points of the liquid level and the glass tube wall can be determined. Using the pre-stored inverse matrix M_back, the coordinates of the left and right points of the liquid level and the coordinates of the four vertices of the glass tube are all transformed back to the coordinate system of the original tilted image. That is, the entire smoothed image is rotated inversely to restore the original tilt angle, resulting in the final output image. For the final output sample liquid level image, all coordinates can be normalized to generate YOLO (You Only Look Once) format labels, and the image and accompanying label file can be saved for subsequent model training.
[0114] In this embodiment, an initial acquisition image is obtained, which is an image containing a glass tube. The glass tube in the initial acquisition image may be tilted. Based on the initial acquisition image, a target image and a first liquid level block image can be obtained. The target image represents the vertical glass tube image, and the first liquid level block image represents an image block containing liquid levels extracted from the target image. Geometric correction is performed on the initial acquisition image to improve the processing accuracy of subsequent liquid level blocks. Based on the first liquid level block image, a second liquid level block image is generated in the target image. The second liquid level block image is the same size as the first liquid level block image but in a different position, and both contain liquid levels. That is, there are two liquid levels in the target image. Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled so that the target image only contains the liquid level of the second liquid level block, thereby obtaining a sample liquid level image. The liquid level height in the sample liquid level image differs from that in the initially acquired image, thus amplifying the sample liquid level image and improving its generation efficiency. The sample liquid level image can then be used to train a pre-defined model, enabling the model to accurately identify the liquid level height in the image and improving the recognition accuracy.
[0115] Figure 9 This is a flowchart illustrating the method for generating liquid level images, as shown below. Figure 9 As shown, a method for generating a liquid level image according to an embodiment of this application may include: Step 910: Obtain the initial acquisition image, and rotate the initial acquisition image to obtain the vertically corrected image; Step 920: Based on the vertically corrected image, obtain the target image and the first liquid level block image; Step 930: Generate a second liquid level block image in the target image based on the first liquid level block image; wherein, the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position; Step 940: Based on the position information of the first liquid level block image and the second liquid level block image in the target image, determine the filling region in the target image and fill the filling region to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a different liquid level height than the initially acquired image, and the sample liquid level image is used to train the preset model, and the preset model is used to identify the liquid level height in the image.
[0116] Steps 930 and 940 have been described in detail above and will not be repeated here. Steps 910 and 920 will be described in detail below.
[0117] In step 910, the initial acquired image is the original image of the tilted glass tube and the liquid inside, acquired by the substation's on-site imaging equipment. The initial acquired image shows the actual lighting characteristics, tube wall texture, imaging noise, and tilt deformation characteristics of the glass tube. To facilitate subsequent image processing, the initial acquired image can be rotated to bring the glass tube into a vertical position, resulting in a vertically corrected image. The vertically corrected image is a standardized image obtained after the initial acquired image has been rotated and corrected, ensuring the glass tube's central axis is vertical. This eliminates the spatial coordinate deviation and imaging deformation caused by the tilt of the glass tube in the initial acquired image. It unifies the spatial reference for subsequent liquid level calculations, filling region division, and texture interpolation operations, simplifies various pixel calculations and coordinate transformation logic, and reduces calculation errors during image synthesis.
[0118] In this embodiment, the rotation processing involves a geometric transformation operation that performs inverse angle correction on the entire image based on the tilt angle of the glass tube in the initial acquired image. For example, when performing the rotation processing, the annotation information corresponding to the initial acquired image can be parsed first, the coordinates of the glass tube's contour vertices can be extracted to calculate the overall tilt angle of the glass tube, and an inverse rotation transformation matrix M can be generated based on the tilt angle. The initial acquired image is then rotated as a whole according to the transformation matrix M, and the coordinates of the glass tube's annotation points and the liquid level key points are simultaneously transformed accordingly to obtain a vertically corrected image free from tilt distortion. The annotation information corresponding to the initial acquired image can be JSON annotation, which may include information about the four vertices of the glass tube and the two key points of the left and right liquid levels. This embodiment does not specifically limit the calculation method of the transformation matrix M.
[0119] In step 920, the target image can be the vertically corrected image itself, or it can be a standardized image of the glass tube obtained after processing the vertically corrected image, where the glass tube is in a vertical position. For example, the glass tube in the vertically corrected image can be cropped to obtain a target image containing only the glass tube and without the surrounding environmental background.
[0120] The first liquid level block image can be a local image block containing the original liquid level features, extracted from a vertically corrected image or a target image. For example, a rectangle of a preset size can be cropped from the vertically corrected image, containing the complete liquid level line, and this rectangle can be used as the first liquid level block image.
[0121] For example, when acquiring the target image and the first liquid level block image based on the vertically corrected image, the target image can be obtained by cropping an image containing only the glass tube region based on the outline boundary of the glass tube in the vertically corrected image. Then, based on the boundary range of the original liquid level inside the target image, an image region containing the complete liquid surface and the surrounding local tube wall is extracted to generate the first liquid level block image for subsequent sample synthesis.
[0122] In this embodiment, a vertically corrected image is obtained by rotating the initial acquired image. Then, the target image and the first liquid level block image are extracted based on the vertically corrected image. This can eliminate the computational deviation caused by the tilt distortion of the glass tube in the original image, unify the spatial reference for subsequent image processing, accurately extract real liquid level texture materials, and provide a regular and reliable image foundation for the subsequent automated synthesis of full-range liquid level samples.
[0123] In one embodiment, rotating the initial acquired image to obtain a vertically corrected image includes: determining the coordinate information of the four vertices of the glass tube from the initial acquired image; determining the tilt angle of the glass tube in the initial acquired image based on the coordinate information of the four vertices of the glass tube in the initial acquired image; and rotating the initial acquired image based on the tilt angle to obtain the vertically corrected image.
[0124] Specifically, the complete pixel coordinate data corresponding to the four corner points of the outer contour of the glass tube are obtained from the pixel coordinate system of the initially acquired image, serving as the coordinate information of the four vertices of the glass tube. Based on the coordinate information of these four vertices, the tilt angle of the glass tube in the initially acquired image can be calculated.
[0125] For example, a contour detection algorithm can be used to identify the continuous outer boundary of the glass tube in the initial acquired image. The four corner extreme points with the largest vertical span can be selected along the outer boundary contour. The horizontal and vertical pixel values corresponding to the four points are recorded to form complete coordinate information, thereby obtaining the coordinate information of the four vertices.
[0126] The tilt angle is the angle formed between the longitudinal edge of the glass tube and the vertical coordinate axis of the image. Based on the tilt angle, a reverse rotation transformation rule, or transformation matrix M, can be generated to counteract the deflection deformation of the glass tube in the initial acquired image, thus adjusting the tilted glass tube to a vertical position. In other words, based on the tilt angle, the initial acquired image can be rotated to obtain a vertically corrected image.
[0127] For example, when performing rotation processing based on the tilt angle, a reverse rotation transformation matrix M can be generated based on the tilt angle. All pixel positions in the initially acquired image are synchronously substituted into the transformation matrix to complete coordinate remapping. Edge filling compensation is performed on pixels that exceed the original image boundary after mapping. After all pixels are mapped, a vertically corrected image with the central axis of the glass tube kept vertical is output.
[0128] In this embodiment, the tilt angle of the glass tube is calculated by extracting the coordinate information of the four vertices of the glass tube in the initial acquisition image. Based on the tilt angle, the initial acquisition image is rotated in reverse to obtain a vertically corrected image. This method can improve the accuracy of tilt angle calculation by relying on the complete contour of the four corners of the tube body, reduce the probability of residual slight deflection of the glass tube after correction, and provide a low-error standardized vertical image base for the accurate extraction of subsequent target images and first liquid level block images.
[0129] In one embodiment, determining the tilt angle of the glass tube in the initial acquisition image based on the coordinate information of the four vertices of the glass tube in the initial acquisition image includes: determining the axis vector of the glass tube in the initial acquisition image based on the coordinate information of the four vertices of the glass tube in the initial acquisition image; and determining the angle between the direction of the axis vector and the vertical direction as the tilt angle of the glass tube in the initial acquisition image.
[0130] Specifically, the axis vector represents the central axis of the glass tube. It is a spatial vector representing the overall longitudinal extension trend of the glass tube and can accurately reflect the overall tilt direction of the glass tube within the image frame. The axis vector of the glass tube in the initial acquired image can be determined based on the coordinates of the four vertices of the glass tube. For example, the coordinates of the center points of two vertices on the upper surface of the glass tube and the center points of two vertices on the lower surface of the glass tube can be calculated; the line connecting these two center points is the central axis of the glass tube. That is, the vector of the line connecting these two center points is the axis vector.
[0131] The vertical direction is a fixed vertical reference direction in the image pixel coordinate system. The vertical direction forms an angle with the axis vector of the glass tube, and this angle is the tilt angle of the glass tube. Figure 10 This is a schematic diagram of the initial image acquisition. Figure 10 In this context, θ represents the tilt angle, p1, p2, p3, and p4 are the four vertices of the glass tube, Level_L is the left intersection point of the liquid level, and Level_R is the right intersection point of the liquid level.
[0132] In this embodiment, the axis vector of the glass tube is obtained by fitting the coordinate information of the four vertices of the glass tube, and the tilt angle of the glass tube is obtained by calculating the angle between the axis vector and the vertical direction. The tilt state of the glass tube is accurately determined, reducing the angle calculation error caused by local imaging interference. This provides high-precision angle parameters for the rotation correction of the initially acquired image, effectively improving the regularity and standardization of the vertically corrected image.
[0133] In one embodiment, obtaining a target image and a first liquid level block image based on a vertically corrected image includes: cropping the glass tube in the vertically corrected image based on the coordinate information of the four vertices of the glass tube in the vertically corrected image to obtain a target image; and cropping the liquid level in the target image based on a preset image block size to obtain a first liquid level block image.
[0134] Specifically, the vertically calibrated image is a standardized image of the glass tube after the initial acquired image has undergone reverse rotation correction, ensuring the entire tube is vertically aligned. The coordinates of the four vertices of the glass tube in the vertically calibrated image are determined. Based on these coordinates, a partial view of the glass tube is cropped and used as the target image. The effective imaging area of the glass tube is precisely extracted from the complete vertically calibrated image, and irrelevant background interference is removed, ensuring that the generated target image retains only the effective monitoring area.
[0135] After obtaining the target image, the first liquid level block image is extracted from the target image. The image size and shape of the first liquid level block image are preset, and the first liquid level block image of the preset shape is obtained based on the image size and the position of the liquid level in the target image.
[0136] For example, a fixed-size cropping region can be defined centered on the original liquid surface position in the target image according to a preset image block size. The target image can then be locally cropped to crop an image region containing complete liquid surface boundary features and upper and lower local pipe walls, generating a first liquid level block image with uniform size and complete features.
[0137] In this embodiment, a precise target image is obtained by extracting the coordinate information of the four vertices of the glass tube in the vertically corrected image. Then, the liquid level area is extracted according to the preset image block size to obtain the first liquid level block image. This can gradually purify the effective image area, standardize the liquid level material size, effectively eliminate background interference, reduce the amount of calculation, and ensure the accuracy and stability of subsequent liquid level offset calculation, filling area division and texture filling processing.
[0138] In this embodiment, an initial acquisition image is obtained, which is an image containing a glass tube. The glass tube in the initial acquisition image may be tilted. Based on the initial acquisition image, a target image and a first liquid level block image can be obtained. The target image represents the vertical glass tube image, and the first liquid level block image represents an image block containing liquid levels extracted from the target image. Geometric correction is performed on the initial acquisition image to improve the processing accuracy of subsequent liquid level blocks. Based on the first liquid level block image, a second liquid level block image is generated in the target image. The second liquid level block image is the same size as the first liquid level block image but in a different position, and both contain liquid levels. That is, there are two liquid levels in the target image. Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled so that the target image only contains the liquid level of the second liquid level block, thereby obtaining a sample liquid level image. The liquid level height in the sample liquid level image differs from that in the initially acquired image, thus amplifying the sample liquid level image and improving its generation efficiency. The sample liquid level image can then be used to train a pre-defined model, enabling the model to accurately identify the liquid level height in the image and improving the recognition accuracy.
[0139] It is understood that although the steps in the above flowcharts are shown sequentially according to the arrows, these steps are not necessarily executed in the order indicated by the arrows. Unless explicitly stated in this embodiment, there is no strict order restriction on the execution of these steps, and they can be executed in other orders. Moreover, at least some steps in the above flowcharts may include multiple steps or multiple stages. These steps or stages are not necessarily completed at the same time, but can be executed at different times. The execution order of these steps or stages is not necessarily sequential, but can be performed alternately or in turn with other steps or at least some of the steps or stages in other steps.
[0140] It should be noted that in various specific embodiments of this application, when processing is required based on data related to the characteristics of the target object, such as target object attribute information or a set of attribute information, the permission or consent of the target object will be obtained first. Furthermore, the collection, use, and processing of this data will comply with relevant laws, regulations, and standards. In addition, when embodiments of this application require obtaining target object attribute information, separate permission or consent from the target object will be obtained through pop-ups or redirection to a confirmation page. Only after obtaining the target object's separate permission or consent will the necessary target object-related data for the normal operation of the embodiments of this application be obtained.
[0141] Description of apparatus and devices in embodiments of this application Reference Figure 11 , Figure 11 This is a schematic diagram of the structure of the liquid level image generation apparatus 1100 provided in an embodiment of this application. The liquid level image generation apparatus 1100 includes: The image acquisition module 1101 is used to acquire an initial acquisition image and obtain a target image and a first liquid level block image based on the initial acquisition image; wherein, the initial acquisition image is an image of a glass tube containing liquid, the target image represents the vertical glass tube image, and the first liquid level block image represents an image block containing liquid level extracted from the target image; The image block generation module 1102 is used to generate a second liquid level block image in the target image based on the first liquid level block image; wherein, the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position; The sample generation module 1103 is used to determine the filling region in the target image based on the position information of the first liquid level block image and the position information of the second liquid level block image in the target image, and to fill the filling region to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a liquid level height different from that in the initial acquisition image, and the sample liquid level image is used to train a preset model, and the preset model is used to identify the liquid level height in the image.
[0142] In one example, the image patch generation module 1102 includes: The random point determination unit is used to determine random points on the left side of the glass tube wall of the target image and to determine the random points as the coordinates of the upper left corner of the second liquid level block image; The liquid level block generation unit is used to generate a second liquid level block image based on the coordinates of the upper left corner of the first liquid level block image and the second liquid level block image.
[0143] In one example, the random point determination unit is specifically used for: Based on the height information of the first liquid level block image, the random range information on the left glass tube wall of the target image is determined; wherein, the random range information represents the range within which random points can be generated. Based on the random range information, random points are determined on the left side of the glass tube wall of the target image.
[0144] In one example, the sample generation module 1103 includes: The offset determination unit is used to determine the liquid level offset based on the position information of the first liquid level block image and the position information of the second liquid level block image in the target image; wherein, the liquid level offset represents the direction of liquid level movement from the first liquid level block image to the second liquid level block image. The region determination unit is used to determine the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the position information of the second liquid level block image in the target image.
[0145] In one example, the region-defining unit is specifically used for: Based on the position information of the second liquid level block image in the target image, determine the coordinates of the center point of the liquid level in the second liquid level block image; Determine the horizontal edge containing the center point coordinates in the target image; The filling area in the target image is determined based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located.
[0146] In one example, the region-defining unit is specifically used for: If the liquid level offset indicates that the liquid level is moving upward, then the bottom horizontal edge of the first liquid level block image is determined based on the position information of the first liquid level block image in the target image. The area between the bottom horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located is defined as the filling area.
[0147] In one example, the region-defining unit is specifically used for: If the liquid level offset indicates that the liquid level is moving downwards, then the top horizontal edge of the first liquid level block image is determined based on the position information of the first liquid level block image in the target image. The area between the top horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located is defined as the filling area.
[0148] In one example, the sample generation module 1103 is specifically used for: The average pixel value of the pixels in a preset number of rows above the bottom horizontal edge of the first liquid level block image is determined as the first average pixel value, and the average pixel value of the pixels in a preset number of rows below the bottom horizontal edge of the first liquid level block image is determined as the second average pixel value. Based on the average value of the first pixel and the average value of the second pixel, the filling region is filled using a preset one-dimensional linear interpolation algorithm to obtain the filled target image. Based on the filled target image, determine the sample liquid level image.
[0149] In one example, the sample generation module 1103 is specifically used for: The average pixel value of the pixels in a preset number of rows above the top horizontal edge of the first liquid level block image is determined as the third average pixel value, and the average pixel value of the pixels in a preset number of rows below the top horizontal edge of the first liquid level block image is determined as the fourth average pixel value. Based on the mean values of the third and fourth pixels, the filling region is filled using a preset one-dimensional linear interpolation algorithm to obtain the filled target image. Based on the filled target image, determine the sample liquid level image.
[0150] In one example, the sample generation module 1103 is specifically used for: The transition region is determined based on the height information of the second liquid level block image; wherein, the transition region represents the area in the second liquid level block image that needs to be blended with the background of the glass tube. For each row of pixels in the transition region, determine the one-dimensional cosine decay mask corresponding to each row of pixels; Based on the one-dimensional cosine decay mask corresponding to each row of pixels, and using a preset Alpha fusion algorithm based on bidirectional cosine decay weights, the transition region in the filled target image is smoothed to obtain the sample liquid level image.
[0151] In one example, the sample generation module 1103 is specifically used for: Based on the one-dimensional cosine decay mask corresponding to each row of pixels, and using the preset Alpha fusion algorithm based on bidirectional cosine decay weights, the transition region in the filled target image is smoothed to obtain the smoothed image. The smoothed image is then rotated inversely to obtain the sample liquid level image; the tilt angle of the glass tube in the sample liquid level image is the same as the tilt angle of the glass tube in the initial acquired image.
[0152] In one example, the image acquisition module 1101 includes: The image correction unit is used to rotate the initially acquired image to obtain a vertically corrected image. The image determination unit is used to obtain the target image and the first liquid level block image based on the vertically corrected image.
[0153] In one example, the image correction unit is specifically used for: Determine the coordinates of the four vertices of the glass tube from the initial acquired image; Based on the coordinate information of the four vertices of the glass tube in the initial acquired image, determine the tilt angle of the glass tube in the initial acquired image. Based on the tilt angle, the initially acquired image is rotated to obtain a vertically corrected image.
[0154] In one example, the image correction unit is specifically used for: Based on the coordinate information of the four vertices of the glass tube in the initial acquired image, determine the axis vector of the glass tube in the initial acquired image; Determine the angle between the direction of the axis vector and the vertical direction, which is the tilt angle of the glass tube in the initial acquired image.
[0155] In one example, the image determination unit is specifically used for: Based on the coordinate information of the four vertices of the glass tube in the vertically corrected image, the glass tube in the vertically corrected image is cropped to obtain the target image; Based on the preset image block size, the liquid level in the target image is cropped to obtain the first liquid level block image.
[0156] It should be noted that the information interaction and execution process between the above-mentioned devices / units are based on the same concept as the method embodiments of this application. For details on their specific functions and technical effects, please refer to the method embodiments section, and they will not be repeated here.
[0157] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the above-described division of functional units and modules is merely an example. In practical applications, the above functions can be assigned to different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiments can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit. Furthermore, the specific names of the functional units and modules are only for easy differentiation and are not intended to limit the scope of protection of this application. The specific working process of the units and modules in the above system can be referred to the corresponding process in the foregoing method embodiments, and will not be repeated here.
[0158] Figure 12 This is a schematic diagram of the structure of an electronic device provided in an embodiment of this application. Figure 12 As shown, the electronic device 1200 of this embodiment includes: at least one processor 1201 ( Figure 12 (Only one is shown in the diagram), memory 1202, and computer program 1203 stored in the memory 1202 and executable on the at least one processor 1201, wherein the processor 1201 executes the computer program 1203 to implement the steps in any of the above embodiments of the method for generating liquid level images.
[0159] Electronic device 1200 can be a computing device such as a desktop computer, laptop, handheld computer, or cloud server. This electronic device may include, but is not limited to, a processor 1201 and a memory 1202. Those skilled in the art will understand that... Figure 12This is merely an example of electronic device 1200 and does not constitute a limitation on electronic device 1200. It may include more or fewer components than shown, or combine certain components, or different components, such as input / output devices, network access devices, etc.
[0160] The processor 1201 may be a Central Processing Unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor.
[0161] In some embodiments, the memory 1202 may be an internal storage unit of the electronic device 1200, such as a hard disk or memory of the electronic device 1200. In other embodiments, the memory 1202 may be an external storage device of the electronic device 1200, such as a plug-in hard disk, smart media card (SMC), secure digital (SD) card, flash card, etc., equipped on the electronic device 1200. Furthermore, the memory 1202 may include both internal and external storage units of the electronic device 1200. The memory 1202 is used to store operating systems, applications, bootloaders, data, and other programs, such as the program code of computer programs. The memory 1202 can also be used to temporarily store data that has been output or will be output.
[0162] This application also provides an electronic device, which includes: at least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor executes the computer program to implement the steps in any of the above method embodiments.
[0163] This application also provides a computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps described in the various method embodiments above.
[0164] This application provides a computer program product that, when run on a mobile terminal, enables the mobile terminal to implement the steps described in the above-described method embodiments.
[0165] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, all or part of the processes in the methods of the above embodiments of this application can be implemented by a computer program instructing related hardware. The computer program can be stored in a computer-readable storage medium, and when executed by a processor, it can implement the steps of the various method embodiments described above. The computer program includes computer program code, which can be in the form of source code, object code, executable files, or certain intermediate forms. The computer-readable medium can include at least: any entity or device capable of carrying the computer program code to a photographic device / terminal device, a recording medium, a computer memory, a read-only memory (ROM), a random access memory (RAM), an electrical carrier signal, a telecommunication signal, and a software distribution medium. Examples include USB flash drives, portable hard drives, magnetic disks, or optical disks. In some jurisdictions, according to legislation and patent practice, computer-readable media cannot be electrical carrier signals or telecommunication signals.
[0166] In the above embodiments, the descriptions of each embodiment have different focuses. For parts that are not described in detail or recorded in a certain embodiment, please refer to the relevant descriptions of other embodiments.
[0167] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this application.
[0168] In the embodiments provided in this application, it should be understood that the disclosed apparatus / network devices and methods can be implemented in other ways. For example, the apparatus / network device embodiments described above are merely illustrative. For instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between devices or units may be electrical, mechanical, or other forms.
[0169] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0170] The above-described embodiments are only used to illustrate the technical solutions of this application, and are not intended to limit them. Although this application has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that modifications can still be made to the technical solutions described in the foregoing embodiments, or equivalent substitutions can be made to some of the technical features. Such modifications or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of this application, and should all be included within the protection scope of this application.
Claims
1. A method for generating a liquid level image, characterized in that, include: An initial acquisition image is obtained, and a target image and a first liquid level block image are obtained based on the initial acquisition image; wherein, the initial acquisition image is an image containing a glass tube containing liquid, the target image represents a vertical glass tube image, and the first liquid level block image represents an image block containing liquid level extracted from the target image; Based on the first liquid level block image, a second liquid level block image is generated in the target image; wherein, the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position; Based on the position information of the first liquid level block image and the second liquid level block image in the target image, a filling region in the target image is determined, and the filling region is filled to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a liquid level height different from that in the initial acquisition image, and the sample liquid level image is used to train a preset model, and the preset model is used to identify the liquid level height in the image; The step of generating a second liquid level block image in the target image based on the first liquid level block image includes: A random point is determined on the left side of the glass tube wall of the target image, and the random point is determined as the upper left corner coordinate point of the second liquid level block image; The second liquid level block image is generated based on the coordinates of the upper left corner of the first liquid level block image and the second liquid level block image. The step of determining the filling region in the target image based on the position information of the first liquid level block image and the position information of the second liquid level block image in the target image includes: Based on the position information of the first liquid level block image in the target image and the position information of the second liquid level block image in the target image, the liquid level offset is determined; wherein, the liquid level offset represents the direction of liquid level movement from the first liquid level block image to the second liquid level block image; The filling area in the target image is determined based on the liquid level offset, the position information of the first liquid level block image in the target image, and the position information of the second liquid level block image in the target image.
2. The method according to claim 1, characterized in that, Determining random points on the left side of the glass tube wall of the target image includes: Based on the height information of the first liquid level block image, the random range information on the left glass tube wall of the target image is determined; wherein, the random range information represents the range within which random points can be generated; Based on the random range information, a random point is determined on the left side of the glass tube wall of the target image.
3. The method according to claim 1, characterized in that, The step of determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the position information of the second liquid level block image in the target image includes: Based on the position information of the second liquid level block image in the target image, determine the coordinates of the center point of the liquid level in the second liquid level block image; Determine the horizontal edge containing the coordinates of the center point in the target image; The filling area in the target image is determined based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located.
4. The method according to claim 3, characterized in that, The step of determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located includes: If the liquid level offset indicates that the liquid level is moving upward, then the bottom horizontal edge of the first liquid level block image is determined according to the position information of the first liquid level block image in the target image. The area between the bottom horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located is determined as the filling area.
5. The method according to claim 3, characterized in that, The step of determining the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the horizontal edge where the center point coordinates are located includes: If the liquid level offset indicates that the liquid level is moving downwards, then the top horizontal edge of the first liquid level block image is determined according to the position information of the first liquid level block image in the target image. The area between the top horizontal edge of the first liquid level block image and the horizontal edge where the center point coordinates are located is defined as the filling area.
6. The method according to claim 4, characterized in that, The process of filling the filling area to obtain a sample liquid level image includes: The average pixel value of the pixels in a preset number of rows above the bottom horizontal edge of the first liquid level block image is determined as the first average pixel value, and the average pixel value of the pixels in a preset number of rows below the bottom horizontal edge of the first liquid level block image is determined as the second average pixel value. Based on the first pixel mean and the second pixel mean, the filling region is filled using a preset one-dimensional linear interpolation algorithm to obtain the filled target image; The sample liquid level image is determined based on the filled target image.
7. The method according to claim 5, characterized in that, The process of filling the filling area to obtain a sample liquid level image includes: The average pixel value of the pixels in a preset number of rows above the top horizontal edge of the first liquid level block image is determined as the third average pixel value, and the average pixel value of the pixels in a preset number of rows below the top horizontal edge of the first liquid level block image is determined as the fourth average pixel value. Based on the average value of the third pixel and the average value of the fourth pixel, the filling region is filled using a preset one-dimensional linear interpolation algorithm to obtain the filled target image. The sample liquid level image is determined based on the filled target image.
8. The method according to claim 6 or 7, characterized in that, Determining the sample liquid level image based on the filled target image includes: Based on the height information of the second liquid level block image, a transition region is determined; wherein, the transition region represents the area in the second liquid level block image that needs to be blended with the background of the glass tube; For each row of pixels in the transition region, determine the one-dimensional cosine attenuation mask corresponding to each row of pixels; Based on the one-dimensional cosine decay mask corresponding to each row of pixels, and using a preset Alpha fusion algorithm based on bidirectional cosine decay weights, the transition region in the filled target image is smoothed to obtain the sample liquid level image.
9. The method according to claim 8, characterized in that, The step of smoothing the transition region in the filled target image based on the one-dimensional cosine attenuation mask corresponding to each row of pixels, using a preset Alpha fusion algorithm based on bidirectional cosine attenuation weights, to obtain the sample liquid level image includes: Based on the one-dimensional cosine decay mask corresponding to each row of pixels, and based on the preset Alpha fusion algorithm based on bidirectional cosine decay weights, the transition region in the filled target image is smoothed to obtain a smoothed image. The smoothed image is then subjected to inverse rotation processing to obtain a sample liquid level image; wherein the tilt angle of the glass tube in the sample liquid level image is the same as the tilt angle of the glass tube in the initial acquired image.
10. The method according to claim 1, characterized in that, The step of obtaining the target image and the first liquid level block image based on the initial acquired image includes: The initial acquired image is rotated to obtain a vertically corrected image; Based on the vertically corrected image, the target image and the first liquid level block image are obtained.
11. The method according to claim 10, characterized in that, The step of rotating the initially acquired image to obtain a vertically corrected image includes: The coordinate information of the four vertices of the glass tube is determined from the initial acquired image; Based on the coordinate information of the four vertices of the glass tube in the initial acquired image, the tilt angle of the glass tube in the initial acquired image is determined. Based on the tilt angle, the initial acquired image is rotated to obtain the vertically corrected image.
12. The method according to claim 11, characterized in that, Determining the tilt angle of the glass tube in the initial acquired image based on the coordinate information of the four vertices of the glass tube in the initial acquired image includes: Based on the coordinate information of the four vertices of the glass tube in the initial acquired image, determine the axis vector of the glass tube in the initial acquired image; The angle between the direction of the axis vector and the vertical direction is determined as the tilt angle of the glass tube in the initial acquired image.
13. The method according to claim 10, characterized in that, The step of obtaining the target image and the first liquid level block image based on the vertically corrected image includes: Based on the coordinate information of the four vertices of the glass tube in the vertically corrected image, the glass tube in the vertically corrected image is cropped to obtain the target image; Based on a preset image block size, the liquid level in the target image is cropped to obtain the first liquid level block image.
14. A device for generating a liquid level image, characterized in that, include: An image acquisition module is used to acquire an initial image and obtain a target image and a first liquid level block image based on the initial image; wherein, the initial image is an image of a glass tube containing liquid, the target image represents a vertical glass tube image, and the first liquid level block image represents an image block containing liquid level extracted from the target image; An image block generation module is used to generate a second liquid level block image in the target image based on the first liquid level block image; wherein the second liquid level block image represents an image block containing liquid level that is the same size as the first liquid level block image but in a different position. A sample generation module is used to determine a filling region in the target image based on the position information of the first liquid level block image and the position information of the second liquid level block image in the target image, and to fill the filling region to obtain a sample liquid level image; wherein, the sample liquid level image represents an image with a liquid level height different from that in the initially acquired image, and the sample liquid level image is used to train a preset model, and the preset model is used to identify the liquid level height in the image; The image patch generation module includes: The random point determination unit is used to determine random points on the left side of the glass tube wall of the target image and to determine the random points as the coordinates of the upper left corner of the second liquid level block image; The liquid level block generation unit is used to generate a second liquid level block image based on the coordinates of the upper left corner of the first liquid level block image and the second liquid level block image. The sample generation module includes: The offset determination unit is used to determine the liquid level offset based on the position information of the first liquid level block image and the position information of the second liquid level block image in the target image; wherein, the liquid level offset represents the direction of liquid level movement from the first liquid level block image to the second liquid level block image. The region determination unit is used to determine the filling region in the target image based on the liquid level offset, the position information of the first liquid level block image in the target image, and the position information of the second liquid level block image in the target image.
15. An electronic device, characterized in that, include: At least one processor, a memory, and a computer program stored in the memory and executable on the at least one processor, wherein the processor, when executing the computer program, implements the method as claimed in any one of claims 1 to 13.
16. A computer-readable storage medium storing a computer program, characterized in that, When the computer program is executed by a processor, it implements the method as described in any one of claims 1 to 13.
17. A computer program product, comprising a computer program, characterized in that, When the computer program is executed by a processor, it implements the method described in any one of claims 1 to 13.
Citation Information
Patent Citations
Liquid level meter dial plate image recognition method based on deep learning
CN121789191A
Model training method, scene recognition method, and related device
US20240169687A1
