Ship name recognition method, electronic device and storage medium
By acquiring the trajectory association between the ship and the text detection box during the ship's movement, and then performing trajectory fitting to correct the text detection box, the problem of interference with ship name recognition is solved, and the recognition accuracy is improved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- ZHEJIANG DAHUA TECH CO LTD
- Filing Date
- 2022-12-28
- Publication Date
- 2026-05-08
AI Technical Summary
During ship operation, ship name recognition is affected by interference, leading to a decrease in recognition accuracy. Existing technologies are unable to effectively correct text detection boxes to improve recognition accuracy.
By obtaining the trajectory association between ships and text detection boxes in multiple images to be identified, trajectory fitting is performed to obtain the angle between the trajectory fitting line and the horizontal plane. The text detection boxes are then corrected to make the target text parallel to the horizontal plane, thereby improving the recognition accuracy.
It improves the recognition instability caused by ship movement and enhances the accuracy of ship name recognition.
Smart Images

Figure CN116152794B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer vision technology, and in particular to a ship name recognition method, electronic device and storage medium. Background Technology
[0002] With the increasing maturity and popularity of computer technology, in the process of ship name recognition, the text region is often detected in the text detection stage, and then the characters in the text region are identified in the text recognition stage.
[0003] In the research and practice of current technologies, ship name recognition effectiveness is reduced and recognition accuracy is affected when ships are in operation due to interference with the ship's name. Summary of the Invention
[0004] The main technical problem addressed by this application is to provide a ship name recognition method, electronic device, and storage medium that can determine the associated target ship and target text based on the associated ship detection box and text detection box, obtain the angle between the trajectory fitting line of the target text and the horizontal plane, and then correct the text detection box, thereby improving the impact on ship name recognition and increasing recognition accuracy.
[0005] To address the aforementioned technical problems, this application provides a ship name recognition method, comprising: acquiring multiple images to be recognized; associating ship detection boxes and text detection boxes in the multiple images to be recognized with trajectories to determine mutually associated target ships and target text; performing trajectory fitting based on the trajectory of the text detection boxes associated with the target text to obtain the angle between the trajectory fitting line and the horizontal plane; correcting the text detection boxes according to the angle, and recognizing the target text based on the corrected text detection boxes to obtain the ship name recognition result of the target ship.
[0006] In some embodiments, the step of fitting a trajectory based on the text detection box trajectory associated with the target text to obtain the angle between the trajectory fitting line and the horizontal plane includes: obtaining the trajectories of text detection boxes associated with the target text in multiple images to be identified; fitting the trajectory of the text detection box center point to the trajectory of the text detection box to obtain the trajectory fitting line corresponding to the target text; and determining the angle between the trajectory fitting line and the horizontal plane as the angle between the target text and the horizontal plane.
[0007] In some embodiments, correcting the text detection box according to the included angle includes: performing quality scoring on the target text in a plurality of images to be identified, and obtaining the target image corresponding to the target text with the highest quality score; wherein the target image contains the target text and the text detection box associated with the target text; rotating the target image by the included angle at the image center so that the target text in the target image is parallel to the horizontal plane, thereby obtaining the corrected text detection box.
[0008] In some embodiments, the step of recognizing the target text based on the corrected text detection box to obtain the ship name recognition result of the target vessel includes: using the smallest bounding rectangle of the corrected text detection box as the text recognition box; generating a plurality of text candidate boxes based on the text recognition box; performing text recognition on the plurality of text candidate boxes, scoring the text recognition results, and taking the text recognition result with the highest score as the ship name recognition result of the target vessel.
[0009] In some embodiments, the step of associating the ship detection boxes and text detection boxes in a plurality of images to be identified with trajectories to determine the mutually associated target ships and target text includes: acquiring ship detection boxes and text detection boxes in a plurality of images to be identified; performing target tracking on the ship detection boxes and the text detection boxes respectively to obtain the corresponding ship trajectories and text trajectories; when the ship trajectory and the text trajectory match, determining that the ship corresponding to the ship trajectory is the target ship, and determining that the text corresponding to the text trajectory is the target text.
[0010] In some embodiments, after obtaining the target text, the method further includes: performing quality scoring on the target text in a plurality of images to be identified to obtain a text quality score for the target text in each image; and caching the target binding information of the target vessel and the associated text quality score of the target text in a target cache corresponding to the target vessel, wherein the target binding information is the binding information between the target vessel and the target text.
[0011] In some embodiments, after caching the target binding information, the method further includes: traversing the target text in multiple images to be identified; if the target text does not have an associated target vessel and the target text is located within another vessel detection box, then binding the target text to the target vessel within the vessel detection box and updating the target cache; and / or, if the target text does not have an associated target vessel and the target text is located outside the vessel detection box of the target vessel, then discarding the target text.
[0012] In some embodiments, after caching the target binding information, the method further includes: querying the running trajectory of the target vessel; if the running trajectory of the target vessel cannot be retrieved, creating a new running trajectory of the target vessel, and inserting the running trajectory, the target binding information corresponding to the target vessel, and the target text quality score into the target cache.
[0013] To solve the above-mentioned technical problems, another technical solution adopted in this application is: to provide an electronic device, the electronic device including a memory and a processor coupled to the memory, the memory storing at least one computer program, and when the at least one computer program is loaded and executed by the processor, it is used to implement the ship name recognition method as described above.
[0014] To solve the above-mentioned technical problems, another technical solution adopted in this application is to provide a computer-readable storage medium having at least one program, which, when loaded and executed by a processor, is used to implement the ship name recognition method as described above.
[0015] Unlike current technologies, the ship name recognition method provided in this application includes: acquiring multiple images to be recognized; associating ship detection boxes and text detection boxes in the multiple images to be recognized with trajectories to determine mutually associated target ships and target text; performing trajectory fitting based on the trajectory of the text detection boxes associated with the target text to obtain the angle between the trajectory fitting line and the horizontal plane; correcting the text detection boxes according to the angle, and recognizing the target text based on the corrected text detection boxes to obtain the ship name recognition result of the target ship. In other words, this application improves the recognition accuracy of target text associated with target ships by correcting the text detection boxes corresponding to the target text boxes by using the angle between the trajectory fitting line of the target text and the horizontal plane. Attached Figure Description
[0016] Figure 1 This is a flowchart illustrating the first embodiment of the ship name identification method of this application;
[0017] Figure 2 This is a flowchart illustrating an embodiment of step S12 in this application;
[0018] Figure 3 This is a flowchart of an embodiment following step S12 in this application;
[0019] Figure 4 This is a flowchart illustrating an embodiment of step S125 in this application;
[0020] Figure 5 This is a flowchart illustrating an embodiment of step S13 in this application;
[0021] Figure 6This is a flowchart illustrating an embodiment of step S14 in this application;
[0022] Figure 7 This is a flowchart illustrating another embodiment of step S14 in this application;
[0023] Figure 8 This is a flowchart illustrating the second embodiment of the ship name identification method of this application;
[0024] Figure 9 This is a schematic diagram of the structure of an embodiment of the electronic device of this application;
[0025] Figure 10 This is a schematic diagram of the structure of an embodiment of the computer-readable storage medium of this application. Detailed Implementation
[0026] The present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be particularly noted that the following embodiments are for illustrative purposes only and do not limit the scope of the invention. Similarly, the following embodiments are only some, not all, embodiments of the present invention, and all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] In this document, the term "embodiment" means that a particular feature, structure, or characteristic described in connection with an embodiment may be included in at least one embodiment of the invention. The appearance of this phrase in various places throughout the specification does not necessarily refer to the same embodiment, nor is it a separate or alternative embodiment mutually exclusive with other embodiments. It will be explicitly and implicitly understood by those skilled in the art that the embodiments described herein can be combined with other embodiments.
[0028] Current ship name recognition methods, especially those used to identify ships in motion, are susceptible to the influence of objective factors such as viewing angle, lighting, and the ship's hull extending beyond the field of view. This can lead to the ship names being skewed when captured by the text detection box, thus affecting the accuracy of ship name recognition.
[0029] Therefore, a ship name recognition method is proposed. This method determines the associated target ship and target text by analyzing the trajectory relationship between ship detection boxes and text detection boxes. Then, the text detection box corresponding to the target text box is corrected by fitting the angle between the straight line and the horizontal plane along the target text's trajectory, thereby improving the recognition accuracy of target text associated with the target ship. In other words, the technical solution of this application improves the instability of ship name recognition by improving the ship's angle and viewing angle during its movement and by integrating historical frame information, thus enhancing recognition accuracy.
[0030] Please see Figure 1 , Figure 1This is a flowchart illustrating the first embodiment of the ship name recognition method of this application. It should be noted that if substantially the same result is obtained, the method of this application is not necessarily identical. Figure 1 The sequence of processes shown is limited.
[0031] like Figure 1 As shown, the ship name identification method includes the following steps:
[0032] S11. Acquire multiple images to be recognized.
[0033] The images to be identified are images of ships in motion. In order to obtain the trajectories of the ship detection boxes and the text detection boxes in the images, multiple images to be identified are required.
[0034] Specifically, multiple images to be identified are acquired, that is, multiple images of the ship in motion are acquired, so that the ship's motion trajectory and the text motion trajectory of the corresponding ship name can be obtained from these multiple images.
[0035] For example: acquire captured video images of ships, detect ship targets to obtain the ships in the video images, denoted as Ωb{b1,b2,…,bm}, where m is the number of ship targets, b1 is the first target ship, and bm is the m-th target ship; and detect text to obtain the text in the video images, denoted as Ωt{t1,t2,…,tn}, where n is the number of text targets, t1 is the first target text, and tn is the n-th target text.
[0036] In some embodiments, the multiple images to be identified can be continuous or discontinuous, as long as the ship's motion trajectory can be obtained subsequently.
[0037] S12. Perform trajectory association on the ship detection boxes and text detection boxes in multiple images to be identified, so as to determine the interrelated target ships and target text.
[0038] Among them, the ship detection box is the detection box when detecting ships in the image to be recognized, and the text detection box is the detection box when detecting the text of the ship name in the image to be recognized.
[0039] Specifically, in multiple images to be identified, ship detection boxes and text detection boxes corresponding to the names of each ship are obtained in each image. Based on the positional relationship of the ship detection boxes in each image, the motion trajectories of the ship detection boxes and the text detection boxes corresponding to the names of each ship in each image are determined. Then, the ship detection boxes and text detection boxes in the multiple images to be identified are associated with each other, that is, the ship detection boxes and text detection boxes are matched. If the trajectories match, the ship detection box and the estimated matching text detection box are determined to be the associated target ship and target text.
[0040] For example: Track the target ship set Ωb and target text set Ωt obtained in step S12, and assign a corresponding ID to each target ship and target text, thereby obtaining the trajectory of the ship detection box corresponding to the target ship set Ωb and the trajectory of the target text box corresponding to the target text set Ωt; and take each target ship b in the target ship set Ωb as an example. i (1≤i≤m) is the main target, and each target text t in the target text set Ωt is the target text t. j (1≤j≤n) is the secondary target; then, based on trajectory matching, the primary target and the secondary target are bound together, and a relationship between them is established.
[0041] S13. Based on the trajectory of the text detection box associated with the target text, perform trajectory fitting and obtain the angle between the trajectory fitting line and the horizontal plane.
[0042] In this context, the target text refers to the text associated with a target ship. Therefore, during the movement of the target ship, its trajectory matches the trajectory of the associated target text. Trajectory fitting refers to using trajectory fitting methods to fit multiple irregular trajectory points into regular line segments, such as straight lines.
[0043] Specifically, the motion trajectory of the text detection box associated with the target text is obtained, i.e., the text detection box trajectory. Based on this text detection box trajectory, a trajectory fitting method is used to fit it into a trajectory fitting line, and then the angle between the trajectory fitting line and the horizontal plane can be obtained. The trajectory fitting method can be the least squares method.
[0044] S14. Correct the text detection box according to the included angle, and recognize the target text based on the corrected text detection box to obtain the ship name recognition result of the target ship.
[0045] The angle between the trajectory fitting line and the horizontal plane is also equivalent to the angle between the target text and the horizontal plane. Therefore, by correcting the text detection box according to the angle, the corrected target text can be made parallel to the horizontal plane.
[0046] Specifically, based on step S13, the angle between the trajectory fitting line and the horizontal plane is obtained. Using this angle as the rotation angle, the image to be recognized corresponding to the target text is rotated, with the rotation center as the image center, so that the target text in the rotated image to be recognized is parallel to the horizontal plane; then, the target text is recognized based on the corrected text detection box.
[0047] In this embodiment, the present application improves the problem of unstable recognition results caused by the angle and viewing angle deviation of the ship by tilting the image of the target text so that the corrected target text is parallel to the horizontal plane, thereby improving the accuracy of the ship name recognition results of the target ship.
[0048] In one embodiment, see Figure 2 , Figure 2 This is a flowchart illustrating an embodiment of step S12. To reduce the impact of inaccurate detection boxes on recognition, it is necessary to further determine the associated ships and text. This requires trajectory association, such as... Figure 2 As shown, step S12 includes:
[0049] S121. Obtain ship detection boxes and text detection boxes from multiple images to be identified.
[0050] In this context, the ship detection box is the detection box corresponding to the ship in the image to be identified, and the text detection box is the detection box corresponding to the text in the image to be identified. The text here can be ship names, ship numbers, or other text used to identify ship information.
[0051] Specifically, in multiple images to be identified, the ship detection box corresponding to the ship and the text detection box corresponding to the text in each image to be identified are obtained;
[0052] In one embodiment, each image to be identified may contain one ship; therefore, it is only necessary to obtain the ship detection box and the corresponding text for that ship.
[0053] In another embodiment, each image to be identified may contain multiple ships. Therefore, it is necessary to obtain the ship detection boxes corresponding to the multiple ships in each image to be identified. Similarly, there will be multiple text detection boxes corresponding to the text.
[0054] S122. Perform target tracking on the ship detection box and the text detection box respectively to obtain the corresponding ship trajectory and text trajectory.
[0055] In order to obtain the ship trajectory and text trajectory, it is necessary to track the ship detection box corresponding to the ship and the text detection box corresponding to the text in multiple images to be recognized.
[0056] Specifically, in multiple images to be identified, target tracking is performed on the ship detection boxes and text detection boxes in the images to be identified respectively. Based on the positional relationship of the ship detection boxes in each image to be identified, the ship trajectory corresponding to the ship detection box is obtained, and based on the positional relationship of the text detection boxes in each image to be identified, the text trajectory corresponding to the text detection box is obtained.
[0057] S123. When matching ship trajectories and text trajectories, determine the ship corresponding to the ship trajectory as the target ship, and determine the text corresponding to the text trajectory as the target text.
[0058] In order to establish a relationship between ships and text, it is necessary to determine whether the trajectories match. That is, when the ship's trajectory and the text trajectory match, the ship and the text are associated. Here, matching means that the trajectories can overlap in space through movement.
[0059] Specifically, after obtaining the ship trajectory and text trajectory in the image to be identified in step S122, the ship trajectory and text trajectory are matched, and when the ship trajectory and text trajectory can be matched, the ship corresponding to the ship trajectory is determined to be the target ship, and the text corresponding to the text trajectory that matches the ship trajectory is determined to be the target text.
[0060] In one embodiment, the image to be identified may contain multiple ships, i.e., multiple target ships. These target ships can be numbered. Therefore, the trajectory of each ship must be matched with a text trajectory to obtain a text trajectory that matches the ship's trajectory. Based on the ship's number, this text is then set as the target text corresponding to that ship. For example, if the image to be identified contains three ships and three texts, the first, second, and third ships are matched with the first, second, and third texts, respectively. If the first ship matches the first text, the second ship matches the second text, and the third ship matches the third text, then the first ship is set as the first target ship, the first text as the first target text, the second ship as the second target ship, the second text as the second target text, and the third ship as the third target ship, and the third text as the third target text.
[0061] In this embodiment, the trajectory is associated with the ship detection box associated with the ship and the text detection box associated with the text, so that the ship is associated with the text, reducing the probability of misidentification of ship and ship name mismatch and improving the recognition accuracy.
[0062] In one embodiment, see Figure 3 , Figure 3 This is a flowchart illustrating an embodiment following step S12. To further improve the recognition accuracy caused by poor image quality, this embodiment employs an image quality scoring method to improve image quality and thus enhance recognition accuracy. Figure 3 As shown, it includes:
[0063] S124. Perform quality scoring on the target text in multiple images to be identified, so as to obtain the text quality score of the target text in each image.
[0064] Quality scoring refers to evaluating the target text in the images to be recognized. To obtain the best target text, it is necessary to score the quality of the target text in each image to be recognized. This quality scoring can be based on factors such as the clarity and slant of the target text, so that the target text can be clearly and accurately obtained.
[0065] Specifically, for an image containing target text, a quality score is applied to the text detection bounding box based on the target text to obtain the text quality score of each target text in each image to be identified.
[0066] S125. Cache the target binding information of the target vessel and the text quality score of the associated target text into the target cache corresponding to the target vessel.
[0067] The target binding information consists of the binding information between the associated target ships and the target text. The ship trajectory of each ship and the text trajectory of the matching target text need to be cached so that when matching between them, the corresponding ship and text matching information can be obtained.
[0068] Specifically, a corresponding target cache is established for each target vessel, and the target binding information of that target vessel and the text quality score of the target text associated with that vessel are cached in this target cache. For example, if there are three target vessels in the image to be identified, three target caches need to be established, corresponding one-to-one with each target vessel: the first target vessel corresponds to the first target cache, the second target vessel corresponds to the second target cache, and the third target vessel corresponds to the third target cache. The first target cache stores the target binding information of the first target vessel and the text quality score of the associated target text. Specifically, this may include: the vessel detection box information and vessel trajectory information of the first target vessel, the text detection box information and text trajectory information of the first target text, the trajectory matching information of the vessel detection box and the text detection box, the trajectory fitting information of the text detection box, the angle information between the trajectory fitting line and the horizontal plane, and the text quality score information of the first target text. The cache information of the second and third target caches is similar to that of the first target cache, and will not be described in detail here.
[0069] In one embodiment, see Figure 4 , Figure 4 This is a flowchart illustrating an embodiment of step S125. To ensure that each target text has an associated target ship, binding is required, such as... Figure 4 As shown, it includes:
[0070] S1251, Traverse the target text in multiple images to be recognized.
[0071] In this process, after the target text is determined, each image to be identified contains the corresponding target text. In order to determine whether each target text has a corresponding target ship, it is necessary to traverse multiple target texts.
[0072] For example: using the target ship as the primary target and the target text as the secondary target, iterate through each target text t in the target text set Ωt. j (1≤j≤n), if the target text t j The corresponding main target is already held, indicating the target text t. j There is already a primary target associated with it.
[0073] S1252. If the target text does not have an associated target ship, and the target text is located in another ship detection box, then bind the target text to the target ship in the ship detection box it is in, and update the target cache.
[0074] If the target text does not have an associated target ship, it means that no corresponding target ship has been found to bind to the target text. Therefore, it is necessary to further determine the relationship between the target text and the ship detection box.
[0075] Specifically, during the process of traversing the target text, if the target text in the image to be identified does not yet have an associated target ship, but the target text is located within one of the ship detection boxes, then the target text is bound to the target ship corresponding to the ship detection box, and the target cache corresponding to the target ship is updated.
[0076] For example: with the target ship as the primary target and the target text as the secondary target, if the target text t j The primary target is not held, and the target text t j The text detection box is located on the target ship b i Within the ship detection box, the target text t will be displayed. j As the target vessel b i A secondary target, the secondary target information contains the target text t j The quality score will be used to evaluate the target text. j With target vessel b i Perform association and link the target text t j Mark as holding the primary target.
[0077] S1253. If the target text has no associated target ship and the target text is outside the ship detection box of the target ship, then discard the target text.
[0078] If the target text has no associated target vessel and is located outside the target vessel's detection box, it indicates that the target vessel associated with the target text is not in the image to be identified. Therefore, the target text needs to be discarded.
[0079] Specifically, during the process of traversing the target text, if the target text does not have an associated target ship and the target text is not located within any target ship detection box in the image to be identified, then the target text does not have a bound target ship in the image to be identified and needs to be discarded.
[0080] For example: with the target ship as the primary target and the target text as the secondary target, if the target text t j The primary target is not held, and the target text t j The text detection box is located on the target ship b i Outside the ship detection box, the target text t is explained. j With target vessel b i If there is no relationship between them, then the target text t will not be affected. j With the target vessel b i Related.
[0081] In one embodiment, after caching the target binding information, the method further includes: querying the target vessel's trajectory; if the target vessel's trajectory cannot be retrieved, creating a new trajectory for the target vessel, and inserting the trajectory, the target binding information corresponding to the target vessel, and the target text quality score into the target cache.
[0082] Specifically, the target cache may not have cached new target vessels entering the image to be identified, or some vessels may be docked and starting operation midway, or the target vessel's trajectory may not have been obtained. Therefore, the trajectory of a new target vessel cannot be found. To ensure that all target vessels have corresponding trajectories, for target vessels whose trajectories are not cached, it is necessary to create new trajectories and update the relevant information of the new trajectories in the target cache.
[0083] For example: with target ships as the primary target and target text as the secondary target, and the target ships already associated with their corresponding target texts, for each primary target in the target ship set Ωb, i.e., each target ship b i (1≤i≤m), with target ship b i The system queries the target ship ID to see if it already exists in the target ship cache. If the target ship ID does not exist, it means that the target is a new target, and the system uses the target ship b as the target. i The ID is the key-value pair, which will be the target ship b. i The associated secondary targets are inserted into the ship's target cache, and the target ship b is... i The corresponding trajectory is inserted into the target ship b. i In the corresponding target cache, the cache length is the preset cache length K, which can be set according to the actual situation.
[0084] In one embodiment, if the ID of the target vessel already exists, it indicates that historical frame information for the target vessel already exists. Based on the target vessel b... i The ID of the target ship b i The associated secondary targets are inserted into the target buffer of the corresponding ship. It is then determined whether the target buffer is full. If the target buffer is full, the historical frame information that was first inserted into the buffer is deleted, and the target b of the ship with the current frame number t is added. i The information is inserted into the corresponding position. If the corresponding target cache is not full, it is directly inserted into the target ship b. i The target cache corresponding to the ID.
[0085] After obtaining the ship target cache information, the cache information contains historical frame information of the main ship target. The main ship target includes textual secondary targets, and for each main target, the target ship b... i (1≤i≤m), cache the target text t of its secondary target. ij (1≤i≤m, 1≤j≤k) i ), where k i The number of target texts corresponding to the text auxiliary targets contained in the target ship.
[0086] In one embodiment, see Figure 5 , Figure 5 This is a flowchart illustrating an embodiment of step S13. To obtain the offset angle between the target text and the horizontal plane, it is necessary to perform trajectory fitting based on the text detection box trajectory of the target text, and determine the offset angle using the trajectory-fitted straight line and the horizontal plane, such as... Figure 5 As shown, step S13 includes:
[0087] S131. Obtain the trajectory of the text detection box associated with the target text in multiple images to be recognized.
[0088] Each image to be recognized contains text detection box information associated with the target text. Based on the text detection box information, the position information of the text detection box in each image to be recognized can be known. The trajectory of the text detection box can be obtained based on the change of position information. Therefore, it is necessary to obtain the trajectory of the text detection box from multiple images to be recognized based on the position information of the text detection box.
[0089] Specifically, the position information of the text detection box associated with the target text is obtained in each image to be recognized. Based on several position information, the trajectory of the text detection box in multiple images to be recognized can be determined.
[0090] S132. Fit the trajectory of the center point of the text detection box to obtain the trajectory fitting line corresponding to the target text.
[0091] Among them, the trajectory fitting line is a straight line obtained by linear fitting based on the trajectory.
[0092] Specifically, a trajectory fitting method is used to fit the trajectory of the text detection box with the center point of the text detection box, thereby obtaining the trajectory fitting line of the target text associated with the text detection box.
[0093] In one embodiment, the trajectory fitting method can be the least squares method, that is, the least squares method is used to calculate the fitting line equation of the trajectory of the text detection box, and then the trajectory fitting line of the target text associated with the text detection box is obtained.
[0094] S133. Determine the angle between the trajectory fitting line and the horizontal plane as the angle between the target text and the horizontal plane.
[0095] In the process of ship operation, the target text obtained from the image to be recognized may be tilted, that is, the target text will have an angle with the horizontal plane; and the angle between the trajectory fitting line and the horizontal plane corresponds to the angle between the target text and the horizontal plane. Therefore, the angle between the trajectory fitting line and the horizontal plane can be determined as the angle between the target text and the horizontal plane.
[0096] In this embodiment, by fitting a straight line to the trajectory, the angle between the text target and the horizontal plane can be determined. Then, the image corresponding to the target text is tilted and corrected based on the angle so that the target text is parallel to the horizontal plane, reducing the impact of ship perspective shift on the recognition results.
[0097] In one embodiment, Figure 6 This is a flowchart illustrating an embodiment of step S14. To further improve the stability and accuracy of image recognition, it is necessary to select the target image corresponding to the target text with the highest quality score, such as... Figure 6 As shown, step S14 includes:
[0098] S141. Calculate the quality score of the target text in multiple images to be identified, and obtain the target image corresponding to the target text with the highest quality score; wherein, the target image contains the target text and the text detection box associated with the target text.
[0099] Each target text needs to have a corresponding quality score, and then the best target image corresponding to the target text can be selected based on the quality score.
[0100] Specifically, a quality score is assigned to the target text in each image to be identified, so as to obtain the quality score ranking of the target text in multiple images to be identified. Then, the target image corresponding to the target text with the highest quality score can be selected based on the quality score.
[0101] S142. Rotate the target image at an angle to the center of the image so that the target text in the target image is parallel to the horizontal plane, thereby obtaining the corrected text detection box.
[0102] The target image is the image corresponding to the target text with the highest quality score. The object to be rotated is the image, and the center of rotation is the center of the image. Therefore, the target image needs to be rotated around the center of the image at this angle.
[0103] Specifically, after obtaining the angle between the target text and the horizontal plane, the target image corresponding to the target text is rotated around this angle, so that the target text in the rotated target image is parallel to the horizontal plane, thus obtaining the corrected text detection box. For example, before correction, the text detection box is parallel to the horizontal plane, and the tilt angle between the target text within the text detection box and the horizontal plane is 30°. After correction, the tilt angle between the text detection box and the horizontal plane is 30°, and the corresponding target text is now parallel to the horizontal plane.
[0104] In one embodiment, see Figure 7 , Figure 7 This is a flowchart illustrating another embodiment of step S14. To ensure the target text is parallel to the horizontal plane during recognition, a recognition box parallel to both the target text and the horizontal plane needs to be obtained, such as... Figure 7 As shown, step S14 further includes:
[0105] S143. The smallest bounding rectangle of the corrected text detection box is taken as the text recognition box.
[0106] The minimum bounding rectangle refers to the bounding rectangle of a contour, also known as the minimum boundary rectangle, which is a rectangle parallel to the horizontal plane. The corrected text monitoring box can be tilted. Therefore, it is necessary to obtain the minimum bounding rectangle of the corrected text detection box and use this minimum bounding rectangle as the text recognition box. At this time, the text recognition box is parallel to the horizontal plane, which reduces the impact of poor recognition effect caused by the difference in viewing angle.
[0107] Specifically, based on the obtained corrected text detection box, the smallest bounding rectangle of the corrected text detection box is taken, and the smallest bounding rectangle is used as the text recognition box, so that when subsequent recognition is performed, the target text in the text recognition box is parallel to the horizontal plane.
[0108] S144. Based on the text recognition bounding box, generate several text candidate bounding boxes.
[0109] When the target text is tilted, after the text detection box is corrected to obtain the text recognition box, the corresponding target text may be wider on one side than the other or part of the text may be outside the text recognition box. In order to ensure that all the target text is within the text recognition box, some text candidate boxes need to be generated and adjusted by appropriate offsets so that the target text is within the text recognition box and that the target text is of equal width.
[0110] Specifically, candidate boxes are generated based on the text recognition bounding boxes. This involves applying random offsets, such as random length offsets, random width offsets, or random length and width offsets, to the text recognition bounding boxes to generate multiple candidate text boxes. For example, if the corrected target bounding box is R′ and the text recognition bounding box is R″, and the top-left corner coordinates of the text recognition bounding box R″ are (x1, y1), the width is w, and the height is h, then after applying random length and width offsets, the top-left corner coordinates of the candidate box are (x1+αw, y1+βh), where 0.04<|α|≤0.1, 0.04<|β|≤0.1, and β and α are different offset parameters. Following this step, O candidate boxes for the target text are generated, which, together with the original text recognition bounding boxes, result in a total of O+1 target boxes to be recognized.
[0111] S145. Perform text recognition on several text candidate boxes, score the text recognition results, and take the text recognition result with the highest score as the recognition result of the target ship's name.
[0112] In order to obtain the best recognition results, you can choose to score the recognition results of each target box to be recognized.
[0113] Specifically, after obtaining multiple target boxes to be identified, text recognition is performed on each target box. After obtaining the text recognition results of each target box, each text recognition result is scored. Finally, the text recognition result with the highest score is used as the ship name recognition result of the target ship.
[0114] In this embodiment, in order to further improve the stability and accuracy of image recognition, when selecting target images, the target image corresponding to the target text with the highest quality score is selected, and when obtaining recognition results, the text recognition result with the highest score is selected, so as to reduce the impact of poor target image quality or inaccurate target detection boxes on the ship name recognition results and improve the accuracy of ship name recognition.
[0115] Please see Figure 8 , Figure 8 This is a flowchart illustrating the second embodiment of the ship name recognition method of this application. To reduce the impact of interference with ship identification due to factors such as different viewing angles, lighting, ship parts exceeding the field of view, and temporary occlusion of characters, which can lead to poor recognition results, this embodiment improves the instability of ship name recognition results and enhances recognition accuracy by performing quality scoring optimization on the target image and combining it with tilt correction.
[0116] like Figure 8 As shown, some content overlaps with the above, so it will not be repeated here. The ship name identification method includes the following steps:
[0117] S21. Acquire multiple images to be recognized.
[0118] S22. Perform trajectory association on the ship detection boxes and text detection boxes in multiple images to be identified, so as to determine the interrelated target ships and target text.
[0119] S23. Calculate the quality score of the target text in multiple images to be identified, and obtain the target image corresponding to the target text with the highest quality score; wherein, the target image contains the target text and the text detection box associated with the target text.
[0120] Each target text needs to have a corresponding quality score, and then the best target image corresponding to the target text can be selected based on the quality score.
[0121] Specifically, a quality score is assigned to the target text in each image to be identified, so as to obtain the quality score ranking of the target text in multiple images to be identified. Then, the target image corresponding to the target text with the highest quality score can be selected based on the quality score.
[0122] S24. Based on the trajectory of the text detection box associated with the target text, perform trajectory fitting and obtain the angle between the trajectory fitting line and the horizontal plane.
[0123] S25. Rotate the target image at an angle to the center of the image so that the target text in the target image is parallel to the horizontal plane, thus obtaining the corrected text detection box.
[0124] The target image is the image corresponding to the target text with the highest quality score. The object to be rotated is the image, and the center of rotation is the center of the image. Therefore, the target image needs to be rotated around the center of the image at this angle.
[0125] Specifically, after obtaining the angle between the target text and the horizontal plane, the target image corresponding to the target text is rotated around the center of the image with respect to the angle, so that the target text in the rotated target image is parallel to the horizontal plane, thereby obtaining the corrected text detection box.
[0126] S26. Correct the text detection box according to the included angle, and recognize the target text based on the corrected text detection box to obtain the ship name recognition result of the target ship.
[0127] In this embodiment, when selecting a target image, the target image corresponding to the target text with the highest quality score is selected, and the target text is tilted to make the target text in the target image parallel to the horizontal plane, so as to reduce the impact of poor target image quality or inaccurate target detection box on the ship name recognition result and improve the ship name recognition accuracy.
[0128] Please see Figure 9 , Figure 9 This is a schematic diagram of an embodiment of the electronic device of this application. The electronic device can perform the steps in the above-described ship name recognition method. The electronic device 300 includes: a memory 310 and a processor 320 coupled to the memory. The memory 310 stores at least one computer program. When the at least one computer program is loaded and executed by the processor, it is used to implement the above-described ship name recognition method.
[0129] Please see Figure 10 , Figure 10 This is a schematic diagram of a computer-readable storage medium according to an embodiment of the present invention. The computer-readable storage medium 400 stores at least one program 410, which, when loaded and executed by a processor, is used to implement the above-described ship name recognition method.
[0130] The above scheme, on the one hand, establishes a trajectory association between the ship detection box and the text detection box, enabling the target ship and the target text to be related, and obtains the required target image through multiple images to be recognized, thereby avoiding interference from characters being temporarily obscured or the ship's hull being out of the field of view; on the other hand, it corrects the tilt of the text detection box, making the target text within the text detection box parallel to the horizontal plane, thereby avoiding interference caused by different viewing angles and improving recognition accuracy.
[0131] In the several embodiments provided by this invention, it should be understood that the disclosed systems, apparatuses, and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of modules or units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces, indirect coupling or communication connection of apparatuses or units, and may be electrical, mechanical, or other forms.
[0132] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment, depending on actual needs.
[0133] Furthermore, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or as a software functional unit.
[0134] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute all or part of the steps of the methods described in the various embodiments of the present invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0135] The above description is merely an embodiment of the present invention and does not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.
Claims
1. A method for identifying ship names, characterized in that, The ship name recognition method includes: Acquire multiple images to be recognized; Trajectory association is performed on ship detection boxes and text detection boxes in multiple images to be identified to determine the mutually associated target ships and target texts. Specifically, the ship trajectory corresponding to the ship detection box and the text trajectory corresponding to the text detection box are obtained respectively, and the target ship and the target text are determined by matching the ship trajectory and the text trajectory. Based on the trajectory of the text detection box associated with the target text, trajectory fitting is performed to obtain the angle between the trajectory fitting line and the horizontal plane. Specifically, the trajectories of the text detection boxes associated with the target text in multiple images to be identified are obtained. The trajectory of the text detection box is fitted with the trajectory of the center point of the text detection box to obtain the trajectory fitting line corresponding to the target text. The angle between the trajectory fitting line and the horizontal plane is determined as the angle between the target text and the horizontal plane. The text detection box is corrected according to the included angle, and the target text is identified based on the corrected text detection box to obtain the ship name recognition result of the target ship.
2. The ship name recognition method according to claim 1, characterized in that, The step of correcting the text detection box according to the included angle includes: The target text in multiple images to be identified is scored for quality, and the target image corresponding to the target text with the highest quality score is obtained; wherein, the target image contains the target text and the text detection box associated with the target text; The target image is rotated around the included angle to make the target text in the target image parallel to the horizontal plane, thus obtaining the corrected text detection box.
3. The ship name recognition method according to claim 2, characterized in that, The step of recognizing the target text based on the corrected text detection box to obtain the ship name recognition result of the target vessel includes: The smallest bounding rectangle of the corrected text detection box is taken as the text recognition box; Based on the text recognition box, several text candidate boxes are generated; Text recognition is performed on several of the text candidate boxes, and the text recognition results are scored. The text recognition result with the highest score is taken as the ship name recognition result of the target ship.
4. The ship name identification method according to claim 1, characterized in that, The step of associating the ship detection boxes and text detection boxes in multiple images to be identified with trajectories to determine the interrelated target ships and target text includes: Obtain ship detection boxes and text detection boxes from multiple images to be identified; Target tracking is performed on the ship detection box and the text detection box respectively to obtain the corresponding ship trajectory and text trajectory; When the ship trajectory and the text trajectory match, the ship corresponding to the ship trajectory is determined to be the target ship, and the text corresponding to the text trajectory is determined to be the target text.
5. The ship name identification method according to claim 4, characterized in that, After obtaining the target text, the process also includes: The target text in multiple images to be identified is scored to obtain a text quality score for the target text in each image. The target binding information of the target vessel and the text quality score of the associated target text are cached in the target cache corresponding to the target vessel, wherein the target binding information is the binding information between the associated target vessel and the target text.
6. The ship name identification method according to claim 5, characterized in that, Following the cached target binding information, it also includes: The target text is traversed through multiple images to be identified; If the target text does not have an associated target ship, and the target text is located within another ship detection box, then the target text is bound to the target ship within its own ship detection box, and the target cache is updated; and / or If the target text is not associated with any target vessel and is located outside the vessel detection box of the target vessel, then the target text is discarded.
7. The ship name identification method according to claim 5, characterized in that, Following the cached target binding information, it also includes: The trajectory of the target vessel is queried. If the trajectory of the target vessel cannot be found, a new trajectory of the target vessel is created, and the trajectory, the target binding information corresponding to the target vessel, and the target text quality score are inserted into the target cache.
8. An electronic device, characterized in that, The electronic device includes a memory and a processor coupled to the memory, the memory storing at least one computer program, which, when loaded and executed by the processor, is used to implement the ship name recognition method as described in any one of claims 1-7.
9. A computer-readable storage medium, characterized in that, The computer-readable storage medium has at least one program that, when loaded and executed by a processor, is used to implement the ship name recognition method as described in any one of claims 1-7.
Citation Information
Patent Citations
Ship license plate correction and recognition method in natural scene
CN111985470A
Character recognition method, character recognition device and storage medium
CN113498520A