A ship name recognition system and method based on a random forest model

CN121191147BActive Publication Date: 2026-09-25JIANGSU CHANGTIAN ZHIYUAN TRAFFIC TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202511353086.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-09-22
Publication Date
2026-09-25
Estimated Expiration
2045-09-22

AI Technical Summary

Technical Problem

传统船名识别主要依赖人工观测或简单的图像匹配技术,存在识别效率低、易受环境干扰(如光照变化、水雾遮挡、船体倾斜)、泛化能力差等问题

Benefits of technology

识别精度高:通过多维度特征融合(基础视觉特征+文本结构特征+上下文环境特征),结合注意力机制提升关键特征的权重,解决了单一特征区分度不足的问题;改进随机森林模型通过自适应决策树生成(分层抽样、互信息特征选择、PSO阈值优化)与权重投票机制,提升了分类精度;

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121191147B_ABST
    Figure CN121191147B_ABST
Patent Text Reader

Abstract

The application relates to the technical field of computer vision and pattern recognition, and discloses a ship name recognition system and method based on a random forest model, an image acquisition module, which is used for acquiring ship image and attitude positioning data; a preprocessing module, which is used for carrying out noise suppression and target region segmentation on the collected image data; a feature extraction module, which is used for outputting a multi-dimension fusion feature vector; and an improved random forest classification module, which is used for classifying the fusion feature vector and realizing ship name character recognition; through multi-dimension feature fusion, the weight of a key feature is improved in combination with an attention mechanism, the problem of insufficient single feature discrimination is solved; and the improved random forest model improves the classification precision through adaptive decision tree generation and a weight voting mechanism.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of computer vision and pattern recognition technology, specifically to a ship name recognition system and method based on a random forest model. Background Technology

[0002] In maritime traffic management and port operations, vessel name recognition is a crucial step in confirming vessel identity, tracking navigation routes, and conducting compliance checks. Traditional vessel name recognition mainly relies on manual observation or simple image matching techniques, which suffers from low recognition efficiency, susceptibility to environmental interference (such as changes in lighting, water mist, and vessel tilting), and poor generalization ability. With the development of machine learning technology, deep learning-based image recognition methods (such as CNN, YOLO, etc.) have begun to be applied to ship name recognition. However, such methods have the following drawbacks: First, they require a large amount of training data, which requires the collection of a large number of ship name image samples in different scenarios, resulting in high data acquisition costs. Second, the model complexity is high, and the inference process takes a long time, making it difficult to meet the low latency requirements of real-time port supervision. Third, the recognition accuracy drops significantly for small samples or blurry images, and the adaptability to harsh maritime environments is insufficient. Random forest models, as an ensemble learning algorithm, have advantages such as fast training speed, strong anti-overfitting ability, and good robustness to noisy data, and have been applied in fields such as text classification and image feature recognition. However, existing random forest-based recognition methods still have the following shortcomings in ship name recognition scenarios: Limited feature extraction: They rely solely on grayscale features or simple texture features of the ship name region, without combining the structural characteristics of the ship name text (such as character spacing and font style) and the contextual environment (such as the ship's background and character color contrast), resulting in insufficient feature discriminative power. Blindly constructing decision trees: The number of decision trees and the node splitting threshold in the random forest are both fixed parameters or randomly selected, without being optimized according to the task characteristics of ship name recognition, resulting in poor model generalization ability; Fragmented algorithm process: Existing methods treat image preprocessing, feature extraction, and model classification as independent modules, without forming an end-to-end collaborative optimization mechanism, resulting in low recognition efficiency and serious error accumulation.

[0003] To address the above problems, this invention proposes a ship name recognition system and method based on a random forest model. Summary of the Invention

[0004] This invention provides a ship name recognition system and method based on a random forest model, which helps to solve the problems mentioned in the background art.

[0005] This invention provides the following technical solution: a ship name recognition system based on a random forest model, wherein the image acquisition module, preprocessing module, feature extraction module, improved random forest classification module, and result output module are sequentially and communicatively connected, including: The image acquisition module includes an industrial camera, a 5G / Ethernet image transmission unit, and a GPS / IMU positioning auxiliary unit, used to acquire ship images and attitude positioning data; The preprocessing module is used to perform noise suppression and target region segmentation on the acquired image data; The feature extraction module is used to output a multi-dimensional fused feature vector, and the feature extraction module includes a basic visual feature extraction unit, a text structure feature extraction unit, a contextual environment feature extraction unit, and an attention mechanism feature fusion unit; The improved random forest classification module is used to classify the fused feature vectors to recognize ship name characters; The result output module is used to output the ship name recognition results and store the relevant data.

[0006] Furthermore, multiple industrial cameras are installed at different locations on the dock berth to collect raw image data of the ship; the 5G / Ethernet image transmission unit uses the 5G / Ethernet transmission protocol to transmit the collected image data to the preprocessing module in real time; the GPS / IMU positioning assistance unit integrates GPS and an inertial measurement unit (IMU) to record the ship's position, heading, and attitude information during image acquisition.

[0007] Furthermore, the preprocessing module includes an adaptive noise suppression unit and a ship name region segmentation unit. The adaptive noise suppression unit uses an improved bilateral filtering algorithm to adaptively suppress noise in the original image data. The strategy of the improved bilateral filtering algorithm is as follows: Let the pixel coordinates of the original image data be... The improved bilateral filtering algorithm formula is as follows: ,in Let S be the coordinates of other pixels within a neighborhood S centered on the current pixel. Indicates coordinates as The original grayscale value of the pixel. Indicates coordinates as The original grayscale value of the pixel. Let Gaussian kernel function be used in the spatial domain. The standard deviation of the Gaussian function in the spatial domain is used to measure the impact of spatial distance between pixels on the filtering result. For pixels With pixels The Euclidean distance between them The Gaussian kernel function with range, The standard deviation of the Gaussian function over the range is used to measure the impact of differences in grayscale values ​​between pixels on the filtering result. For pixels With pixels The absolute value of the difference in grayscale values. As the normalization factor, Represented as the coordinates after bilateral filtering. The new grayscale value of the pixel; The ship name region segmentation unit, combined with ship attitude information, employs a region growing algorithm based on edge detection. The specific strategy is as follows: A1. Perform Canny edge detection on the denoised image to obtain the hull outline; A2. Determine the possible areas for the ship's name based on the ship's heading information; A3. Using the edge detection results as seed points, set the gray-scale difference threshold T with a value range of 10-30 to grow the candidate region for ship names.

[0008] Furthermore, the basic visual feature extraction unit is used to extract grayscale histogram features, LBP texture features, and HOG shape features, and principal component analysis (PCA) is used to reduce the dimensionality of the extracted features, retaining principal components with a cumulative contribution rate of ≥95%, to obtain the basic feature vector. ; The text structure feature extraction unit (302) is used to extract text structure features, and the extraction strategy is as follows: B1. Perform character segmentation on the candidate ship name region, and use the projection method to calculate the character width, height, and spacing to form a structural parameter vector; B2. Extract font style features based on Fourier descriptors of character contours; B3. By fusing the structural parameter vector and font style features, the text structural feature vector is obtained. ; The contextual feature extraction unit (303) is used to extract the color contrast between the ship name region and the ship hull background, the light intensity, and the tilt angle of the region after ship attitude correction, forming a contextual feature vector. ; The attention mechanism feature fusion unit (304) uses an attention mechanism to... , , Weighted fusion is performed, and the weighted fusion formula is: ,and ,in , , The attention weights are adaptively learned through training data, and the final output is a fused feature vector F.

[0009] Furthermore, the improved random forest classification module includes an adaptive decision tree generation unit, a random forest ensemble optimization unit, and an incremental learning model update unit. The adaptive decision tree generation unit is used to generate adaptive decision trees, dynamically adjusting the generation process based on the characteristics and distribution of the input data. The strategy is as follows: Sample sampling optimization: Stratified sampling is adopted, and the sampling ratio is adjusted according to the category distribution of ship name characters to ensure that the deviation of the proportion of each type of sample in the decision tree training set is ≤10%; Feature selection optimization: A feature importance evaluation method based on mutual information is adopted to calculate the mutual information value between each feature and the character category label. ,choose The top 30% of features are used as candidate features for classification in the decision tree; Node splitting threshold optimization: The particle swarm optimization algorithm (PSO) is used to optimize the splitting threshold. The objective function is to minimize the Gini coefficient of the decision tree nodes. The formula for the Gini coefficient is: Where D is the node sample set and K is the number of character categories. Let k be the number of samples in the k-th class. It is represented as the Gini index of the node sample set. The number of node samples; The strategy of the random forest ensemble optimization unit (402) is as follows: Adaptive adjustment of the number of decision trees: The optimal number of decision trees T is determined by the validation set error curve. When the number of decision trees is increased, if the decrease in validation set error is ≤0.5%, the increase is stopped. The initial range of T is set to 50-200. Weighted voting mechanism: Based on the classification accuracy of each decision tree on the validation set. , Assigning voting weights The final classification result is the character category with the highest weighted vote; Model update unit: An incremental learning mechanism is adopted. When a new ship name image sample is input and the number of new ship name image samples is ≥1000, only the decision trees in the random forest with a classification accuracy of less than 85% are updated.

[0010] Furthermore, the result output module includes a result correction unit based on a maritime dictionary, a data storage unit using HBase distributed storage, and a Web visualization unit; Result correction unit: Employs a dictionary-based error correction algorithm to compare the recognition results with a maritime vessel name dictionary and correct erroneous characters; Data storage unit: Stores original images, preprocessing results, feature vectors, recognition results and positioning information. It adopts distributed database storage and supports fast data query and backtracking. Web visualization unit: Displays ship images, ship name recognition results, and recognition confidence levels in real time through a web interface, and supports manual annotation and feedback of abnormal results.

[0011] Furthermore, a ship name recognition method based on a random forest model is provided, which includes the following steps: S1. Image Acquisition Image data of the target area of ​​the ship is acquired through the image acquisition module, and the ship's position, heading and attitude information are recorded at the time of acquisition. The image resolution is set to 1920×1080 and the frame rate is set to 25fps, and then transmitted to the preprocessing module. S2. Image Preprocessing Adaptive noise suppression: An improved bilateral filtering algorithm is used to denoise the acquired images. The noise intensity is calculated based on the grayscale standard deviation. If the standard deviation is greater than 15, it is considered high noise. The spatial domain Gaussian kernel parameter is dynamically adjusted. With grayscale Gaussian kernel parameters Furthermore, the Gaussian kernel parameter in the spatial domain is set to 2.0 for high noise and 0.5 for low noise, resulting in a denoised image output. Ship name region segmentation: Canny edge detection is performed on the denoised image, with a low threshold of 50 and a high threshold of 150 to obtain the ship's hull edges. Based on the ship's heading information, the candidate direction for the ship name region is determined to be parallel to the heading. The width range of the candidate region is set to 1 / 5-1 / 3 of the ship's width, and the height range is 1 / 10-1 / 5 of the ship's height. A region growing algorithm is used, with the edge detection results as seed points, and a gray-level difference threshold T is set to grow the candidate ship name regions. The gray-level difference threshold T is adaptively adjusted according to the average gray value of the image. When the average gray value is >128, the candidate region is obtained. ,otherwise The growth yielded a candidate area for ship names; S3. Multi-dimensional feature extraction is performed through the feature extraction module (3); S4. Model Training Phase: Construct a training dataset: Collect over 100,000 ship name image samples from different scenarios, label the character categories, including 26 English letters and 10 numbers, for a total of 36 categories, and divide the samples into training set, validation set, and test set in a 7:2:1 ratio; Adaptive Generative Decision Tree: Stratified sampling is used on the training set to ensure that the sampling ratio of each type of character sample is consistent with that of the original dataset. Calculate the mutual information value between each feature and the character category. ,choose The top 30% of features are used as candidate features for splitting; The PSO algorithm is used to optimize the node splitting threshold, with the number of particles set to 20, the number of iterations set to 50, and the objective function being to minimize the node Gini coefficient, thereby generating a single decision tree. Ensemble decision tree: Repeatedly generate decision trees adaptively, generate multiple decision trees, determine the optimal number of decision trees T by using the validation set error curve, and stop when the validation set error decreases by ≤0.5%; Calculate the classification accuracy of each decision tree on the validation set. Assigning voting weights Complete the training of the improved random forest model; Model inference stage: The fused feature vector F is input into the improved random forest model, and each decision tree outputs the character category prediction result; A weighted voting mechanism is used to calculate the weighted vote rate for each category, and the category with the highest vote rate is the prediction result. Output the prediction results and confidence levels, where the confidence level is equal to the highest vote percentage; Step S5: Outputting Results and Updating the Model.

[0012] Furthermore, S3 specifically includes: Basic visual feature extraction: The gray-level histogram statistics of the candidate ship name regions were performed, and the gray-level range of 0-255 was divided into 128 intervals to obtain 128-dimensional gray-level histogram features. The LBP texture features of the candidate regions were calculated using a 3×3 neighborhood with 8 sampling points, resulting in 256-dimensional LBP features. HOG features were extracted from candidate regions. The cell unit size was set to 8×8, the block unit size was set to 2×2, and the orientation bins were set to 9, resulting in 320-dimensional HOG features. PCA dimensionality reduction is performed on the three types of features, and principal components with a cumulative contribution rate of ≥95% are retained to obtain the basic feature vector. ; Text structure feature extraction: The candidate region for ship names is horizontally projected, and the characters are segmented according to the projection valley value. The width, height, and character spacing of each character are calculated to form a 16-dimensional structural parameter vector. Perform a Fourier transform on each character outline, and take the first 32 Fourier coefficients as font style features to obtain a 32-dimensional font style feature vector. By fusing the structural parameter vector and the font style feature vector, the text structure feature vector is obtained. ; Contextual feature extraction: The RGB color contrast between the ship name area and the ship hull background is calculated, and two statistics are used for each channel: mean difference and variance difference, to obtain a 6-dimensional color contrast feature. Using light sensor data or image grayscale mean, the mean, variance, maximum and minimum values ​​of light intensity are calculated to obtain 4-dimensional light intensity characteristics; Based on the ship's attitude information, which includes the tilt angle and pitch angle, the tilt angle of the ship's name area is corrected to obtain a 2D tilt angle feature. By fusing the three types of features, a context feature vector is obtained. ; Feature fusion: Employing an attention mechanism , , We perform weighted fusion and learn attention weights from the training data. The output is the fused feature vector F.

[0013] Furthermore, S5 specifically includes: S5.1 Result Correction: Match the prediction results with the maritime vessel name dictionary, and correct the errors for results with a confidence level ≥90% but with character confusion according to the dictionary; S5.2 Result Output: The ship image, ship name recognition result, and confidence level are displayed through the visualization unit, while the raw data and processing results are stored in the distributed database. S5.3 Model Update: When the number of newly collected samples is ≥1000, calculate the classification accuracy of each decision tree in the existing random forest on the new samples. For decision trees with an accuracy of less than 85%, retrain using the method in S4 to update the random forest model and achieve incremental learning.

[0014] Furthermore, a storage medium stores a computer program that, when read and run by a processor, performs the steps of a ship name recognition method based on a random forest model.

[0015] The present invention has the following beneficial effects: High recognition accuracy: By fusing multi-dimensional features (basic visual features + text structure features + contextual features) and combining attention mechanism to enhance the weight of key features, the problem of insufficient discrimination of single features is solved; the improved random forest model improves classification accuracy through adaptive decision tree generation (stratified sampling, mutual information feature selection, PSO threshold optimization) and weight voting mechanism. Strong generalization ability: The adaptive noise suppression and ship name region segmentation algorithm adapt to different lighting (day / night / foggy days) and ship attitude (tilt / pitch) environments. The improved hierarchical sampling and incremental learning mechanism of random forest reduces the impact of sample distribution imbalance and new scenes on model performance. In cross-port and cross-ship type tests, the recognition accuracy fluctuates little. Good real-time performance: The number of decision trees in the improved random forest model is adaptively optimized through the validation set (usually 80-120 trees), which improves the inference speed compared with deep learning models (such as CNN), reduces end-to-end recognition latency, and meets the needs of real-time port supervision. Highly practical: The incremental learning mechanism avoids full retraining of the model, reducing computational overhead and data dependence; the design of result correction and visualization units facilitates real-time monitoring and manual intervention by staff, lowering the operational threshold of the system and enabling it to quickly adapt to the maritime regulatory needs of ports of different sizes. Attached Figure Description

[0016] Figure 1 This is a schematic diagram of the system flow of the present invention; Figure 2 This is a flowchart illustrating the image acquisition module in the system of the present invention; Figure 3 This is a flowchart illustrating the preprocessing module in the system of the present invention; Figure 4 This is a flowchart illustrating the feature extraction module in the system of the present invention; Figure 5 This is a flowchart illustrating the improved random forest classification module in the system of this invention; Figure 6 This is a flowchart illustrating the result output module in the system of this invention; Figure 7 This is a schematic diagram of the method flow of the present invention.

[0017] In the diagram: 1. Image acquisition module; 101. Industrial camera; 102. 5G / Ethernet image transmission unit; 103. GPS / IMU positioning assistance unit; 2. Preprocessing module; 201. Adaptive noise suppression unit; 202. Ship name region segmentation unit; 3. Feature extraction module; 301. Basic visual feature extraction unit; 302. Text structure feature extraction unit; 303. Contextual environment feature extraction unit; 304. Attention mechanism feature fusion unit; 4. Improved random forest classification module; 401. Adaptive decision tree generation unit; 402. Random forest ensemble optimization unit; 403. Incremental learning model update unit; 5. Result output module; 501. Result correction unit; 502. Data storage unit; 503. Web visualization unit. Detailed Implementation

[0018] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.

[0019] Example 1

[0020] Reference Figures 1-6 A ship name recognition system based on a random forest model, comprising an image acquisition module 1, a preprocessing module 2, a feature extraction module 3, an improved random forest classification module 4, and a result output module 5, all interconnected in sequence, including: The image acquisition module 1 includes an industrial camera 101, a 5G / Ethernet image transmission unit 102 and a GPS / IMU positioning auxiliary unit 103, used to acquire ship images and attitude positioning data; Multiple industrial cameras 101 are installed at different locations on the dock berth to collect raw image data of the ship; the 5G / Ethernet image transmission unit 102 uses the 5G / Ethernet transmission protocol to transmit the collected image data to the preprocessing module 2 in real time; the GPS / IMU positioning assistance unit 103 integrates GPS and an inertial measurement unit (IMU) to record the ship's position, heading, and attitude information during image acquisition. The preprocessing module 2 is used to perform noise suppression and target region segmentation on the acquired image data; Preprocessing module 2 includes an adaptive noise suppression unit 201 and a ship name region segmentation unit 202. The adaptive noise suppression unit 201 uses an improved bilateral filtering algorithm to adaptively suppress noise in the original image data. The strategy of the improved bilateral filtering algorithm is as follows: Let the pixel coordinates of the original image data be... The improved bilateral filtering algorithm formula is as follows: ,in Let S be the coordinates of other pixels within a neighborhood S centered on the current pixel. Indicates coordinates as The original grayscale value of the pixel. Indicates coordinates as The original grayscale value of the pixel. Let Gaussian kernel function be used in the spatial domain. The standard deviation of the Gaussian function in the spatial domain is used to measure the impact of spatial distance between pixels on the filtering result. For pixels With pixels The Euclidean distance between them The Gaussian kernel function with range, The standard deviation of the Gaussian function over the range is used to measure the impact of differences in grayscale values ​​between pixels on the filtering result. For pixels With pixels The absolute value of the difference in grayscale values. As the normalization factor, Represented as the coordinates after bilateral filtering. The new grayscale value of the pixel; The ship name region segmentation unit 202 combines ship attitude information with a region growing algorithm based on edge detection. The specific strategy is as follows: A1. Perform Canny edge detection on the denoised image to obtain the hull outline; A2. Determine the possible areas for the ship's name based on the ship's heading information; A3. Using the edge detection results as seed points, set the gray-level difference threshold T with a value range of 10-30, and grow the candidate region for ship name; The feature extraction module 3 is used to output a multi-dimensional fused feature vector, and the feature extraction module 3 includes a basic visual feature extraction unit 301, a text structure feature extraction unit 302, a contextual environment feature extraction unit 303, and an attention mechanism feature fusion unit 304. The basic visual feature extraction unit 301 is used to extract grayscale histogram features, LBP texture features, and HOG shape features. Principal component analysis (PCA) is then used to reduce the dimensionality of the extracted features, retaining principal components with a cumulative contribution rate of ≥95%, thus obtaining the basic feature vector. ; The text structure feature extraction unit (302) is used to extract text structure features, and the extraction strategy is as follows: B1. Perform character segmentation on the candidate ship name region, and use the projection method to calculate the character width, height, and spacing to form a structural parameter vector; B2. Extract font style features based on Fourier descriptors of character contours; B3. By fusing the structural parameter vector and font style features, the text structural feature vector is obtained. ; The contextual feature extraction unit (303) is used to extract the color contrast between the ship name region and the ship hull background, the light intensity, and the tilt angle of the region after ship attitude correction, forming a contextual feature vector. ; The attention mechanism feature fusion unit (304) uses an attention mechanism to... , , Weighted fusion is performed, and the weighted fusion formula is: ,and ,in , , The attention weights are adaptively learned through training data, and the final output is a fused feature vector F. The improved random forest classification module 4 is used to classify the fused feature vectors to achieve the recognition of ship name characters; The improved random forest classification module 4 includes an adaptive decision tree generation unit 401, a random forest ensemble optimization unit 402, and an incremental learning model update unit 403. The adaptive decision tree generation unit 401 is used to generate adaptive decision trees, dynamically adjusting the generation process of the decision trees according to the characteristics and distribution of the input data. The strategy is as follows: Sample sampling optimization: Stratified sampling is adopted, and the sampling ratio is adjusted according to the category distribution of ship name characters to ensure that the deviation of the proportion of each type of sample in the decision tree training set is ≤10%; Feature selection optimization: A feature importance evaluation method based on mutual information is adopted to calculate the mutual information value between each feature and the character category label. ,choose The top 30% of features are used as candidate features for classification in the decision tree; Node splitting threshold optimization: The particle swarm optimization algorithm (PSO) is used to optimize the splitting threshold. The objective function is to minimize the Gini coefficient of the decision tree nodes. The formula for the Gini coefficient is: Where D is the node sample set and K is the number of character categories. Let k be the number of samples in the k-th class. It is represented as the Gini index of the node sample set. The number of node samples; The strategy of the random forest ensemble optimization unit (402) is as follows: Adaptive adjustment of the number of decision trees: The optimal number of decision trees T is determined by the validation set error curve. When the number of decision trees is increased, if the decrease in validation set error is ≤0.5%, the increase is stopped. The initial range of T is set to 50-200. Weighted voting mechanism: Based on the classification accuracy of each decision tree on the validation set. , Assigning voting weights The final classification result is the character category with the highest weighted vote; Model update unit: An incremental learning mechanism is adopted. When a new ship name image sample is input and the number of new ship name image samples is ≥1000, only the decision tree in the random forest with a classification accuracy of less than 85% is updated. The result output module 5 is used to output the ship name recognition result and store the relevant data.

[0021] The result output module 5 includes a result correction unit 501 based on a maritime dictionary, a data storage unit 502 using HBase distributed storage, and a web visualization unit 503. Result correction unit 501: Uses a dictionary-based error correction algorithm to compare the recognition results with the maritime vessel name dictionary and correct erroneous characters; Data storage unit 502: Stores original images, preprocessing results, feature vectors, recognition results and positioning information. It adopts distributed database storage and supports fast data query and backtracking. Web Visualization Unit 503: Displays ship images, ship name recognition results, and recognition confidence levels in real time through a web interface, and supports manual annotation and feedback of abnormal results.

[0022] Example 2

[0023] Please see Figure 7 A ship name recognition method based on a random forest model, comprising the following steps: S1. Image Acquisition Image data of the target area of ​​the ship is acquired by the image acquisition module 1, and the ship's position, heading and attitude information are recorded at the time of acquisition. The image resolution is set to 1920×1080 and the frame rate is set to 25fps. The data is then transmitted to the preprocessing module 2. S2. Image Preprocessing Adaptive noise suppression: An improved bilateral filtering algorithm is used to denoise the acquired images. The noise intensity is calculated based on the grayscale standard deviation. If the standard deviation is greater than 15, it is considered high noise. The spatial domain Gaussian kernel parameter is dynamically adjusted. With grayscale Gaussian kernel parameters Furthermore, the Gaussian kernel parameter in the spatial domain is set to 2.0 for high noise and 0.5 for low noise, resulting in a denoised image output. Ship name region segmentation: Canny edge detection is performed on the denoised image, with a low threshold of 50 and a high threshold of 150 to obtain the ship's hull edges. Based on the ship's heading information, the candidate direction for the ship name region is determined to be parallel to the heading. The width range of the candidate region is set to 1 / 5-1 / 3 of the ship's width, and the height range is 1 / 10-1 / 5 of the ship's height. A region growing algorithm is used, with the edge detection results as seed points, and a gray-level difference threshold T is set to grow the candidate ship name regions. The gray-level difference threshold T is adaptively adjusted according to the average gray value of the image. When the average gray value is >128, the candidate region is obtained. ,otherwise The growth yielded a candidate area for ship names; S3. Multi-dimensional feature extraction is performed through feature extraction module 3; S3 specifically includes: Basic visual feature extraction: The gray-level histogram statistics of the candidate ship name regions were performed, and the gray-level range of 0-255 was divided into 128 intervals to obtain 128-dimensional gray-level histogram features. The LBP texture features of the candidate regions were calculated using a 3×3 neighborhood with 8 sampling points, resulting in 256-dimensional LBP features. HOG features were extracted from candidate regions. The cell unit size was set to 8×8, the block unit size was set to 2×2, and the orientation bins were set to 9, resulting in 320-dimensional HOG features. PCA dimensionality reduction is performed on the three types of features, and principal components with a cumulative contribution rate of ≥95% are retained to obtain the basic feature vector. ; Text structure feature extraction: The candidate region for ship names is horizontally projected, and the characters are segmented according to the projection valley value. The width, height, and character spacing of each character are calculated to form a 16-dimensional structural parameter vector. Perform a Fourier transform on each character outline, and take the first 32 Fourier coefficients as font style features to obtain a 32-dimensional font style feature vector. By fusing the structural parameter vector and the font style feature vector, the text structure feature vector is obtained. ; Contextual feature extraction: The RGB color contrast between the ship name area and the ship hull background is calculated, and two statistics are used for each channel: mean difference and variance difference, to obtain a 6-dimensional color contrast feature. Using light sensor data or image grayscale mean, the mean, variance, maximum and minimum values ​​of light intensity are calculated to obtain 4-dimensional light intensity characteristics; Based on the ship's attitude information, which includes the tilt angle and pitch angle, the tilt angle of the ship's name area is corrected to obtain a 2D tilt angle feature. By fusing the three types of features, a context feature vector is obtained. ; Feature fusion: Employing an attention mechanism , , We perform weighted fusion and learn attention weights from the training data. Output the fused feature vector F; S4. Model Training Phase: Construct a training dataset: Collect over 100,000 ship name image samples from different scenarios, label the character categories, including 26 English letters and 10 numbers, for a total of 36 categories, and divide the samples into training set, validation set, and test set in a 7:2:1 ratio; Adaptive Generative Decision Tree: Stratified sampling is used on the training set to ensure that the sampling ratio of each type of character sample is consistent with that of the original dataset. Calculate the mutual information value between each feature and the character category. ,choose The top 30% of features are used as candidate features for splitting; The PSO algorithm is used to optimize the node splitting threshold, with the number of particles set to 20, the number of iterations set to 50, and the objective function being to minimize the node Gini coefficient, thereby generating a single decision tree. Ensemble decision tree: Repeatedly generate decision trees adaptively, generate multiple decision trees, determine the optimal number of decision trees T by using the validation set error curve, and stop when the validation set error decreases by ≤0.5%; Calculate the classification accuracy of each decision tree on the validation set. Assigning voting weights Complete the training of the improved random forest model; Model inference stage: The fused feature vector F is input into the improved random forest model, and each decision tree outputs the character category prediction result; A weighted voting mechanism is used to calculate the weighted vote rate for each category, and the category with the highest vote rate is the prediction result. Output the prediction results and confidence levels, where the confidence level is equal to the highest vote percentage; Step S5: Outputting Results and Updating the Model.

[0024] Specifically in S5: S5.1 Result Correction: Match the prediction results with the maritime vessel name dictionary, and correct the errors for results with a confidence level ≥90% but with character confusion according to the dictionary; S5.2 Result Output: The ship image, ship name recognition result, and confidence level are displayed through the visualization unit, while the raw data and processing results are stored in the distributed database. S5.3 Model Update: When the number of newly collected samples is ≥1000, calculate the classification accuracy of each decision tree in the existing random forest on the new samples. For decision trees with an accuracy of less than 85%, retrain using the method in S4 to update the random forest model and achieve incremental learning.

[0025] Example 3

[0026] A storage medium storing a computer program, which, when read and run by a processor, performs the steps of a ship name recognition method based on a random forest model.

[0027] It should be noted that, in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.

[0028] The above description is only a preferred embodiment of the present invention. It should be noted that for those skilled in the art, several improvements and modifications can be made without departing from the technical principles of the present invention, and these improvements and modifications should also be considered within the scope of protection of the present invention.

Claims

1. A ship name recognition system based on a random forest model, comprising an image acquisition module (1), a preprocessing module (2), a feature extraction module (3), an improved random forest classification module (4), and a result output module (5), wherein each module is sequentially connected in communication, characterized in that, include: The image acquisition module (1) includes an industrial camera (101), a 5G / Ethernet image transmission unit (102), and a GPS / IMU positioning auxiliary unit (103), used to acquire ship images and attitude positioning data; The preprocessing module (2) is used to perform noise suppression and target region segmentation on the acquired image data; The feature extraction module (3) is used to output a multi-dimensional fused feature vector, and the feature extraction module (3) includes a basic visual feature extraction unit (301), a text structure feature extraction unit (302), a contextual environment feature extraction unit (303), and an attention mechanism feature fusion unit (304). The basic visual feature extraction unit (301) is used to extract grayscale histogram features, LBP texture features, and HOG shape features. Principal component analysis (PCA) is used to reduce the dimensionality of the extracted features, retaining principal components with a cumulative contribution rate of ≥95%, to obtain the basic feature vector. ; The text structure feature extraction unit (302) is used to extract text structure features, and the extraction strategy is as follows: B1. Perform character segmentation on the candidate ship name region, and use the projection method to calculate the character width, height, and spacing to form a structural parameter vector; B2. Extract font style features based on Fourier descriptors of character contours; B3. By fusing the structural parameter vector and font style features, the text structural feature vector is obtained. ; The context feature extraction unit (303) is used to extract the color contrast between the ship name region and the ship hull background, the light intensity, and the tilt angle of the region after ship attitude correction, forming a context feature vector. ; The attention mechanism feature fusion unit (304) uses an attention mechanism to... , , Weighted fusion is performed, and the weighted fusion formula is: ,and ,in , , The attention weights are adaptively learned through training data, and the final output is a fused feature vector F. The improved random forest classification module (4) is used to classify the fused feature vectors to realize the recognition of ship name characters; The result output module (5) is used to output the ship name recognition result and store the relevant data.

2. The ship name recognition system based on a random forest model according to claim 1, characterized in that, Multiple industrial cameras (101) are installed at different locations on the dock to collect raw image data of the ship. The 5G / Ethernet image transmission unit (102) uses the 5G / Ethernet transmission protocol to transmit the collected image data to the preprocessing module (2) in real time. The GPS / IMU positioning assistance unit (103) integrates GPS and an inertial measurement unit (IMU) to record the ship's position, heading and attitude information during image acquisition.

3. The ship name recognition system based on a random forest model according to claim 2, characterized in that, The preprocessing module (2) includes an adaptive noise suppression unit (201) and a ship name region segmentation unit (202). The adaptive noise suppression unit (201) uses an improved bilateral filtering algorithm to adaptively suppress noise in the original image data. The strategy of the improved bilateral filtering algorithm is as follows: let the pixel coordinates of the original image data be... The improved bilateral filtering algorithm formula is as follows: ,in Let S be the coordinates of other pixels within a neighborhood S centered on the current pixel. Indicates coordinates as The original grayscale value of the pixel. Indicates coordinates as The original grayscale value of the pixel. Let Gaussian kernel function be used in the spatial domain. The standard deviation of the Gaussian function in the spatial domain is used to measure the impact of spatial distance between pixels on the filtering result. For pixels With pixels The Euclidean distance between them The Gaussian kernel function with range, The standard deviation of the Gaussian function over the range is used to measure the impact of differences in grayscale values ​​between pixels on the filtering result. For pixels With pixels The absolute value of the difference in grayscale values. As the normalization factor, Represented as the coordinates after bilateral filtering. The new grayscale value of the pixel; The ship name region segmentation unit (202) combines ship attitude information with a region growing algorithm based on edge detection. The specific strategy is as follows: A1. Perform Canny edge detection on the denoised image to obtain the hull outline; A2. Determine the possible areas for the ship's name based on the ship's heading information; A3. Using the edge detection results as seed points, set the gray-scale difference threshold T with a value range of 10-30 to grow the candidate region for ship names.

4. The ship name recognition system based on a random forest model according to claim 1, characterized in that, The improved random forest classification module (4) includes an adaptive decision tree generation unit (401), a random forest ensemble optimization unit (402), and an incremental learning model update unit (403). The adaptive decision tree generation unit (401) is used to generate adaptive decision trees. Based on the characteristics and distribution of the input data, the generation process of the decision tree is dynamically adjusted. The strategy is as follows: Sample sampling optimization: Stratified sampling is adopted, and the sampling ratio is adjusted according to the category distribution of ship name characters to ensure that the deviation of the proportion of each type of sample in the decision tree training set is ≤10%; Feature selection optimization: A feature importance evaluation method based on mutual information is adopted to calculate the mutual information value between each feature and the character category label. ,choose The top 30% of features are used as candidate features for classification in the decision tree; Node splitting threshold optimization: The particle swarm optimization algorithm (PSO) is used to optimize the splitting threshold. The objective function is to minimize the Gini coefficient of the decision tree nodes. The formula for the Gini coefficient is: Where D is the node sample set and K is the number of character categories. Let k be the number of samples in the k-th class. denoted as the Gini coefficient of the node sample set. The number of node samples; The strategy of the random forest ensemble optimization unit (402) is as follows: Adaptive adjustment of the number of decision trees: The optimal number of decision trees T is determined by the validation set error curve. When the number of decision trees is increased, if the decrease in validation set error is ≤0.5%, the increase is stopped. The initial range of T is set to 50-200. Weighted voting mechanism: Based on the classification accuracy of each decision tree on the validation set. , Assigning voting weights The final classification result is the character category with the highest weighted vote; Model update unit: An incremental learning mechanism is adopted. When a new ship name image sample is input and the number of new ship name image samples is ≥1000, only the decision trees in the random forest with a classification accuracy of less than 85% are updated.

5. The ship name recognition system based on a random forest model according to claim 4, characterized in that, The result output module (5) includes a result correction unit (501) based on a maritime dictionary, a data storage unit (502) using HBase distributed data storage, and a Web visualization unit (503). Result correction unit (501): Uses a dictionary-based error correction algorithm to compare the recognition results with the maritime vessel name dictionary and correct erroneous characters; Data storage unit (502): Stores original images, preprocessing results, feature vectors, recognition results and positioning information. It adopts distributed database storage and supports fast data query and backtracking. Web visualization unit (503): Displays ship images, ship name recognition results, and recognition confidence in real time through a web interface, and supports manual annotation and feedback of abnormal results.

6. A ship name recognition method based on a random forest model, applied to the ship name recognition system based on a random forest model as described in any one of claims 1-5, characterized in that, The method includes the following steps: S1. Image Acquisition Image data of the target area of ​​the ship is acquired through the image acquisition module (1), and the ship's position, heading and attitude information are recorded at the time of acquisition. The image resolution is set to 1920×1080 and the frame rate is set to 25fps. The data is then transmitted to the preprocessing module (2). S2. Image Preprocessing Adaptive noise suppression: An improved bilateral filtering algorithm is used to denoise the acquired images. The noise intensity is calculated based on the grayscale standard deviation. If the standard deviation is greater than 15, it is considered high noise. The spatial domain Gaussian kernel parameter is dynamically adjusted. With grayscale Gaussian kernel parameters Furthermore, the Gaussian kernel parameter in the spatial domain is set to 2.0 for high noise and 0.5 for low noise, resulting in a denoised image output. Ship name region segmentation: Canny edge detection is performed on the denoised image, with a low threshold of 50 and a high threshold of 150 to obtain the ship's hull edges. Based on the ship's heading information, the candidate direction for the ship name region is determined to be parallel to the heading. The width range of the candidate region is set to 1 / 5-1 / 3 of the ship's width, and the height range is 1 / 10-1 / 5 of the ship's height. A region growing algorithm is used, with the edge detection results as seed points, and a gray-level difference threshold T is set to grow the candidate ship name regions. The gray-level difference threshold T is adaptively adjusted according to the average gray value of the image. When the average gray value is >128, the candidate region is obtained. ,otherwise The growth yielded a candidate area for ship names; S3. Multi-dimensional feature extraction is performed through the feature extraction module (3); S4. Model Training Phase: Construct a training dataset: Collect over 100,000 ship name image samples from different scenarios, label the character categories, including 26 English letters and 10 numbers, for a total of 36 categories, and divide the samples into training set, validation set, and test set in a 7:2:1 ratio; Adaptive Generative Decision Tree: Stratified sampling is used on the training set to ensure that the sampling ratio of each type of character sample is consistent with that of the original dataset; Calculate the mutual information value between each feature and the character category. ,choose The top 30% of features are used as candidate features for splitting; The PSO algorithm is used to optimize the node splitting threshold, with the number of particles set to 20, the number of iterations set to 50, and the objective function being to minimize the node Gini coefficient, thereby generating a single decision tree. Ensemble decision tree: Repeatedly generate decision trees adaptively, generate multiple decision trees, determine the optimal number of decision trees T by using the validation set error curve, and stop when the validation set error decreases by ≤0.5%; Calculate the classification accuracy of each decision tree on the validation set. Assigning voting weights Complete the training of the improved random forest model; Model inference phase: The fused feature vector F is input into the improved random forest model, and each decision tree outputs the character category prediction result; A weighted voting mechanism is used to calculate the weighted vote rate for each category, and the category with the highest vote rate is the prediction result. Output the prediction results and confidence levels, where the confidence level is equal to the highest vote percentage; Step S5: Outputting Results and Updating the Model.

7. The ship name recognition method based on a random forest model according to claim 6, characterized in that, Specifically, S3 includes: Basic visual feature extraction: The gray-level histogram statistics of the candidate ship name region were performed, and the gray-level range of 0-255 was divided into 128 intervals to obtain 128-dimensional gray-level histogram features. The LBP texture features of the candidate regions were calculated using a 3×3 neighborhood with 8 sampling points, resulting in 256-dimensional LBP features. HOG features were extracted from candidate regions. The cell unit size was set to 8×8, the block unit size was set to 2×2, and the orientation bins were set to 9, resulting in 320-dimensional HOG features. PCA dimensionality reduction is performed on the three types of features, and principal components with a cumulative contribution rate of ≥95% are retained to obtain the basic feature vector. ; Text structure feature extraction: The candidate region for ship names is horizontally projected, and the characters are segmented according to the projection valley value. The width, height, and character spacing of each character are calculated to form a 16-dimensional structural parameter vector. Perform a Fourier transform on each character outline, and take the first 32 Fourier coefficients as font style features to obtain a 32-dimensional font style feature vector. By fusing the structural parameter vector and the font style feature vector, the text structure feature vector is obtained. ; Contextual feature extraction: The RGB color contrast between the ship name area and the ship hull background is calculated, and two statistics are used for each channel: mean difference and variance difference, to obtain a 6-dimensional color contrast feature. Using light sensor data or image grayscale mean, the mean, variance, maximum and minimum values ​​of light intensity are calculated to obtain 4-dimensional light intensity characteristics; Based on the ship's attitude information, which includes the tilt angle and pitch angle, the tilt angle of the ship's name area is corrected to obtain a 2D tilt angle feature. By fusing the three types of features, a context feature vector is obtained. ; Feature fusion: Employing an attention mechanism , , We perform weighted fusion and learn attention weights from the training data. The output is the fused feature vector F.

8. The ship name recognition method based on a random forest model according to claim 7, characterized in that, Specifically, S5 refers to: S5.1 Result Correction: Match the prediction results with the maritime vessel name dictionary, and correct the errors for results with a confidence level ≥90% but with character confusion according to the dictionary; S5.2 Result Output: The ship image, ship name recognition result, and confidence level are displayed through the visualization unit, while the raw data and processing results are stored in the distributed database. S5.3 Model Update: When the number of newly collected samples is ≥1000, calculate the classification accuracy of each decision tree in the existing random forest on the new samples. For decision trees with an accuracy of less than 85%, retrain using the method in S4 to update the random forest model and achieve incremental learning.

9. A storage medium, characterized in that, The storage medium stores a computer program, which is read and executed by a processor to perform the steps of the ship name recognition method based on the random forest model as described in any one of claims 6-8.

Citation Information

Patent Citations

  • Ship working condition online identification method and system based on random forest algorithm

    CN117892230A

  • Vision-language combined ocean ship positioning method based on Transform

    CN119169096A