Marine ship collision prediction method, prediction device, and electronic equipment
Through vectorized digital sea charts and ship dynamic estimates, vector diagrams for navigation trajectories are generated, which solves the problem of maritime ship collision prediction, realized real -time predictions, and improved navigation safety.
Patent Information
- Application Number
- CN202410370692.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-03-29
- Publication Date
- 2025-01-28
- Estimated Expiration
- 2044-03-29
AI Technical Summary
The prior art is difficult to effectively predict and prevent marine ship collisions, especially in complex and variable navigation environments, and lacks automated real-time prediction capabilities.
By obtaining the digital sea chart and permission, obtain the dynamic estimation flow of the monitored ship and calibrate, generate the spatial sequence of the navigation trajectory, and to vectrate it. Finally Strand collision.
A real -time bandal collision forecast of automation can be achieved, which can cope with the complex and changeable navigation environment, improve the safety of navigation, and combine it with the implementation mechanism of ship traffic management and the implementation of navigation plans.
Smart Images

Figure CN118155458B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of data processing technology, and in particular to a method, device and electronic device for predicting marine ship collisions. Background Art
[0002] With the continuous growth of global trade, ports and waterways, as the core nodes of logistics, have shouldered the mission of expanding cargo transportation. A large number of ships frequently enter and exit in a compact space, which constitutes a heavy navigation scene. This high-intensity transportation demand shortens the distance between ships, thereby increasing the complexity of scheduling ships to avoid collisions and maintain safe distances, and increasing the risk of grounding and collision. In addition, the navigation of ships is also deeply affected by various natural factors such as weather and hydrological conditions. For example, strong winds, heavy fog, water currents, tides, etc. can all interfere with the navigation of ships. Under these unfavorable conditions, the control of ships becomes more difficult, and any negligence may lead to grounding and collision.
[0003] In order to reduce the risk of ship grounding and collision, on the one hand, it is necessary to strengthen ship traffic management, optimize navigation plans, and ensure the orderly navigation of ships in the waterway. On the other hand, it is necessary to enhance communication and coordination between ships and build an effective information sharing mechanism to improve the safety and efficiency of navigation.
[0004] However, although the above-mentioned scheme to reduce ship grounding and collision is feasible in theory, in actual operation, due to the complexity and variability of the ship's navigation environment, factors such as water current, wind direction, visibility, etc. may affect the navigation safety of the ship. Especially in severe weather or sea conditions, the risk of ship grounding and collision is still significant. In addition, the implementation of ship traffic management and navigation plans requires a sound management and supervision mechanism as a guarantee. However, in actual operation, there may be problems such as poor management and inadequate supervision, which makes it difficult for these measures to play an effective role. At the same time, communication and coordination between ships also require the establishment of an effective supervision mechanism to ensure the accuracy and timeliness of information. Summary of the invention
[0005] The purpose of this application is to propose a method, device and electronic equipment for predicting marine ship collisions, so as to solve or alleviate the technical problems existing in the prior art.
[0006] A method for predicting marine ship collisions, comprising:
[0007] Acquiring a digital nautical chart, and vectorizing the digital nautical chart to obtain a vector nautical chart;
[0008] Acquiring a dynamic estimation flow of the monitored ship and calibrating the dynamic estimation flow to generate a spatial sequence of navigation trajectories;
[0009] Vectorizing the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector diagram;
[0010] According to the vector nautical chart and the navigation track vector chart, it is determined whether the monitored ship will run aground or collide.
[0011] A marine ship collision prediction device, comprising:
[0012] A nautical chart vectorization unit, used for acquiring a digital nautical chart and vectorizing the digital nautical chart to obtain a vector nautical chart;
[0013] A calibration unit, used for acquiring a dynamic estimation flow of the monitored ship and calibrating the dynamic estimation flow to generate a spatial sequence of navigation trajectories;
[0014] A sequence vectorization unit, used for vectorizing the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector map;
[0015] The estimation unit is used to determine whether the monitored ship will run aground or collide based on the vector chart and the navigation track vector map.
[0016] An electronic device comprising:
[0017] one or more processors;
[0018] A computer readable medium configured to store one or more programs,
[0019] When the one or more programs are executed by the one or more processors, the one or more processors implement the method described in any embodiment of the present application.
[0020] The present application provides a method, device and electronic device for predicting marine ship collisions. A digital nautical chart is obtained and the digital nautical chart is vectorized to obtain a vector nautical chart; a dynamic estimation stream of a monitored ship is obtained and the dynamic estimation stream is calibrated to generate a spatial sequence of navigation trajectories; the spatial sequence of navigation trajectories is vectorized to obtain a navigation trajectory vector diagram; and based on the vector nautical chart and the navigation trajectory vector diagram, it is determined whether the monitored ship will run aground or collide, thereby realizing automated real-time prediction of grounding or collision, being able to cope with the impact of the complexity and variability of the ship's navigation environment on the navigation safety of the ship, and when combined with the management and supervision mechanism for ship traffic management and the implementation of the navigation plan, the safety of the ship's navigation is ensured as much as possible. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] Hereinafter, some specific embodiments of the present application will be described in detail in an exemplary and non-limiting manner with reference to the accompanying drawings. The same reference numerals in the accompanying drawings indicate the same or similar components or parts. It should be understood by those skilled in the art that these drawings are not necessarily drawn to scale. In the accompanying drawings:
[0022] Figure 1 A schematic flow chart of a method for predicting marine ship collisions according to an embodiment of the present application.
[0023] Figure 2 This is a schematic structural diagram of a marine ship collision prediction device according to an embodiment of the present application.
[0024] Figure 3 Schematic diagram of the structure of the electronic device of this embodiment.
[0025] Figure 4 Detailed description of the hardware structure of the electronic device of this embodiment. DETAILED DESCRIPTION
[0026] 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.
[0027] Figure 1 FIG. 1 is a flow chart of a method for predicting a marine ship collision according to an embodiment of the present application. Figure 1 As shown, it includes:
[0028] S101, obtaining a digital nautical chart, and vectorizing the digital nautical chart to obtain a vector nautical chart;
[0029] S102, obtaining a dynamic estimation flow of the monitored ship, and calibrating the dynamic estimation flow to generate a spatial sequence of the navigation trajectory;
[0030] S103, vectorizing the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector map;
[0031] S104: judging whether the monitored ship will run aground or collide according to the vector nautical chart and the navigation track vector map.
[0032] The present application provides a method, device and electronic device for predicting marine ship collisions. A digital nautical chart is obtained and the digital nautical chart is vectorized to obtain a vector nautical chart; a dynamic estimation stream of a monitored ship is obtained and the dynamic estimation stream is calibrated to generate a spatial sequence of navigation trajectories; the spatial sequence of navigation trajectories is vectorized to obtain a navigation trajectory vector diagram; and based on the vector nautical chart and the navigation trajectory vector diagram, it is determined whether the monitored ship will run aground or collide, thereby realizing automated real-time prediction of grounding or collision, being able to cope with the impact of the complexity and variability of the ship's navigation environment on the navigation safety of the ship, and when combined with the management and supervision mechanism for ship traffic management and the implementation of the navigation plan, the safety of the ship's navigation is ensured as much as possible.
[0033] Optionally, vectorizing the digital nautical chart to obtain a vector nautical chart includes:
[0034] Performing element segmentation on the digital nautical chart to determine a vector matrix description in the digital nautical chart;
[0035] Vectorizing the vector base description to generate vector layer elements;
[0036] A vector chart is generated according to the vector layer elements.
[0037] To this end, by dividing the elements in the digital chart into a finer vector matrix description, each chart element (such as coastline, channel, shoal, etc.) can be represented in a more precise way. Compared with the traditional pixel map, the accuracy of the chart elements is guaranteed. In addition, because the vector map describes the graphics through mathematical formulas, instead of storing the color information of each pixel like a pixel map, it saves storage space and improves data processing speed for the ship collision prediction system that needs to process a large amount of chart data.
[0038] The following is a code for product implementation to illustrate the implementation of vectorizing the digital chart to obtain a vector chart:
[0039] # Assume there is a function load_digital_chart() that loads a digital chart
[0040] def vectorize_digital_chart(digital_chart):
[0041] # Element segmentation of digital charts
[0042] segmentation_result = segment_map_elements(digital_chart)
[0043] # Determine the vector matrix description and vectorize it
[0044] vector_features = []
[0045] for element in segmentation_result:
[0046] vector_description = describe_vector_base(element)
[0047] vector_layer_element = vectorize_description(vector_description)
[0048] vector_features.append(vector_layer_element)
[0049] # Generate vector charts based on vector layer elements
[0050] vector_sea_chart = VectorSeaChart()
[0051] for feature in vector_features:
[0052] vector_sea_chart.add_feature(feature)
[0053] return vector_sea_chart
[0054] def segment_map_elements(digital_map_image):
[0055] def describe_vector_base(segmented_element):
[0056] def vectorize_description(description):
[0057] # Load digital chart
[0058] digital_chart = load_digital_chart()
[0059] # Vectorized digital charts
[0060] vectorized_sea_chart = vectorize_digital_chart(digital_chart)
[0061] Optionally, the performing element segmentation on the digital nautical chart to determine the vector matrix description in the digital nautical chart includes:
[0062] Performing feature extraction on the digital nautical chart to generate a texture feature vector, a color feature vector, and a morphology feature vector;
[0063] Performing feature space clustering analysis on the texture feature vector, the color feature vector, and the morphology feature vector to obtain a family of nautical chart elements;
[0064] According to the nautical chart element family, a land description, a water description, a coastline description, and a waterway description are generated and corresponding description tags are assigned;
[0065] A vector matrix description in the digital nautical chart is generated according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels.
[0066] To this end, by extracting features from digital nautical charts, including texture features, color features, and morphological features, the automatic recognition and segmentation of nautical chart elements can be achieved, reducing the workload of manual annotation and improving work efficiency. In addition, through the generation of feature vectors and feature space clustering analysis, different geographical elements such as land, water, coastline, and waterway in the nautical chart can be accurately distinguished, making the classification more scientific and objective, and reducing the errors caused by human judgment. Furthermore, according to the nautical chart element family, the corresponding land, water, coastline, and waterway descriptions are generated, and description labels are assigned, converting the originally unstructured nautical chart information into a structured vector matrix description, which is conducive to the subsequent use of data.
[0067] In product implementation, the above-mentioned element segmentation of the digital nautical chart to determine the vector matrix description in the digital nautical chart is developed based on Python and OpenCV libraries, and its exemplary code is as follows:
[0068] import cv2
[0069] from sklearn.cluster import KMeans
[0070] from skimage.feature import texture, color_feature, shape_features
[0071] from sklearn.preprocessing import StandardScaler
[0072] from shapely.geometry import Polygon, LineString
[0073] # digital_map is the loaded digital chart image
[0074] digital_map = cv2.imread('digital_sea_chart.png')
[0075] # Feature extraction
[0076] texture_vectors = texture_features(digital_map)
[0077] color_vectors = color_feature(digital_map)
[0078] shape_vectors = shape_features(extract_shape_info(digital_map))
[0079] # Feature normalization
[0080] scaler = StandardScaler()
[0081] features = scaler.fit_transform(np.concatenate((texture_vectors,color_vectors, shape_vectors), axis=1))
[0082] # Feature space clustering analysis
[0083] kmeans = KMeans(n_clusters=4) # Preset 4 categories (land, water, coastline, waterway)
[0084] labels = kmeans.fit_predict(features)
[0085] # Map the clustering results back to the image coordinate system to generate the corresponding geographic feature description
[0086] land_description = []
[0087] water_description = []
[0088] coastline_description = []
[0089] channel_description = []
[0090] for label in np.unique(labels):
[0091] mask = (labels == label).reshape(digital_map.shape[:2])
[0092] # Process each clustering result
[0093] if is_land(mask): # Determine whether it is land
[0094] land_polygons = extract_polygons(mask)
[0095] land_description.extend(land_polygons)
[0096] elif is_water(mask): # Determine whether it is a water area
[0097] water_description.append(mask_to_polygon(mask))
[0098] elif is_coastline(mask): # Determine whether it is a coastline
[0099] coastline_description.extend(extract_lines(mask))
[0100] elif is_channel(mask): # Determine whether it is a channel
[0101] channel_description.extend(extract_channel_lines(mask))
[0102] # Assign description tags
[0103] for geom, label in zip([land_description, water_description, coastline_description, channel_description], ['land', 'water', 'coastline', 'channel']):
[0104] for element in geom:
[0105] element['label'] = label
[0106] # Generate vector matrix description
[0107] vector_basemap_description = {
[0108] 'land': land_description,
[0109] 'water': water_description,
[0110] 'coastline': coastline_description,
[0111] 'channel': channel_description
[0112] }
[0113] Optionally, generating the vector matrix description in the digital nautical chart according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels includes:
[0114] Based on the description labels, the land description, the water description, and the coastline description are classified to obtain a land feature category set, a water feature category set, and a coastline feature category set;
[0115] Generate a feature category set topological structure according to the land feature category set, the water feature category set, and the coastline feature category set;
[0116] A vector matrix description in the digital nautical chart is generated according to the feature category set topological structure.
[0117] To this end, by identifying and segmenting different geographic elements from digital nautical charts, human intervention is significantly reduced, and data processing efficiency and accuracy are improved. In addition, by quantitatively extracting the texture, color and morphological features of the nautical chart, complex image information is converted into feature vectors that can be measured and compared, which is conducive to subsequent rapid processing. In addition, multiple features such as texture, color and morphological features are comprehensively considered to better adapt to the presentation of nautical charts under different environmental conditions and avoid misjudgments caused by a single feature. Finally, the topological structure is generated based on the feature category set, which can effectively express the connection and adjacency between geographic elements, such as the boundary relationship between the coastline and land and water, and the relationship between the waterway and water.
[0118] In product implementation, based on the design of a specific GIS library (such as GDAL, Shapely, GeoPandas, etc.), the exemplary code for generating the vector matrix description in the digital nautical chart according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels is as follows:
[0119] # Assume that there is a preprocessing module for reading and preliminarily processing the nautical chart data, which contains land descriptions, water descriptions, coastline descriptions, channel descriptions and their corresponding labels
[0120] class VectorBasemapGenerator:
[0121] def __init__(self, land_descriptions, water_descriptions,coastline_descriptions, route_descriptions, tags):
[0122] self.land_desc = land_descriptions
[0123] self.water_desc = water_descriptions
[0124] self.coastline_desc = coastline_descriptions
[0125] self.route_desc = route_descriptions
[0126] self.tags = tags
[0127] def classify_features(self):
[0128] # Classification based on description tags
[0129] land_classes = classify_by_tags(self.land_desc, self.tags)
[0130] water_classes = classify_by_tags(self.water_desc, self.tags)
[0131] coastline_classes = classify_by_tags(self.coastline_desc,self.tags)
[0132] return land_classes, water_classes, coastline_classes
[0133] def generate_topology(self, land_classes, water_classes,coastline_classes):
[0134] #Build the feature category set topology
[0135] topology = build_topology(land_classes, water_classes,coastline_classes)
[0136] Return topology
[0137] def create_vector_basemap(self, topology):
[0138] # Generate vector matrix description based on topological structure
[0139] vector_basemap = VectorBasemap()
[0140] for feature_class in topology:
[0141] for geom, attributes in feature_class.geometries.items():
[0142] vector_feature = VectorFeature(geometry=geom,attributes=attributes)
[0143] vector_basemap.add_feature(vector_feature)
[0144] return vector_basemap
[0145] # Implement the function
[0146] def classify_by_tags(descriptions, tags):
[0147] def build_topology(land_classes, water_classes, coastline_classes):
[0148] generator = VectorBasemapGenerator(land_data, water_data,coastline_data, route_data, tag_data)
[0149] land_classes, water_classes, coastline_classes = generator.classify_features()
[0150] topology = generator.generate_topology(land_classes, water_classes,coastline_classes)
[0151] vector_basemap = generator.create_vector_basemap(topology)
[0152] Optionally, generating a vector matrix description in the digital nautical chart according to the feature category set topological structure includes:
[0153] Determining vector matrix attributes based on the feature category set topological structure, and encoding the matrix attributes to obtain vector matrix encoding values;
[0154] Associating the vector base encoding value with the vector base geometric information to generate a vector feature object;
[0155] Performing feature space index construction on the vector feature object to obtain a vector feature index;
[0156] A vector matrix description in the digital nautical chart is generated according to the vector feature index.
[0157] To this end, by determining the attributes of the vector matrix and encoding them, the data storage space can be effectively compressed, and it is easy to quickly identify and process various types of geographic features, such as different types of land, water, coastline and waterway, thereby improving the real-time prediction. In addition, the coded value is associated with the vector matrix geometric information to form a vector feature object, which can intuitively express the spatial position and shape of the geographic entity. Moreover, through encoding, rich non-spatial attribute information can be recorded, giving the digital chart more semantic connotations. Finally, constructing a vector feature index (such as R-tree, quadtree, kd-tree, etc.) improves the response speed and performance of the prediction.
[0158] In product implementation, the exemplary code for generating the vector matrix description in the digital nautical chart according to the feature category set topology is as follows:
[0159] class FeatureCategorySet:
[0160] # Define the VectorBody class to represent the vector body
[0161] class VectorBody:
[0162] def __init__(self, geometry, attributes):
[0163] self.geometry = geometry # Geometry information
[0164] self.attributes = attributes # Attribute dictionary, used to store information such as encoding values
[0165] # Get attributes from feature category set and encode
[0166] def determine_and_encode_attributes(category_set):
[0167] vector_body_attributes = {}
[0168] for category in category_set.categories:
[0169] # Determine attributes based on category and topology
[0170] attribute_value = calculate_attribute_value_from_topology(category)
[0171] # Encode the attributes
[0172] encoded_value = encode_attribute(attribute_value)
[0173] vector_body_attributes[category.name]= encoded_value
[0174] return vector_body_attributes
[0175] # Create vector feature object
[0176] def create_vector_feature(vector_body_attributes, geometry):
[0177] vector_body = VectorBody(geometry, vector_body_attributes)
[0178] return vector_body
[0179] # Build feature space index
[0180] def build_feature_index(vector_features):
[0181] spatial_index = SpatialIndex()
[0182] for feature in vector_features:
[0183] spatial_index.insert(feature.geometry.bounds, feature) #bounds is the bounding box corresponding to the geometric information
[0184] return spatial_index
[0185] # Generate Vector Body Description Based on Feature Index
[0186] def generate_vector_body_description(spatial_index, vector_features):
[0187] description = []
[0188] for feature_id in spatial_index.query(bounding_box_of_interest):
[0189] feature = vector_features[feature_id]
[0190] body_description = {
[0191] 'geometry': serialize_geometry(feature.geometry),
[0192] 'attributes': feature.attributes,
[0193] }
[0194] description.append(body_description)
[0195] return description
[0196] categories = load_feature_categories() # Load the set of feature categories
[0197] vector_bodies_attributes = [determine_and_encode_attributes(categories) for _ in input_geometries]
[0198] vector_features = [create_vector_feature(attrs, geom) for attrs, geom in zip(vector_bodies_attributes, input_geometries)]
[0199] spatial_index = build_feature_index(vector_features)
[0200] vector_body_descriptions = generate_vector_body_description(spatial_index, vector_features)
[0201] # Output vector basis description
[0202] output_vector_map_description(vector_body_descriptions)
[0203] Optionally, generating a vector matrix description in the digital nautical chart according to the vector feature index includes:
[0204] According to the vector feature index, risk ontology identification is performed on all the marine ship risk representations to obtain a marine ship risk representation ontology description;
[0205] The marine vessel risk characterization ontology description is semantically encoded to obtain a vector matrix description.
[0206] To this end, through risk ontology identification, complex marine ship dynamic information can be structured and organized according to risk characteristics, forming an easy-to-understand and easy-to-process marine ship risk characterization ontology description, so as to clearly show the specific risk attributes of the ship and their interrelationships, which helps to quickly locate and evaluate potential risk points. Furthermore, risk semantic coding is to convert the risk ontology description into a unified numerical coding system, which makes the originally non-quantitative risk factors quantified, facilitating subsequent risk prediction.
[0207] In product implementation, the exemplary code for generating the vector matrix description in the digital nautical chart according to the vector feature index is as follows:
[0208] # Dataset of maritime ship risk characterization (dataset) and corresponding risk feature vector (vector_features)
[0209] # Risk ontology identification stage
[0210] class RiskOntologyRecognizer:
[0211] def __init__(self):
[0212] # Initialize risk ontology model or rules
[0213] def recognize_risk_ontology(self, vector_features):
[0214] # Identify risk ontology based on vector feature index
[0215] risk_description = self.analyze_vector(vector_features)
[0216] return risk_description
[0217] # Create an instance and apply it to the dataset
[0218] recognizer = RiskOntologyRecognizer()
[0219] ship_risk_ontologies = []
[0220] for ship_data in dataset:
[0221] risk_desc = recognizer.recognize_risk_ontology(ship_data['vector_features'])
[0222] ship_risk_ontologies.append(risk_desc)
[0223] # Semantic encoding stage
[0224] class SemanticEncoder:
[0225] def __init__(self, ontology_mapping):
[0226] # Initialize the semantic coding mapping table to map the risk ontology description to the coding value
[0227] def encode_semantically(self, risk_description):
[0228] # Convert risk ontology description into semantic encoding value
[0229] semantic_code = self.map_to_code(risk_description)
[0230] return semantic_code
[0231] # Create an encoder instance and apply it to the risk ontology description
[0232] encoder = SemanticEncoder(ontology_mapping_dict)
[0233] risk_codes = []
[0234] for risk_desc in ship_risk_ontologies:
[0235] risk_code = encoder.encode_semantically(risk_desc)
[0236] risk_codes.append(risk_code)
[0237] # Apply these risk coding values to the vector matrix description generation of digital charts
[0238] generate_vector_basemap_on_digital_chart(risk_codes)
[0239] Optionally, the step of obtaining the dynamic estimation flow of the monitored ship further includes:
[0240] Collect the position, heading and speed data of the monitored ship to generate GPGGA sentences, HDT sentences and VTG sentences;
[0241] A dynamic estimation flow of the monitored ship is generated according to the GPGGA sentence, HDT sentence and VTG sentence.
[0242] To this end, by collecting the key navigation parameters of the ship in real time, the current position, heading and speed of the ship can be understood in a timely and accurate manner, which improves the dynamics of collision prediction and ensures the accuracy of the estimation. In addition, based on the continuous dynamic estimation flow (i.e. the continuously updated position, heading and speed data), the accurate simulation and prediction of the ship's motion state can be achieved, which helps to improve navigation efficiency, avoid potential collision risks, and optimize route planning.
[0243] In product implementation, the position, heading, and speed data of the monitored ship are collected to generate GPGGA statements, HDT statements, and VTG statements; according to the GPGGA statements, HDT statements, and VTG statements, an exemplary code for generating a dynamic estimation flow of the monitored ship is as follows:
[0244] class Vessel:
[0245] def __init__(self):
[0246] self.position = (0.0, 0.0)
[0247] self.heading = 0.0
[0248] self.speed_over_ground = 0.0
[0249] def update_data(self, lat, lon, heading, sog): # Update real-time ship data
[0250] self.position = (lat, lon)
[0251] self.heading = heading
[0252] self.speed_over_ground = sog
[0253] def generate_nmea_sentences(self):
[0254] gpgga_sentence = f'$GPGGA,{datetime.now().strftime("%H%M%S.%f")},{self.position[0]:.4f},{self.position[1]:.4f},1,08,0.9,545.4,M,46.9,M,,*{calculate_checksum(gpgga_sentence)}'
[0255] hdt_sentence = f'$HDT,{self.heading:.2f}*{calculate_checksum(hdt_sentence)}'
[0256] vtg_sentence = f'$GPVTG,{self.speed_over_ground:.2f},T,{self.heading:.2f},M,000.0,N,000.0,K,A*{calculate_checksum(vtg_sentence)}'
[0257] return [gpgga_sentence, hdt_sentence, vtg_sentence]
[0258] def calculate_checksum(sentence):
[0259] return checksum
[0260] ship = Vessel()
[0261] ship.update_data(37.7749, -122.4194, 170.0, 15.0) sentences = ship.generate_nmea_sentences() # Generate NMEA sentence list
[0262] # Build the dynamic estimation flow of the ship based on these statements
[0263] dynamic_estimate_stream = {
[0264] 'timestamp': datetime.now(),
[0265] 'gpgga': sentences[0],
[0266] 'hdt': sentences[1],
[0267] 'vtg': sentences[2],
[0268] 'position': ship.position,
[0269] 'heading': ship.heading,
[0270] 'speed_over_ground': ship.speed_over_ground,
[0271] Optionally, the collecting of the position, heading and speed data of the monitored vessel to generate GPGGA sentences, HDT sentences and VTG sentences includes:
[0272] The collected data of the position, heading and speed of the monitored ship are encoded in the order of timestamps to obtain an ASCII code character stream;
[0273] Generate GPGGA statements, HDT statements and VTG statements based on the ASCII code character stream.
[0274] To this end, the position, heading and speed data are encoded into ASCII character streams for easy storage and further processing. Furthermore, organizing the data in the order of timestamps helps to maintain the temporal consistency of the data, which is useful for subsequent real-time monitoring and can accurately reflect the state changes of the ship at different times. Finally, the ASCII character stream greatly improves the efficiency of data processing, reduces the complexity of prediction, and improves the timeliness of prediction.
[0275] When the product is implemented, the exemplary code for collecting the position, heading, and speed data of the monitored ship to generate the GPGGA sentence, HDT sentence, and VTG sentence is as follows:
[0276] import time
[0277] def get_ship_data():
[0278] position = (40.7128, -74.0060)
[0279] heading_true = 270
[0280] speed_over_ground = 15.5
[0281] timestamp = time.time()
[0282] return position, heading_true, speed_over_ground, timestamp
[0283] # Build NMEA sentence function
[0284] def build_nmea_sentence(sentence_type, *data):
[0285] if sentence_type == 'GPGGA':
[0286] lat, lon = data[0]
[0287] gga_string = f'$GPGGA,{time.strftime("%H%M%S", time.localtime(data[3]))},{lat:.4f},{lon:.4f},0,00,0.0,M,0,M,,*{calculate_checksum(gga_string)}\r\n'
[0288] elif sentence_type == 'HDT':
[0289] # HDT statement construction
[0290] hdt_string = f'$HDT,{data[1]:.1f}*{calculate_checksum(hdt_string)}\r\n'
[0291] elif sentence_type == 'VTG':
[0292] # VTG statement construction
[0293] track_true = data[1]
[0294] speed_knots = data[2]
[0295] vtg_string = f'$GPVTG,{track_true:.1f}T,{speed_knots:.1f}N,0.0K,A*{calculate_checksum(vtg_string)}\r\n'
[0296] else:
[0297] raise ValueError("Invalid sentence type")
[0298] return gga_string if sentence_type == 'GPGGA' else hdt_string ifsentence_type == 'HDT' else vtg_string
[0299] # Checksum calculation function for the * at the end of the NMEA sentence
[0300] def calculate_checksum(sentence):
[0301] checksum = 0
[0302] for char in sentence[1:-3]:
[0303] checksum ^= ord(char)
[0304] return format(checksum, '02X')
[0305] # Get ship data and build statements
[0306] position, heading_true, speed_over_ground, timestamp = get_ship_data()
[0307] gpgga_sentence = build_nmea_sentence('GPGGA', position, None, None,timestamp)
[0308] hdt_sentence = build_nmea_sentence('HDT', heading_true, None, None)
[0309] vtg_sentence = build_nmea_sentence('VTG', heading_true, speed_over_ground)
[0310] print(f"GPGGA Sentence: {gpgga_sentence}")
[0311] print(f"HDT Sentence: {hdt_sentence}")
[0312] print(f"VTG Sentence: {vtg_sentence}")
[0313] Optionally, the calibrating the dynamic estimation flow to generate a spatial sequence of navigation trajectories includes:
[0314] Calibrate the dynamic estimation stream to generate a spatial spectrum estimate of the monitored vessel;
[0315] A spatial sequence of navigation trajectories is generated according to the spatial spectrum estimation.
[0316] To this end, the dynamic estimation flow is calibrated to ensure the accuracy of collision estimation. In addition, the spatial sequence means that the continuous changes of the ship in time and space can be tracked, which helps to accurately reflect the actual driving path of the observed ship and analyze its behavior pattern. Finally, through spatial spectrum estimation, the motion state of the ship can be characterized from multiple dimensions, such as determining the instantaneous speed, acceleration, heading change rate, etc., so as to more accurately carry out collision risk warning, route optimization design, etc.
[0317] In product implementation, the exemplary code for calibrating the dynamic estimation stream to generate a spatial sequence of navigation trajectories is as follows:
[0318] class VesselTracking:
[0319] def __init__(self, dynamic_estimates):
[0320] self.dynamic_estimates = dynamic_estimates # Obtained ship dynamic estimation data stream
[0321] def calibrate_estimate_flow(self):
[0322] # Calibrate the dynamic estimation flow
[0323] calibrated_data = self.apply_calibration_algorithm(self.dynamic_estimates)
[0324] return calibrated_data
[0325] def estimate_space_spectrum(self, calibrated_data):
[0326] # Spatial spectrum estimation, using FFT method
[0327] space_spectrum = spatial_spectral_analysis(calibrated_data)
[0328] return space_spectrum
[0329] def generate_trajectory_sequence(self, space_spectrum):
[0330] # Generate spatial sequence based on spatial spectrum estimation, including inverse transformation and / or fitting process
[0331] trajectory_sequence = reconstruct_trajectory(space_spectrum)
[0332] return trajectory_sequence
[0333] def main():
[0334] vessel_data = get_dynamic_estimates_from_sensor() # Get the ship dynamic estimation data stream
[0335] tracker = VesselTracking(vessel_data)
[0336] calibrated_data = tracker.calibrate_estimate_flow()
[0337] space_spectrum = tracker.estimate_space_spectrum(calibrated_data)
[0338] trajectory_sequence = tracker.generate_trajectory_sequence(space_spectrum)
[0339] plot_trajectory(trajectory_sequence)
[0340] Optionally, generating a spatial sequence of navigation trajectories according to the spatial spectrum estimation includes:
[0341] Performing map spectrum projection on the spatial spectrum estimation to obtain a map spectrum projection vector;
[0342] Performing spectral decomposition on the map spectrum projection vector to obtain dominant frequency components and their corresponding amplitudes;
[0343] A spatial sequence of navigation trajectories is generated according to the dominant frequency components and their corresponding amplitudes.
[0344] To this end, the spatial spectrum estimation is combined with the geographic coordinate system through map spectrum projection, so that the estimation results can better reflect the actual movement of the ship on the earth's surface and enhance the geographical relevance of the spatial data. In addition, by processing the map spectrum projection vector, spectral decomposition can extract the dominant frequency components of the ship's motion from the complex spatial signal, effectively separate the useful signal, and eliminate the noise caused by non-main dynamic factors. Furthermore, the dominant frequency components and their corresponding amplitudes can reveal the typical motion mode of the ship (such as uniform straight-line navigation, curved navigation with a constant turning radius, etc.), improving the accuracy of the prediction. Finally, by focusing on the dominant frequency components, this method can generate a more concise spatial spectrum estimate that represents the core motion characteristics of the ship, avoiding the influence of redundant data, and facilitating subsequent data analysis and processing. More importantly, compared with directly processing the original data, spectral decomposition can reduce the dimensionality of complex spatiotemporal trajectory data and reduce the amount of calculation. It also facilitates data compression, storage and transmission, ensuring the real-time prediction.
[0345] In product implementation, the exemplary code for generating a spatial sequence of navigation trajectories according to the spatial spectrum estimation is as follows:
[0346] import numpy as np
[0347] from scipy.signal import periodogram, welch
[0348] from sklearn.decomposition import PCA
[0349] ship_positions = ... # 2D or 3D numpy array
[0350] # Spatial spectrum estimation (using Welch method for power spectral density estimation)
[0351] frequencies, psd = welch(ship_positions, nperseg=appropriate window length, fs=sampling frequency)
[0352] # Step 2: Map spectrum projection (here it is assumed that there is already a map projection function project_to_map)
[0353] map_projected_spectrum = project_to_map(psd, ship_positions)
[0354] # Convert the projected spectrum into vector form for subsequent spectrum decomposition
[0355] map_projection_vector = map_projected_spectrum.flatten()
[0356] # Spectral decomposition (using PCA)
[0357] pca = PCA()
[0358] dominant_components = pca.fit_transform(map_projection_vector)
[0359] # Get the dominant frequency component and its corresponding amplitude
[0360] dominant_frequency = frequencies[pca.explained_variance_ratio_.argmax()]
[0361] dominant_amplitude = pca.components_[0].dot(map_projection_vector)
[0362] # Generate spatial spectrum estimate based on dominant frequency components and amplitudes
[0363] estimated_spatial_spectrum = generate_spatial_spectrum(dominant_frequency, dominant_amplitude, ship_positions)
[0364] Optionally, performing spectral decomposition on the map spectrum projection vector to obtain dominant frequency components and their corresponding amplitudes includes:
[0365] Performing discrete Fourier transform on the map spectrum projection vector to obtain a frequency complex array;
[0366] The frequency complex array is subjected to frequency and amplitude separation to obtain a dominant frequency component and its corresponding amplitude.
[0367] To this end, DFT is used to convert data in the time domain or space domain into the frequency domain, thereby revealing the periodicity and frequency characteristics in the data. In the ship monitoring scenario, DFT can be used to discover the main dynamic modes of ship motion at different spatial scales, such as its main moving direction or periodic change law. In addition, the dominant frequency component usually represents the most significant dynamic behavior in the data. By finding and extracting the dominant frequency and its amplitude, complex spatial spectrum data can be simplified and only the most representative features can be retained, which is very valuable for monitoring important dynamic behaviors of ships (such as heading, speed fluctuations, etc.) and anomaly detection. Furthermore, the fast Fourier transform (FFT) greatly reduces the computing resources and time required for spectral analysis on large data sets. By identifying and removing unnecessary high-frequency noise components, the quality of the signal and the accuracy of data analysis can be improved, which helps to improve the performance and reliability of the entire system.
[0368] In product implementation, the exemplary code for performing spectral decomposition on the map spectrum projection vector to obtain the dominant frequency component and its corresponding amplitude is as follows:
[0369] import numpy as np
[0370] # Time series of ship position sequence after map projection
[0371] map_projection_vector = np.array([...])
[0372] # Perform discrete Fourier transform on the map spectrum projection vector
[0373] freq_domain_data = np.fft.fft(map_projection_vector)
[0374] # Get frequency complex array
[0375] # freq_domain_data is already frequency domain data, where the real part corresponds to the amplitude and the imaginary part corresponds to the phase
[0376] amplitudes = np.abs(freq_domain_data) # Extract amplitude (amplitude)
[0377] frequencies = np.fft.fftfreq(map_projection_vector.size) # Calculate frequency array
[0378] # Find the dominant frequency components and their corresponding amplitudes
[0379] dominant_frequency_index = np.argmax(amplitudes)
[0380] dominant_frequency = frequencies[dominant_frequency_index]
[0381] dominant_amplitude = amplitudes[dominant_frequency_index]
[0382] # Output dominant frequency and amplitude
[0383] print(f"Dominant frequency: {dominant_frequency}")
[0384] print(f"Dominant amplitude: {dominant_amplitude}")
[0385] # Restore the frequency-amplitude pairs to real form and create an array
[0386] dominant_freq_amp_pairs = [(frequencies[i], amplitudes[i]) for i inrange(len(frequencies))]
[0387] Optionally, generating a spatial sequence of navigation trajectories according to the dominant frequency components and their corresponding amplitudes includes:
[0388] Performing maximum likelihood estimation of spatial features according to the dominant frequency components and their corresponding amplitudes to obtain spatial component estimation;
[0389] A spatial sequence of navigation trajectories is generated based on the spatial component estimation.
[0390] To this end, by focusing on the dominant frequency components, the noise impact caused by non-dominant frequencies can be effectively filtered out, the signal-to-noise ratio of the ship's dynamic signal can be improved, and the real motion pattern of the ship can be more accurately identified and tracked. In addition, spatial spectrum estimation can help extract the main spatial characteristics of ship motion, such as heading changes, roll, pitch, etc., which is crucial for understanding the behavior of ships in the marine environment. Furthermore, by performing maximum likelihood estimation based on the dominant frequency components, a simplified prediction difficulty can be constructed, which is convenient for subsequent prediction, control and anomaly detection work, and reduces computational complexity.
[0391] When the product is implemented, the exemplary code for generating the spatial sequence of the navigation trajectory according to the dominant frequency component and its corresponding amplitude is as follows:
[0392] import numpy as np
[0393] from scipy.signal import periodogram
[0394] from scipy.optimize import minimize # Use the method of minimizing the error function to perform maximum likelihood estimation
[0395] # data is the time series data of the collected ship dynamic signal
[0396] data = get_ship_signal_data()
[0397] # Calculate the spectrum of the signal and find the dominant frequency component and its amplitude
[0398] freqs, psd = periodogram(data)
[0399] dominant_freq, dominant_amplitude = find_dominant_frequency(freqs,psd)
[0400] # Define the function of maximum likelihood estimation of spatial features
[0401] def spatial_feature_likelihood_estimate(params, freq, amp):
[0402] # params is the spatial feature variable to be estimated
[0403] # freq and amp are the known dominant frequency and its amplitude
[0404] # Spatial feature model and calculate likelihood function
[0405] likelihood
[0406] return-likelihood
[0407] # Initialize the initial guess value of the spatial feature parameters
[0408] initial_guess = np.array([...])
[0409] # Use minimization method to estimate spatial features
[0410] result = minimize(spatial_feature_likelihood_estimate, initial_guess,args=(dominant_freq, dominant_amplitude))
[0411] # Get the estimated spatial component
[0412] space_components_estimate = result.x
[0413] # Generate spatial spectrum estimate based on spatial component estimate
[0414] estimated_space_spectrum = generate_space_spectrum(space_components_estimate)
[0415] Optionally, performing spectral decomposition on the map spectrum projection vector to obtain dominant frequency components and their corresponding amplitudes includes:
[0416] Performing modal decomposition on the map spectrum projection vector to obtain a modal component vector;
[0417] Extracting frequency features from the modal component vector;
[0418] Based on the extracted frequency features, the dominant frequency component and its corresponding amplitude are determined.
[0419] To this end, modal decomposition can decompose the system response into independent modal components, which correspond to the possible frequency and vibration characteristics of the collision, thereby improving the accuracy of collision prediction. In addition, by extracting the main modal components, the data dimension can be reduced and the focus can be placed on the features with significant impact, thereby simplifying the analysis process and improving the efficiency of subsequent processing.
[0420] In product implementation, the exemplary code for performing spectral decomposition on the map spectrum projection vector to obtain the dominant frequency component and its corresponding amplitude is as follows:
[0421] import numpy as np
[0422] from scipy.linalg import eig
[0423] # map_projection_vector map spectrum projection vector
[0424] map_projection_vector = np.array([...]) # The actual data should be.
[0425] # Convert vector to matrix for eigenvalue decomposition
[0426] matrix_form = construct_matrix_from_vector(map_projection_vector)
[0427] # Perform eigenvalue decomposition on the matrix to obtain modal components
[0428] eigenvalues, eigenvectors = eig(matrix_form)
[0429] # Extract modal frequencies (square roots of eigenvalues)
[0430] modal_frequencies = np.sqrt(np.abs(eigenvalues))
[0431] # Sort by modal frequency and select the dominant frequency
[0432] dominant_frequency_index = np.argsort(modal_frequencies)[-1]
[0433] dominant_frequency = modal_frequencies[dominant_frequency_index]
[0434] # Extract the modal amplitude (eigenvector) corresponding to the dominant frequency
[0435] dominant_mode = eigenvectors[:, dominant_frequency_index]
[0436] # Calculate the amplitude corresponding to the dominant frequency (can be obtained through the L2 norm of the modal amplitude vector)
[0437] dominant_amplitude = np.linalg.norm(dominant_mode)
[0438] print(f"Dominant frequency: {dominant_frequency}")
[0439] print(f"Dominant amplitude: {dominant_amplitude}")
[0440] Optionally, determining the dominant frequency component and its corresponding amplitude according to the extracted frequency feature includes:
[0441] Perform frequency component analysis on the extracted frequency features to determine the frequency component distribution;
[0442] Probability density statistics are performed on the frequency component distribution to determine the dominant frequency component and its corresponding amplitude.
[0443] To this end, by carefully analyzing the frequency characteristics, the dominant frequency components in the signal can be identified and separated, and irrelevant noise or secondary frequency components can be effectively eliminated, thereby improving the signal-to-noise ratio and accuracy of signal processing. In addition, frequency component analysis can extract key features that reflect the dynamic behavior of the ship, such as heading and speed changes. These features are useful for understanding and predicting the trajectory of the ship, thereby improving the accuracy of the collision risk. Furthermore, by statistically analyzing the probability density distribution of frequency components, the relative probability and intensity of the occurrence of different frequency components can be quantified, making it easier to determine which frequency components play a dominant role overall, thereby accurately determining the key factors affecting the prediction.
[0444] When the product is implemented, the exemplary code for determining the dominant frequency component and its corresponding amplitude according to the extracted frequency characteristics is as follows:
[0445] import numpy as np
[0446] import matplotlib.pyplot as plt
[0447] from scipy.stats import kde # for probability density estimation
[0448] # Frequency features frequency_features = np.array([...])
[0449] # Perform frequency component analysis on frequency features
[0450] plt.figure(figsize=(10, 6))
[0451] plt.hist(frequency_features, bins=50, density=True, alpha=0.5, color='b', edgecolor='black')
[0452] plt.xlabel('Frequency Components')
[0453] plt.ylabel('Probability Density')
[0454] plt.title('Frequency Distribution of the Features')
[0455] plt.grid(True)
[0456] plt.show()
[0457] # Perform probability density statistics on frequency distribution using kernel density estimation (Kernel Density Estimation, KDE)
[0458] kde_model = kde.gaussian_kde(frequency_features)
[0459] # Calculate frequency range
[0460] x_min, x_max = min(frequency_features), max(frequency_features)
[0461] grid = np.linspace(x_min, x_max, 1000)
[0462] # Estimate the probability density of each frequency point
[0463] density = kde_model(grid)
[0464] # Find the frequency point with the highest probability density, which is the dominant frequency component
[0465] dominant_frequency = grid[np.argmax(density)]
[0466] # The corresponding amplitude can be estimated by the total energy of the frequency component in the original data
[0467] # Calculate amplitude
[0468] dominant_amplitude = calculate_amplitude_at_frequency(frequency_features, dominant_frequency)
[0469] print(f"Dominant frequency component: {dominant_frequency}")
[0470] print(f"The amplitude corresponding to the dominant frequency component: {dominant_amplitude}")
[0471] # Draw a probability density curve
[0472] plt.figure(figsize=(10, 6))
[0473] plt.plot(grid, density)
[0474] plt.vlines(dominant_frequency, 0, max(density), colors='r',linestyles='dashed', label='Dominant Frequency')
[0475] plt.xlabel('Frequency')
[0476] plt.ylabel('Probability Density')
[0477] plt.title('Kernel Density Estimate of Frequency Components')
[0478] plt.legend()
[0479] plt.grid(True)
[0480] plt.show()
[0481] Optionally, vectorizing the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector map includes:
[0482] Converting the spatial sequence of the navigation trajectory into a vector coordinate system to obtain vector feature data;
[0483] Generate a composite vector layer according to the vector feature data;
[0484] The composite vector layers are fused to obtain a navigation track vector map.
[0485] Therefore, vectorization can significantly reduce storage space requirements, effectively compress data volume, improve data processing efficiency, and ensure real-time prediction. In addition, vectorized data can be easily used for geometric operations and spatial analysis, such as calculating dynamic characteristics such as trajectory length, direction, and speed changes, as well as spatial relationship analysis with other geographic elements (such as determining whether to enter a specific area).
[0486] In product implementation, the exemplary code for vectorizing the spatial sequence of the navigation trajectory to obtain the navigation trajectory vector map is as follows:
[0487] import geopandas as gpd
[0488] from shapely.geometry import LineString
[0489] # DataFrame containing the coordinates of the flight track
[0490] # trajectory_df = pd.DataFrame({
[0491] # 'longitude': [...]
[0492] # 'latitude': [...]
[0493] })
[0494] # Convert to vector feature data
[0495] trajectory_line = LineString(zip(trajectory_df['longitude'],trajectory_df['latitude']))
[0496] # Create a GeoDataFrame to store vector data
[0497] gdf = gpd.GeoDataFrame(geometry=[trajectory_line],crs="EPSG:4326") #Use WGS84 coordinate system
[0498] # composite_lines = [LineString(zip(row['longitude'], row['latitude'])) for _, row in trajectory_df.iterrows()]
[0499] # gdf = gpd.GeoDataFrame(geometry=composite_lines, crs="EPSG:4326")
[0500] # Merge composite vector layers
[0501] # If multiple layers need to be merged, you can use the unary_union method
[0502] # gdf['geometry'] = gdf.unary_union
[0503] # Save as vector graphics file, GeoJSON
[0504] gdf.to_file("navigation_path.geojson", driver='GeoJSON')
[0505] # Or draw the vector layer directly on the map
[0506] ax = gdf.plot(figsize=(10, 10), linewidth=2, color='red')
[0507] Optionally, generating a composite vector layer according to the vector feature data includes:
[0508] Separating vector elements according to the vector feature data;
[0509] Performing topological analysis based on the vector elements to generate vector element relationships;
[0510] A composite vector layer is generated according to the relationship between the vector elements.
[0511] Therefore, by sorting out the vector feature data of the navigation trajectory, we can clearly identify and distinguish the vector elements such as each track segment and turning point, so as to accurately express the spatial structure and form of the navigation trajectory. Furthermore, topological analysis can ensure that the connectivity, adjacency and inclusion of spatial data can be accurately constructed to help determine the intersection, overlap and adjacency between routes, thus improving the accuracy of collision prediction.
[0512] In product implementation, the exemplary code for generating a composite vector layer according to the vector feature data is as follows:
[0513] # Vector feature data class VectorFeatureData, and has a corresponding vector element class VectorElement
[0514] # Topological analysis function topological_analysis
[0515] class VectorLayerComposer:
[0516] def __init__(self, vector_feature_data):
[0517] self.vector_data = vector_feature_data
[0518] self.elements = self.extract_vector_elements()
[0519] def extract_vector_elements(self):
[0520] # Separate vector elements
[0521] vector_elements = []
[0522] for feature in self.vector_data:
[0523] # Parse out vector elements
[0524] element = VectorElement(feature.geometry,feature.attributes)
[0525] vector_elements.append(element)
[0526] return vector_elements
[0527] def perform_topological_analysis(self):
[0528] # Topological analysis based on vector features
[0529] topology_relations = topological_analysis(self.elements)
[0530] #Store topological relationships in each element or in a separate data structure
[0531] for element in self.elements:
[0532] element.topology_relations = topology_relations[element]
[0533] def generate_composite_layer(self):
[0534] # Generate composite vector layer based on vector feature relationships
[0535] composite_layer = CompositeVectorLayer()
[0536] for element in self.elements:
[0537] # Add vector features with topological relationships to the composite layer
[0538] composite_layer.add_element(element)
[0539] # After processing all features, complete the construction of the composite vector layer
[0540] composite_layer.finalize()
[0541] return composite_layer
[0542] vector_data = load_vector_feature_data() # Load vector feature data
[0543] composer = VectorLayerComposer(vector_data)
[0544] composer.perform_topological_analysis()
[0545] composite_layer = composer.generate_composite_layer()
[0546] save_composite_layer(composite_layer) # Save the generated composite vector layer
[0547] Optionally, fusing the composite vector map layer to obtain a navigation track vector map includes:
[0548] Performing time series regularization analysis on the composite vector layer to obtain dynamic attribute relationships of the navigation track;
[0549] The dynamic attribute relationships of the navigation track are aggregated to generate a navigation track vector map.
[0550] Therefore, through time series regularization, the time sequence of the navigation trajectory can be ensured to be accurate. It is crucial to understand and reproduce the real-time position changes during the navigation process, which ensures the accuracy of collision prediction. Moreover, by processing time series data, the changing rules of navigation speed and direction can be discovered and analyzed, which helps to identify specific behavior patterns (such as departure, cruising, mooring, etc.), which is conducive to ensuring the accuracy of collision prediction.
[0551] When the product is implemented, the exemplary code for fusing the composite vector layer to obtain the navigation track vector map is as follows:
[0552] import geopandas as gpd
[0553] import pandas as pd
[0554] from shapely.geometry import LineString
[0555] # Assume a GeoDataFrame containing navigation track point data, including time and longitude and latitude coordinates
[0556] # The 'timestamp' column represents the timestamp, and the 'geometry' column stores the geographic coordinates of the Point type
[0557] track_points = gpd.GeoDataFrame({
[0558] 'timestamp': [...],
[0559] 'geometry': [...]
[0560] }, geometry='geometry')
[0561] # Sort by time
[0562] track_points = track_points.sort_values(by='timestamp')
[0563] tracks = []
[0564] for vessel_id, group in track_points.groupby('vessel_id'): # Assume that vessel_id identifies different vessels
[0565] line = LineString(group['geometry'].tolist())
[0566] tracks.append((vessel_id, line))
[0567] # Create a new GeoDataFrame to store trajectory segments
[0568] trajectory_lines = gpd.GeoDataFrame(geometry=tracks[1])
[0569] trajectory_lines['length'] = trajectory_lines.geometry.length
[0570] trajectory_lines.to_file('voyage_tracks.shp', driver='ESRIShapefile')
[0571] Optionally, judging whether the monitored ship will run aground or collide according to the vector nautical chart and the navigation track vector diagram includes:
[0572] Aligning the navigation track vector diagram and the vector nautical chart to the same coordinate system and superimposing them in the same coordinate system to determine the spatial relationship between the ship track and the land, shoal, channel and prohibited navigation area in the nautical chart;
[0573] According to the spatial relationship, it is determined whether the monitored ship will run aground or collide.
[0574] To this end, by aligning and superimposing the coordinate system of the navigation track and the nautical chart, it can ensure that the real-time position, heading, speed and other information of the ship are accurately matched with the geographical features on the nautical chart, thereby improving the accuracy of spatial position analysis. In addition, by comparing the spatial relationship between the ship's trajectory and obstacles (such as land, shoals, reefs, shipwreck areas, etc.) and restricted areas (such as waterways, no-fly zones, etc.) in the nautical chart, the system can detect the risk of the ship entering a dangerous area at the first time, and realize real-time warning of potential grounding or collision events. It provides visual decision support for crew members and shore-based managers, allowing them to intuitively see the position of the ship relative to the surrounding environment, take timely obstacle avoidance measures, optimize route planning, and ensure navigation safety.
[0575] In product implementation, the exemplary code for judging whether the monitored ship will run aground or collide based on the vector chart and the navigation track vector diagram is as follows:
[0576] # Vector chart data and navigation track vector data
[0577] sea_map = gpd.read_file('sea_map.shp') # Vector chart data
[0578] voyage_track = gpd.read_file('voyage_track.shp') # Voyage track vector map data
[0579] # Make sure both coordinate systems are the same
[0580] if sea_map.crs != voyage_track.crs:
[0581] voyage_track = voyage_track.to_crs(sea_map.crs) # Convert the navigation track to the same coordinate system as the sea map
[0582] # Merge the navigation track with the chart data
[0583] combined_data = gpd.overlay(sea_map, voyage_track, how='intersection')
[0584] # Determine whether the navigation track intersects with dangerous areas in the nautical chart (such as land, shoals, prohibited navigation areas, etc.)
[0585] dangerous_areas = combined_data[combined_data['area_type'].isin(['land','shoal', 'restricted_area'])]
[0586] # If there are intersecting records, there may be a risk of stranding or collision
[0587] if not dangerous_areas.empty:
[0588] print("Warning: The monitored ship is at risk of running aground or colliding!")
[0589] else:
[0590] print("There is no risk of grounding or collision for the monitored ship at present.")
[0591] Optionally, judging whether the monitored ship will run aground or collide based on the spatial relationship includes:
[0592] Performing Boolean encoding on the spatial relationship to obtain a Boolean encoding value;
[0593] The Boolean code value is logically operated with the set risk collision factor to obtain a risk collision quantization value;
[0594] According to the magnitude of the risk collision quantification value, it is determined whether the monitored ship will run aground or collide.
[0595] To this end, by performing logical operations with the risk collision factor to obtain the risk collision quantification value, the collision risk can be quantitatively evaluated, making risk management more targeted and comparable. Moreover, different risk collision factors can be flexibly set according to actual needs to adapt to various complex navigation environments and ship types, thereby improving the adaptability and effectiveness of the system. Furthermore, through logical operations, more evaluation factors can be easily added or weights can be adjusted to cope with different application scenarios.
[0596] When the product is implemented, the exemplary code for judging whether the monitored ship will run aground or collide based on the spatial relationship is as follows:
[0597] import numpy as np
[0598] # The distance between the current position of the ship and each risk area
[0599] distances = {
[0600] 'land': 100, # distance to the nearest land
[0601] 'shoal': 500, # Distance to the nearest shoal
[0602] 'restricted_area': 200 # The distance to the nearest restricted area
[0603] }
[0604] # Set the risk collision factor. Each risk area has a threshold. If the value is below the threshold, it is considered to have a collision risk.
[0605] risk_factors = {
[0606] 'land': 200,
[0607] 'shoal': 1000,
[0608] 'restricted_area': 500
[0609] }
[0610] # Boolean encoding of spatial relationships. If the distance is less than the threshold, it is considered that there is a collision risk and the encoding is True, otherwise it is False
[0611] boolean_codes = {area: distances[area] <risk_factors[area] for areaindistances.keys()}
[0612] # Assign different weights to different risk areas
[0613] weights = {'land': 1, 'shoal': 1, 'restricted_area': 1}
[0614] # Perform a logical operation on the Boolean encoding value and the risk weight to obtain the risk collision quantification value
[0615] risk_collision_value = sum(weight * bool_code for weight, bool_codein zip(weights.values(), boolean_codes.values()))
[0616] # Determine whether a stranded collision will occur based on the size of the risk collision quantification value
[0617] if risk_collision_value>0:
[0618] print("The monitored ship is at risk of running aground or colliding!")
[0619] else:
[0620] print("There is currently no risk of grounding or collision for the monitored ship.")
[0621] In practical applications, the quantified value of collision risk may need to be combined with more factors (such as ship speed, direction, etc.) to comprehensively judge the risk level.
[0622] Figure 2 This is a schematic diagram of the structure of a marine ship collision prediction device according to an embodiment of the present application. Figure 2 As shown, it includes:
[0623] A nautical chart vectorization unit 201 is used to obtain a digital nautical chart and vectorize the digital nautical chart to obtain a vector nautical chart;
[0624] A calibration unit 202, used to obtain a dynamic estimation flow of the monitored ship and calibrate the dynamic estimation flow to generate a spatial sequence of the navigation trajectory;
[0625] A sequence vectorization unit 203, configured to vectorize the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector map;
[0626] The estimation unit 204 is used to determine whether the monitored ship will run aground or collide according to the vector nautical chart and the navigation track vector map.
[0627] Here, Figure 2 In the embodiments, the exemplary description of each functional unit can be found in the above Figure 1 Description.
[0628] Figure 3 Schematic diagram of the structure of the electronic device of this embodiment; the electronic device may include:
[0629] One or more processors 301;
[0630] The computer readable medium 302 may be configured to store one or more programs,
[0631] When the one or more programs are executed by the one or more processors, the one or more processors implement the methods described in the above embodiments.
[0632] Figure 4 is the hardware structure of the electronic device of this embodiment; Figure 4As shown, the hardware structure of the electronic device may include: a processor 401, a communication interface 402, a computer readable medium 403 and a communication bus 404;
[0633] The processor 401, the communication interface 402, and the computer readable medium 403 communicate with each other via a communication bus 404;
[0634] Optionally, the communication interface 402 may be an interface of a communication module, such as an interface of a GSM module;
[0635] Among them, the processor 401 can be specifically configured to implement the method of the above-mentioned embodiment of the present application.
[0636] The processor 401 may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field-programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components. The methods, steps and logic block diagrams disclosed in the embodiments of the present application may be implemented or executed. The general-purpose processor may be a microprocessor or the processor may also be any conventional processor, etc.
Claims
1. A method for predicting marine ship collision, characterized in that: include: Acquiring a digital nautical chart, and vectorizing the digital nautical chart to obtain a vector nautical chart; Acquiring a dynamic estimation flow of the monitored ship and calibrating the dynamic estimation flow to generate a spatial sequence of navigation trajectories; Vectorizing the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector diagram; Determining whether the monitored ship will run aground or collide according to the vector chart and the navigation track vector diagram; The step of vectorizing the digital nautical chart to obtain a vector nautical chart includes: Performing element segmentation on the digital nautical chart to determine a vector matrix description in the digital nautical chart; Vectorizing the vector base description to generate vector layer elements; Generate a vector chart according to the vector layer elements; The step of performing element segmentation on the digital nautical chart to determine a vector matrix description in the digital nautical chart includes: Performing feature extraction on the digital nautical chart to generate a texture feature vector, a color feature vector, and a morphology feature vector; Performing feature space clustering analysis on the texture feature vector, the color feature vector, and the morphology feature vector to obtain a family of nautical chart elements; According to the nautical chart element family, a land description, a water description, a coastline description, and a waterway description are generated and corresponding description tags are assigned; Generate a vector matrix description in the digital nautical chart according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels; The step of generating a vector matrix description in the digital nautical chart according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels includes: Based on the description labels, the land description, the water description, and the coastline description are classified to obtain a land feature category set, a water feature category set, and a coastline feature category set; Generate a feature category set topological structure according to the land feature category set, the water feature category set, and the coastline feature category set; generating a vector matrix description in the digital nautical chart according to the feature category set topological structure; The step of generating a vector matrix description in the digital nautical chart according to the topological structure of the feature category set includes: Determining vector matrix attributes based on the feature category set topological structure, and encoding the matrix attributes to obtain vector matrix encoding values; Associating the vector base encoding value with the vector base geometric information to generate a vector feature object; Performing feature space index construction on the vector feature object to obtain a vector feature index; generating a vector matrix description in the digital nautical chart according to the vector feature index; The step of generating a vector matrix description in the digital nautical chart according to the vector feature index includes: According to the vector feature index, risk ontology identification is performed on all maritime ship risk representations to obtain a maritime ship risk representation ontology description; Semantically encoding the marine vessel risk characterization ontology description to obtain a vector matrix description; The step of judging whether the monitored ship will run aground or collide according to the vector nautical chart and the navigation track vector diagram includes: Aligning the navigation track vector diagram and the vector nautical chart to the same coordinate system and superimposing them in the same coordinate system to determine the spatial relationship between the ship track and the land, shoal, channel and prohibited navigation area in the nautical chart; According to the spatial relationship, determining whether the monitored ship will run aground or collide; Wherein, judging whether the monitored ship will run aground or collide based on the spatial relationship includes: Performing Boolean encoding on the spatial relationship to obtain a Boolean encoding value; The Boolean code value is logically operated with the set risk collision factor to obtain a risk collision quantization value; According to the magnitude of the risk collision quantification value, it is determined whether the monitored ship will run aground or collide.
2. The method according to claim 1, characterized in that The step of obtaining the dynamic estimation flow of the monitored ship also includes: Collect the position, heading and speed data of the monitored ship to generate GPGGA sentences, HDT sentences and VTG sentences; A dynamic estimation flow of the monitored ship is generated according to the GPGGA sentence, HDT sentence and VTG sentence.
3. The method according to claim 1, characterized in that The step of calibrating the dynamic estimation flow to generate a spatial sequence of navigation trajectories includes: Calibrate the dynamic estimation stream to generate a spatial spectrum estimate of the monitored vessel; A spatial sequence of navigation trajectories is generated according to the spatial spectrum estimation.
4. The method according to claim 3, characterized in that The step of generating a spatial sequence of navigation trajectories according to the spatial spectrum estimation includes: Performing map spectrum projection on the spatial spectrum estimation to obtain a map spectrum projection vector; Performing spectral decomposition on the map spectrum projection vector to obtain dominant frequency components and their corresponding amplitudes; A spatial sequence of navigation trajectories is generated according to the dominant frequency components and their corresponding amplitudes.
5. The method according to claim 1, characterized in that The vectorizing of the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector diagram includes: Converting the spatial sequence of the navigation trajectory into a vector coordinate system to obtain vector feature data; Generate a composite vector layer according to the vector feature data; The composite vector layers are fused to obtain a navigation track vector map.
6. The method according to claim 5, characterized in that The step of generating a composite vector layer according to the vector feature data includes: Separating vector elements according to the vector feature data; Performing topological analysis based on the vector elements to generate vector element relationships; A composite vector layer is generated according to the relationship between the vector elements.
7. A marine ship collision prediction device, characterized in that: include: A nautical chart vectorization unit, used for acquiring a digital nautical chart and vectorizing the digital nautical chart to obtain a vector nautical chart; A calibration unit, used for acquiring a dynamic estimation flow of the monitored ship and calibrating the dynamic estimation flow to generate a spatial sequence of navigation trajectories; A sequence vectorization unit, used for vectorizing the spatial sequence of the navigation trajectory to obtain a navigation trajectory vector map; An estimation unit, used for judging whether the monitored ship will run aground or collide according to the vector chart and the navigation track vector diagram; The step of vectorizing the digital nautical chart to obtain a vector nautical chart includes: Performing element segmentation on the digital nautical chart to determine a vector matrix description in the digital nautical chart; Vectorizing the vector base description to generate vector layer elements; Generate a vector chart according to the vector layer elements; The step of performing element segmentation on the digital nautical chart to determine a vector matrix description in the digital nautical chart includes: Performing feature extraction on the digital nautical chart to generate a texture feature vector, a color feature vector, and a morphology feature vector; Performing feature space clustering analysis on the texture feature vector, the color feature vector, and the morphology feature vector to obtain a family of nautical chart elements; According to the nautical chart element family, a land description, a water description, a coastline description, and a waterway description are generated and corresponding description tags are assigned; Generate a vector matrix description in the digital nautical chart according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels; The step of generating a vector matrix description in the digital nautical chart according to the land description, the water description, the coastline description, the waterway description and the corresponding description labels includes: Based on the description labels, the land description, the water description, and the coastline description are classified to obtain a land feature category set, a water feature category set, and a coastline feature category set; Generate a feature category set topological structure according to the land feature category set, the water feature category set, and the coastline feature category set; generating a vector matrix description in the digital nautical chart according to the feature category set topological structure; The step of generating a vector matrix description in the digital nautical chart according to the topological structure of the feature category set includes: Determining vector matrix attributes based on the feature category set topological structure, and encoding the matrix attributes to obtain vector matrix encoding values; Associating the vector base encoding value with the vector base geometric information to generate a vector feature object; Performing feature space index construction on the vector feature object to obtain a vector feature index; generating a vector matrix description in the digital nautical chart according to the vector feature index; The step of generating a vector matrix description in the digital nautical chart according to the vector feature index includes: According to the vector feature index, risk ontology identification is performed on all maritime ship risk representations to obtain a maritime ship risk representation ontology description; Semantically encoding the marine vessel risk characterization ontology description to obtain a vector matrix description; The step of judging whether the monitored ship will run aground or collide according to the vector nautical chart and the navigation track vector diagram includes: Aligning the navigation track vector diagram and the vector nautical chart to the same coordinate system and superimposing them in the same coordinate system to determine the spatial relationship between the ship track and the land, shoal, channel and prohibited navigation area in the nautical chart; According to the spatial relationship, determining whether the monitored ship will run aground or collide; Wherein, judging whether the monitored ship will run aground or collide based on the spatial relationship includes: Performing Boolean encoding on the spatial relationship to obtain a Boolean encoding value; The Boolean code value is logically operated with the set risk collision factor to obtain a risk collision quantization value; According to the magnitude of the risk collision quantification value, it is determined whether the monitored ship will run aground or collide.
8. An electronic device, characterized in that: include: one or more processors; A computer readable medium configured to store one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 6.
Citation Information
Patent Citations
Ship motion prediction method based on time-frequency analysis and BP neural network
CN103577877A
Unmanned ship dynamic safe trajectory planning method considering dynamic water depth
CN114610046A
Shipborne intelligent nautical chart system supporting safe / autonomous navigation of ship
CN115544295A
Ship trajectory prediction method based on multi-source heterogeneous ship shipping data
CN115545293A
Ship AIS data compression method
CN116527778A