Parking space number identification method, terminal, medium, program product and vehicle
Through multi-frame image processing and editing distance matrix backtracking technology, the error problem of parking space number identification under different lighting and weather conditions is solved, and the accuracy of identification is improved.
Patent Information
- Application Number
- CN202510178255.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-02-18
- Publication Date
- 2025-06-13
AI Technical Summary
The existing parking space number identification method is subject to different lighting conditions, weather changes and camera resolution changes, resulting in parking space number identification errors, such as multiple characters, missing characters, typos, etc.
By obtaining multi-frame images for the same parking space, building a character table, generating a parking space number vector, calculating a unit vector matrix, selecting a reference parking space number, calculating and editing distance matrix, searching back and correcting errors, and outputting the correct result.
The accuracy of parking space number recognition is improved, and identification errors are avoided due to low image target quality or insufficient generalization performance of the recognition algorithm.
Smart Images

Figure CN120148002A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of identification of parking space numbers, and particularly to a method, a terminal, a medium, a program product and a vehicle for identifying parking space numbers. Background Art
[0002] The identification of parking space numbers uses image processing and computer vision technologies to automatically identify the numbers in each parking space. The existing parking space number identification methods perform image character positioning through methods such as image gradient and edge calculation, and then classify the characters through template matching to identify the parking space numbers; or use deep learning to automatically learn and obtain the features of the parking space numbers in the image through a neural network to obtain the identification results of the parking space numbers. However, different lighting conditions, weather changes, and camera resolutions will affect the clarity of the parking space numbers in the image, resulting in errors in the identification of parking space numbers, such as problems of multiple characters, missing characters, and wrong characters. Summary of the Invention
[0003] Embodiments of the present invention provide a method, a terminal, a medium, a program product and a vehicle for identifying parking space numbers to improve the accuracy of parking space number identification.
[0004] To achieve the above object, on the one hand, a method for identifying a parking space number is provided, including:
[0005] Obtaining multiple frames of images including a parking space number taken for the same parking space;
[0006] Identifying the parking space number for the multiple frames of images to obtain a set of parking space numbers;
[0007] Using all the characters that appear in the set of parking space numbers to construct a character table, wherein in the character table, each character has a preset position index;
[0008] For each parking space number in the set of parking space numbers, traversing the characters of the parking space number, and obtaining a parking space number vector corresponding to the parking space number according to the characters included in the parking space number and the position index of each character in the character table, the length of the parking space number vector is the same as the length of the character table;
[0009] For the set of parking space number vectors corresponding to the set of parking space numbers, by dividing each parking space number vector by its modulus length, obtaining the unit vectors of the parking space number vectors, and splicing the unit vectors of the parking space number vectors row by row to obtain a unit vector matrix;
[0010] For each unit vector, multiply the unit vector by the unit vector matrix to obtain the cosine similarity between the unit vector and each unit vector, and sum the cosine similarities between the unit vector and each unit vector to obtain the total cosine similarity between the unit vector and the unit vector matrix. Then, use the parking space number corresponding to the unit vector with the highest total cosine similarity as the reference parking space number;
[0011] Sort the parking space numbers corresponding to each unit vector in descending order according to the total cosine similarity of each unit vector;
[0012] According to the pre-set state transition matrix, calculate the edit distance matrix between the reference parking space number and each parking space number in the sorted order;
[0013] Start backtracking from the lower right corner of the edit distance matrix, determine the error type of the parking space number character according to the direction in which the value in the edit distance matrix decreases, and correct the parking space number character according to the error type of the parking space number character until backtracking to the position with index 0 in the edit distance matrix;
[0014] Output the corrected correct result.
[0015] Preferably, in the parking space number recognition method, the backtracking search step further includes one or more of the following;
[0016] If the value decreases upward, it is determined that the parking space number character is missing, and a placeholder is inserted at the corresponding index position for correction;
[0017] If the value decreases to the left, it is determined that the reference parking space number character is missing, and a placeholder is inserted at the corresponding index position;
[0018] If the value decreases to the upper left, it is determined that the character recognition is incorrect, and the character confidence of each parking space number corresponding index position is counted, and the character with the highest confidence is selected as the correct result.
[0019] Preferably, in the parking space number recognition method, an optical character recognition method is used to recognize the parking space number.
[0020] Preferably, in the parking space number recognition method, the step of obtaining the parking space number vector corresponding to the parking space number according to the characters included in the parking space number and the position index of each character in the character table includes:
[0021] When the parking space number does not contain a character, the value at the position corresponding to the character in the parking space vector corresponding to the parking space number is 0; when the parking space number includes m identical characters, the value at the position corresponding to the character in the parking space vector corresponding to the parking space number is m; m is an integer greater than or equal to 1.
[0022] On the other hand, a vehicle-mounted terminal is provided, which includes a memory and a processor. The memory stores at least one program, and the at least one program is executed by the processor to implement the steps of the parking space number recognition method described in any one of the above.
[0023] In another aspect, a computer-readable storage medium is provided. At least one program is stored in the storage medium, and the at least one program is executed by the processor to implement the steps of the parking space number recognition method described in any one of the above.
[0024] In another aspect, a computer program product is provided, including a computer program. It is characterized in that when the computer program is executed by a processor, the steps of the parking space number recognition method described in any one of the above are implemented.
[0025] In another aspect, a vehicle is provided, including the vehicle-mounted terminal described above.
[0026] The above technical solutions have the following technical effects:
[0027] The technical solution of the embodiment of the present invention fuses multiple frames of images for the same parking space, constructs a character table using all the characters that appear in the parking space number, obtains the parking space vector corresponding to each parking space number, selects the parking space number with the highest reliability among multiple parking space numbers as the reference parking space number, compares the text edit distance between the remaining parking space numbers and the reference parking space number, locates and corrects the positions of the characters with errors according to the edit distance, and then outputs the correct result, improving the accuracy of parking space number recognition and avoiding the parking space number recognition error caused by the low quality of the image target or the insufficient generalization performance of the image recognition algorithm. BRIEF DESCRIPTION OF THE DRAWINGS
[0028] Figure 1 is a schematic flow chart of the parking space number recognition method according to an embodiment of the present invention;
[0029] Figure 2 is an example of an edit distance matrix between the calculated reference parking space number and a parking space number. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0030] To further illustrate the embodiments, the present invention provides drawings. These drawings are a part of the disclosure of the present invention, mainly used to illustrate the embodiments, and can be used to explain the operating principle of the embodiments in conjunction with the relevant descriptions in the specification. With reference to these contents, those of ordinary skill in the art should be able to understand other possible implementation manners and the advantages of the present invention. The components in the drawings are not drawn to scale, and similar component symbols are usually used to represent similar components.
[0031] Now, the present invention will be further described in conjunction with the drawings and specific embodiments.
[0032] Embodiment 1:
[0033] Figure 1 The flowchart of the method for identifying parking space numbers according to an embodiment of the present invention is shown as Figure 1 , and the method for identifying parking space numbers in this embodiment includes:
[0034] S1. Obtain multiple frames of images containing parking space numbers taken for the same parking space;
[0035] S2. Identify the parking space numbers for the multiple frames of images to obtain a set of parking space numbers; in a specific implementation, an optical character recognition (OCR) method is used to identify the parking space numbers;
[0036] S3. Construct a character table using all the characters that appear in a set of parking space numbers, where in the character table, each character has a preset position index;
[0037] S4. For each parking space number in a set of parking space numbers, traverse the characters of the parking space number, and obtain the parking space number vector corresponding to the parking space number according to the characters included in the parking space number and the position index of each character in the character table. The length of the parking space number vector is the same as the length of the character table;
[0038] In a specific implementation, the step of obtaining the parking space number vector corresponding to the parking space number according to the characters included in the parking space number and the position index of each character in the character table includes:
[0039] When the parking space number does not include a character, the value at the position corresponding to the character in the parking space vector corresponding to the parking space number is 0; when the parking space number includes m identical characters, the value at the position corresponding to the character in the parking space vector corresponding to the parking space number is m; m is an integer greater than or equal to 1;
[0040] The following uses an actual example to illustrate the generation of the parking space number vector:
[0041] For example, a set of parking space numbers obtained is: ["AB1234", "AC345", "AB1224"];
[0042] Generate a character table according to the characters that have appeared in this set of parking space numbers. The key is the character that appears, and the value is the position index of the character. The character table is:
[0043] ['1': 0, '2': 1, '3': 2, '4': 3, '5': 4, 'A': 5, 'B': 6, 'C': 7];
[0044] Then, a 0 vector with the same length as the character table is generated for each parking space number. Traverse each character. According to the included characters, when a character appears, increment the value at the index position corresponding to the character by 1. For example, if the parking space number "AB1224" contains two "2" characters, the value at the position corresponding to this character is taken as 2. Thus, the above group of parking space numbers is converted into the following corresponding group of parking space vectors: [[1 1 1 1 0 1 1 0][0 0 1 1 1 1 0 1][1 2 0 1 0 1 1 0]];
[0046] S5. For a group of parking space vectors corresponding to a group of parking space numbers, by dividing each parking space vector by its respective modulus length, the unit vector of each parking space vector is obtained, and the unit vectors of each parking space vector are concatenated row by row to obtain a unit vector matrix;
[0047] S6. For each unit vector, multiply the unit vector by the unit vector matrix to obtain the cosine similarity between the unit vector and each unit vector, and sum the cosine similarities between the unit vector and each unit vector to obtain the total cosine similarity between the unit vector and the unit vector matrix. The parking space number corresponding to the unit vector with the highest total cosine similarity is used as the reference parking space number;
[0048] S7. Sort the parking space numbers corresponding to each unit vector in descending order according to the total cosine similarity of each unit vector;
[0049] S8. According to the pre-set state transition matrix, calculate the edit distance matrix between the reference parking space number and each parking space number in the sorted order; wherein, there is an edit distance matrix between each parking space number and the reference parking space number, and this edit distance matrix is composed of the edit distance values between the characters in the reference parking space number and the characters of each parking space number; wherein, the edit distance is the minimum number of edit operations required to convert one string into another string. For example, adding a character, deleting a character, or replacing a character; the greater the edit distance, the smaller the similarity between the two strings; on the contrary, the smaller the edit distance, the greater the similarity between the two strings; for two identical strings, the edit distance is 0; preferably, the edit distance is the Levenshtein Distance;
[0050] Figure 2 An example of the edit distance matrix calculated between the reference parking space number and a parking space number is as follows. For example Figure 2 , in this example, taking "South C-231" as the reference parking space number, which contains 6 characters; another parking space number is "South C231", which contains 5 characters. The constructed edit distance matrix is 6 rows and 6 columns, and the matrix size is determined by the number of characters in the reference parking space number. Figure 2The example in a,b uses the following state transition matrix to calculate the edit distance matrix between these two strings. Here, a is the first string, such as the reference parking space number, b is the second string, such as the other parking space number mentioned above, i is the row number of the matrix, j is the column number of the matrix, and lev
[0051]
[0052] max(i, j) represents the maximum value between the row number i and the column number j;
[0053] min(i, j) represents the minimum value between the row number i and the column number j;
[0054] lev a,b (i - 1, j) is the value of the element at the position of the j-th column in the (i - 1)-th row of the edit distance matrix between these two parking space numbers a and b;
[0055] lev a,b (i, j - 1) is the value of the element at the position of the (j - 1)-th column in the i-th row of the edit distance matrix between these two parking space numbers a and b;
[0056] lev a,b (i - 1, j - 1) is the value of the element at the position of the (j - 1)-th column in the (i - 1)-th row of the edit distance matrix between these two parking space numbers a and b;
[0057] a i represents the character corresponding to the string of parking space number a at the position index i, and b j represents the character corresponding to the string of parking space number b at the position index j; where means that when a i ≠b j it is equal to lev a,b (i - 1, j - 1) + 1; when a i =b j it is equal to lev a,b (i - 1, j - 1). S9. Starting from the lower right corner of the edit distance matrix, perform backtracking search. Determine the error type of the parking space number characters according to the direction in which the values in the edit distance matrix decrease, and correct the parking space number characters according to the error type of the parking space number characters until backtracking to the position with index 0 in the edit distance matrix;
[0058] In a specific implementation, the steps of the above backtracking search further include one or more of the following;
[0059] If the value decreases upward, it is determined that the parking space number character is missing, and a placeholder is inserted at the corresponding index position for correction;
[0060] If the value decreases to the left, it is determined that the reference parking space number character is missing, and a placeholder is inserted at the corresponding index position;
[0061] If the value decreases to the upper left, it is determined that the character recognition is incorrect, and the character confidence of each index position corresponding to the parking space number is counted, and the character with the highest confidence is selected as the correct result;
[0062] In a specific implementation, according to the editing path search, a group of parking space numbers and reference parking space numbers are aligned at the character level, and then the character confidence of each index position is counted, and the character with the highest confidence is selected as the output at that position; as Figure 2 It can be seen that the value at the position of the 4th row and the 3rd column of the edit distance matrix is 1, and the value above it is 0, that is, the situation where the value decreases upward appears. It is determined that the parking space number character is missing, and a placeholder is inserted at the corresponding index position for correction.
[0063] Similarly, the edit distance matrix between other parking space numbers and reference parking space numbers can be calculated and corresponding corrections can be made. S10, output the correct result after correction.
[0064] In a specific implementation, after obtaining the corrected result, it is further determined whether the obtained parking space number meets the output conditions, including: whether its format conforms to the pre-set rules and whether the confidence of its characters exceeds the threshold; if both are yes, it is determined that it is the correct result and output; if the output conditions are met, the previous steps S1 to S9 are repeated until the parking space number recognition result that meets the output conditions is found.
[0065] Embodiment 2:
[0066] The present invention also provides a vehicle-mounted terminal, including a memory and a processor, where the memory stores at least one segment of program, and the at least one segment of program is executed by the processor to implement the steps of the above-mentioned parking space number recognition method embodiment.
[0067] Embodiment 3:
[0068] The present invention also provides a computer-readable storage medium, where the storage medium stores at least one segment of program, and the at least one segment of program is executed by the processor to implement the steps of the above-mentioned parking space number recognition method embodiment.
[0069] If the modules / units integrated in the computer unit are implemented in the form of software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, to implement all or part of the processes in the above-described embodiment methods of the present invention, it can also be completed by a computer program instructing relevant hardware. The computer program can be stored in a computer-readable storage medium. When the computer program is executed by a processor, the steps of the above-described method embodiments can be implemented. Among them, the computer program includes computer program code, and the computer program code can be in the form of source code, object code, executable file, or some intermediate form, etc. The computer-readable medium can include: any entity or device capable of carrying the computer program code, recording medium, USB flash drive, mobile hard disk, magnetic disk, optical disc, computer memory, read-only memory (ROM), random access memory (RAM), and software distribution medium, etc. It should be noted that the content included in the computer-readable medium can be appropriately increased or decreased according to the requirements of legislation and patent practice in the jurisdiction.
[0070] Embodiment 4:
[0071] The present invention also provides a computer program product, including a computer program, and when the computer program is executed by a processor, the steps of the method embodiment for identifying the parking space number as described above are implemented.
[0072] Embodiment 5:
[0073] The present invention also provides a vehicle, including the in-vehicle terminal as described above.
[0074] Although the present invention is specifically shown and described in conjunction with the preferred embodiments, those skilled in the art should understand that various changes can be made to the present invention in terms of form and details without departing from the spirit and scope of the present invention defined by the appended claims, and all of them fall within the protection scope of the present invention.
Claims
1. A method for identifying a parking space number, characterized in that: include: Obtain multiple frames of images including parking space numbers taken for the same parking space; Recognize parking space numbers for the multiple frames of images to obtain a set of parking space numbers; Constructing a character table using all characters appearing in the set of parking space numbers, wherein each character in the character table has a preset position index; For each parking space number in the set of parking space numbers, traverse the characters of the parking space number, and obtain a parking space number vector corresponding to the parking space number according to the characters included in the parking space number and the position index of each character in the character table, wherein the length of the parking space number vector is the same as the length of the character table; For a group of parking space number vectors corresponding to the group of parking space numbers, the parking space number vectors are divided by their respective module lengths to obtain unit vectors of each parking space number vector, and the unit vectors of each parking space number vector are concatenated row by row to obtain a unit vector matrix; For each unit vector, multiply the unit vector by the unit vector matrix to obtain the cosine similarity between the unit vector and each unit vector, and sum the cosine similarities between the unit vector and each unit vector to obtain the sum of the cosine similarities between the unit vector and the unit vector matrix, and use the parking space number corresponding to the unit vector with the highest sum of cosine similarities as the reference parking space number; Sort the parking space numbers corresponding to each unit vector according to the sum of the cosine similarities of each unit vector from large to small; According to a preset state transition matrix, an edit distance matrix between the reference parking space number and each parking space number is calculated in a sorted order; Starting from the lower right corner of the edit distance matrix, backtracking the search, determining the error type of the parking space number character according to the direction in which the value in the edit distance matrix decreases, and correcting the parking space number character according to the error type of the parking space number character, until backtracking to the position with index 0 in the edit distance matrix; Output the correct result after correction.
2. The method for identifying a parking space number according to claim 1, characterized in that: The step of backtracking search also includes one or more of the following: If the value decreases upward, it is determined that the parking space number character is missing, and a placeholder is inserted at the corresponding index position to correct it; If the value decreases to the left, it is determined that the reference parking space number character is missing, and a placeholder is inserted at the corresponding index position; If the value decreases toward the upper left, it is determined that the character recognition is wrong, and the character confidence of each parking space number corresponding to the index position is counted, and the character with the highest confidence is selected as the correct result.
3. The method for identifying a parking space number according to claim 1, characterized in that: Optical character recognition is used to identify parking space numbers.
4. The method for identifying a parking space number according to claim 1, characterized in that: The step of obtaining a parking space number vector corresponding to the parking space number according to the characters included in the parking space number and the position index of each character in the character table comprises: When the parking space number does not contain a character, the value of the position corresponding to the character in the parking space vector corresponding to the parking space number is 0; when the parking space number includes m identical characters, the value of the position corresponding to the character in the parking space vector corresponding to the parking space number is m; m is an integer greater than or equal to 1.
5. A vehicle-mounted terminal, characterized in that: The method comprises a memory and a processor, wherein the memory stores at least one program, and the at least one program is executed by the processor to implement the steps of the parking space number recognition method as described in any one of claims 1 to 4.
6. A computer-readable storage medium, characterized in that: The storage medium stores at least one program, and the at least one program is executed by a processor to implement the steps of the parking space number recognition method as described in any one of claims 1 to 4.
7. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the parking space number recognition method as described in any one of claims 1 to 4 are implemented.
8. A means of transport, characterized in that: Comprising the vehicle-mounted terminal as claimed in claim 5.