A method and system for identifying dynamic water level in ship cabin

By using a camera in the ship compartment to acquire liquid level images, perform image preprocessing and recognition, and using the PP-YOLO model to achieve liquid level recognition, solving the problems of high cost of liquid level measurement and inaccurate measurement of dynamic changes in the prior art, and achieving high accuracy and low cost liquid level recognition.

CN114066837BActive Publication Date: 2025-04-08NO 719 RES INST CHINA SHIPBUILDING IND
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111331109.X
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-11
Publication Date
2025-04-08
Estimated Expiration
2041-11-11

AI Technical Summary

Technical Problem

In the prior art, the liquid level measurement cost is high and it is impossible to effectively measure the accurate value of the liquid level when it changes dynamically.

Method used

A dynamic water level recognition method for ship cabins is adopted. By obtaining the liquid level images taken by the cabin camera, image preprocessing such as threshold segmentation, smoothing processing and noise removal are performed, and finally the liquid level recognition is used using the pre-trained PP-YOLO model.

Benefits of technology

It achieves a high accuracy of liquid level recognition, with a relative error of 1.33%, an accuracy rate of 98.67%, and reduces the system construction cost.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114066837B_ABST
    Figure CN114066837B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a method and system for identifying the dynamic water level in a ship cabin. First, the acquired image is preprocessed. After image graying, image segmentation, and morphological processing, the dynamic liquid level is identified based on the PP‑YOLO v2 algorithm. The water tank is simulated as a cabin for experiment to obtain the liquid level detection result. The relative error of the liquid level result measured by the algorithm is 1.33%, and the accuracy rate reaches 98.67%, which has strong reliability. The automation level of ship cabin liquid level identification is improved, and it has strong application value.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The embodiments of the present invention relate to the technical field of ship safety monitoring, and in particular to a method and system for identifying dynamic water levels in ship cabins. Background Art

[0002] In order to ensure the safety of ships on the sea and avoid accidents such as shipwrecks, it is necessary to detect the water level in the cabin in real time to prevent it from exceeding the warning line. The current methods for measuring liquid levels mainly include direct measurement using floats, pressure, radar, ultrasound and other level gauges, and image recognition and measurement of liquid levels based on machine vision. Due to the complex sea environment, the measurement method of the level gauge is limited by the cabin equipment, environment and cost, which is inferior to the image processing method. The liquid level detection technology based on machine vision can obtain images through the cabin camera, convert the liquid level to be detected into a signal, and then convert and calculate it through image processing technology to obtain the actual liquid level. This technology has been applied in many fields due to its small size, wide range and non-contact characteristics.

[0003] Scholars at home and abroad have applied image processing technology to liquid level measurement and conducted many explorations. For example, according to the vertical coordinates of the laser line composed of laser points affected by the liquid surface fluctuation in the liquid level measurement image, a voting method is adopted to estimate the actual coordinates of the laser line, thereby obtaining the liquid level measurement result. Although this method can avoid the influence of noise pulses, it is easy to have large errors in the face of dynamic changes in the liquid level. A liquid level measurement system based on a secondary confirmation recognition algorithm is also proposed in the prior art. This method uses template matching to find a number from the image, and then separates the digital image from the regular image to complete digital recognition. However, it needs to cooperate with the tracking control system, and the application scope is not wide enough. A single-camera machine vision system is also designed in the prior art for liquid level measurement. The software realizes the liquid level detection of the standard container through image preprocessing, detection of scale lines and liquid levels, correction of lens distortion and parallax effects, and final unit conversion. The system has high construction cost and cannot solve the problem of dynamic changes in liquid level. Summary of the invention

[0004] The embodiment of the present invention provides a method and system for identifying the dynamic water level of a ship cabin, so as to solve the problems in the prior art that the liquid level measurement cost is high and the liquid level cannot be measured when it changes dynamically.

[0005] In order to solve the above technical problems, in a first aspect, an embodiment of the present invention provides a method for identifying a dynamic water level in a ship cabin, comprising:

[0006] Step S1, obtaining a liquid level image captured by a cabin camera, and intercepting a continuous frame image with fluctuation;

[0007] Step S2, performing threshold segmentation on the continuous frame images based on the maximum inter-class variance method (OTSU) to obtain a dynamic liquid level image; performing smoothing processing on the dynamic liquid level image based on a median filtering method, and performing corrosion and expansion processing to remove noise points in the dynamic liquid level image;

[0008] Step S3: input the dynamic liquid level image into a pre-trained PP-YOLO model, and obtain a liquid level recognition result based on the PP-YOLO model.

[0009] As a preferred embodiment, it also includes:

[0010] Step S4: if at least two water level lines are obtained based on the current frame dynamic liquid level image, then the coordinates of the at least two water level lines are fitted to a straight line equation based on the least squares method;

[0011] Determine two intersection points of the straight line equation and the cabin, and determine a first pixel height of the water level based on end points of the two intersection points;

[0012] Determine a second pixel height of the water tank and a standard height of the cabin, and determine a dynamic liquid level height of the cabin based on the first pixel height, the second pixel height and the standard height.

[0013] Preferably, in step S1, obtaining an image captured by a cabin camera from the side of the cabin specifically includes:

[0014] An LED lighting source is arranged on the top of the cabin. When the LED lighting source illuminates the liquid level in the cabin, a cabin camera arranged in the cabin and having the same shooting direction as the LED lighting source is used to capture a liquid level image.

[0015] Preferably, in step S2, threshold segmentation is performed on the continuous frame images based on the OTSU algorithm to obtain a dynamic liquid level image, which specifically includes:

[0016] Grayscale processing is performed on the continuous frame images:

[0017] Gray=R*0.299+G*0.587+B*0.114

[0018] In the above formula, Gray represents the gray value, R represents the red component in the image, G represents the green component in the image, and B represents the blue component;

[0019] The probability that the gray level of a pixel in a continuous frame image is i is:

[0020]

[0021] In the above formula, N = n0 + n1 + ... + n L-1 ;ni represents the number of pixels with gray level i; L represents that there are L different gray levels in the continuous frame image;

[0022] Let the initial threshold t = 0, and the continuous frame images are divided into C1 and C2 after threshold segmentation, where the probabilities of pixels being classified into C1 and C2 are:

[0023]

[0024]

[0025] The class mean μ of pixels classified into C1 and C2 i It is expressed as:

[0026]

[0027]

[0028] The grayscale averages of pixels with grayscale levels from 0 to L-1 are:

[0029]

[0030] The corresponding class variance is:

[0031]

[0032]

[0033] The intra-class variance and inter-class variance are:

[0034]

[0035] σ B 2 =ω1(μ1-μ T ) 2 +ω2(μ2-μ T ) 2

[0036] The gray level variance is determined based on the intra-class variance and inter-class variance:

[0037]

[0038] The segmentation threshold is determined based on the t value when the between-class variance takes the maximum value or the within-class variance takes the minimum value:

[0039]

[0040] Preferably, the step S3 specifically includes:

[0041] Step S31, the dynamic liquid level image is divided into 13×13 cells, so that the liquid level can be detected when it falls within the cell. With the cell as the center, based on the anchor box in the PP-YOLO model, N region candidate boxes with different aspect ratios are predicted, and corresponding to different parameters, namely, the center coordinates x, y, width and height w, h, and confidence score:

[0042]

[0043] In the above formula, P r (object) indicates the possibility that the candidate box contains liquid level information, and object indicates the liquid level to be identified. Indicates the accuracy of the predicted candidate box; if the candidate box is the background, then P r (object) = 0 means the candidate box is the background, P r (object)=1 means that the candidate box contains liquid level information;

[0044] According to the predicted liquid level border box truth The actual liquid level border box pred Calculation accuracy:

[0045]

[0046] Given X categories for each cell, each category includes X conditional probabilities:

[0047] P r (Class i |object)i=1,2,...,X

[0048] Based on the PP-YOLO model, the candidate box is bound to the category prediction probability, and the posterior probability is calculated. The category confidence of the candidate box is:

[0049]

[0050] By reducing the batch and thus increasing the input size to enhance the liquid level area, the loss function IoU in PP-YOLO is improved based on the soft label method:

[0051] loss=-t*log(σ(p))-(1-t)*log(1-σ(p))

[0052] Where t represents the loss function IoU between the anchor point and the true candidate box, and p represents the output of the original IoU branch.

[0053] Preferably, the method further comprises: training a PP-YOLO model;

[0054] Take a number of dynamic liquid level images with dynamic change characteristics, obtain annotation files in XML format based on annotation tools, and divide them into training samples and verification samples;

[0055] Select the PP-YOLOv2 network for training, modify the values ​​of class and filters to adapt to the tank liquid level that needs to be identified;

[0056] Based on the PP-YOLOv2 network, training is performed to obtain the PP-YOLO model for identifying liquid levels.

[0057] In a second aspect, an embodiment of the present invention provides a system for identifying dynamic water level in a ship cabin, comprising:

[0058] The camera module obtains the liquid level image captured by the cabin camera and captures the continuous frame image with fluctuation;

[0059] An image preprocessing module performs threshold segmentation on the continuous frame images based on the maximum inter-class variance method (OTSU) to obtain a dynamic liquid level image;

[0060] Based on the median filtering method, the dynamic liquid level image is smoothed, and corrosion and expansion processing is performed to remove noise points in the dynamic liquid level image;

[0061] The liquid level recognition module inputs the dynamic liquid level image into a pre-trained PP-YOLO model, and obtains a liquid level recognition result based on the PP-YOLO model.

[0062] In a third aspect, an embodiment of the present invention provides an electronic device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the program, the steps of the method for identifying the dynamic water level of a ship cabin as described in the embodiment of the first aspect of the present invention are implemented.

[0063] In a fourth aspect, an embodiment of the present invention provides a non-transitory computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the steps of the method for identifying the dynamic water level of a ship cabin as described in the embodiment of the first aspect of the present invention.

[0064] The embodiment of the present invention provides a method and system for identifying the dynamic water level in a ship cabin. First, the acquired image is preprocessed. After image graying, image segmentation, and morphological processing, the dynamic liquid level is identified based on the PP-YOLO v2 algorithm. The water tank is simulated as a cabin for experiment to obtain the liquid level detection result. The relative error of the liquid level result measured by the algorithm is 1.33%, and the accuracy rate reaches 98.67%, which has strong reliability. The automation level of ship cabin liquid level identification is improved, and it has strong application value. BRIEF DESCRIPTION OF THE DRAWINGS

[0065] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the following briefly introduces the drawings required for use in the embodiments or the description of the prior art. Obviously, the drawings described below are some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.

[0066] Figure 1 A flowchart of a method for identifying dynamic water level in a ship cabin according to an embodiment of the present invention;

[0067] Figure 2 A schematic diagram of image capture during liquid level detection according to an embodiment of the present invention;

[0068] Figure 3 is a schematic diagram of an initial image according to an embodiment of the present invention;

[0069] Figure 4 is a grayscale image according to an embodiment of the present invention;

[0070] Figure 5 is an image after threshold segmentation according to an embodiment of the present invention;

[0071] Figure 6 is an image after morphological operation according to an embodiment of the present invention;

[0072] Figure 7 FIG. 4 is a schematic diagram of a physical structure according to an embodiment of the present invention. DETAILED DESCRIPTION

[0073] In order to make the purpose, technical solution and advantages of the embodiments of the present invention clearer, the technical solution in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0074] In the embodiments of the present application, the term "and / or" is merely a description of the association relationship between associated objects, indicating that three relationships may exist. For example, A and / or B may represent three situations: A exists alone, A and B exist at the same time, and B exists alone.

[0075] The terms "first" and "second" in the embodiments of the present application are only used for descriptive purposes and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features. Thus, the features defined as "first" and "second" can explicitly or implicitly include at least one of the features. In the description of the present application, the terms "including" and "having" and any of their variations are intended to cover non-exclusive inclusions. For example, a system, product or device comprising a series of parts or units is not limited to the listed parts or units, but optionally also includes parts or units that are not listed, or optionally also includes other parts or units inherent to these products or devices. In the description of the present application, the meaning of "multiple" is at least two, such as two, three, etc., unless otherwise clearly and specifically defined.

[0076] Reference to "embodiment" herein means that a particular feature, structure, or characteristic described in conjunction with the embodiment may be included in at least one embodiment of the present application. The appearance of the phrase in various locations in the specification does not necessarily refer to the same embodiment, nor is it an independent or alternative embodiment that is mutually exclusive with other embodiments. It is explicitly and implicitly understood by those skilled in the art that the embodiments described herein may be combined with other embodiments. The following will be described and introduced through multiple embodiments.

[0077] Figure 1 A method for identifying dynamic water level in a ship cabin is provided in an embodiment of the present invention, comprising:

[0078] Step S1, obtaining a liquid level image captured by a cabin camera, and intercepting a continuous frame image with fluctuation;

[0079] In the embodiment of the present invention, the image is collected by the camera arranged in the cabin and the LED lighting source on the top of the cabin. The camera collects the image with a resolution of 1920x1080, and the lighting part is kept in the same direction as the camera. The computer software is written based on Qt, and OpenCV is used to call the machine vision algorithm library to achieve the final liquid level detection. The water tank is used to simulate the on-site cabin, and the liquid level height is recognized through the image. The actual cabin liquid level height is converted according to the height ratio of the water tank to the cabin, such as Figure 2 In the embodiment of the present invention, under the condition of light source, the image captured by the cabin on-site CCD camera is extracted, the source image size is 1920x1080, and the continuous frames are intercepted to have the image of fluctuation characteristics.

[0080] Step S2, performing threshold segmentation on the continuous frame images based on the maximum inter-class variance method (OTSU) to obtain a dynamic liquid level image; performing smoothing processing on the dynamic liquid level image based on a median filtering method, and performing corrosion and expansion processing to remove noise points in the dynamic liquid level image;

[0081] The embodiment of the present invention first needs to pre-process the extracted continuous frame images, mainly including image grayscale, image segmentation and morphological processing, such as Figure 3 as shown in .

[0082] Since the images acquired in the cabin are RGB color images, the images need to be grayed out first. The conversion is mainly done through the following formula:

[0083] Gray=R*0.299+G*0.587+B*0.114

[0084] In the above formula, Gray represents the gray value, R represents the red component in the image, G represents the green component in the image, and B represents the blue component. The grayscale image is as follows: Figure 4 as shown in .

[0085] In order to achieve efficient processing of images acquired by the cabin camera, it is necessary to extract the area of ​​interest. Here, the image segmentation technology is used to extract the key area to reduce unnecessary calculations and improve the image processing speed. For liquid level recognition in a cabin environment, due to its high requirements for processing speed, the embodiment of the present invention selects the maximum inter-class variance method, namely the OTSU algorithm, for binarization processing. This method has the characteristics of simple calculation and fast processing speed. It uses the initial threshold for classification, divides the acquired original image into two categories, and updates the initial threshold by calculating the variance, and so on, until the inter-class variance reaches the maximum value to obtain the optimal threshold. The algorithm steps are designed as follows.

[0086] The probability that the gray level of a pixel in a continuous frame image is i is:

[0087]

[0088] In the above formula, N = n0 + n1 + ... + n L-1 ;n i represents the number of pixels with gray level i; L represents that there are L different gray levels in the continuous frame image;

[0089] Let the initial threshold t = 0, and the continuous frame images are divided into C1 and C2 after threshold segmentation, where the probabilities of pixels being classified into C1 and C2 are:

[0090]

[0091]

[0092] The class mean μ of pixels classified into C1 and C2 i It is expressed as:

[0093]

[0094]

[0095] The grayscale averages of pixels with grayscale levels from 0 to L-1 are:

[0096]

[0097] The corresponding class variance is:

[0098]

[0099]

[0100] The intra-class variance and inter-class variance are:

[0101]

[0102] σ B 2 =ω1(μ1-μ T ) 2 +ω2(μ2-μ T ) 2

[0103] The gray level variance is determined based on the intra-class variance and inter-class variance:

[0104]

[0105] The segmentation threshold is determined based on the t value when the between-class variance takes the maximum value or the within-class variance takes the minimum value:

[0106]

[0107] Figure 5 That is, after the OTSU algorithm, the image of the area above the liquid surface is extracted.

[0108] The image after image threshold segmentation can show the liquid and the top, but for the interference above the liquid level, it is necessary to use the median filtering method to reduce the image edge. At the same time, in order to remove the interference that still exists on the top, the filtered image is further eroded and expanded to remove the noise in the image. Dilation merges the target set and replaces the value of the target element with the area covered by the convolution kernel and the local maximum value. The formula is expressed as follows:

[0109]

[0110] Taking the center point of structure B as the criterion, finding a point in A that satisfies structure B is called erosion, and placing each point of structure A at the center point of B and expanding outward from structure B is called expansion. Erosion can be expressed as:

[0111]

[0112] The image after morphological processing is Figure 6 shown.

[0113] Step S3: input the dynamic liquid level image into a pre-trained PP-YOLO model, and obtain a liquid level recognition result based on the PP-YOLO model.

[0114] Compared with the traditional yolo algorithm, the performance of the PP-Yolo v2 algorithm on the COCO2017 test-dev data has been improved from 45.9% mAP to 49.5% mAP, and can reach 68.9FPS at an input size of 640x640. The PP-YOLOv2 with the ResNet101 skeleton can achieve 50.3% mAP on the COCO2017 test-dev dataset.

[0115]

[0116] In the above formula, P r (object) indicates the possibility that the candidate box contains liquid level information, and object indicates the liquid level to be identified. Indicates the accuracy of the predicted candidate box; if the candidate box is the background, then P r (object) = 0 means the candidate box is the background, P r (object)=1 means that the candidate box contains liquid level information;

[0117] According to the predicted liquid level border box truth The actual liquid level border box pred Calculation accuracy:

[0118]

[0119] Given X categories for each cell, each category includes X conditional probabilities:

[0120] P r (Class i |object)i=1,2,...,X

[0121] Based on the PP-YOLO model, the candidate box is bound to the category prediction probability, and the posterior probability is calculated. The category confidence of the candidate box is:

[0122]

[0123] By reducing the batch and increasing the input size to enhance the liquid level area, the model performance is improved. The loss function IoU in PP-YOLO is improved based on the soft label method to obtain:

[0124] loss=-t*log(σ(p))-(1-t)*log(1-σ(p))

[0125] In the formula, t represents the loss function IoU between the anchor point and the true candidate box, and p represents the output of the original IoU branch. By replacing the loss function, the model performance is improved.

[0126] In this embodiment, for the dynamically changing liquid level, the preprocessed image is first divided into 13x13 cells. The liquid level is detected when it falls within the cell. Based on the center of the cell, N region candidate boxes with different aspect ratios are predicted based on the anchor box in PP-YOLO v2, and the corresponding parameters are the center coordinates x, y, width and height w, h, and confidence score:

[0127] Step S4, extracting the input dynamic liquid level image frame by frame, and identifying it through the trained model, if at least two water level lines are obtained based on the dynamic liquid level image of the current frame, then fitting the coordinates of the at least two water level lines to a straight line equation l based on the least squares method;

[0128] Since the cabin camera only moves vertically and the cabin position remains unchanged, according to the established coordinate system, its horizontal coordinates are fixed to x1 and x2, which are substituted into l to determine the two intersection points A and B of the straight line equation l and the cabin, and the first pixel height l1 of the water level is determined based on the end points of the two intersection points;

[0129] Determine the second pixel height l2 of the water tank and the standard height H of the cabin, and determine the dynamic liquid level height of the cabin based on the first pixel height l1, the second pixel height l2 and the standard height H:

[0130]

[0131] Also includes: training the PP-YOLO model;

[0132] Several dynamic liquid level images with dynamic change characteristics were taken, and the annotation files in XML format were obtained based on the annotation tools, which were divided into training samples and verification samples. 600 liquid level images with dynamic change characteristics were taken, and the annotation files in XML format were obtained by using the annotation tools. 550 of them were selected as training samples and 50 as verification samples.

[0133] Select the PP-YOLOv2 network for training, modify the values ​​of class and filters to adapt to the tank liquid level that needs to be identified;

[0134] Training was performed based on the PP-YOLOv2 network, and the number of iterations was set to 6000 to obtain the PP-YOLO model for identifying liquid levels.

[0135] The camera resolution is 1920x1080, the software uses QT (version 5.13.1) and OpenCV (version 4.4.1), and the hardware is based on PC (model Dell inspiron 5550). On this platform, a water tank is used to simulate the cabin and a liquid level recognition experiment is carried out. After measurement with a standard ruler, the current water tank height is 21.2 (cm). The dynamic liquid level recognition results are shown in Table 1.

[0136] Table 1 Liquid level recognition results

[0137]

[0138] The manual measurement result is the actual liquid level measured by a standard ruler after the dynamic liquid level stabilizes, and the algorithm measurement result represents the liquid level height identified after extracting the image frame by frame based on PP-YOLOv2. After analyzing the results, it was found that the relative error of the liquid level result measured by the dynamic liquid level recognition algorithm of the cabin using PP-YOLOv2 was 1.33%, and the accuracy rate reached 98.67%.

[0139] The embodiment of the present invention further provides a ship cabin dynamic water level recognition system, based on the ship cabin dynamic water level recognition method in the above embodiments, comprising:

[0140] The camera module obtains the liquid level image captured by the cabin camera and captures the continuous frame image with fluctuation;

[0141] An image preprocessing module performs threshold segmentation on the continuous frame images based on the maximum inter-class variance method (OTSU) to obtain a dynamic liquid level image;

[0142] Based on the median filtering method, the dynamic liquid level image is smoothed, and corrosion and expansion processing is performed to remove noise points in the dynamic liquid level image;

[0143] The liquid level recognition module inputs the dynamic liquid level image into a pre-trained PP-YOLO model, and obtains a liquid level recognition result based on the PP-YOLO model.

[0144] Based on the same concept, the embodiment of the present invention also provides a schematic diagram of an entity structure, such as Figure 7As shown, the server may include: a processor 810, a communication interface 820, a memory 830 and a communication bus 840, wherein the processor 810, the communication interface 820 and the memory 830 communicate with each other through the communication bus 840. The processor 810 may call the logic instructions in the memory 830 to execute the steps of the ship cabin dynamic water level identification method as described in the above embodiments. For example, it includes:

[0145] Step S1, obtaining a liquid level image captured by a cabin camera, and intercepting a fluctuating continuous frame image; performing threshold segmentation on the continuous frame image based on the maximum between-class variance method (OTSU) to obtain a dynamic liquid level image;

[0146] Step S2, smoothing the dynamic liquid level image based on a median filtering method, and performing corrosion and expansion processing to remove noise points in the dynamic liquid level image;

[0147] Step S3: input the dynamic liquid level image into a pre-trained PP-YOLO model, and obtain a liquid level recognition result based on the PP-YOLO model.

[0148] In addition, the logic instructions in the above-mentioned memory 830 can be implemented in the form of a software functional unit and can be stored in a computer-readable storage medium when it is sold or used as an independent product. Based on such an understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, and the computer software product is stored in a storage medium, including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.

[0149] Based on the same concept, an embodiment of the present invention further provides a non-transitory computer-readable storage medium, which stores a computer program, which includes at least one code segment, and the at least one code segment can be executed by a main control device to control the main control device to implement the steps of the ship cabin dynamic water level identification method as described in the above embodiments. For example, it includes:

[0150] Step S1, obtaining a liquid level image captured by a cabin camera, and intercepting a fluctuating continuous frame image; performing threshold segmentation on the continuous frame image based on the maximum between-class variance method (OTSU) to obtain a dynamic liquid level image;

[0151] Step S2, smoothing the dynamic liquid level image based on a median filtering method, and performing corrosion and expansion processing to remove noise points in the dynamic liquid level image;

[0152] Step S3: input the dynamic liquid level image into a pre-trained PP-YOLO model, and obtain a liquid level recognition result based on the PP-YOLO model.

[0153] Based on the same technical concept, an embodiment of the present application also provides a computer program, which, when executed by a main control device, is used to implement the above method embodiment.

[0154] The program may be stored in whole or in part on a storage medium packaged together with the processor, or may be stored in whole or in part on a memory not packaged together with the processor.

[0155] Based on the same technical concept, the embodiment of the present application further provides a processor, which is used to implement the above method embodiment. The above processor can be a chip.

[0156] The various embodiments of the present invention can be combined arbitrarily to achieve different technical effects.

[0157] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in this application is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line) or wireless (e.g., infrared, wireless, microwave, etc.) mode. The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk SolidStateDisk), etc.

[0158] Those skilled in the art can understand that to implement all or part of the processes in the above-mentioned embodiments, the processes can be completed by computer programs to instruct related hardware, and the programs can be stored in computer-readable storage media. When the programs are executed, they can include the processes of the above-mentioned method embodiments. The aforementioned storage media include: ROM or random access memory RAM, magnetic disk or optical disk and other media that can store program codes.

[0159] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.

Claims

1. A method for identifying dynamic water level in a ship cabin, characterized in that: include: Step S1, obtaining a liquid level image captured by a cabin camera, and intercepting a continuous frame image with fluctuation; Step S2, performing threshold segmentation on the continuous frame images based on the maximum inter-class variance method (OTSU) to obtain a dynamic liquid level image; performing smoothing processing on the dynamic liquid level image based on a median filtering method, and performing corrosion and expansion processing to remove noise points in the dynamic liquid level image; Step S3, inputting the dynamic liquid level image into a pre-trained PP-YOLO model, and obtaining a liquid level recognition result based on the PP-YOLO model recognition; Step S4: if at least two water level lines are obtained based on the current frame dynamic liquid level image, then the coordinates of the at least two water level lines are fitted to a straight line equation based on the least squares method; Determine two intersection points of the straight line equation and the cabin, and determine a first pixel height of the water level based on end points of the two intersection points; Determine a second pixel height of the water tank and a standard height of the cabin, and determine a dynamic liquid level height of the cabin based on the first pixel height, the second pixel height and the standard height; In the step S2, threshold segmentation is performed on the continuous frame images based on the OTSU algorithm to obtain a dynamic liquid level image, which specifically includes: Grayscale processing is performed on the continuous frame images: Gray=R*0.299+G*0.587+B*0.114 In the above formula, Gray represents the gray value, R represents the red component in the image, G represents the green component in the image, and B represents the blue component; The probability that the gray level of a pixel in a continuous frame image is i is: In the above formula, N = n0 + n1 + ... + n L-1 ;n i represents the number of pixels with gray level i; L represents that there are L different gray levels in the continuous frame image; Let the initial threshold t = 0, and the continuous frame images are divided into C1 and C2 after threshold segmentation, where the probabilities of pixels being classified into C1 and C2 are: The class mean μ of pixels classified into C1 and C2 i It is expressed as: The grayscale averages of pixels with grayscale levels from 0 to L-1 are: The corresponding class variance is: The intra-class variance and inter-class variance are: s B 2 =ω1(μ1-μ T ) 2 +ω2(μ2-μ T ) 2 The grayscale variance is determined based on the intra-class variance and inter-class variance: The segmentation threshold is determined based on the t value when the between-class variance takes the maximum value or the within-class variance takes the minimum value: The step S3 specifically includes: The dynamic liquid level image is divided into 13×13 cells so that the liquid level can be detected when it falls within the cells. With the cells as the center, based on the anchor boxes in the PP-YOLO model, N candidate boxes of regions with different aspect ratios are predicted, and the corresponding parameters are the center coordinates x, y, width and height w, h, and confidence score: In the above formula, P r (object) indicates the possibility that the candidate box contains liquid level information, and object indicates the liquid level to be identified. Indicates the accuracy of the predicted candidate box; if the candidate box is the background, then P r (object) = 0 means the candidate box is the background, P r (object)=1 means that the candidate box contains liquid level information; According to the predicted liquid level border box truth The actual liquid level border box pred Calculation accuracy: Given X categories for each cell, each category includes X conditional probabilities: P r (Class i |object)i=1,2,...,X Based on the PP-YOLO model, the candidate box is bound to the category prediction probability, and the posterior probability is calculated. The category confidence of the candidate box is: By reducing the batch and thus increasing the input size to enhance the liquid level area, the loss function IoU in PP-YOLO is improved based on the soft label method: loss=-t*log(σ(p))-(1-t)*log(1-σ(p)) Where t represents the loss function IoU between the anchor point and the true candidate box, and p represents the output of the original IoU branch.

2. The method for identifying dynamic water level in a ship cabin according to claim 1, characterized in that: In the step S1, obtaining an image captured by the cabin camera from the side of the cabin specifically includes: An LED lighting source is arranged on the top of the cabin. When the LED lighting source illuminates the liquid level in the cabin, a cabin camera arranged in the cabin and having the same shooting direction as the LED lighting source is used to capture a liquid level image.

3. The method for identifying dynamic water level in a ship cabin according to claim 1, characterized in that: Also includes: Train the PP-YOLO model; Take a number of dynamic liquid level images with dynamic change characteristics, obtain annotation files in XML format based on annotation tools, and divide them into training samples and verification samples; Select the PP-YOLOv2 network for training, modify the values ​​of class and filters to adapt to the tank liquid level that needs to be identified; Based on the PP-YOLOv2 network, training is performed to obtain the PP-YOLO model for identifying liquid levels.

4. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the program, the steps of the method for identifying dynamic water level in a ship cabin as described in any one of claims 1 to 3 are implemented.

5. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method for identifying dynamic water level in a ship cabin as described in any one of claims 1 to 3 are implemented.

Citation Information

Patent Citations

  • Unmanned aerial vehicle intelligent ship water gauge identification method and device

    CN111476120A

  • YOLO-based image target recognition method and apparatus, electronic device, and storage medium

    WO2020164282A1