Waterway monitoring method, device and computer storage medium
Using deep learning algorithms and non-maximum suppression technology to identify and analyze ships in the waterway, it solves the problems of inaccurate ship positioning and difficulty in occlusion detection, achieves accurate identification and flow measurement of ships in the waterway, and improves waterway safety and intelligence. management.
Patent Information
- Application Number
- CN202210582111.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-05-26
- Publication Date
- 2024-10-15
- Estimated Expiration
- 2042-05-26
AI Technical Summary
In the existing waterway monitoring technology, ship positioning is inaccurate and it is difficult to detect blocked ships, which affects the intelligent management and safe navigation of ships in the waterway.
The ship target detection algorithm based on deep learning is used, combined with the YOLOv3 algorithm, by obtaining the video frame to be detected, identifying the ship and generating the target detection frame, analyzing the ship flow and navigation direction, and using the non-maximum suppression algorithm and generalized intersection ratio calculation. Improve detection accuracy and recall rate and solve the problem of blocked ship detection.
It achieves accurate identification and flow measurement of ships in the waterway, and improves the driving safety and intelligent management of ships in the waterway.
Smart Images

Figure CN115131743B_ABST
Abstract
Description
Technical Field
[0001] The embodiments of the present application relate to the field of image recognition technology, and in particular to a waterway monitoring method, device and computer storage medium. Background Art
[0002] The perception and acquisition of surrounding information at sea is one of the core technologies for autonomous and safe navigation of intelligent ships. Through real-time detection and high-precision identification of other ships within the visual range of the ship, intelligent autonomous avoidance and dynamic path planning can be achieved for other ships in the waterway, which has important research significance for promoting unmanned and intelligent management of ships.
[0003] The current channel ship detection scheme has major problems such as inaccurate ship positioning and difficulty in detecting obstructed ships.
[0004] In view of this, an improved waterway monitoring solution is needed to improve the various problems existing in the prior art. Summary of the invention
[0005] In view of the above problems, the present application provides a waterway monitoring method, device and computer storage mechanism, which can at least partially solve various problems in the prior art.
[0006] The first aspect of the present application provides a waterway monitoring method, comprising: obtaining each image frame to be detected in a video to be detected, and determining a target detection area of the video to be detected; identifying each ship in each image frame to be detected, and obtaining each target detection frame corresponding to each ship in each image frame to be detected; and determining the ship flow passing through the target detection area and the navigation direction of each ship based on each target detection frame of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected.
[0007] The second aspect of the present application provides a waterway detection device, comprising: an acquisition module, used to acquire each image frame to be detected in a video to be detected, and determine a target detection area of the video to be detected; an identification module, used to identify each ship in each image frame to be detected, and acquire each target detection frame corresponding to each ship in each image frame to be detected; an analysis module, used to determine the ship flow passing through the target detection area and the navigation direction of each ship based on each target detection frame of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected.
[0008] A third aspect of the present application provides a computer storage medium, characterized in that the computer storage medium stores instructions for executing the steps described in the first aspect.
[0009] To sum up, the waterway monitoring solution provided in each embodiment of the present application can accurately identify ships sailing in the waterway, so as to accurately calculate the ship flow in the waterway and the sailing direction of each ship, realize the intelligent management of ship navigation, and improve the safety of ship navigation. BRIEF DESCRIPTION OF THE DRAWINGS
[0010] In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments recorded in the embodiments of the present application. For ordinary technicians in this field, other drawings can also be obtained based on these drawings.
[0011] Figure 1 This is a processing flow chart of a waterway monitoring method according to an exemplary embodiment of the present application.
[0012] Figure 2 It is a schematic diagram of an image frame to be detected in a waterway monitoring method according to an exemplary embodiment of the present application.
[0013] Figures 3 to 8 This is a processing flow chart of the waterway monitoring method of other exemplary embodiments of the present application.
[0014] Fig. 9 It is a structural block diagram of a waterway monitoring device according to an exemplary embodiment of the present application. DETAILED DESCRIPTION
[0015] In order to enable those skilled in the art to better understand the technical solutions in the embodiments of the present application, the technical solutions in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. All other embodiments obtained by ordinary technicians in this field based on the embodiments in the embodiments of the present application should fall within the scope of protection of the embodiments of the present application.
[0016] In order to improve the accuracy and real-time performance of intelligent ship target detection, the current deep learning-based ship target detection algorithms mainly include: RCNN, Fast RCNN, FasterRCNN, SSD and YOLO algorithms.
[0017] Among them, the deep learning algorithm with fast detection speed and high accuracy is the YOLO algorithm. The ship target detection method based on the YOLOv3 algorithm can be used for monitoring and tracking of video images.
[0018] However, the current YOLO algorithm still has shortcomings in target positioning, small target detection, and detection of occluded ships, which greatly affects the accuracy and recall rate of ship target detection. In addition, it is also necessary to identify the ship flow in the target channel and the navigation direction of each ship.
[0019] In view of this, the present application provides a waterway detection solution, which can improve the various problems in the above-mentioned prior art.
[0020] The embodiments of the present application will be described in detail below in conjunction with the accompanying drawings.
[0021] Figure 1 This is a processing flow chart of a waterway monitoring method according to an exemplary embodiment of the present application. As shown in the figure, this embodiment mainly includes the following steps:
[0022] Step S102, obtaining each image frame to be detected in the video to be detected, and determining a target detection area of the video to be detected.
[0023] Optionally, the target channel in the video to be detected can be detected to determine the target detection area covering the target channel (refer to Figure 2 shown in dashed box).
[0024] Step S104, identifying each ship in each image frame to be detected, and obtaining each target detection frame corresponding to each ship in each image frame to be detected.
[0025] In this embodiment, the trained ship recognition model can be used to identify each ship in each image frame to be detected, and determine each target detection frame corresponding to each ship in each image frame to be detected (refer to Figure 2 solid line boxes shown).
[0026] Optionally, background filtering may be performed for each image frame to be detected to improve the accuracy of the ship recognition result.
[0027] Optionally, a background filtering operation may be performed using a MOG algorithm (Gaussian Mixture Model Separation algorithm).
[0028] Step S106, determining the ship flow passing through the target detection area and the navigation direction of each ship according to each target detection frame of each image frame to be detected and the target detection area of the video to be detected corresponding to the same ship.
[0029] Optionally, based on the target detection frames of the same ship corresponding to each image frame to be detected, the navigation paths corresponding to each ship can be generated, and based on the navigation paths corresponding to each ship and the target detection area of the video to be detected, the ship flow passing through the target detection area and the navigation direction of each ship relative to the target detection area can be determined.
[0030] Optionally, a ship analysis model may be used to determine the flow of ships passing through the target detection area and the navigation direction of each ship based on target detection frames of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected.
[0031] To summarize, the embodiments of the present application can accurately determine the flow of ships passing through the target detection area in the image to be detected and the navigation direction of each ship by identifying the target detection frame of the same ship corresponding to each image frame to be detected, so as to realize intelligent waterway monitoring and improve the driving safety of ships in the waterway.
[0032] Figure 3 This is another exemplary processing flow chart of the waterway monitoring method of the present application. This embodiment mainly shows a training scheme for the ship identification model for executing the above step S104. As shown in the figure, this embodiment mainly includes the following steps:
[0033] Step S302: Identify each ship in the sample image, and obtain a ship detection frame of each ship and a confidence value of each ship detection frame.
[0034] Specifically, a plurality of continuous sample images can be obtained from the sample video, and for each sample image, each ship in the sample image is detected and located to obtain a ship detection frame containing each ship (refer to Figure 2 The solid box shown in the figure), as well as the confidence value of each ship detection box.
[0035] Step S304: based on the non-maximum suppression algorithm, the confidence value of each ship detection frame is updated, and the ship detection frames whose updated confidence values are greater than a preset confidence threshold are determined as target detection frames.
[0036] Specifically, each ship detection frame can be sorted in sequence according to the size of the confidence score, and based on the sorting result and the intersection and union ratio of each ship detection frame, the confidence value of each ship detection frame is updated in sequence to determine the target detection frame of the ship to be detected.
[0037] Step S306: training a ship recognition model based on each target detection frame and each real annotation frame corresponding to each ship.
[0038] In summary, the embodiment of the present application uses a non-maximum suppression algorithm to determine the ships to be detected in the channel, which can effectively avoid the problem of missed detection of obscured ships due to the close distance between ships, and can improve the training effect of the ship recognition model.
[0039] Figure 4The processing flow chart of the waterway monitoring method of another exemplary embodiment of the present application is shown. This embodiment is a specific implementation plan of the above step S304. As shown in the figure, this embodiment mainly includes the following steps:
[0040] Step S402: determine all ship detection frames in the sample image that are not determined as non-suppression detection frames as candidate detection frames.
[0041] Step S404: According to the confidence value of each candidate detection frame, a candidate detection frame with the highest confidence value is determined as a non-suppression detection frame, and all other candidate detection frames except the non-suppression detection frame are determined as suppression detection frames.
[0042] Specifically, each candidate detection frame may be sorted according to its confidence value, the candidate detection frame with the highest confidence value may be determined as the non-suppressed detection frame, and all other candidate detection frames may be determined as suppressed detection frames of the non-suppressed detection frame.
[0043] Step S406, calculating the intersection-and-union ratio of the non-suppression detection frame relative to each suppression detection frame according to the coordinate values of the non-suppression detection frame and each suppression detection frame, and obtaining the intersection-and-union ratio of each suppression detection frame.
[0044] Specifically, the intersection and union between the non-suppressed detection frame and each suppressed detection frame can be calculated according to their respective coordinate values, and the intersection and union of the non-suppressed detection frame with respect to each suppressed detection frame can be obtained, thereby determining the intersection and union value of each suppressed detection frame.
[0045] Step S408 , selectively updating the confidence value of the suppressed detection frame according to the IoU value of each suppressed detection frame and a preset IoU threshold.
[0046] In this embodiment, for each suppressed detection frame, if the IoU value of the candidate detection frame is not greater than the IoU threshold, the IoU value of the suppressed detection frame is not updated; if the IoU value of the candidate detection frame is greater than the IoU threshold, the IoU value of the suppressed detection frame is updated.
[0047] Optionally, the confidence value of the suppressed detection box may be updated according to the intersection-and-union ratio of the suppressed detection box and a preset confidence update rule.
[0048] In this embodiment, the preset credibility update rule is expressed as:
[0049]
[0050] in, represents the confidence value of the i-th suppressed detection box, M represents the location information of the non-suppressed detection box, and b iRepresents the location information of the i-th suppressed detection box, I(M,b i ) represents the intersection-over-union ratio of the i-th suppressed detection box; N t Indicates the preset intersection-over-union ratio threshold.
[0051] Step S410, determining whether each ship detection frame in the sample image is determined as a non-suppression detection frame, if so, ending the process, if not, returning to executing step S402.
[0052] In summary, this embodiment selectively updates the confidence value of the suppressed detection frame based on the non-maximum suppression algorithm, so as to facilitate the subsequent accurate determination of the target detection frame of the ship to be detected.
[0053] Figure 5 The processing flow chart of the waterway monitoring method of another exemplary embodiment of the present application is shown. This embodiment is a specific implementation plan of the above step S306. As shown in the figure, this embodiment mainly includes the following steps:
[0054] Step S502: Determine the real labeling frame of the ship according to the ship corresponding to each target detection frame.
[0055] Specifically, according to each ship in the target detection frame, a real annotation frame corresponding to the ship is obtained from the sample label of the sample image.
[0056] Step S504, obtaining the generalized intersection-union ratio of each ship according to the target detection frame and the true annotation frame of each ship.
[0057] Optionally, the generalized intersection-and-union ratio of each ship may be obtained according to the target detection frame, the real annotation frame, and a preset generalized intersection-and-union ratio conversion rule of each ship.
[0058] In this embodiment, the preset generalized intersection-and-union ratio conversion rule can be expressed as:
[0059]
[0060] Among them, GIoU i is the generalized intersection ratio of the i-th ship, A i is the target detection frame of the i-th ship, B i is the true annotation box of the i-th ship, IOU i is the intersection and union ratio of the i-th ship, C i Based on A i and B i The area of the minimum enclosed region determined.
[0061] Step S506, determining a first loss function according to the generalized intersection-union ratio of each ship.
[0062] In this embodiment, the first loss function is expressed as:
[0063] L GIoU =1-GIoU
[0064] Among them, L GIoU represents the first loss function, and GIoU represents the generalized intersection-over-union ratio of each ship.
[0065] Step S508: training the ship recognition model based on the first loss function until the first loss function meets a preset convergence condition to obtain a trained ship recognition model.
[0066] Specifically, the ship identification model may be updated based on the first loss function, and based on the updated ship identification model, the ship detection step of step S302 may be returned to be executed until the first loss function satisfies a preset convergence condition.
[0067] Optionally, when the first loss function satisfies a preset threshold, it can be obtained that the first loss function satisfies a preset convergence condition.
[0068] Optionally, when the first loss function tends to be stable, it can be obtained that the first loss function satisfies a preset convergence condition.
[0069] In summary, this embodiment calculates the loss function of the ship identification model based on the generalized intersection-over-union ratio (GIOU) of each ship, and performs the training of the ship identification model accordingly. Since the value range of GIOU is between (-1, 1), the distance between two non-contact rectangles can be measured. When the distance between the two rectangles is infinite, the value of GIOU is -1; when the two rectangles are infinitely overlapped, the value of GIOU is 1. Therefore, the embodiment of the present application can effectively avoid the problem of poor training effect of the ship identification model due to the inability to backpropagate when the gradient is 0.
[0070] Figure 6 The flowchart of the waterway monitoring method according to another exemplary embodiment of the present application is shown. This embodiment is a specific implementation of the above step S106.
[0071] Step S602: Generate a target detection point of each target detection frame according to the center point or any vertex of each target detection frame in each video to be detected.
[0072] Optionally, the center point of each target detection frame may be determined as the target detection point of each target detection frame.
[0073] Optionally, any vertex of each target detection frame may be determined as the target detection point of each target detection frame.
[0074] Step S604, connecting multiple target detection points of the same ship in multiple consecutive image frames to be detected, and generating navigation paths corresponding to each ship.
[0075] Optionally, each image frame to be detected may be determined as a current image frame, and the previous image frame to be detected before the current image frame may be determined as a previous image frame.
[0076] Optionally, each target detection point in the current image frame may be determined as the current detection point, the distance between the current detection point and the tail end of each navigation path in the previous image frame may be calculated, and based on the distance calculation result, each navigation path corresponding to each ship may be generated, mainly including the following implementation schemes:
[0077] In one embodiment, if there is a navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, the navigation path is determined as the path to be updated, and the current detection point is connected to the end of the path to be updated, and the end of the path to be updated is updated to the current detection point.
[0078] Specifically, if there is a navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, it means that this navigation path in the previous image frame and the current detection point in the current image frame identify the same ship, then the current detection point is connected to the tail end of this navigation path.
[0079] In one embodiment, if there is no navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, a new navigation path is generated based on the current detection point.
[0080] Specifically, if there is no navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, it means that a new ship appears in the current image frame, and the navigation path of the new ship is generated based on the current detection point.
[0081] In one embodiment, for each navigation path in the previous image frame, if there is no target detection point in the current image frame whose distance from the tail end of the navigation path is less than a preset distance threshold, the navigation path is determined as a path to be predicted, and based on at least two target detection points adjacent to the tail end in the path to be predicted, a predicted detection point of the path to be predicted is generated, and the tail end of the path to be predicted is updated to the predicted detection point.
[0082] Specifically, for each navigation path in the previous image frame, if a detection point connected to the navigation path cannot be found in the current image frame, it means that there is a possibility that the ship in this navigation path is lost, and this navigation path is determined as the path to be predicted. Prediction can be performed based on the position information of the last two target detection points in the path to be predicted to generate a predicted detection point of the path to be predicted, and the predicted detection point is connected to the tail end of the path to be predicted, and the tail end of the path to be predicted is updated to the predicted detection point.
[0083] In this embodiment, the preset distance threshold may be determined based on a frame interval between two adjacent image frames to be detected.
[0084] Optionally, the number of target detection points included in each navigation path may be detected, and if the number exceeds a preset number threshold, the navigation path update operation is stopped.
[0085] Step S606, determining the flow of ships passing through the target detection area according to the positional relationship between the navigation path of each ship and the target detection area.
[0086] Optionally, a judgment result of whether the ship corresponding to each navigation path passes through the target detection area may be obtained based on the relative position relationship between a plurality of target detection points at the tail end of each navigation path and the target detection area.
[0087] Step S608, determining the navigation direction of the ship corresponding to each navigation path according to the moving direction of each navigation path and the angle relationship between each navigation path and the target detection area.
[0088] Optionally, each navigation path can be determined as the current navigation path, and the navigation direction of the ship corresponding to the current navigation path can be determined based on the angle between the current navigation path and the baseline of the target detection area and the moving direction of each target detection point in the current navigation path.
[0089] Optionally, the reference line of the target detection area may be perpendicular to the axis of the target channel in the video to be detected.
[0090] Specifically, straight line fitting can be performed according to each target detection point in the current navigation path to determine the fitting straight line of the current navigation path, and the navigation direction of the ship corresponding to the current navigation path can be determined according to the angle between the fitting straight line of the current navigation path and the baseline of the target detection area and the moving direction of each target detection point in the current navigation path.
[0091] Figure 7 The processing flow chart of the waterway monitoring method of another exemplary embodiment of the present application is shown. This embodiment is a specific implementation plan of the above step S606. As shown in the figure, this embodiment mainly includes the following steps:
[0092] Step S702: determine a navigation path as the current navigation path.
[0093] Step S704: According to each target detection point in the current navigation path, a plurality of target detection points that are close to the end of the current navigation path and meet a preset number are determined as detection points to be analyzed.
[0094] Optionally, the last two or three target detection points of the current navigation path may be determined as detection points to be analyzed.
[0095] Step S706, determining whether all the detection points to be analyzed are located in the target detection area, if so, proceeding to step S708, if not, proceeding to step S710.
[0096] Step S708, obtaining the judgment result of the ship passing through the target detection area corresponding to the current navigation path.
[0097] Step S710, obtaining a judgment result that the ship corresponding to the current navigation path has not passed through the target detection area.
[0098] Step S712, determine whether all navigation paths have been analyzed, if so, proceed to step S714, if not, return to step S702.
[0099] Step S714, counting all ships passing through the target detection area to determine the ship flow passing through the target detection area.
[0100] To summarize, the embodiments of the present application can accurately determine the ship flow in the target detection area and the navigation direction of each ship by judging the positional relationship of the navigation path corresponding to each ship relative to the target detection area, so as to realize intelligent monitoring and control of the waterway and improve the navigation safety of ships in the waterway.
[0101] Figure 8 The processing flow chart of the waterway monitoring method of another exemplary embodiment of the present application is shown. This embodiment is a training scheme for the ship analysis model of the above step S106. As shown in the figure, this example mainly includes the following steps:
[0102] Step S802, taking each target detection frame of each sample image frame corresponding to each sample ship in the sample video and the target detection area of the sample video as input for the ship analysis model to perform prediction, and outputting the predicted ship flow passing through the target detection area and the predicted sailing direction of each sample ship.
[0103] Specifically, the ship analysis model can generate navigation paths corresponding to each sample ship based on the target detection frames corresponding to each sample image frame, and predict the positional relationship of each navigation path relative to the target detection area of the sample video, so as to output the predicted ship flow passing through the target detection area and the predicted navigation direction of each sample ship.
[0104] Step S804, determining a second loss function based on the predicted ship flow through the target detection area, the actual ship flow through the target detection area, and the predicted sailing direction and the actual sailing direction of each sample ship.
[0105] Optionally, the predicted ship flow and the actual ship flow passing through the target detection area, as well as the predicted sailing direction and the actual sailing direction of each sample ship may be compared respectively to determine the second loss function.
[0106] Step S806, training the ship analysis model according to the second loss function until the second loss function meets a preset convergence condition to obtain a trained ship analysis model.
[0107] Optionally, the ship analysis model may be updated according to the second loss function, and based on the updated ship analysis model, the process returns to step S802 until the second loss function satisfies a preset convergence condition.
[0108] Optionally, when the second loss function satisfies a preset threshold, it can be obtained that the second loss function satisfies a preset convergence condition.
[0109] Optionally, when the second loss function tends to be stable, it can be obtained that the second loss function satisfies a preset convergence condition.
[0110] In summary, by using the model training scheme provided in this embodiment, a ship analysis model that accurately identifies ship flow and ship heading can be obtained to achieve intelligent monitoring of waterways.
[0111] Fig. 9 As shown in the figure, the waterway monitoring device 900 of this embodiment mainly includes an acquisition module 902 , an identification module 904 , and an analysis module 906 .
[0112] The acquisition module 902 is used to acquire each image frame to be detected in the video to be detected, and determine the target detection area of the video to be detected.
[0113] The identification module 904 is used to identify each ship in each image frame to be detected, and obtain each target detection frame corresponding to each ship in each image frame to be detected.
[0114] The analysis module 906 is used to determine the ship flow passing through the target detection area and the navigation direction of each ship according to each target detection frame of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected.
[0115] Optionally, the acquisition module 902 is further used to: detect the target channel in the video to be detected, and determine the target detection area covering all target channels.
[0116] Optionally, the recognition module 904 is further configured to: use a ship recognition model to recognize each ship in each image frame to be detected, and determine each target detection frame corresponding to each ship in each image frame to be detected.
[0117] Optionally, the waterway monitoring device 900 also includes a training module (not shown) for training the ship recognition model, which includes: identifying each ship in the sample image, obtaining a ship detection frame of each ship and a confidence value of each ship detection frame; based on a non-maximum suppression algorithm, updating the confidence value of each ship detection frame, and determining each ship detection frame whose updated confidence value is greater than a preset confidence threshold as a target detection frame; training the ship recognition model based on each target detection frame and each real annotation frame corresponding to each ship.
[0118] Optionally, the training module is also used to: execute the candidate detection frame determination step, determine all ship detection frames in the sample image that have not been determined as non-suppression detection frames as candidate detection frames; determine a candidate detection frame with the highest confidence value as a non-suppression detection frame according to the confidence value of each candidate detection frame, and determine all other candidate detection frames except the non-suppression detection frame as suppression detection frames; calculate the intersection and union ratio of the non-suppression detection frame relative to each suppression detection frame according to the respective coordinate values of the non-suppression detection frame and each suppression detection frame, and obtain the intersection and union ratio value of each suppression detection frame; selectively update the confidence value of the suppression detection frame according to the intersection and union ratio value of each suppression detection frame and a preset intersection and union ratio threshold; return to execute the candidate detection frame determination step until each ship detection frame is determined as a non-suppression detection frame.
[0119] Optionally, the training module is also used to: for each suppressed detection frame, if the intersection-and-union ratio of the candidate detection frame is not greater than the intersection-and-union ratio threshold, not update the intersection-and-union ratio of the suppressed detection frame; if the intersection-and-union ratio of the candidate detection frame is greater than the intersection-and-union ratio threshold, update the intersection-and-union ratio of the suppressed detection frame.
[0120] Optionally, the step of updating the intersection-and-union ratio of the suppressed detection frame includes: updating the confidence value of the suppressed detection frame according to the intersection-and-union ratio of the suppressed detection frame and a preset confidence update rule; the preset confidence update rule is expressed as: in, represents the confidence value of the i-th suppressed detection box, M represents the position information of the non-suppressed detection box, and b i represents the position information of the i-th suppressed detection box, the I(M,b i ) represents the intersection-and-union ratio of the i-th suppressed detection box; the N t represents the preset intersection-over-union ratio threshold.
[0121] Optionally, the training module is also used to: determine the true labeling frame of each ship according to the ship corresponding to each target detection frame; obtain the generalized intersection-and-union ratio of each ship according to the target detection frame and the true labeling frame of each ship; determine the first loss function according to the generalized intersection-and-union ratio of each ship; train the ship recognition model based on the first loss function until the first loss function meets a preset convergence condition to obtain a trained ship recognition model.
[0122] Optionally, the first loss function is expressed as:
[0123] L GIoU =1-GIoU
[0124] Among them, the L GIoU represents the first loss function, and the GIoU represents the generalized intersection-over-union ratio of each ship.
[0125] Optionally, the analysis module 906 is also used to: generate navigation paths corresponding to each ship based on the target detection frames of the same ship corresponding to each image frame to be detected; determine the ship flow passing through the target detection area and the navigation direction of each ship relative to the target detection area based on the navigation paths corresponding to each ship and the target detection area of the video to be detected.
[0126] Optionally, the analysis module 906 is also used to: generate a target detection point for each target detection frame based on the center point or any vertex of each target detection frame in each video to be detected; connect multiple target detection points of the same ship in multiple consecutive image frames to be detected to generate navigation paths corresponding to each ship.
[0127] Optionally, the analysis module 906 is also used to: determine each image frame to be detected as a current image frame, and determine the previous image frame to be detected of the current image frame as a previous image frame; determine each target detection point in the current image frame as a current detection point, and calculate the distance between the current detection point and the tail end of each navigation path in the previous image frame; if there is a navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, determine the navigation path as a path to be updated, connect the current detection point with the tail end of the path to be updated, and update the tail end of the path to be updated to the current detection point; if there is no navigation path in the previous image frame whose distance from the current detection point is less than the preset distance threshold, generate a new navigation path based on the current detection point.
[0128] Optionally, the analysis module 906 is also used to: for each navigation path in the previous image frame, if there is no target detection point in the current image frame whose distance from the tail end of the navigation path is less than a preset distance threshold, determine the navigation path as a path to be predicted, and based on at least two target detection points adjacent to the tail end in the path to be predicted, generate a predicted detection point of the path to be predicted, and update the tail end of the path to be predicted to the predicted detection point.
[0129] Optionally, the analysis module 906 is further configured to: detect the number of target detection points included in each navigation path, and if the number exceeds a preset number threshold, stop the updating operation of the navigation path.
[0130] Optionally, the analysis module 906 is also used to: determine the ship flow passing through the target detection area based on the positional relationship between the navigation path of each ship and the target detection area; determine the navigation direction of the ship corresponding to each navigation path based on the moving direction of each navigation path and the angle relationship between each navigation path and the target detection area.
[0131] Optionally, the analysis module 906 is also used to: determine each navigation path as the current navigation path, and according to the target detection points in the current navigation path, determine multiple target detection points that are close to the end of the current navigation path and meet a preset number as detection points to be analyzed; if each of the detection points to be analyzed is located in the target detection area, obtain a judgment result of the ship corresponding to the current navigation path passing through the target detection area; count all ships passing through the target detection area to determine the ship flow passing through the target detection area.
[0132] Optionally, the analysis module 906 is also used to: determine each navigation path as the current navigation path; determine the navigation direction of the ship corresponding to the current navigation path based on the angle between the current navigation path and the baseline of the target detection area, and the moving direction of each target detection point in the current navigation path.
[0133] Optionally, the reference line of the target detection area is perpendicular to the axis of the target channel in the video to be detected.
[0134] Optionally, the analysis module 906 is also used to: utilize the ship analysis model to determine the ship flow passing through the target detection area and the navigation direction of each ship based on the target detection boxes of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected.
[0135] Optionally, the training module is also used to train a ship analysis model, which includes: taking each target detection box corresponding to each sample image frame of each sample ship in the sample video and the target detection area of the sample video as input for the ship analysis model to perform prediction, and output the predicted ship flow passing through the target detection area and the predicted sailing direction of each sample ship; determining a second loss function based on the predicted ship flow passing through the target detection area, the actual ship flow passing through the target detection area, and the predicted sailing direction and the actual sailing direction of each sample ship; training the ship analysis model according to the second loss function until the second loss function meets a preset convergence condition to obtain a trained ship analysis model.
[0136] Another embodiment of the present application further provides a computer storage medium, in which instructions for executing each step in each waterway monitoring method embodiment are stored.
[0137] In summary, the waterway monitoring method, device and computer storage medium provided in each embodiment of the present application can accurately identify the ship flow and the navigation direction of each ship to provide intelligent waterway monitoring management and improve the navigation safety of waterway ships.
[0138] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the embodiments of the present application, rather than to limit them. Although the present application 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 application.
Claims
1. A waterway monitoring method, comprising: Acquire each image frame to be detected in the video to be detected, and determine the target detection area of the video to be detected; Identify each ship in each image frame to be detected, and obtain each target detection frame corresponding to each ship in each image frame to be detected; According to each target detection frame of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected, determining the ship flow passing through the target detection area and the navigation direction of each ship; The ship flow is determined according to the positional relationship between the navigation path of each ship and the target detection area; specifically, Determine each navigation path as the current navigation path, and determine multiple target detection points that are close to the tail end of the current navigation path and meet a preset number as detection points to be analyzed according to each target detection point in the current navigation path; wherein, according to the center point or any vertex of each target detection frame in each video to be detected, generate the target detection point of each target detection frame; connect multiple target detection points of the same ship in multiple consecutive image frames to be detected to generate each navigation path corresponding to each ship; If each of the detection points to be analyzed is located within the target detection area, obtaining a judgment result that the ship corresponding to the current navigation path passes through the target detection area; All ships passing through the target detection area are counted to determine the ship flow passing through the target detection area.
2. The method according to claim 1, wherein: The determining of the target detection area of the video to be detected includes: Detect the target waterway in the video to be detected, and determine the target detection area covering all target waterways.
3. The method according to claim 1, wherein: The method further comprises: using a ship recognition model to identify each ship in each image frame to be detected, and determining each target detection frame corresponding to each ship in each image frame to be detected; The ship identification model is trained in the following way: Identify each ship in the sample image, and obtain a ship detection frame of each ship and a confidence value of each ship detection frame; Based on the non-maximum suppression algorithm, the confidence value of each ship detection frame is updated, and the ship detection frames whose updated confidence values are greater than the preset confidence threshold are determined as the target detection frames; The ship recognition model is trained based on each target detection frame and each real annotation frame corresponding to each ship.
4. The method according to claim 3, wherein: The non-maximum suppression algorithm is used to update the confidence value of each ship detection frame, including: a candidate detection frame determination step, determining all ship detection frames in the sample image that are not determined as non-suppression detection frames as candidate detection frames; According to the confidence value of each candidate detection frame, a candidate detection frame with the highest confidence value is determined as a non-suppression detection frame, and all other candidate detection frames except the non-suppression detection frame are determined as suppression detection frames; Calculating the intersection-and-union ratio of the non-suppression detection frame relative to each suppression detection frame according to the coordinate values of the non-suppression detection frame and each suppression detection frame, and obtaining the intersection-and-union ratio value of each suppression detection frame; Selectively update the confidence value of the suppressed detection box according to the intersection-and-union ratio of each suppressed detection box and the preset intersection-and-union ratio threshold; Return to execute the candidate detection frame determination step until each ship detection frame is determined as a non-suppressed detection frame.
5. The method according to claim 4, wherein: The selectively updating the confidence value of the suppressed detection frame according to the intersection-and-union ratio value of each suppressed detection frame and the preset intersection-and-union ratio threshold value includes: For each suppressed detection box, If the IoU value of the candidate detection frame is not greater than the IoU threshold, the IoU value of the suppressed detection frame is not updated; If the IoU value of the candidate detection frame is greater than the IoU threshold, updating the IoU value of the suppressed detection frame; The step of updating the intersection-over-union ratio of the suppression detection frame includes: updating the confidence value of the suppressed detection frame according to the intersection-and-union ratio of the suppressed detection frame and a preset confidence update rule; The preset credibility update rule is expressed as: in, represents the confidence value of the i-th suppressed detection box, M represents the position information of the non-suppressed detection box, and b i represents the position information of the i-th suppressed detection box, the I(M,b i ) represents the intersection-and-union ratio of the i-th suppressed detection box; the N t represents the preset intersection-over-union ratio threshold.
6. The method according to claim 3, wherein: The training of the ship recognition model based on each target detection frame and each real annotation frame corresponding to each ship includes: Determine a true labeling frame of each ship according to the ship corresponding to each target detection frame; According to the target detection frame and the real annotation frame of each ship, the generalized intersection-union ratio of each ship is obtained; Determine the first loss function according to the generalized intersection-union ratio of each ship; Training the ship identification model based on the first loss function until the first loss function meets a preset convergence condition to obtain a trained ship identification model; The first loss function is expressed as: L GIoU =1-GIoU Among them, the L GIoU represents the first loss function, and the GIoU represents the generalized intersection-over-union ratio of each ship.
7. The method according to claim 1 or 2, wherein: Determining the navigation direction of each ship according to each target detection frame of each image frame to be detected and the target detection area of the video to be detected, including: According to each navigation path corresponding to each ship and the target detection area of the video to be detected, the navigation direction of each ship relative to the target detection area is determined.
8. The method according to claim 1, wherein: The method of connecting multiple target detection points of the same ship in multiple consecutive image frames to be detected to generate navigation paths corresponding to each ship includes: Determine each image frame to be detected as a current image frame, and determine the image frame to be detected that is a previous image frame of the current image frame as a previous image frame; Determine each target detection point in the current image frame as a current detection point, and calculate the distance between the current detection point and the tail end of each navigation path in the previous image frame; If there is a navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, the navigation path is determined as a path to be updated, the current detection point is connected to the tail end of the path to be updated, and the tail end of the path to be updated is updated as the current detection point; If there is no navigation path in the previous image frame whose distance from the current detection point is less than a preset distance threshold, a new navigation path is generated based on the current detection point.
9. The method according to claim 8, wherein: The method further comprises: For each navigation path in the previous image frame, if there is no target detection point in the current image frame whose distance from the tail end of the navigation path is less than a preset distance threshold, the navigation path is determined as a path to be predicted, and based on at least two target detection points adjacent to the tail end in the path to be predicted, a predicted detection point of the path to be predicted is generated, and the tail end of the path to be predicted is updated to the predicted detection point.
10. The method according to claim 9, wherein: The method further comprises: The number of target detection points included in each navigation path is detected, and if the number exceeds a preset number threshold, the updating operation of the navigation path is stopped.
11. The method according to claim 7, wherein: The determining, according to each navigation path corresponding to each ship and the target detection area of the video to be detected, the navigation direction of each ship relative to the target detection area includes: The navigation direction of the ship corresponding to each navigation path is determined according to the moving direction of each navigation path and the angle relationship between each navigation path and the target detection area.
12. The method according to claim 11, wherein: The determining the navigation direction of the ship corresponding to each navigation path according to the moving direction of each navigation path and the angle relationship between each navigation path and the target detection area includes: Determine each navigation path as a current navigation path; The navigation direction of the ship corresponding to the current navigation path is determined according to the angle between the current navigation path and the baseline of the target detection area and the moving direction of each target detection point in the current navigation path.
13. The method according to claim 12, wherein: The reference line of the target detection area is perpendicular to the axis of the target channel in the video to be detected.
14. The method according to claim 1, wherein: The method further comprises: using a ship analysis model, according to each target detection frame of the same ship corresponding to each image frame to be detected and the target detection area of the video to be detected, determining the ship flow passing through the target detection area and the navigation direction of each ship; The ship analysis model is trained in the following way: Taking each target detection frame corresponding to each sample image frame of each sample ship in the sample video and the target detection area of the sample video as input for the ship analysis model to perform prediction, and outputting the predicted ship flow passing through the target detection area and the predicted sailing direction of each sample ship; Determine a second loss function based on the predicted ship flow rate passing through the target detection area, the actual ship flow rate passing through the target detection area, and the predicted sailing direction and the actual sailing direction of each sample ship; The ship analysis model is trained according to the second loss function until the second loss function meets a preset convergence condition to obtain a trained ship analysis model.
15. A waterway detection device, comprising: An acquisition module is used to acquire each image frame to be detected in the video to be detected, and determine the target detection area of the video to be detected; The recognition module is used to recognize each ship in each image frame to be detected, and obtain each target detection frame corresponding to each ship in each image frame to be detected; The analysis module is used to determine the ship flow passing through the target detection area and the navigation direction of each ship according to each target detection frame of each image frame to be detected corresponding to the same ship and the target detection area of the video to be detected; wherein the ship flow is determined according to the positional relationship between the navigation path of each ship and the target detection area; specifically, Each navigation path is determined as the current navigation path, and according to each target detection point in the current navigation path, multiple target detection points that are close to the tail end of the current navigation path and meet a preset number are determined as detection points to be analyzed; wherein, according to the center point or any vertex of each target detection frame in each video to be detected, the target detection point of each target detection frame is generated; multiple target detection points of the same ship in multiple consecutive image frames to be detected are connected to generate navigation paths corresponding to each ship; if each detection point to be analyzed is located in the target detection area, a judgment result of the ship corresponding to the current navigation path passing through the target detection area is obtained; all ships passing through the target detection area are counted to determine the ship flow passing through the target detection area.
16. A computer storage medium, characterized in that: The computer storage medium stores instructions for executing the steps in the method according to any one of claims 1 to 14.
