Ship shadow detection method and device based on continuous frame memory

By using the continuous frame memory method in ship shadow detection, combined with large segmentation model and dynamic behavior prediction model, and using the time correlation information of multi-frame images, the incoherence problem of single frame segmentation method is solved and the accuracy of shadow area segmentation is improved. and efficiency, reducing computational complexity and improving navigation safety.

CN118570468APending Publication Date: 2024-08-30709TH RESEARCH INSTITUTE CHINA STATE SHIPBUILDING CORP LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202410622054.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-05-20
Publication Date
2024-08-30

AI Technical Summary

Technical Problem

Existing single-frame shadow segmentation methods cannot fully utilize the temporal correlation information between adjacent frames, resulting in incoherent segmentation results and poor segmentation performance, which affects the accuracy of ship shadow detection.

Method used

The ship shadow detection method based on continuous frame memory is used to perform semantic segmentation of the large segmentation model by acquiring multiple frames of images within a predetermined time period during the ship's travel. Combined with the dynamic behavior prediction model, the segmentation results of the previous frame and the previous m frames are used to The shadow area segmentation results are updated in real time, making full use of the temporal correlation information between adjacent frames.

Benefits of technology

It significantly improves the accuracy of obstacle recognition, avoids recognition inaccuracies caused by changes in the ship's shadow position, makes the segmentation process more coherent, reduces computational complexity, improves model detection efficiency, and effectively improves navigation safety.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118570468A
    Figure CN118570468A
Patent Text Reader

Abstract

The invention relates to the technical field of ship target detection, in particular to a ship shadow detection method and device based on continuous frame memory, and the method comprises the steps: obtaining m frames of images in a preset time period in a ship driving process, sequentially inputting the m frames of images into a large segmentation model, and carrying out the semantic segmentation of a shadow region, obtaining a shadow region segmentation result corresponding to each frame of image; after the preset time period, acquiring a current image frame in the ship running process in real time; inputting the current image frame, the shadow region segmentation result of the previous frame of the current image frame and the shadow region segmentation results of the previous m frames of images of the current image frame into a dynamic behavior prediction model to obtain a segmentation result variable quantity; and modifying the shadow region segmentation result of the previous frame according to the segmentation result variable quantity to obtain a shadow region segmentation result of the current image frame.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of ship target detection, and in particular to a ship shadow detection method and device based on continuous frame memory. Background Art

[0002] Ship surveillance video is of great significance for the safe navigation of ships. Shadow detection and elimination is one of the key links. At sea, the shadow of a ship may block other objects (such as reefs, small boats, etc.) and cause collisions, thus affecting the safety of the ship's navigation.

[0003] The biggest feature of surface target detection is that the background of the target occupies a large area of ​​water. The water surface will produce constantly changing ripples with the wind. In rain, snow or hail weather, raindrops, snowdrops, etc. falling on the water surface will cause ripples of varying sizes on the water surface. The fluidity of water makes the color feature quantity of the corresponding water surface area pixels in the foreground image and the background image not consistent or similar, but a dynamically changing range. In the prior art, the further shadow segmentation of the detection result of the moving object has the following difficulties: first, the shape of the detected moving object (such as a reef or a boat, etc.) will be affected by the shadow of the moving target (such as a ship, etc.). When the position of the same moving target in the scene is different, the light blocked will be different, and the shape and direction of the shadow will also be different, which indirectly leads to the subsequent accurate classification of the object and the accurate positioning of its position; secondly, the shadow of the moving target may also make two or more objects become one, so that the detected moving object target is originally a plurality of different objects but is regarded as a single whole.

[0004] The existing solutions mainly perform semantic segmentation on a single frame of the video to determine the location of the shadow area. Due to the need for real-time performance, shadow detection systems usually use lightweight models, and the segmentation effect and accuracy are not ideal; secondly, because the model usually only receives a single frame when working, it does not consider the continuity of the image during navigation, and the shadow segmentation results are not consistent, which affects the detection accuracy of the shadow area.

[0005] In view of this, overcoming the defects of the prior art is an urgent problem to be solved in the field of this technology. Summary of the invention

[0006] The technical problem to be solved by the present invention is that the existing single-frame shadow segmentation method cannot fully utilize the temporal correlation information between adjacent frames, resulting in incoherent segmentation results and poor segmentation performance.

[0007] The present invention adopts the following technical solution:

[0008] In a first aspect, the present invention provides a ship shadow detection method based on continuous frame memory, comprising:

[0009] Obtain m frames of images within a predetermined time period during the ship's travel, input the m frames of images into the large segmentation model in sequence to perform semantic segmentation of the shadow area, and obtain the shadow area segmentation result corresponding to each frame of the image;

[0010] After a predetermined time period, a current image frame of the ship during its travel is acquired in real time;

[0011] Inputting the shadow area segmentation results of the current image frame, the previous frame of the current image frame, and the shadow area segmentation results of the previous m frames of the current image frame into the dynamic behavior prediction model to obtain a change in the segmentation results;

[0012] The shadow area segmentation result of the previous frame is modified according to the segmentation result variation to obtain the shadow area segmentation result of the current image frame.

[0013] Preferably, the process of acquiring m frames of images within a predetermined time period during the travel of the ship, sequentially inputting the m frames of images into a large segmentation model for semantic segmentation of shadow areas, and obtaining the shadow area segmentation result corresponding to each frame of image includes:

[0014] Acquire m frames of images within a predetermined time period, and preprocess the m frames of images;

[0015] The preprocessed m frames of images are input into a large segmentation model to perform semantic segmentation of shadow areas;

[0016] The shadow area segmentation result is represented as a matrix of element 0 and element 1, wherein element 0 indicates that the corresponding area in the image frame is not a shadow, and element 1 indicates that the corresponding area in the image frame is a shadow.

[0017] Preferably, the acquiring of m frames of images within a predetermined time period and preprocessing of the m frames of images comprises:

[0018] Scaling the m image frames so that the image sizes of the m image frames are uniform;

[0019] The pixel value distribution of the m frames of images is normalized from [0, 255] to [0, 1].

[0020] Preferably, the step of inputting the shadow area segmentation results of the current image frame, the shadow area segmentation results of the previous frame of the current image frame, and the shadow area segmentation results of the previous m frames of the current image frame into the dynamic behavior prediction model to obtain the segmentation result variation comprises:

[0021] Obtaining a first feature matrix of the current image frame from the dynamic behavior prediction model, obtaining a second feature matrix of the previous m frames of the current image frame from the shadow area segmentation results of the previous m frames of the current image frame, and obtaining a fourth feature matrix of the previous frame from the shadow area segmentation results of the previous frame, using the second feature matrix as a historical flow for segmentation reference, comparing the first feature matrix and the fourth feature matrix, and for the same area, when the elements of the first feature matrix and the fourth feature matrix are consistent, the element value corresponding to the area is 0; when the elements of the first feature matrix and the fourth feature matrix are inconsistent, the element value corresponding to the area is 1;

[0022] The values ​​corresponding to the multiple regions are represented as a matrix of element 0 and element 1 to obtain the variation of the segmentation result.

[0023] Preferably, the step of modifying the shadow area segmentation result of the previous frame according to the segmentation result variation to obtain the shadow area segmentation result of the current image frame comprises:

[0024] Obtaining element values ​​of each region from the segmentation result variation;

[0025] For the same area, when the element value of the area is 0, the output result is True, and the shadow area segmentation result of the corresponding area is the shadow area detection result of the previous frame; when the element value of the area is 1, the output result is False, then the shadow area detection result of the previous frame is flipped to obtain the shadow area segmentation result of the corresponding area;

[0026] The shadow area segmentation result of each area is integrated to obtain the shadow area segmentation result of the current image frame.

[0027] Preferably, it also includes:

[0028] The shadow area segmentation result of the current image frame is continuously updated in a continuous frame memory pool, wherein the shadow area detection result of the image frame at the current moment is used as the shadow area detection result of the previous frame at the next moment.

[0029] Preferably, the dynamic behavior prediction model specifically includes a self-attention layer, a long-term attention layer, a short-term attention layer and a multi-layer perceptron;

[0030] The self-attention layer is used to learn the shadow features of the current image frame to obtain a first feature matrix;

[0031] The long-term attention layer obtains a second feature matrix of m frames before the current image frame, and calculates the second feature matrix and the first feature matrix to obtain a third feature matrix;

[0032] The short-term attention layer obtains a fourth feature matrix of the previous frame, and calculates the fourth feature matrix and the first feature matrix to obtain a fifth feature matrix;

[0033] The multilayer perceptron is used to combine the first feature matrix, the third feature matrix and the fifth feature matrix to obtain a change in the segmentation result of the current image frame compared to the previous frame.

[0034] Preferably, the dynamic behavior prediction model adopts an encoder and decoder structure, wherein the decoder corresponds to the multi-layer perceptron; the encoder is used to extract shadow area features from the current image frame for calculation by the self-attention layer; the decoder is used to process the combined first feature matrix, the third feature matrix and the fifth feature matrix to obtain the change in the segmentation result of the current image frame compared to the previous frame, and perform an XOR operation on the shadow area segmentation result of the previous frame and the change in the segmentation result.

[0035] In a second aspect, the present invention provides a ship shadow detection device based on continuous frame memory, which is used to implement the ship shadow detection method based on continuous frame memory described in the first aspect, comprising:

[0036] At least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the ship shadow detection method based on continuous frame memory as described in any one of claims 1-8.

[0037] In a third aspect, the present invention further provides a non-volatile computer storage medium, wherein the computer storage medium stores computer executable instructions, which are executed by one or more processors to complete the ship shadow detection method based on continuous frame memory described in the first aspect.

[0038] In a fourth aspect, a chip is provided, comprising: a processor and an interface, for calling and running a computer program stored in the memory from a memory, and executing the method as described in the first aspect.

[0039] In a fifth aspect, a computer program product comprising instructions is provided, which, when executed on a computer or a processor, causes the computer or the processor to execute the method as described in the first aspect.

[0040] The beneficial effects of the present invention are as follows: compared with the single-frame shadow segmentation method used in the prior art for obstacle recognition, the present invention adopts a continuous frame method to significantly improve the accuracy of obstacle recognition, takes the shadow area segmentation result of the previous frame of the current image frame as a benchmark, takes the m frames of image within a predetermined time period as a historical information reference, and makes full use of the time correlation information and space correlation information between adjacent image frames, so that the obstacle shadow area segmentation result is more accurate, avoids the inaccuracy of obstacle recognition caused by the change of the shadow position of the ship as much as possible, and makes the segmentation process more coherent; and, the present invention adopts a combination of a large segmentation model and a dynamic behavior prediction model, taking into account the large segmentation The operation of the segmentation model is time-consuming, so it is only run during the startup phase of the ship. The higher accuracy of the segmentation results of the large segmentation model is used to provide a good initial segmentation result for the subsequent real-time segmentation, so that the subsequent recognition process of the change in the segmentation results of the current image frame and the previous frame using the dynamic behavior prediction model is more accurate. At the same time, the network of the recognition system is lightweight, which effectively improves the efficiency of the model in detecting the shadow area of ​​obstacles. Among them, the function of the dynamic behavior prediction model is simplified, and the function of the dynamic behavior prediction model is simplified from predicting the position of the shadow area to predicting the change in the position of the shadow area, which effectively reduces the computational complexity of the overall model and improves the computational efficiency.

[0041] In summary, the present invention can effectively improve the accuracy of the ship shadow detection device, effectively reduce the risks of ship collision, reefing, etc. that may occur during navigation, and improve the safety of navigation. BRIEF DESCRIPTION OF THE DRAWINGS

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

[0043] Figure 1 It is a schematic diagram of the overall process of a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0044] Figure 2 It is a working logic state diagram of a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0045] Figure 3 1 is a specific flow chart of step 1 of a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0046] Figure 4This is an example diagram of calculating the variation of segmentation results of a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0047] Figure 5 It is a flow chart of obtaining the shadow area segmentation result of the current image frame in a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0048] Figure 6 It is a dynamic behavior prediction model diagram of a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0049] Figure 7 It is a schematic diagram of the calculation principle of a dynamic behavior prediction model of a ship shadow detection method based on continuous frame memory provided by an embodiment of the present invention;

[0050] Figure 8 It is a module structure diagram of a ship shadow detection device based on continuous frame memory provided by an embodiment of the present invention;

[0051] Fig. 9 It is an overall structural diagram of a ship shadow detection device based on continuous frame memory provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0052] In order to make the purpose, technical solution and advantages of the present invention more clearly understood, the present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not intended to limit the present invention.

[0053] Unless the context requires otherwise, throughout the specification and claims, the term "including" is to be interpreted as open inclusion, that is, "including, but not limited to". In the description of the specification, the terms "one embodiment", "some embodiments", "exemplary embodiments", "examples", "specific examples" or "some examples" and the like are intended to indicate that specific features, structures, materials or characteristics associated with the embodiment or example are included in at least one embodiment or example of the present disclosure. The schematic representation of the above terms does not necessarily refer to the same embodiment or example. In addition, the specific features, structures, materials or characteristics may be included in any one or more embodiments or examples in any appropriate manner, that is, although they may be carried in the embodiments or examples of the above terms due to reasons such as the order and position of appearance, it is not limited to that they can be carried in combination by one embodiment or example.

[0054] In the description of the present invention, the terms "first" and "second" are used only 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" may explicitly or implicitly include one or more of the features. In the description of the embodiments of the present disclosure, unless otherwise specified, the meaning of "multiple" is two or more. In addition, for example, the same type of nouns may be described as two independent individuals by adding "A" and "B" at the end. In this case, the corresponding features defined as "A" and "B" are only used to distinguish the same type of individuals for description purposes, and cannot be understood as indicating or implying relative importance or implicitly indicating the number of indicated technical features.

[0055] In the description of the present invention, the expression "A and / or B" (where A and B are used to formally represent specific characteristic contents) will be involved, and the corresponding expressions include the following three combinations: only A, only B, and a combination of A and B.

[0056] As used herein, "about," "substantially," or "approximately" includes the stated value and an average value that is within an acceptable range of deviation from the particular value as determined by one of ordinary skill in the art taking into account the measurements in question and the errors associated with the measurement of the particular quantity (i.e., the limitations of the measurement system).

[0057] In addition, the technical features involved in the various embodiments of the present invention described below can be combined with each other as long as they do not conflict with each other.

[0058] Embodiment 1:

[0059] Embodiment 1 of the present invention provides a ship shadow detection method based on continuous frame memory, such as Figure 1 As shown, including:

[0060] In step 1, m frames of images within a predetermined time period during the ship's travel are obtained, and the m frames of images are sequentially input into a large segmentation model for semantic segmentation of shadow areas to obtain the shadow area segmentation result corresponding to each frame of the image.

[0061] The predetermined time period may be the sailing phase of the ship, or may be other time periods during the ship's formation process. m may be determined according to actual conditions, for example, m may be 10.

[0062] In one embodiment, the m frames of images within the predetermined time period may be 10 frames of images from the moment the ship starts sailing, and the m frames of images within the predetermined time period play a role in shadow detection in providing historical segmentation information for subsequent image frames for reference.

[0063] During the ship's travel, the formation and change of the shadow area are often related to the movement of the ship and the change of the light source. By comparing the current image frame with the previous m frames, the movement trajectory of the object and the relative stability of the light source over a period of time can be obtained, which helps the model detect the generation and change of shadows. In some cases, the shadow detection of a single frame may be affected by noise, occlusion or other interference factors and cause misjudgment. By introducing historical frames, the continuity in time can be used to smooth these noises and interferences, thereby improving the robustness of detection. Secondly, the shape, size and position of the shadow may change with time and changes in the light source. By comparing the current image frame with the previous m frames, the dynamic change process of the shadow can be captured, which is crucial for accurately identifying the shadow area of ​​the current image frame. In actual application scenarios, if the movement trajectory of the ship and the state of the light source are relatively stable over a period of time, then by comparing the current image frame with the previous m frames, the possible position and shape of the shadow in the next few frames can be predicted, so that the shadow area can be detected and processed in advance.

[0064] Specifically, the large segmentation model can be a segmentation model (Segment Anything Model, abbreviated as SAM). After obtaining the shadow area segmentation result corresponding to each frame of the image, the shadow area segmentation result of each frame of the image is stored in the continuous frame memory pool M mentioned in the subsequent content as a cache unit to save the m frames of images after semantic segmentation, and to save the detection result of the current moment image frame mentioned later.

[0065] In step 2, after a predetermined period of time, a current image frame of the ship during its travel is acquired in real time.

[0066] As time goes by, the current image frame is also changing.

[0067] In step 3, the shadow area segmentation results of the current image frame, the previous frame of the current image frame, and the shadow area segmentation results of the previous m frames of the current image frame are input into the dynamic behavior prediction model to obtain the change in the segmentation results.

[0068] In combination with the embodiment described in step 1, when m is 10, and the current image frame (t) is the 11th image frame since the ship starts sailing, the previous frame (t-1) of the current image frame is the 10th image frame since the ship starts sailing, and the previous m frames (tm) of the current image frame are the 1st image frame since the ship starts sailing. Therefore, the 11th image frame will use the segmentation result of the 1st frame and the segmentation result of the 10th frame; when the current image frame (t) is the 12th image frame since the ship starts sailing, the 12th frame will use the segmentation result of the 2nd frame and the segmentation result of the 11th frame, and so on. From a global perspective, each current image frame needs to use the segmentation results of tm and t-1 for calculation respectively. Therefore, the m frames of images within the predetermined time period use the large segmentation model to obtain the segmentation results from the 1st frame to the mth frame, and from the m+1th frame, the small segmentation model is used in combination with the results of tm and t-1 for segmentation prediction.

[0069] In the embodiment of the present invention, the large segmentation model is only used to segment the preset number of frames of images acquired from the moment the ship sets sail. The reason is that the reasoning of the large segmentation model takes a long time and cannot work in real time, so it is only run during the ship startup phase to accurately segment the shadow area of ​​the first few frames of the monitoring video in the initial stage. In order to ensure the real-time performance of semantic segmentation, it is necessary to call the dynamic behavior prediction model to calculate the change in the segmentation result of the current image frame compared to the previous image frame in real time, so as to determine the shadow area segmentation result of the current image frame according to the change in the segmentation result; in the initial stage, the use of the large segmentation model can ensure that the segmentation result is more accurate, and can provide a good initial segmentation result for the shadow area segmentation of subsequent image frames.

[0070] In step 4, the shadow area segmentation result of the previous frame is modified according to the segmentation result variation to obtain the shadow area segmentation result of the current image frame.

[0071] Specifically, after obtaining the shadow area segmentation result of the current image frame, the shadow area segmentation result of the current image frame is continuously updated in a continuous frame memory pool, wherein the shadow area detection result of the image frame at the current moment is used as the shadow area detection result of the previous frame at the next moment, and this cycle is repeated.

[0072] like Figure 2 As shown, it is the overall logic state diagram of the above steps 1 to 4, which can clearly show the working logic relationship between the large segmentation model, the dynamic behavior prediction model and the continuous frame memory pool M.

[0073] Compared with the single-frame shadow segmentation method used in the prior art for obstacle recognition, the present invention adopts a continuous frame method to significantly improve the accuracy of obstacle recognition. The shadow area segmentation result of the previous image frame of the current image frame is used as a benchmark, and the m frames of images within a predetermined time period are used as historical information references. The time correlation information and spatial correlation information between adjacent image frames are fully utilized to make the obstacle shadow area segmentation result more accurate, and the inaccuracy of obstacle recognition caused by the change of the ship's shadow position is avoided as much as possible, so that the segmentation process is more coherent; and the present invention adopts a large segmentation model and a dynamic behavior prediction model in combination. Considering that the operation of the large segmentation model is time-consuming, it is only run in the ship startup stage. The high-precision characteristics of the segmentation result of the large segmentation model are used to provide a good initial segmentation result for subsequent real-time segmentation, so that the subsequent recognition process of the change amount of the segmentation result of the current image frame and the previous frame using the dynamic behavior prediction model is more accurate, and at the same time, the network of the recognition system is lightweight, which effectively improves the efficiency of the model in detecting the obstacle shadow area; wherein, the function of the dynamic behavior prediction model is simplified, and the function of the dynamic behavior prediction model is simplified from predicting the shadow area position to predicting the change amount of the shadow area position, which effectively reduces the calculation complexity of the overall model and improves the calculation efficiency.

[0074] In summary, the present invention can effectively improve the accuracy of the ship shadow detection device, effectively reduce the risks of ship collision, reefing, etc. that may occur during navigation, and improve the safety of navigation.

[0075] According to the above-mentioned ship shadow detection method based on continuous frame memory, the implementation details of the method will be described in detail below to fully illustrate the solution provided by the embodiment of the present invention.

[0076] In the above step 1, m frames of images are obtained within a predetermined time period during the ship's travel, and the m frames of images are sequentially input into the large segmentation model for semantic segmentation of the shadow area to obtain the shadow area segmentation result corresponding to each frame of the image, such as Figure 3 As shown, including:

[0077] In step 10, m frames of images within a predetermined time period are acquired, and the m frames of images are preprocessed.

[0078] In step 11, the preprocessed m frames of images are input into a large segmentation model for semantic segmentation of shadow areas.

[0079] In step 12, the shadow area segmentation result is represented as a matrix of element 0 and element 1, wherein element 0 indicates that the corresponding area in the image frame is not a shadow, and element 1 indicates that the corresponding area in the image frame is a shadow.

[0080] Wherein, for step 10, the acquiring of m frames of images within a predetermined time period and preprocessing of the m frames of images include: scaling the m frames of images to make the image size of each frame in the m frames of images uniform, and normalizing the pixel value distribution of the m frames of images from [0, 255] to [0, 1].

[0081] Similarly, for the current image frame, after acquiring the current image frame, the current image frame is also scaled to unify the image size of the current image frame and each frame in the m-frame image, and the pixel value distribution of the current image frame is normalized from [0,255] to [0,1]. After the current image frame is input into the dynamic behavior prediction model, the encoder in the dynamic behavior prediction model will calculate the shadow area features of the current image frame and divide the current image frame into a matrix of element 0 and element 1, wherein element 0 indicates that the corresponding area in the image frame is not a shadow, and element 1 indicates that the corresponding area in the image frame is a shadow, for subsequent comparison with the shadow area segmentation results of the previous frame and the first frame of the m-frame image.

[0082] In step 3, the shadow area segmentation results of the current image frame, the previous frame of the current image frame, and the shadow area segmentation results of the previous m frames of the current image frame are input into the dynamic behavior prediction model to obtain the segmentation result variation, including:

[0083] A first feature matrix of the current image frame is obtained from the dynamic behavior prediction model, a second feature matrix of the previous m frames of the current image frame is obtained from the shadow area segmentation results of the previous m frames of the current image frame, and a fourth feature matrix of the previous frame is obtained from the shadow area segmentation results of the previous frame. The second feature matrix is ​​used as a historical flow for segmentation reference, and the first feature matrix and the fourth feature matrix are compared. For the same area, when the elements of the first feature matrix and the fourth feature matrix are consistent, the element value corresponding to the area is 0; when the elements of the first feature matrix and the fourth feature matrix are inconsistent, the element value corresponding to the area is 1; the values ​​corresponding to multiple areas are represented as a matrix of element 0 and element 1 to obtain a change in the segmentation result.

[0084] Specifically, in the process of obtaining the variation of the segmentation result, an exclusive OR operation (abbreviated as xor) is used, that is, the same elements in the image frame are taken as 0, and the different elements are taken as 1. Figure 4As shown in the figure, assume that an image frame is a matrix composed of four elements. In order from left to right and from top to bottom, the four elements of the previous frame (t-1) are 0, 1, 0, 1, and the four elements of the current frame (t) are 0, 0, 1, 0. The elements of the previous frame and the elements of the current frame are XORed to obtain the matrix 0, 1, 0, 0; in the matrix obtained by the XOR operation, 0 represents that the elements of the current image frame are not changed compared with the elements of the previous frame, and 1 represents that the elements of the current image frame are changed compared with the elements of the previous frame.

[0085] Therefore, based on the above method, in step 4, the shadow area segmentation result of the previous frame is modified according to the segmentation result variation to obtain the shadow area segmentation result of the current image frame, such as Figure 5 As shown, including:

[0086] In step 40, the element value of each region is obtained from the segmentation result variation.

[0087] The element value here is the value in the element matrix obtained after the XOR operation.

[0088] In step 41, for the same area, when the element value of the area is 0, the output result is True, and the shadow area segmentation result of the corresponding area is the shadow area detection result of the previous frame; when the element value of the area is 1, the output result is False, then the shadow area detection result of the previous frame is flipped to obtain the shadow area segmentation result of the corresponding area.

[0089] In step 42, the shadow area segmentation results of each area are integrated to obtain the shadow area segmentation result of the current image frame.

[0090] In summary, the dynamic behavior prediction model mentioned in the above method, such as Figure 6As shown, the dynamic behavior prediction model specifically includes a self-attention layer, a long-term attention layer, a short-term attention layer and a multi-layer perceptron. Among them, the self-attention layer is used to learn the shadow features of the current image frame to obtain a first feature matrix; the long-term attention layer obtains the second feature matrix of the first m frames of the current image frame, and calculates the second feature matrix with the first feature matrix to obtain a third feature matrix; the short-term attention layer obtains the fourth feature matrix of the previous frame, and calculates the fourth feature matrix with the first feature matrix to obtain a fifth feature matrix; the multi-layer perceptron is used to combine the first feature matrix, the third feature matrix and the fifth feature matrix to obtain the change in the segmentation result of the current image frame compared to the previous frame. Specifically, the long-term attention layer and the short-term attention layer adopt the transformer attention mechanism, which is realized by calculating the matrix multiplication operation between the query (Query, abbreviated as Q), the key (Key, abbreviated as K) and the value (Value, abbreviated as V).

[0091] Among them, Figure 7 As shown, the self-attention layer calculates the current image frame as Q, K, and V, the long-term attention layer calculates the previous m frames of the current image frame as Q, and the current image frame as K and V; the short-term attention layer calculates the previous frame of the previous image frame as Q, and the current image frame as K and V; wherein, the purpose of the long-term attention layer calculating the previous m frames of the current image frame as Q is that, since the previous m frames are the result of segmentation by the large segmentation model, they can be used as a segmentation experience reference for training the model, and provide historical information reference for the segmentation of the current image frame, and the calculation results are input into the multi-layer perceptron to calculate the output, so as to obtain the change in the segmentation result of the current image frame compared with the previous frame.

[0092] Continue reading Figure 6 As shown, the dynamic behavior prediction model adopts an encoder and decoder structure, wherein the decoder corresponds to the multi-layer perceptron; the encoder is used to extract shadow area features from the current image frame for calculation by the self-attention layer; the decoder is used to process the combined first feature matrix, the third feature matrix and the fifth feature matrix to obtain the change in the segmentation result of the current image frame compared to the previous frame, and perform an XOR operation on the shadow area segmentation result of the previous frame and the change in the segmentation result. After the decoder performs the XOR operation, the output feature obtains the shadow area segmentation result of the current image frame.

[0093] Embodiment 2:

[0094] The embodiment of the present invention provides a ship shadow detection device based on continuous frame memory, which is applicable to the ship shadow detection method based on continuous frame memory described in Example 1. Figure 8 As shown, it includes: a video frame acquisition module, an initial stage analytical model processing module, a dynamic behavior prediction model processing module and a detection result output module. The video frame acquisition module is used to acquire image frames in the ship monitoring video; the initial stage analytical model processing module corresponds to the large segmentation model, and is used for the shadow area segmentation of the video frame in the initial stage of the ship's departure; in the actual application scenario, the initial stage analytical model processing module is also used to save the segmentation results of several frames in the initial stage to the continuous frame memory pool M. The dynamic behavior prediction model processing module is used to predict the change in the segmentation result of the current image frame relative to the previous image frame; the detection result output module is used to superimpose the shadow area segmentation result of the shadow area of ​​the shadow area of ​​the previous image frame with the change in the segmentation result of the current image frame to obtain the shadow area detection result of the current image frame. Specifically, the detection result output module is used to modify the shadow area segmentation result of the previous image frame according to the matrix element value of the segmentation result change, and is also used to save the shadow area detection result of the image frame at the current moment to the continuous frame memory pool M.

[0095] Embodiment 3:

[0096] like Fig. 9 , which is a schematic diagram of the architecture of a ship shadow detection device based on continuous frame memory according to an embodiment of the present invention. The ship shadow detection device based on continuous frame memory according to this embodiment includes one or more processors 21 and a memory 22. Fig. 9 A processor 21 is taken as an example.

[0097] The processor 21 and the memory 22 may be connected via a bus or other means. Fig. 9 The example of connecting through bus is taken in the following.

[0098] The memory 22 is a non-volatile computer-readable storage medium that can be used to store non-volatile software programs and non-volatile computer executable programs, such as the content recommendation method based on human body state in Example 1. The processor 21 executes the content recommendation method based on human body state by running the non-volatile software programs and instructions stored in the memory 22.

[0099] The memory 22 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage devices. In some embodiments, the memory 22 may optionally include a memory remotely arranged relative to the processor 21, and these remote memories may be connected to the processor 21 via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.

[0100] The program instructions / modules are stored in the memory 22, and when executed by the one or more processors 21, the content recommendation method based on human body state in the above embodiment 1 is executed, for example, the above described Figure 1 The steps shown.

[0101] Among them, the processor can be a central processing unit (CPU), or other general-purpose processors such as a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc.

[0102] An embodiment of the present invention also provides a non-volatile computer storage medium, which stores computer executable instructions. The computer executable instructions are executed by one or more processors to complete the ship shadow detection method based on continuous frame memory described in Example 1.

[0103] It is worth noting that the information interaction, execution process, etc. between the modules and units within the above-mentioned devices and systems are based on the same concept as the processing method embodiment of the present invention. The specific contents can be found in the description of the method embodiment of the present invention and will not be repeated here.

[0104] A person skilled in the art may understand that all or part of the steps in the various methods of the embodiments may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the storage medium may include: a read-only memory (ROM), a random access memory (RAM), a disk or an optical disk, etc.

[0105] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions and improvements made within the spirit and principles of the present invention should be included in the protection scope of the present invention.

Claims

1. A ship shadow detection method based on continuous frame memory, characterized in that: include: Obtain m frames of images within a predetermined time period during the ship's travel, input the m frames of images into the large segmentation model in sequence to perform semantic segmentation of the shadow area, and obtain the shadow area segmentation result corresponding to each frame of the image; After a predetermined time period, a current image frame of the ship during its travel is acquired in real time; Inputting the shadow area segmentation results of the current image frame, the previous frame of the current image frame, and the shadow area segmentation results of the previous m frames of the current image frame into the dynamic behavior prediction model to obtain a change in the segmentation results; The shadow area segmentation result of the previous frame is modified according to the segmentation result variation to obtain the shadow area segmentation result of the current image frame.

2. The ship shadow detection method based on continuous frame memory according to claim 1 is characterized in that: The process of acquiring m frames of images within a predetermined time period during the ship's travel, sequentially inputting the m frames of images into a large segmentation model for semantic segmentation of shadow areas, and obtaining shadow area segmentation results corresponding to each frame of images includes: Acquire m frames of images within a predetermined time period, and preprocess the m frames of images; The preprocessed m frames of images are input into a large segmentation model to perform semantic segmentation of shadow areas; The shadow area segmentation result is represented as a matrix of element 0 and element 1, wherein element 0 indicates that the corresponding area in the image frame is not a shadow, and element 1 indicates that the corresponding area in the image frame is a shadow.

3. The ship shadow detection method based on continuous frame memory according to claim 2 is characterized in that: The acquiring of m frames of images within a predetermined time period and preprocessing of the m frames of images comprises: Scaling the m image frames so that the image sizes of the m image frames are uniform; The pixel value distribution of the m frames of images is normalized from [0, 255] to [0, 1].

4. The ship shadow detection method based on continuous frame memory according to claim 1, characterized in that: The segmentation results of the shadow area of ​​the current image frame, the previous frame of the current image frame, and the shadow area segmentation results of the previous m frames of the current image frame are input into the dynamic behavior prediction model to obtain the segmentation result variation, which includes: Obtaining a first feature matrix of the current image frame from the dynamic behavior prediction model, obtaining a second feature matrix of the previous m frames of the current image frame from the shadow area segmentation results of the previous m frames of the current image frame, and obtaining a fourth feature matrix of the previous frame from the shadow area segmentation results of the previous frame, using the second feature matrix as a historical flow for segmentation reference, comparing the first feature matrix and the fourth feature matrix, and for the same area, when the elements of the first feature matrix and the fourth feature matrix are consistent, the element value corresponding to the area is 0; when the elements of the first feature matrix and the fourth feature matrix are inconsistent, the element value corresponding to the area is 1; The values ​​corresponding to the multiple regions are represented as a matrix of element 0 and element 1 to obtain the variation of the segmentation result.

5. The ship shadow detection method based on continuous frame memory according to claim 4 is characterized in that: The step of modifying the shadow area segmentation result of the previous frame according to the segmentation result variation to obtain the shadow area segmentation result of the current image frame comprises: Obtaining element values ​​of each region from the segmentation result variation; For the same area, when the element value of the area is 0, the output result is True, and the shadow area segmentation result of the corresponding area is the shadow area detection result of the previous frame; when the element value of the area is 1, the output result is False, then the shadow area detection result of the previous frame is flipped to obtain the shadow area segmentation result of the corresponding area; The shadow area segmentation result of each area is integrated to obtain the shadow area segmentation result of the current image frame.

6. The ship shadow detection method based on continuous frame memory according to claim 1, characterized in that: Also includes: The shadow area segmentation result of the current image frame is continuously updated in a continuous frame memory pool, wherein the shadow area detection result of the image frame at the current moment is used as the shadow area detection result of the previous frame at the next moment.

7. The ship shadow detection method based on continuous frame memory according to claim 1, characterized in that: The dynamic behavior prediction model specifically includes a self-attention layer, a long-term attention layer, a short-term attention layer and a multi-layer perceptron; The self-attention layer is used to learn the shadow features of the current image frame to obtain a first feature matrix; The long-term attention layer obtains a second feature matrix of m frames before the current image frame, and calculates the second feature matrix and the first feature matrix to obtain a third feature matrix; The short-term attention layer obtains a fourth feature matrix of the previous frame, and calculates the fourth feature matrix and the first feature matrix to obtain a fifth feature matrix; The multilayer perceptron is used to combine the first feature matrix, the third feature matrix and the fifth feature matrix to obtain a change in the segmentation result of the current image frame compared to the previous frame.

8. The ship shadow detection method based on continuous frame memory according to claim 7 is characterized in that: The dynamic behavior prediction model adopts an encoder and decoder structure, wherein the decoder corresponds to the multi-layer perceptron; the encoder is used to extract shadow area features from the current image frame for calculation by the self-attention layer; the decoder is used to process the combined first feature matrix, the third feature matrix and the fifth feature matrix to obtain the change in the segmentation result of the current image frame compared to the previous frame, and perform an XOR operation on the shadow area segmentation result of the previous frame and the change in the segmentation result.

9. A ship shadow detection device based on continuous frame memory, characterized in that: include: at least one processor; And, a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to execute the ship shadow detection method based on continuous frame memory as described in any one of claims 1-8.

10. A non-volatile computer storage medium, characterized in that: The computer storage medium stores computer executable instructions, which are executed by one or more processors to complete the ship shadow detection method based on continuous frame memory as described in any one of claims 1-8.

Citation Information

Cited By

  • Video shadow detection method and device based on dynamic prompt memory network

    CN119850651A