A character recognition method, system, computer device and storage medium
By performing binarization processing and connected component analysis on tunnel mileage marker images, combined with neural network recognition technology, the problem of difficulty in mileage marker recognition caused by low light, character adhesion, and high noise in tunnels was solved, and accurate mileage calculation was achieved.
Patent Information
- Application Number
- CN202210784133.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-07-05
- Publication Date
- 2026-02-13
- Estimated Expiration
- 2042-07-05
AI Technical Summary
In tunnel defect detection, existing technologies struggle to accurately identify characters in tunnel mileage marker images, especially in low light, when characters are stuck together, there is a lot of noise, and characters are of varying sizes, leading to significant errors in mileage calculation.
By binarizing the mileage marker image, the height ratio, relative position, and width ratio of the connected regions are extracted. Combined with the pre-acquired attribute values of the labeled image, the target connected region is selected, and character recognition is performed using a neural network. Finally, the accurate mileage marker value is obtained.
It achieves accurate batch recognition of mileage marker images in tunnel environments, eliminates the influence of inconsistent character sizes and noise, and improves the accuracy of mileage calculation.
Smart Images

Figure CN115294579B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The application belongs to the technical field of mileage marker image recognition, and particularly relates to a character recognition method and system, a computer device and a storage medium. BACKGROUND
[0002] At present, in tunnel disease detection, a vehicle is generally loaded with a detection device to pass through the tunnel, and the detection device emits detection signals to the inner wall, ground and other positions in the tunnel to obtain detection data. In order to determine the positioning corresponding to the detection data, the mileage of the vehicle needs to be calculated.
[0003] An encoder can be installed on the wheel to obtain the mileage of the vehicle, or a positioning camera can be installed on the vehicle to calculate the mileage of the vehicle through the images captured by the camera. However, the wheel may slip, and the images captured by the positioning camera may be blurred, so that the mileage calculated by the above two methods may have errors. A solution to eliminate the errors can be that there are generally mileage markers in the tunnel, a camera is used to capture the mileage markers in the tunnel, and then the characters in the mileage marker images are recognized, and the mileage readings recognized are used to correct the mileage errors obtained by the above two methods.
[0004] However, because the light in the tunnel is relatively dark, the quality of the captured mileage marker images is poor, some characters are connected, and the images contain a large amount of noise; and the camera installed on the vehicle is in a moving state, and the relative distance to the mileage marker is not the same each time of capturing, so that the characters in different images are of different sizes. These situations bring difficulties to batch recognize the characters in the mileage marker images.
[0005] Therefore, how to batch recognize the characters in the mileage marker images containing connected characters, a large amount of noise and characters of different sizes is a problem to be solved in the field. SUMMARY
[0006] In view of the problems in the prior art, the application provides a character recognition method and system, a computer device and a storage medium.
[0007] The application is implemented in the following manner. A character recognition method comprises the following steps: extracting each connected region in a binary image; selecting a target connected region containing a character from each connected region according to a height proportion, a relative position and a first attribute value of a labeled image obtained in advance; segmenting a character image corresponding to a single character from the target connected region according to the number of target connected regions, a width proportion of the target connected region and a second attribute value of the labeled image; and combining character recognition results according to the relative position to obtain a mileage marker value in a mileage marker image.
[0008] Further, the character recognition method comprises the following steps:
[0009] binarize the milestone image containing characters to be recognized to obtain a binarized image;
[0010] extract each connected region in the binarized image, and obtain attribute values of the connected regions respectively; the attribute values include a height proportion, a width proportion of the connected region in the binarized image, and a relative position of the connected region in the binarized image;
[0011] select a target connected region containing characters from the connected regions according to the height proportion, the relative position, and a corresponding attribute value range of a labeled image obtained in advance; the labeled image is a milestone image on which characters have been labeled in advance, and the labeled image and the milestone image are collected from the same road section;
[0012] segment a character image corresponding to a single character from the target connected region according to the number of target connected regions, the width proportion of the target connected region, and the corresponding attribute value range of the labeled image;
[0013] recognize the characters in the character image to obtain a corresponding character recognition result;
[0014] combine the character recognition result according to the relative position to obtain a milestone value in the milestone image.
[0015] Further, the attribute values of the connected regions obtained respectively include:
[0016] obtain the height and width of the connected region and the height and width of the binarized image;
[0017] calculate the ratio of the height of the connected region to the height of the binarized image to obtain the height proportion of the connected region in the binarized image;
[0018] calculate the ratio of the width of the connected region to the width of the binarized image to obtain the width proportion of the connected region in the binarized image;
[0019] determine the minimum bounding rectangle of the connected region;
[0020] calculate the distance between each side of the minimum bounding rectangle and the nearest side of the binarized image;
[0021] obtain the relative position of the connected region in the binarized image according to the distance.
[0022] Further, before the target connected region containing characters is selected from the connected regions according to the height proportion and the relative position, it further includes:
[0023] obtaining a labeled image sample set; the labeled image sample set comprises a plurality of labeled images;
[0024] obtaining an attribute value of each character contained in the labeled image; the attribute value comprises a height proportion, a width proportion, and a relative position of an edge pixel point of the character in the labeled image in the labeled image; the height proportion is a ratio of the height of the character to the height of the labeled image, the width proportion is a ratio of the width of the character to the width of the labeled image, and the relative position is a relative position of the character in the labeled image;
[0025] obtaining a height proportion range, a width proportion range, and a relative position range according to the height proportion, the width proportion, and the relative position of each character in the labeled image sample set;
[0026] selecting a target connected region containing a character from the connected regions according to the height proportion, the relative position, and the corresponding attribute value of the labeled image obtained in advance, comprising:
[0027] determining whether the connected region satisfies a first condition and a second condition simultaneously; the first condition is that the height proportion of the connected region belongs to the height proportion range; the second condition is that the relative position of the connected region in the milestone image belongs to the relative position range;
[0028] if yes, the connected region is determined as a target connected region containing a character.
[0029] Further, after determining whether the connected region satisfies the first condition and the second condition simultaneously, further comprising:
[0030] if the connected region cannot satisfy the first condition and the second condition simultaneously, the connected region is determined as a connected region not containing a character.
[0031] Further, the character image corresponding to a single character is segmented from the target connected region according to the width proportion of the target connected region and the corresponding attribute value of the labeled image, comprising:
[0032] obtaining a highest number of characters contained in a single labeled image from the labeled image sample set to obtain a first number;
[0033] determining a number of target connected regions in the milestone image to obtain a second number;
[0034] if the second number is equal to the first number, a character image corresponding to a single character is segmented from the target connected region according to the width proportion of the connected region in the binary image.
[0035] If the second number is less than the first number, determine a ratio of a width proportion of the target connected region to the width proportion range;
[0036] As the ratio determines the number of characters included in the target connected region;
[0037] As the number of characters is divided into a character image corresponding to a single character from the target connected region.
[0038] Further, the identification of the characters in the character image includes:
[0039] Using a neural network to perform image recognition on the character image to obtain a pre-recognition result corresponding to the character and a confidence value corresponding to the pre-recognition result;
[0040] In the case where the confidence value is greater than a first threshold value, the pre-recognition result is taken as a character recognition result.
[0041] Another object of the present application is to provide a character recognition system, which includes:
[0042] A binarization module for performing binarization processing on a mileage marker image containing a character to be recognized to obtain a binarized image;
[0043] An extraction module for extracting each connected region in the binarized image and obtaining attribute values of each connected region, respectively; the attribute values include a height proportion, a width proportion of the connected region in the binarized image, and a relative position of the connected region in the binarized image;
[0044] A selection module for selecting a target connected region containing a character from the each connected region according to the height proportion, the relative position, and a corresponding attribute value range of a labeled image obtained in advance; the labeled image is a mileage marker image with characters labeled in advance, and the labeled image and the mileage marker image are collected from the same section;
[0045] A segmentation module for segmenting a character image corresponding to a single character from the target connected region according to the number of target connected regions, the width proportion of the target connected region, and the corresponding attribute value range of the labeled image;
[0046] An identification module for identifying characters in the character image to obtain a corresponding character recognition result;
[0047] A combination module for combining the character recognition result according to the relative position to obtain a mileage marker value in the mileage marker image.
[0048] Another object of the present application is to provide a computer device comprising a processor and a memory coupled, the memory being configured to store computer program instructions which, when executed by the processor, cause the electronic device to perform the steps of the character recognition method as described.
[0049] Another object of the present application is to provide a computer storage medium having stored therein program instructions which, when executed on an electronic device, cause the electronic device to perform the steps of the character recognition method as described.
[0050] In combination with the above technical solutions and the technical problems solved, the advantages and positive effects of the technical solutions to be protected by the present application are analyzed from the following aspects:
[0051] First, in view of the technical problems existing in the prior art and the difficulty in solving the problems, the technical solutions to be protected by the present application and the results and data in the research and development process are analyzed in detail and deeply to analyze how the technical solutions solve the technical problems and bring some creative technical effects after solving the problems. The specific description is as follows:
[0052] The present application uses the height proportion to identify the target connected region, which can eliminate the influence of the different sizes of characters in the image on the size of the connected region. In addition, the height proportion and the relative position can be used to identify the noise in the image, and the width proportion can be used to identify the characters that are stuck together, so that the characters in the mileage marker image can be accurately batch-identified.
[0053] Secondly, from the perspective of the product as a whole, the technical solutions to be protected by the present application have the technical effects and advantages, which are described in detail as follows:
[0054] The application carries out binarization processing on a mileage marker image containing characters to be recognized, to obtain a binarization image; extracts each connected region in the binarization image, and respectively obtains attribute values of the connected regions; selects a target connected region containing characters from the connected regions according to the height proportion, the relative position and a first attribute value of a pre-acquired labeled image; divides a character image corresponding to a single character from the target connected region according to the number of the target connected regions, a width proportion of the target connected region and a second attribute value of the labeled image; recognizes characters in the character image to obtain a corresponding character recognition result; and combines the character recognition result according to the relative position to obtain a mileage marker value in the mileage marker image. In the above method, the height proportion is used to recognize the target connected region, which can eliminate the influence of different sizes of characters in the image on the size of the connected region, and the height proportion and the relative position can be used to recognize noise in the image, and the width proportion can be used to recognize characters that are stuck together, so that the characters in the mileage marker image can be accurately batch-recognized. BRIEF DESCRIPTION OF DRAWINGS
[0055] Figure 1 A step flow chart of a first character recognition method provided by an embodiment of the application;
[0056] Figure 2 A schematic diagram of a mileage marker image and a binarization image provided by an embodiment of the application;
[0057] Figure 3 A schematic diagram of a target edge pixel point and a target edge of a binarization image provided by an embodiment of the application;
[0058] Figure 4 A schematic diagram of a character image corresponding to a single character provided by an embodiment of the application;
[0059] Figure 5 A step flow chart of a second character recognition method provided by an embodiment of the application;
[0060] Figure 6 A schematic diagram of a character that is stuck together provided by an embodiment of the application;
[0061] Figure 7 A structure block diagram of a character recognition device provided by an embodiment of the application;
[0062] Figure 8 A raw image provided by an embodiment of the application;
[0063] Figure 9 A schematic diagram of a hundred-meter marker after affine transformation provided by an embodiment of the application;
[0064] Figure 10This is a schematic diagram of the binarized 100-meter marker provided in an embodiment of the present invention;
[0065] Figure 11 The character extraction result of the 100-meter marker provided in this embodiment of the invention (the confidence level of the last 0 is 0.21);
[0066] Figure 12 This is a schematic diagram of the character segmentation error of the 100-meter marker provided in an embodiment of the present invention;
[0067] Figure 13 This is a schematic diagram illustrating an error in character extraction provided in an embodiment of the present invention.
[0068] Figure 14 This is a schematic diagram of the 100-meter marker within the field of view provided in an embodiment of the present invention;
[0069] Figure 15 This is a schematic diagram illustrating the extraction of a line of characters from a 100-meter marker, provided in an embodiment of the present invention.
[0070] Figure 16 Image 1 is a schematic diagram of the 100-meter marker provided in an embodiment of the present invention;
[0071] Figure 17 This is a schematic diagram of the 100-meter marker image 2 provided in an embodiment of the present invention;
[0072] Figure 18 This is a schematic diagram of the recognition results provided in an embodiment of the present invention;
[0073] Figure 19 This is a schematic diagram of a suspected 100-meter marker provided in an embodiment of the present invention;
[0074] Figure 20 This is a schematic diagram of a suspected 100-meter marker provided in an embodiment of the present invention;
[0075] Figure 21 Image 3 is a schematic diagram of a suspected 100-meter marker provided in an embodiment of the present invention. Detailed Implementation
[0076] To make the objectives, technical solutions, and advantages of this invention clearer, the invention will be further described in detail below with reference to embodiments. It should be understood that the specific embodiments described herein are merely illustrative and not intended to limit the invention.
[0077] To enable those skilled in the art to fully understand how the present invention is specifically implemented, this section provides an explanatory description of the embodiments that expand upon the technical solutions of the claims.
[0078] like Figure 1 The diagram shown is a flowchart of the steps of the first output control method provided in an embodiment of the present invention.
[0079] Referring to Figure 1 , the method comprises:
[0080] Step 101, binarization processing is performed on the mileage marker image containing characters to be recognized, to obtain a binarization image.
[0081] The camera field of view for shooting the mileage marker is adjusted to face the height of the tunnel side mileage marker, the vehicle travels in the tunnel, the camera shoots the tunnel side according to the set frequency, to obtain some images containing the mileage marker and some images not containing the mileage marker. The images containing the mileage marker are selected to obtain the mileage marker image containing characters to be recognized.
[0082] Image binarization is to set the gray value of the pixel point on the image to 0 or 255, that is, to present a clear black and white effect on the whole image. The specific method is to select an appropriate threshold, set the gray value of the pixel point greater than or equal to the threshold to 0, and set the gray value of the pixel point less than the threshold to 255; or set the gray value of the pixel point greater than or equal to the threshold to 255, and set the gray value of the pixel point less than the threshold to 0.
[0083] In the embodiment of the application, the gray value of the characters in the mileage marker image is small, and the gray value of the background is large. An appropriate threshold value can be set, which is a value between the gray value of the characters and the gray value of the background. The gray value of the pixel point greater than or equal to the threshold is set to 0, and the gray value of the pixel point less than the threshold is set to 255, so that the characters of interest are highlighted from the background.
[0084] Figure 2 The schematic diagram of the mileage marker image and the binarization image provided by the embodiment of the application.
[0085] Wherein, Figure 2 -a is the mileage marker image shot by the camera, Figure 2 -b is the binarization image corresponding to the mileage marker image. According to the set threshold, Figure 2 the gray value of the pixel point greater than or equal to the threshold in the-a mileage marker image is set to 0, and the gray value of the pixel point less than the threshold is set to 255. Thus, Figure 2 the binarization image with the foreground gray value of 255 and the background gray value of 0 in-b is obtained.
[0086] It can be found that, Figure 2 there are dirt shown by the number 1 and cracks shown by the number 2 in-a, and after binarization processing, Figure 2 the dirt 1 and the cracks 2 are also highlighted as foreground targets in-b.
[0087] Step 102, extracting each connected region in the binary image, and obtaining attribute values of each connected region respectively; the attribute values include height proportion, width proportion of the connected region in the binary image, and relative position of the connected region in the binary image.
[0088] The connected region refers to a group of foreground pixel points with the same pixel value and adjacent positions in an image. After the binary image obtained in step 101 is subjected to connected region extraction, a plurality of connected regions can be obtained.
[0089] Figure 3 FIG. 1 is a schematic diagram of a connected region provided by an embodiment of the present application.
[0090] Referring to FIG. 1, Figure 3 connected regions in the binary image Figure 2 can be obtained, which are shown as labels 3, 4, 5, 6 and 7.
[0091] After the connected regions are obtained, the attribute values of each connected region are obtained. The attribute values can include height proportion, width proportion of the connected region in the binary image, and relative position of the connected region in the binary image.
[0092] Optionally, the attribute values of each connected region are obtained respectively, including the following steps A1-A6.
[0093] A1, obtaining height, width of the connected region and height, width of the binary image.
[0094] A2, calculating a ratio of the height of the connected region to the height of the binary image to obtain the height proportion of the connected region in the binary image.
[0095] A3, calculating a ratio of the width of the connected region to the width of the binary image to obtain the width proportion of the connected region in the binary image.
[0096] A4, determining a minimum circumscribed rectangle of the connected region.
[0097] A5, calculating distances of each side of the minimum circumscribed rectangle to the nearest side of the binary image.
[0098] A6, obtaining the relative position of the connected region in the binary image according to the distances.
[0099] In steps A1-A6, the height of the connected region, the width of the connected region and the height of the binary image, the width of the binary image can be obtained respectively, to obtain the height of the connected region, denoted as L-height, and the width of the connected region, denoted as L-width; to obtain the height of the binary image, denoted as E-height, and the width of the binary image, denoted as E-width.
[0100] The height ratio is denoted as HB, HB = L-height / E-height, and the width ratio is denoted as WB, WB = L-width / E-width.
[0101] The minimum bounding rectangle of the connected region is located in the binary image, and the distance of each side of the minimum bounding rectangle to the respective side of the binary image is different, and the nearest distance is taken to obtain the distance of each side to the nearest side. Each connected region obtains 4 distances, and according to the 4 distances, the relative position of the connected region in the binary image can be located.
[0102] Referring to Figure 3 , the minimum bounding rectangle of the connected region 3 and the connected region 7 is shown in the dashed box. The length of the perpendicular segment of each side of the minimum bounding rectangle to the nearest side of the binary image is the distance of the minimum bounding rectangle to the respective side of the binary image.
[0103] Figure 3 In FIG. 4, the distance PQ of the minimum bounding rectangle of the connected region 3 to the side AD of the binary image, the distance EF of the minimum bounding rectangle of the connected region 7 to the side AD of the binary image, and the distances of other sides of the minimum bounding rectangle to the sides of the binary image are similar, Figure 4 which is not shown in FIG. 4.
[0104] In step 103, a target connected region containing a character is selected from the connected regions according to the height ratio, the relative position and the corresponding attribute value of the labeled image obtained in advance. The labeled image is a milestone image on which characters have been labeled in advance, and the labeled image and the milestone image are collected from the same road section.
[0105] Before the vehicle performs disease detection, a plurality of image samples of milestones can be pre-shot in the tunnel, and attribute values of the samples are obtained. Thus, when the vehicle formally performs disease detection, the character recognition process of the milestone image obtained on site can be guided according to the attribute value information of the pre-learned samples.
[0106] Specifically, characters can be identified and labeled from the sample, and then attribute values of each character are obtained, including height proportion, width proportion, relative position, and number of characters, and finally attribute values of each character in each sample are obtained. Using these attribute values, attribute value ranges can be comprehensively obtained, such as the range of character height proportion, the range of width proportion, and the range of relative position of characters in different regions of the image.
[0107] According to the function, the attribute value range can be divided into a first attribute value range and a second attribute value range. The first attribute value range is the range of character height proportion and the range of relative position of characters. The second attribute value range is the range of character width proportion and the range of number of characters. The corresponding attribute value range here is the first attribute value range.
[0108] There may be cracks, dirt, and other noise points on the mileage marker. When extracting the connected region, these noise points may also be identified as connected regions. However, the height of the crack or dirt is quite different from the height of the character, and these features can be used to identify the noise points. For noise points with a height comparable to that of the character, the relative position of the noise points in the mileage marker image can be used to further identify the noise points, thereby obtaining the connected region that actually contains characters, i.e., the target connected region.
[0109] Specifically, when the vehicle is formally tested for diseases, the height proportion and relative position of each connected region in the mileage marker image can be compared with the first attribute value range obtained in advance. If the attribute value of the connected region falls within the first attribute value range obtained in advance, it is considered that the connected region may contain characters, and the connected region is determined as the target connected region.
[0110] Because the height, width, and relative position of the characters on the mileage marker are fixed, the size of the mileage marker image only affects the overall size of the image, but the height proportion, width proportion, and relative position are relative proportions, and the overall size of the image does not affect these proportions. Therefore, using height proportion, width proportion, and relative position information to identify the target connected region can eliminate the influence and differences caused by the different sizes of characters in the image on the height, width, and relative position of the connected region, and can accurately identify the target connected region in any mileage marker image in the same tunnel.
[0111] Referring to Figure 3 According to the height proportion, the connected region 6 can be identified as a noise point. The connected region 7 has a height similar to that of the character, so it cannot be identified according to the height proportion. However, the connected region 7 is located between two characters, so it can be identified as a noise point according to the relative position. In this way, the final target connected region is the connected regions 3, 4, and 5.
[0112] Step 104: Based on the number of target connected regions, the width ratio of the target connected regions, and the corresponding attribute value range of the labeled image, segment the character image corresponding to a single character from the target connected regions.
[0113] The corresponding attribute value range here is the range of the second attribute value. The range of the second attribute value for the labeled image is the range of the character width ratio and the range of the number of characters in the labeled image.
[0114] If the number of target connected components is the maximum value within the range, then each target connected component corresponds to one character. If the number of target connected components is less than the maximum value within the range, then each target connected component may correspond to one character, or some target connected components may actually contain multiple contiguous characters. In this case, the width proportion of the target connected components can be compared with the width proportion range to determine whether there are contiguous characters in the target connected components. If contiguous characters exist, they can be divided into equal parts.
[0115] Ultimately, the character image corresponding to a single character can be obtained.
[0116] Figure 4 This is a schematic diagram of a character image corresponding to a single character, provided as an embodiment of the present invention.
[0117] Reference Figure 4 ,right Figure 3 The target connected region in the image is segmented according to step 104, resulting in character images corresponding to labels 8, 9, and 10. Image recognition is then performed on these character images to obtain the corresponding character recognition results.
[0118] Step 105: Recognize the characters in the character image to obtain the corresponding character recognition results.
[0119] Character recognition algorithms or neural networks are used to identify characters in character images, and the character recognition results and confidence values are obtained.
[0120] The credibility of the recognition result is determined according to the confidence level value. If the confidence level is high, it is taken as the final recognition result. If the confidence level is low, the recognition result is discarded.
[0121] If the recognition results of all character images in the same mileage marker image are of high confidence, proceed to step 106; if the recognition result of one character image in the same mileage marker image is of low confidence, discard the entire recognition result, and then find an image similar to the mileage marker image in the mileage marker image captured by the camera to re-recognize the character.
[0122] Step 106, combining the character recognition results according to the relative positions to obtain the mileage marker value in the mileage marker image.
[0123] According to the relative positions of the connected regions corresponding to the character images, the specific positions of the character images in the mileage marker image can be determined.
[0124] For example, the characters in the character images are recognized to obtain corresponding character recognition results of 1, 0 and 5 respectively, according to the relative positions, it is judged that 1 is close to the left side, 5 is close to the right side and 0 is close to the middle in the mileage marker image, and thus the combination of 105 can be obtained, which is the mileage marker value in the mileage marker image.
[0125] In summary, in the embodiment of the present application, the mileage marker image containing characters to be recognized is binarized to obtain a binarized image; each connected region in the binarized image is extracted, and attribute values of the connected regions are obtained respectively; according to the height proportion, the relative position and the first attribute value of the labeled image obtained in advance, a target connected region containing characters is selected from the connected regions; according to the number of target connected regions, the width proportion of the target connected region and the second attribute value of the labeled image, a character image corresponding to a single character is segmented from the target connected region; the characters in the character image are recognized to obtain corresponding character recognition results; and the character recognition results are combined according to the relative positions to obtain the mileage marker value in the mileage marker image. In the above method, the height proportion is used to identify the target connected region, which can eliminate the influence of different sizes of characters in the image on the size of the connected region, the height proportion and the relative position are used to identify the noise in the image, and the width proportion is used to identify the characters that are stuck together, so that the characters in the mileage marker image can be accurately batch-recognized.
[0126] Figure 5 The flowchart of the second character recognition method in the embodiment of the present application is shown in Fig. 2. Figure 5 As shown in Fig. 2, the method comprises the following steps.
[0127] Step 201, obtaining a labeled image sample set; the labeled image sample set comprises a plurality of labeled images.
[0128] Before the vehicle detects diseases, a plurality of images of mileage markers can be pre-shot in the tunnel, and characters are recognized and labeled from the samples to obtain labeled images.
[0129] In this way, when the vehicle formally detects diseases, the character recognition process of the mileage marker image obtained on site can be guided according to the information of the pre-learned labeled image.
[0130] Step 202, obtaining attribute values of each character contained in the labeled image; the attribute values include a height proportion of the character in the labeled image, a width proportion of the character, and a relative position of an edge pixel point of the character in the labeled image; the height proportion is a ratio of the height of the character to the height of the labeled image, the width proportion is a ratio of the width of the character to the width of the labeled image, and the relative position is a relative position of the character in the labeled image.
[0131] Similarly, by comparing the method of steps A1-A6, attribute values of each character contained in the labeled image can be obtained, and the specific process is not described again.
[0132] Step 203, obtaining a height proportion range, a width proportion range and a relative position range according to the height proportion, the width proportion and the relative position of each character in the labeled image sample set.
[0133] In the embodiment of the application, a maximum value and a minimum value of the height proportion are obtained, and then the height proportion range is between the maximum value and the minimum value; similarly, the width proportion range and the relative position range can be obtained.
[0134] Step 204, performing binaryzation processing on the milestone image containing the to-be-recognized character to obtain a binaryzation image.
[0135] In the embodiment of the application, step 204 can refer to step 101, and details are not described again.
[0136] Step 205, extracting each connected region in the binaryzation image, and obtaining attribute values of the connected regions respectively; the attribute values include a height proportion of the connected region in the binaryzation image, a width proportion of the connected region, and a relative position of the connected region in the binaryzation image.
[0137] In the embodiment of the application, step 205 can refer to step 102, and details are not described again.
[0138] Step 206, determining whether the connected region satisfies the first condition and the second condition simultaneously; the first condition is that the height proportion of the connected region belongs to the height proportion range; and the second condition is that the relative position of the connected region in the milestone image belongs to the relative position range.
[0139] In the embodiment of the application, there may be noise points such as cracks and dirt on the milestone, and when the connected region is extracted, these noise points may also be extracted as the connected region. In order to remove the noise points, the first condition and the second condition can be used for screening.
[0140] Because the height of the crack and the dirt is quite different from the height of the character, the noise can be identified according to these features, i.e. the first condition is used for identification. For the noise with a height equivalent to that of the character, the noise can be further identified according to the difference between the relative position of the noise in the mileage mark image and the relative position of the character, i.e. the second condition is used for identification.
[0141] Step 207: If yes, the connected region is determined as a target connected region containing a character.
[0142] The connected region satisfying both the first condition and the second condition is generally a connected region containing a character, and the noise is basically removed.
[0143] Step 208: If the connected region cannot satisfy both the first condition and the second condition, the connected region is determined as a connected region not containing a character.
[0144] If one of the first condition and the second condition is not satisfied, or both are not satisfied, it is indicated that the connected region is a connected region corresponding to the noise, and the connected region is discarded.
[0145] Step 209: The highest number of characters contained in a single labeled image is obtained from the labeled image sample set, to obtain a first number.
[0146] In the embodiment of the present application, because the characters in the labeled image sample set have been labeled, the number of characters contained in a single labeled image is easy to obtain, and the highest value of the number is taken to obtain the first number.
[0147] Step 210: The number of target connected regions in the mileage mark image is determined, to obtain a second number.
[0148] The target connected region is a connected region containing a character, and the number of target connected regions can be obtained according to the judgment result of step 207.
[0149] Step 211: If the second number is equal to the first number, a character image corresponding to a single character is segmented from the target connected region according to the width proportion of the connected region in the binary image.
[0150] If the second number is equal to the first number, it is indicated that the number of target connected regions has reached the maximum number of characters in the labeled image, and it is further indicated that there is no character adhesion in the target connected region, because if there is character adhesion, the number of target connected regions will be smaller, and the number of connected regions will not reach the maximum number.
[0151] Then, each target connected region corresponds to a character, and a character image corresponding to a single character can be segmented according to the width proportion of the connected region in the binary image.
[0152] Step 212, if the second number is less than the first number, determining the ratio of the width proportion of the target connected region to the width proportion range.
[0153] If the second number is less than the first number, it may be that the number of target connected regions in the binary image is less than the number of characters, or it may be that the number of target connected regions in the binary image is equal to the number of characters.
[0154] In order to determine which case, the ratio of the width proportion of the target connected region to the width proportion range can be calculated. If the ratio is approximately 1, it means that the number of target connected regions in the binary image is equal to the number of characters; if the ratio is much greater than 1, it means that the number of target connected regions in the binary image is less than the number of characters, and there must be a character sticking phenomenon, which causes the algorithm to regard the sticking characters as a target connected region.
[0155] Step 213, determining the number of characters included in the target connected region according to the ratio.
[0156] If the ratio of the width proportion of the target connected region to the width proportion range is approximately n, it means that the number of characters included in the target connected region is n.
[0157] Step 214, according to the number of characters, the character image corresponding to a single character is segmented from the target connected region.
[0158] If the number of characters is n, the width proportion of a single character is obtained by dividing the width proportion of the target connected region by n, and the character image corresponding to a single character can be segmented according to the width proportion of a single character.
[0159] Figure 6 A schematic diagram of a sticking character provided by an embodiment of the present application.
[0160] Referring to Figure 6 -a, a mileage marker image in which there is a sticking character, Figure 6 -b is the image obtained after the binary processing of Figure 6 -a, in which there is a target connected region. The ratio of the width proportion of the target connected region to the width proportion range is calculated, and the obtained ratio is approximately 2, which means that there are 2 characters in the target connected region. The target connected region is evenly segmented to obtain the character image corresponding to each character. The obtained character image is shown in Figure 6 -c.
[0161] Step 215, using a neural network to perform image recognition on the character image to obtain a pre-recognition result corresponding to the character and a confidence value corresponding to the pre-recognition result.
[0162] Specifically, the character image can be input into an ANN_MLP (Artificial Neural Network_Minsley and Papert, Multi-Layer Perceptron) network model for image recognition, and the network model outputs a pre-recognition result and a corresponding confidence value.
[0163] The neural network has high accuracy and fast recognition speed in recognizing characters, and is suitable for real-time processing.
[0164] Step 216: If the confidence value is greater than a first threshold value, the pre-recognition result is taken as a character recognition result.
[0165] The first threshold value is set in advance, and if the confidence value is greater than or equal to the first threshold value, the pre-recognition result is considered to be reliable, and is taken as a final character recognition result. For example, the first threshold value can be set to 70%, and the pre-recognition result greater than or equal to 70% is considered to be a reliable recognition result.
[0166] If the confidence value is less than the first threshold value, the pre-recognition result is considered to be unreliable, and the recognition result needs to be discarded.
[0167] If the confidence values of the pre-recognition results of all character images in the same milestone image are greater than or equal to the first threshold value, step 217 is performed; if the confidence value of the recognition result of one character image in the same milestone image is low, the entire recognition result is discarded, and then a similar image to the milestone image is searched for in a milestone image captured by a camera to re-perform character recognition.
[0168] Step 217: The character recognition results are combined according to the relative positions to obtain a milestone value in the milestone image.
[0169] In the embodiment of the present application, step 217 can refer to step 106, which will not be described here.
[0170] In summary, the embodiment of the present application has the advantages of Figure 1The beneficial effects of the character recognition method in the background art are further obtained, the highest number of characters contained in a single labeled image is obtained from a labeled image sample set, to obtain a first number; the number of target connected regions in the milestone image is determined, to obtain a second number; if the second number is equal to the first number, a character image corresponding to a single character is segmented from the target connected region according to the width proportion of the connected region in the binary image; if the second number is less than the first number, the ratio of the width proportion of the target connected region to the width proportion range is determined; the number of characters included in the target connected region is determined according to the ratio; and the character image corresponding to a single character is segmented from the target connected region according to the number of characters. In this way, characters with adhesion phenomenon can be effectively recognized, so that single characters are accurately segmented, and the segmentation accuracy is improved. Moreover, in the present scheme, the neural network is used to recognize the character image, so that the accuracy is high, the recognition speed is fast, and real-time processing is suitable.
[0171] Figure 7 A structural block diagram of an output control device is provided for the embodiments of the present application. As shown in Figure 7 the device 300 includes:
[0172] A binary module 301 is configured to perform binary processing on a milestone image containing characters to be recognized, to obtain a binary image.
[0173] An extraction module 302 is configured to extract each connected region in the binary image and obtain attribute values of the connected regions, respectively; the attribute values include a height proportion, a width proportion and a relative position of the connected region in the binary image.
[0174] A selection module 303 is configured to select a target connected region containing characters from the connected regions according to the height proportion, the relative position and the corresponding attribute value range of a labeled image obtained in advance; the labeled image is a milestone image with characters labeled in advance, and the labeled image and the milestone image are collected from the same section.
[0175] A segmentation module 304 is configured to segment a character image corresponding to a single character from the target connected region according to the number of target connected regions, the width proportion of the target connected region and the corresponding attribute value range of the labeled image.
[0176] An identification module 305 is configured to identify characters in the character image to obtain a corresponding character recognition result.
[0177] A combination module 306 is configured to combine the character recognition result according to the relative position to obtain a milestone value in the milestone image.
[0178] Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can be referred to the corresponding processes in the foregoing method embodiments, and will not be repeated here.
[0179] The 100-meter marker recognition algorithm provided in this embodiment of the invention includes the following steps:
[0180] (1) For the entire picture ( Figure 8 MSER detection is performed, and the coordinates of the four vertices of the 100-meter marker area that meet the requirements are selected using various features of the 100-meter marker.
[0181] (2) Based on the pre-set dimensions of the 100-meter marker and the four detected vertices, obtain the affine transformation matrix, and perform an affine transformation on the detected 100-meter marker region to obtain the affine-transformed 100-meter marker. For example... Figure 9 As shown.
[0182] (3) Perform Sauvola binarization on the 100-meter marker to obtain the binary image of the 100-meter marker, as shown below. Figure 10 As shown.
[0183] (4) Extract the characters from the 100-meter marker based on the binary image, such as... Figure 11 As shown.
[0184] (5) Make a prediction for each character to obtain the final result. Remove the prediction results with a confidence level of less than 0.25.
[0185] (6) Since the number of 100-meter markers obtained is not unique, it is necessary to compare the confidence levels of the final prediction results one by one and keep the results with higher confidence levels.
[0186] Example of error in 100-meter marker recognition
[0187] (1) The character segmentation of the 100-meter marker had an error (the upper right corner of K was too large), resulting in errors in the extracted characters and causing character recognition errors. The final recognition result was 441.
[0188] It can detect the 100-meter marker area, but it cannot accurately segment the characters within the marker, thus failing to accurately obtain the grayscale image corresponding to the characters. For example... Figure 12 As shown, (a) the original image; (b) the 100-meter marker region; (c) the binarized 100-meter marker region; (d) the segmented characters; 4(0.9491)4(1.0258)1(1.0245)--(character confidence);
[0189] Due to character segmentation errors, the grayscale region of character K contains part of the information of character 4 (as shown in the red box in image d), resulting in the incorrect recognition of character K.
[0190] (2) Character extraction error. The character extraction error in the lower figure (as shown by the rectangular frame region in d) leads to character recognition error, and the final recognition result is 900kk3. As shown in the figure, (a) original image; (b) 100-meter mark region; (c) 100-meter mark region binary image; (d) final extracted character region. Figure 13
[0191] (3) The 100-meter mark suddenly becomes smaller within the field of view, which leads to failure to locate the position of the 100-meter mark; as shown in the figure. Figure 14
[0192] (4) According to the extraction rule of the characters in one line of the 100-meter mark, the proportion of the characters in the 100-meter mark becomes smaller, so the characters in the 100-meter mark cannot be extracted. As shown in the figure, Figure 15
[0193] (5) The lower figure has two 100-meter mark pictures. In one of the 100-meter marks, the character recognition is correct, but the confidence of one of the characters is too low and is discarded. In the other 100-meter mark, one of the characters is recognized incorrectly, but the confidence is high and is retained, so an error occurs. The final recognition result is 70kk30, as shown in the figure. Figure 16
[0194] (6) Figure 17 Two 100-meter mark pictures are detected, one of which is determined to be a one-line character 100-meter mark, and the corresponding result is obtained according to the prediction; the other is determined to be a two-line character 100-meter mark (which is not actually a 100-meter mark), and 6 characters can be extracted according to the character extraction rule, and then the prediction result is obtained. The final result is 77749k.
[0195] (7) The confidence of the character recognition is too low and is discarded. The final recognition result is 700k7, as shown in the figure. Figure 18
[0196] (8) The lower figure has three suspected 100-meter mark pictures, and character extraction and recognition are performed on them respectively. Due to the interference of non-100-meter marks, the third character is recognized incorrectly. The final recognition result is 801k38, as shown in the figure. Figure 19
[0197] (9) The lower figure has two suspected 100-meter mark pictures, and one of the characters is extracted incorrectly, but the confidence of the incorrect character is higher than that of the correct character, so the recognition is incorrect. The final recognition result is 100k3k, as shown in the figure. Figure 20
[0198] (10) The following figure has two suspected 100-meter marks, one of which has an incorrect character extraction, but the incorrect character has a high confidence, so the recognition is incorrect. The final recognition result is: 700k3k, as shown in Figure 21
[0199] The tunnel mileage character recognition method provided by the embodiment of the application comprises:
[0200] S1, using a first image detection algorithm, determining a tunnel wall image containing a mileage mark in all tunnel wall images (the image containing the mileage mark can be positioned using frames, and the specific positioning method refers to the related cases of mileage correction according to the mileage mark written before. In actual application, the first image detection algorithm is a feature recognition algorithm of the mileage mark);
[0201] S2, using the first image detection algorithm, positioning the mileage mark image (mileage mark image) in the tunnel wall image (generally, the target object image is the mileage mark image, and the mileage mark image is found out from the obtained tunnel wall image according to the size of the mileage mark. In actual application, the second image detection algorithm is a feature positioning algorithm of the mileage mark);
[0202] S3, determining the position of the character in the target image according to the character feature (S31, determining the position of the connected region in the target image (this is the step in the original patent, that is, determining the position of the character, which can include preprocessing, such as threshold segmentation, impurity removal, and connected domain analysis before); S32, determining the position of the number and the letter in the target object according to the height proportion and the width proportion of the connected region and the target image (since the height proportion and the width proportion of the number, the letter, and the Chinese character are different, the position of the character representing the mileage can be determined by the width proportion and the height proportion. Generally, the mileage mark includes the image as shown in the figure, and the characters in each part of the figure need to be recognized, and further calculation is needed after simple sorting of the recognition);
[0203] S4, respectively recognizing the number and the letter in the target object by using a character recognition algorithm (the process of recognition can also include comparison of confidence), and calculating the mileage mark value according to the preset mileage value algorithm, the number and the letter in the target object, and the position of the number and the letter in the target object.
[0204] It should be noted that embodiments of the present application can be realized by hardware, software, or a combination of software and hardware. The hardware portion can be realized by a special logic; the software portion can be stored in a memory and executed by a proper instruction execution system, such as a microprocessor or a specially designed hardware. A person of ordinary skill in the art can understand that the above-mentioned apparatus and method can be realized by computer executable instructions and / or included in processor control codes, such as a carrier medium, such as a magnetic disk, CD or DVD-ROM, a programmable memory, such as a read-only memory (firmware), or a data carrier, such as an optical or electronic signal carrier. The apparatus of the present application and its modules can be realized by a hardware circuit, such as a very large scale integrated circuit or a gate array, a semiconductor, such as a logic chip, a transistor, or a programmable hardware device, such as a field programmable gate array, a programmable logic device, or the like, by software executed by various types of processors, or by a combination of the above-mentioned hardware circuit and software, such as firmware.
[0205] The above description is merely a specific implementation of the present application, but the protection scope of the present application is not limited thereto. Any modification, equivalent replacement, and improvement within the technical range disclosed by the present application, and within the spirit and principle of the present application, should be included in the protection scope of the present application.
Claims
1. A character recognition method, characterized in that, The character recognition method includes: Extract each connected region from the binarized image; Based on the height ratio, relative position, and the first attribute value of the pre-acquired labeled image, target connected regions containing characters are selected from each connected region; Based on the number of target connected regions, the width ratio of the target connected regions, and the second attribute value of the labeled image, the character image corresponding to a single character is segmented from the target connected regions; The character recognition results are combined according to their relative positions to obtain the mileage values in the mileage marker image; The character recognition method includes: The mileage marker image containing the character to be identified is binarized to obtain a binarized image; Extract each connected region from the binarized image and obtain the attribute values of each connected region respectively; the attribute values include the height ratio and width ratio of the connected region in the binarized image, as well as the relative position of the connected region in the binarized image; Based on the height ratio, the relative position, and the corresponding attribute value range of the pre-acquired labeled images, target connected regions containing characters are selected from each connected region; the labeled images are pre-acquired mileage marker images with labeled characters, and the labeled images and the mileage marker images are collected from the same road segment; Based on the number of target connected regions, the width ratio of the target connected regions, and the corresponding attribute value range of the labeled image, the character image corresponding to a single character is segmented from the target connected regions; The characters in the character image are identified to obtain the corresponding character recognition results; The character recognition results are combined according to their relative positions to obtain the mileage values in the mileage marker image; The step of obtaining the attribute values of each connected region includes: Obtain the height and width of the connected region and the height and width of the binarized image; Calculate the ratio of the height of the connected region to the height of the binarized image to obtain the height percentage of the connected region in the binarized image; Calculate the ratio of the width of the connected region to the width of the binarized image to obtain the width proportion of the connected region in the binarized image; Determine the minimum bounding rectangle of the connected region; Calculate the distance between each side of the minimum bounding rectangle and the nearest side of the binarized image; The relative position of the connected region in the binarized image is obtained based on the distance.
2. The character recognition method as described in claim 1, characterized in that, Before selecting a target connected region containing characters from the connected regions based on the height ratio and the relative position, the process further includes: Obtain a set of labeled image samples; the set of labeled image samples includes multiple labeled images; Obtain the attribute value of each character contained in the labeled image; the attribute value includes the height ratio, width ratio, and relative position of the character's edge pixels in the labeled image; the height ratio is the ratio of the height of the character to the height of the labeled image, the width ratio is the ratio of the width of the character to the width of the labeled image, and the relative position is the relative position of the character in the labeled image; Based on the height percentage, width percentage, and relative position of each character in the labeled image sample set, the range of height percentage, width percentage, and relative position are obtained.
3. The character recognition method as described in claim 1, characterized in that, Based on the height percentage, the relative position, and the corresponding attribute values of the pre-acquired labeled images, target connected regions containing characters are selected from each connected region, including: Determine whether the connected region simultaneously satisfies a first condition and a second condition; the first condition is that the height percentage of the connected region belongs to the height percentage range; the second condition is that the relative position of the connected region in the mileage marker image belongs to the relative position range. If so, the connected region is determined as the target connected region containing the character; After determining whether the connected region simultaneously satisfies the first condition and the second condition, the process further includes: If the connected region cannot simultaneously satisfy the first condition and the second condition, then the connected region is determined to be a connected region that does not contain characters.
4. The character recognition method as described in claim 2, characterized in that, Based on the width ratio of the target connected region and the corresponding attribute values of the labeled image, segment the character image corresponding to a single character from the target connected region, including: The highest number of characters contained in a single labeled image is obtained from the labeled image sample set to obtain a first number; Determine the number of target connected regions in the mileage marker image to obtain a second number; If the second quantity is equal to the first quantity, then based on the width ratio of the connected region in the binarized image, the character image corresponding to a single character is segmented from the target connected region; If the second quantity is less than the first quantity, then the ratio of the width percentage of the target connected region to the width percentage range is determined; The number of characters included in the target connected region is determined based on the ratio. Based on the number of characters, the character image corresponding to each individual character is segmented evenly from the target connected region.
5. The character recognition method as described in claim 1, characterized in that, The process of recognizing characters in the character image includes: The character image is recognized using a neural network to obtain the pre-recognition result corresponding to the character and the confidence value corresponding to the pre-recognition result; If the confidence value is greater than the first threshold, the pre-recognition result is used as the character recognition result.
6. A character recognition system that performs the character recognition method as described in any one of claims 1-5, characterized in that, The character recognition system includes: The binarization module is used to binarize the mileage marker image containing the characters to be recognized, and obtain a binarized image. An extraction module is used to extract each connected region in the binarized image and obtain the attribute values of each connected region respectively; the attribute values include the height ratio and width ratio of the connected region in the binarized image, as well as the relative position of the connected region in the binarized image; The selection module is used to select a target connected region containing characters from each connected region based on the height ratio, the relative position, and the corresponding attribute value range of the pre-acquired labeled image; the labeled image is a pre-acquired mileage marker image with characters already labeled, and the labeled image and the mileage marker image are collected from the same road segment; The segmentation module is used to segment the character image corresponding to a single character from the target connected region based on the number of target connected regions, the width ratio of the target connected regions, and the corresponding attribute value range of the labeled image; The recognition module is used to recognize the characters in the character image and obtain the corresponding character recognition results; The combination module is used to combine the character recognition results according to the relative positions to obtain the mileage value in the mileage marker image.
7. A computer device, characterized in that, The device includes a processor and a memory coupled together, the memory being used to store computer program instructions, which, when executed by the processor, cause the electronic device to perform the steps of the character recognition method as described in any one of claims 1-5.
8. A computer storage medium, characterized in that, The computer storage medium stores program instructions that, when executed on the electronic device, cause the electronic device to perform the steps of the character recognition method as described in any one of claims 1-5.
Citation Information
Patent Citations
Character segmentation method and device in image
CN105095890A
License plate character segmentation method and device
CN107273892A