A text recognition method, device and medium

CN122313452BActive Publication Date: 2026-08-14ISA TECH CO LTD +1
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2026-05-29
Publication Date
2026-08-14

AI Technical Summary

Technical Problem

[0003]但是,车辆会长期暴露于复杂的外界环境中,承载车架号的金属表面不可避免的会产生大量随机走向的划痕,这些划痕在成像过程中往往会呈现出与字符笔画高度相似的特征,因此,当划痕贯穿车架号中的字符时,OCR算法极易将贯穿车架号中的字符的划痕误识别为字符的笔画,进而导致识别错误,降低文本识别的准确率

Benefits of technology

本申请提供了一种文本识别方法、设备及介质,在所述方法中,对待识别文本图像进行文本识别获取初始字符和初始字符的置信度;当置信度低于预设置信度阈值时,获取初始字符对应的初始划痕对应的一次函数,并基于一次函数,确定初始字符对应的贯穿划痕在初始字符的最小外接矩形区域图像中对应的直线区域;基于所述直线区域,沿预设扩展方向向两侧扩展,得到第一图像区域以及包含所述第一图像区域的第二图像区域;将第一图像区域中的第一像素点的像素值替换为:从所述第二图像区域中扣除所述第一图像区域后所得的图像区域内,经过该第一像素点且与预设扩展方向平行的直线上所有第二像素点的平均像素值;以对初始字符的最小外接矩形区域图像进行更新,并对完成所有更新的最小外接矩形区域图像进行文本识别,获取目标字符。可知,本申请通过识别低置信度初始字符所对应的贯穿划痕对应的直线区域,并据此扩展出第一图像区域和第二图像区域;利用从第二图像区域中扣除第一图像区域后所得的图像区域中的像素对第一图像区域中的像素进行更新,实现了划痕区域的修复,有效消除了划痕在图像中呈现的线段所造成的干扰,提升了字符区域的图像质量;进而使得基于完成所有更新的最小外接矩形区域图像进行二次识别时,能够获取更准确的目标字符,显著提高了文本识别的准确率。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122313452B_ABST
    Figure CN122313452B_ABST
Patent Text Reader

Abstract

This application provides a text recognition method, device, and medium, relating to the field of text recognition. The method obtains an initial character and its confidence level by performing text recognition on a text image to be recognized. When the confidence level is lower than a preset confidence threshold, it obtains a linear function corresponding to the initial scratch of the initial character and further determines the straight line region corresponding to the penetrating scratch in the minimum bounding rectangle region image of the initial character. Based on the straight line region, it expands a first image region and a second image region. It updates the pixels in the first image region using the pixels in the image region obtained by subtracting the first image region from the second image region. Based on the minimum bounding rectangle region image after all updates are completed, it performs secondary recognition to obtain the target character. This achieves scratch region repair, effectively eliminates the interference caused by the line segments of the scratch in the image, and significantly improves the accuracy of text recognition.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of text recognition, and in particular to a text recognition method, device and medium. Background Technology

[0002] The vehicle identification number (VIN) is a legally recognized identifier in the entire lifecycle management of a vehicle. It is usually directly pressed onto the metal surface of key structural components such as the chassis and B-pillar using an engraving process. In existing technologies, the VIN is mainly obtained by using optical character recognition (OCR) technology to perform text recognition on images containing the VIN, and then managing the vehicle based on the VIN.

[0003] However, vehicles are exposed to complex external environments for a long time, and the metal surface bearing the vehicle identification number will inevitably develop a large number of scratches with random directions. These scratches often exhibit features that are highly similar to the strokes of characters during the imaging process. Therefore, when a scratch penetrates the characters in the vehicle identification number, the OCR algorithm is very likely to misidentify the scratch penetrating the characters in the vehicle identification number as the strokes of the characters, which will lead to recognition errors and reduce the accuracy of text recognition. Summary of the Invention

[0004] To address the aforementioned technical problem, the technical solution adopted in this application is as follows: According to a first aspect of this application, a text recognition method is provided, the method comprising the following steps: S1. Perform text recognition on the text image to be recognized, and obtain the initial characters and their confidence levels; the text image to be recognized is an image of a vehicle identification number with recessed spacing between characters.

[0005] S2, if A i <Q, then obtain B i The corresponding initial scratch corresponds to a linear function; A i For B i The confidence level; Q is the preset confidence threshold; B i Let be the i-th initial character, 1≤i≤n, where n is the number of initial characters; B i The corresponding initial scratch is obtained by B i The minimum bounding rectangle region image C i The corresponding image D of the outer rectangular ring region i The scratches were detected.

[0006] S3, based on B i The corresponding initial scratch corresponds to a linear function, determining B. i The corresponding j-th penetrating scratch is at C i The corresponding straight line region E ij ;1≤j≤m(i), m(i) is B i The corresponding number of penetrating scratches.

[0007] S4, along E ij Preset extension direction K ij , with E ij For reference direction E ij Expand both sides by a pixels to obtain E ij In C i The first image region F corresponding to the middle ij Expand by b pixels to obtain E ij In C i The corresponding second image region G ij ; a is the preset number of first pixels, b is the preset number of second pixels, a < b.

[0008] S5, for F ij For each first pixel in the array, replace the pixel value of the first pixel with H. ij The middle is located at the first pixel and is adjacent to K. ij The average pixel value of all second-pixel points on parallel straight lines, such that for C i Update; H ij To make F ij From G ij The image region obtained after subtraction.

[0009] S6, in C i After all updates are complete, for C i Perform text recognition to obtain the target characters.

[0010] According to a second aspect of this application, a non-transitory computer-readable storage medium is provided, wherein at least one instruction or at least one program is stored in the non-transitory computer-readable storage medium, and the at least one instruction or at least one program is loaded and executed by a processor to implement the above method.

[0011] According to a third aspect of this application, an electronic device is provided, including a processor and the aforementioned non-transitory computer-readable storage medium.

[0012] This application has at least the following beneficial effects: This application provides a text recognition method, device, and medium. In the method, text recognition is performed on the text image to be recognized to obtain an initial character and its confidence level. When the confidence level is lower than a preset confidence threshold, a linear function corresponding to the initial scratch of the initial character is obtained. Based on the linear function, the straight line region corresponding to the penetrating scratch of the initial character in the minimum bounding rectangle region image of the initial character is determined. Based on the straight line region, the image is expanded to both sides along a preset expansion direction to obtain a first image region and a second image region containing the first image region. The pixel value of the first pixel in the first image region is replaced with the average pixel value of all second pixels on a straight line passing through the first pixel and parallel to the preset expansion direction within the image region obtained after subtracting the first image region from the second image region. This updates the minimum bounding rectangle region image of the initial character, and text recognition is performed on the updated minimum bounding rectangle region image to obtain the target character. As can be seen, this application identifies the straight line region corresponding to the penetrating scratch corresponding to the low-confidence initial character, and expands the first image region and the second image region accordingly; it uses the pixels in the image region obtained by subtracting the first image region from the second image region to update the pixels in the first image region, thereby realizing the repair of the scratch region, effectively eliminating the interference caused by the line segments of the scratch in the image, and improving the image quality of the character region; thus, when performing secondary recognition based on the smallest bounding rectangle region image that has completed all updates, it can obtain more accurate target characters, significantly improving the accuracy of text recognition. Attached Figure Description

[0013] To more clearly illustrate the technical solutions in the embodiments of this application, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0014] Figure 1 This is a flowchart of a text recognition method provided in an embodiment of this application.

[0015] Figure 2 Example diagrams of text images to be recognized are provided for embodiments of this application. Detailed Implementation

[0016] The technical solutions in the embodiments of this application will be clearly and completely described below. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.

[0017] It is worth noting that in the following description, specific details such as particular system structures and techniques are set forth for illustrative purposes rather than for limiting purposes, in order to provide a thorough understanding of the embodiments of this application. However, those skilled in the art will understand that this application can also be implemented in other embodiments without these specific details. In other instances, detailed descriptions of well-known systems, apparatuses, circuits, and methods are omitted so as not to obscure the description of this application with unnecessary details.

[0018] It should be understood that in this application specification and the appended claims, the use of the terms "comprising," "including," "including but not limited to," "including but not limited to," "mainly composed of," or "mainly made of" indicates the presence of the described feature, integral, step, operation, element, and / or component, but does not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components, and / or collections thereof.

[0019] It should be understood that in this application specification and the appended claims, the use of the terms "consisting of" or "component of" indicates the presence of the described feature, integral, step, operation, element and / or component, but excludes the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.

[0020] It should be understood that, in this specification and the appended claims, the term "and" indicates a combination in which multiple of the associated listed items exist simultaneously. For example, "A, B, C, and D" means a combination in which "A and B and C and D exist simultaneously".

[0021] It should be understood that in this application specification and the appended claims, the use of the term "or" indicates a combination in which one of the associated listed items exists alone. For example, "A, B, C or D" refers to the four combinations of "A alone", "B alone", "C alone", and "D alone".

[0022] It should be understood that, in this application specification and the appended claims, the term "and / or" indicates any combination of one or more of the associated listed items, as well as all possible combinations, and includes such combinations. For example, "A and / or B" refers to the three combinations of "A alone," "B alone," or "A and B simultaneously." For example, "A, B, and / or C" refers to the seven combinations of "A alone," "B alone," "C alone," "A and B simultaneously," "A and C simultaneously," "B and C simultaneously," and "A, B, and C simultaneously."

[0023] It should be understood that, in this specification and the appended claims, the term "if" is used to indicate, depending on the context, "in the case of," "when," "once," "in response to determination," or "in response to detection." Similarly, the phrase "if determined" or "if [the described condition or event] is detected" can be interpreted, depending on the context, as "once determined," "in response to determination," "once [the described condition or event] is detected," or "in response to detection of [the described condition or event]."

[0024] It should be understood that in this application specification and the appended claims, the terms "greater than", "less than", "exceeding", etc. are understood to exclude the number itself; and the terms "above", "below", "within", etc. are understood to include the number itself.

[0025] It should be understood that in this application specification and the appended claims, the terms "the," "the," "the," "the," "the," "the described," "the mentioned," etc., may be understood, depending on the context, to refer to the content mentioned above.

[0026] It should be understood that in this application specification and the appended claims, the terms "first," "second," "third," etc., are used only for distinguishing descriptions and should not be construed as indicating or implying relative importance, nor are they used to describe a specific order or sequence.

[0027] It should be understood that in this application specification and appended claims, the designations such as "S100," "S200," and "S300" are used only for distinguishing descriptions and should not be construed as indicating or implying a specific order or sequence of execution of steps or processes. For example, "S100, acquire data A; S200, acquire data B; S300, acquire C based on A and B;" is merely an example providing a feasible execution order, not a necessary one. Those skilled in the art can determine the actual and feasible execution order based on the function and internal logic of each step. For example, "step S100 is executed before step S200, then step S300 is executed," "step S200 is executed before step S100, then step S300 is executed," or "steps S100 and S200 are executed in parallel, then step S300 is executed."

[0028] It should be understood that in this application specification and appended claims, if numbering or quantity in the form of “f(i); i=1, 2, ..., n;” is used, the specific value corresponding to the term “f(i)” should be understood as a value that changes with the value of i, and not as a fixed value. For example, in different practical scenarios, “f(1)” and “f(2)”, “f(1)” may be equal to “f(2)” or may not be equal to “f(2)”, and unless otherwise specified, there is no necessary size relationship between “f(1)” and “f(2)”.

[0029] It should be understood that in this application specification and appended claims, if numbers or symbols in the form of superscript are used, and the context or other corresponding locations provide a specific interpretation of them, they should be understood according to their corresponding explanatory description, and cannot be directly and simply understood as concepts such as "exponent" in mathematics or "atomic number" in chemistry. Similarly, if numbers or symbols in the form of subscript are used, they should be understood in the same way, without further explanation.

[0030] It should be understood that in the description of this application and the appended claims, if terms such as "A=(...)" are used, unless otherwise specifically interpreted, they should be understood as "A includes...", and not as "A is composed of...". Furthermore, unless otherwise specifically interpreted, the parentheses "(" and ")" are only used in conjunction with "=" to indicate what items or data A includes, and do not refer to any specific data structure, nor do they limit the type of its elements, whether the number of elements is fixed, whether the elements are ordered, whether the elements are repeatable, what query method is required to query its elements, or what access order is required to access its elements.

[0031] It should be understood that in the description of this application and the appended claims, if common processing functions such as "max(...)", "min(...)", and "avg(...)" are used, the context or other corresponding locations should provide a specific interpretation of these terms. If no specific interpretation exists, those skilled in the art should use relevant technical terms from computer science and technology for connection. For example, "max(...)" refers to a function for determining the maximum value, "min(...)" refers to a function for determining the minimum value, and "avg(...)" refers to a function for determining the average value.

[0032] Embodiments of this application provide a text recognition method, the method comprising the following steps, such as... Figure 1 As shown: S1. Perform text recognition on the text image to be recognized, and obtain the initial characters and their confidence levels; the text image to be recognized is an image of an engraved vehicle identification number with spacing between characters, such as... Figure 2 As shown.

[0033] Specifically, engraving is a process that creates recessed characters on a metal surface by stamping or molding.

[0034] Specifically, the confidence level of the initial character ranges from 0 to 1; the closer the confidence level is to 1, the higher the credibility of the initial character; the closer the confidence level is to 0, the lower the credibility of the initial character.

[0035] Optionally, an OCR model is used to perform text recognition on the text image to be recognized, in order to obtain an initial character, the rectangular boundary coordinates corresponding to the initial character, and a confidence level of 0 to 1 for the initial character. The rectangular boundary coordinates corresponding to the initial character include the coordinates of the four vertices of the rectangular text region corresponding to the initial character in the text image to be recognized. These vertex coordinates are generated based on the coordinate system corresponding to the text image to be recognized, with the upper left vertex as the origin, the horizontal to the right as the positive x-axis, and the vertical downward as the positive y-axis. Those skilled in the art will know that any existing OCR model capable of performing text recognition on a text image to obtain a character, the rectangular boundary coordinates corresponding to the character, and a confidence level of 0 to 1 for the character is within the scope of protection of this invention, such as EasyOCR, which will not be described further here.

[0036] S2, if A i <Q, then obtain B i The corresponding initial scratch corresponds to a linear function; A i For B i The confidence level; Q is the preset confidence threshold; B i Let be the i-th initial character, 1≤i≤n, where n is the number of initial characters; B i The corresponding initial scratch is obtained by B i The minimum bounding rectangle region image C i The corresponding image D of the outer rectangular ring region i The scratches were detected.

[0037] Specifically, step S2 also includes: if A i If ≥Q, then B i As the target character.

[0038] Specifically, 0.8 ≤ Q ≤ 0.9, preferably Q = 0.85.

[0039] Specifically, based on B i The coordinates of the four vertices in the corresponding rectangular boundary coordinates are used to construct B.i The corresponding minimum bounding rectangle region B 0 i And extract B from the text image to be recognized 0 i The corresponding image is C i .

[0040] Specifically, for B 0 i For each of the four boundaries, along the normal direction of that boundary towards B 0 i The boundary is shifted outward by a preset pixel extension distance to obtain B. 0 i The corresponding four extended boundaries; B 0 i The rectangular region enclosed by the four straight lines corresponding to the four extended boundaries is designated as B. i The corresponding outer rectangular region C 0 i Furthermore, B 0 i From C 0 i Deduct from to obtain B i The corresponding outer rectangular ring region D 0 i And extract D from the text image to be recognized 0 i The corresponding image is D i .

[0041] In one specific embodiment, the product of the average stroke width of all initial characters with a confidence level not less than a preset confidence threshold multiplied by a preset multiple is used as B. 0 i The preset pixel extension distance corresponds to each boundary; the preset multiple ranges from 1 to 2; those skilled in the art know that any method for obtaining the stroke width of a character in the prior art is within the protection scope of this invention, such as obtaining the stroke width of a character based on stroke width transformation technology, which will not be elaborated here.

[0042] The above steps calculate the average stroke width by selecting initial characters with acceptable confidence levels, and multiply it by a preset coefficient of 1 to 2 times as the preset pixel expansion distance. This achieves adaptive and accurate expansion of the detection box, effectively covering the stroke edges while avoiding over-expansion.

[0043] In another specific embodiment, B is obtained through the following steps S001-S005. 0 i The preset pixel extension distance for each of the four boundaries: S001, Regarding B 0 i For each of the four boundaries, if the angle between the extension direction of the boundary and the x-axis of the coordinate system corresponding to the text image to be recognized is less than a preset angle threshold, then the boundary is determined to be a horizontal boundary; if the angle between the extension direction of the boundary and the y-axis of the coordinate system corresponding to the text image to be recognized is less than a preset angle threshold, then the boundary is determined to be a vertical boundary.

[0044] Specifically, the preset angle threshold ranges from 10 degrees to 30 degrees.

[0045] S002. For the longitudinal boundary, if the longitudinal boundary is at B 0 i If the center point is to the left, then it will be in position B. i Left side and with B i The two vertical boundaries of the minimum bounding rectangle region corresponding to adjacent initial characters are closer to B. 0 i The longitudinal boundary is used as the corresponding contrast boundary; if the longitudinal boundary is at B 0 i If the center point is to the right, then it will be in position B. i Right side and with B i The vertical boundary closer to B0i among the two vertical boundaries of the minimum bounding rectangle region corresponding to the adjacent initial character is used as the contrast boundary corresponding to that vertical boundary.

[0046] Specifically, if the longitudinal boundary is at B 0 i The center point to the left and B i If there is no initial character on the left, the left boundary of the text image to be recognized is taken as the contrast boundary corresponding to the vertical boundary; if the vertical boundary is at B 0 i The center point to the right and B i If there is no initial character on the right, the right boundary of the text image to be recognized will be used as the contrast boundary corresponding to the vertical boundary.

[0047] S003. The product of the vertical distance between a point on the vertical boundary and the corresponding contrast boundary of the vertical boundary and the preset reduction factor is used as the preset pixel expansion distance corresponding to the vertical boundary.

[0048] Specifically, the preset reduction factor ranges from 0.85 to 0.95.

[0049] S004. For the lateral boundary, if the lateral boundary is at B... 0 iIf the horizontal boundary is below the center point, then the minimum vertical distance from a point on that horizontal boundary to the lower boundary of the text image to be recognized is taken as the maximum acceptable distance corresponding to that horizontal boundary; if the horizontal boundary is below B... 0 i The minimum vertical distance from a point on the horizontal boundary to the upper boundary of the text image to be recognized is taken as the maximum acceptable distance corresponding to the horizontal boundary.

[0050] S005. If the maximum acceptable distance corresponding to the horizontal boundary is less than the minimum value among the preset pixel extension distances corresponding to the two vertical boundaries, then the maximum acceptable distance corresponding to the horizontal boundary shall be taken as the preset pixel extension distance corresponding to the horizontal boundary; otherwise, within the range of the maximum acceptable distance corresponding to the horizontal boundary to the minimum value among the preset pixel extension distances corresponding to the two vertical boundaries, a distance shall be selected as the preset pixel extension distance corresponding to the horizontal boundary.

[0051] The above steps achieve refined control of text region cropping by distinguishing between horizontal and vertical boundaries and using a differentiated strategy to determine the preset pixel expansion distance: For the vertical boundary, the spacing is dynamically calculated using the relative positions of the smallest bounding rectangles of adjacent characters, and a reduction factor of 0.85 to 0.95 is introduced to determine the preset pixel expansion distance, which can effectively isolate interference from adjacent characters and avoid including parts of the strokes of adjacent characters within the scratch detection range of the current character; For the horizontal boundary, the maximum acceptable distance is determined by combining the upper and lower boundaries of the text image to be recognized, and is coordinated with the preset pixel expansion distance corresponding to the vertical boundary to determine the preset pixel expansion distance, thus avoiding over-expansion.

[0052] Specifically, after obtaining C i and D i Afterwards, if C i and D i If the image is presented as a tilted rectangle, then C is transformed using geometric transformations. i and D i Corrected to a horizontally oriented rectangular image; that is, the corrected C i and D i The top and bottom boundaries are parallel to the horizontal direction, and the left and right boundaries are parallel to the vertical direction.

[0053] Specifically, the initial scratches include: initial scratches originating from the left region, initial scratches originating from the right region, initial scratches originating from the upper region, and initial scratches originating from the lower region.

[0054] Furthermore, B i The corresponding initial scratch is obtained by B i The minimum bounding rectangle region image C i The corresponding image D of the outer rectangular ring region iScratch detection yielded results, including S01-S05: S01, D i Image D divided into non-overlapping left regions i1 Right region image D i2 Image D of the upper region i3 and the lower region image D i4 ; where D i1 D i2 D i3 and D i4 In D i The corresponding regions are all rectangular regions, and D is... i1 D i2 D i3 and D i4 By piecing them together according to their corresponding positions, a complete D can be formed. i .

[0055] S02, D i1 Perform scratch detection to obtain B i The corresponding initial scratches originated from the left region.

[0056] S03, D i2 Perform scratch detection to obtain B i The corresponding initial scratches originated from the right region.

[0057] S04, D i3 Perform scratch detection to obtain B i The corresponding initial scratches originated from the upper region.

[0058] S05, D i4 Perform scratch detection to obtain B i The corresponding initial scratches originate from the lower region.

[0059] Through the above steps, the image of the outer rectangular ring region is divided into non-overlapping left, right, upper, and lower region images, and scratch detection is performed on each region to obtain several initial scratches from different regions corresponding to the initial character. This achieves localization and refinement of defect detection, avoiding missed or false detections caused by differences in background texture or partial overlap with character strokes in global detection. It can also accurately locate the spatial origin of the initial scratch relative to the initial character, providing a basis for subsequently determining the penetrating scratch corresponding to the initial character, and significantly improving the accuracy and processing efficiency of scratch recognition.

[0060] Specifically, D is analyzed using a scratch detection algorithm. i1 D i2 D i3 and D i4Scratch detection was performed separately to obtain B. i The corresponding initial scratches originate from the left region, right region, upper region, and lower region. Those skilled in the art will know that any scratch detection algorithm in the prior art falls within the protection scope of this invention, such as scratch detection algorithms based on Canny edge detection and probabilistic Hough transform, and scratch detection algorithms based on the YOLO model, which will not be elaborated here.

[0061] Specifically, in step S2, B is obtained. i The corresponding linear function for the initial scratch includes S21-S23: S21, Regarding B i For each initial scratch, a set of discrete pixels corresponding to the initial scratch is extracted. The set of discrete pixels includes several discrete pixels. As those skilled in the art know, any method for extracting discrete pixels corresponding to scratches in the prior art is within the protection scope of this invention. For example, the discrete pixels corresponding to scratches are extracted using the Canny edge detection algorithm, which will not be elaborated here.

[0062] S22. Obtain the value of each discrete pixel in the discrete pixel set in D. i The corresponding pixel coordinates; D i The corresponding pixel coordinate system is based on D i The origin is the lower left corner of the graph, with the positive x-axis pointing horizontally to the right and the positive y-axis pointing vertically upward.

[0063] S23. Based on the overall least squares method, according to the discrete pixel point in the set of discrete pixels in D i The coordinates in the corresponding pixel coordinate system are used to perform a linear fit on the discrete pixel set to obtain the linear function corresponding to the initial scratch; where the linear function is presented in the general form.

[0064] Through the above steps, discrete pixels corresponding to the initial scratch are extracted. Based on the overall least squares method, the discrete pixels are linearly fitted according to their coordinates in the pixel coordinate system corresponding to the outer rectangular ring region image to obtain the linear function corresponding to the initial scratch. This function can accurately fit the initial scratch at any angle, thus ensuring that the obtained linear function can accurately restore the true geometric shape of the initial scratch, providing a foundation for subsequently determining the penetrating scratch corresponding to the initial character.

[0065] S3, based on B i The corresponding initial scratch corresponds to a linear function, determining B. i The corresponding j-th penetrating scratch is at C i The corresponding straight line region E ij ;1≤j≤m(i), m(i) is Bi The corresponding number of penetrating scratches.

[0066] Specifically, step S3 includes S31-S35: S31, Construct B i The corresponding set of linear function combinations R i ={R i1 R i2 , ..., R ie , ..., R if(i)}, R ie =(R ie1 R ie2 ); R ie For B i The corresponding e-th linear function combination, 1≤e≤f, where f is B. i The number of corresponding linear function combinations; R ie1 and R ie2 For B i The corresponding linear function is derived from any two different initial scratches originating from the left, right, upper, and lower regions.

[0067] S32, if R ie1 and R ie2 The corresponding lines are all not parallel to D. i The straight line along the y-axis of the corresponding pixel coordinate system then yields R. ie1 The corresponding slope K ie1 R ie1 The corresponding intercept L ie1 R ie2 The corresponding slope K ie2 and R ie2 The corresponding intercept L ie2 .

[0068] S33, when |K ie1 -K ie2 |≤K 0 And |L ie1 -L ie2 |≤L 0 At that time, obtain B i The slope K_G of the linear function corresponding to the line of the penetrating scratch i and L_G i ;K 0 The preset slope difference value; L 0 The preset intercept difference value; K_G i and L_G i They each meet the following conditions: K_G i =(K ie1 +K ie2 ) / 2; L_Gi =(L ie1 +L ie2 ) / 2; those skilled in the art know that K 0 Specific values ​​and L 0 The specific value is preset by those skilled in the art according to actual needs, for example: K 0 =0.02, L 0 =3;K 0 =0.04, L 0 =5; I will not elaborate further here.

[0069] S34, based on K_G i and L_G i The penetrating scratch was determined to be at C. i The corresponding line segment.

[0070] Specifically, after step S33 and before step S34, the following is also included: S331, based on K_G i and L_G i Obtain the function T(x, y) = K_G corresponding to the penetrating scratch. i ·x-y+L_G i (x, y) is D i Any coordinate in the corresponding pixel coordinate system.

[0071] S332, C i The four vertices of D i Substitute the corresponding coordinates in the pixel coordinate system into T(x, y) to obtain C. i The function values ​​corresponding to the four vertices.

[0072] S333, if C i If the function values ​​corresponding to the four vertices simultaneously contain both positive and negative values, then the line corresponding to the penetrating scratch is determined to pass through C. i If the scratch does not pass through point C, proceed to step S34; otherwise, determine that the straight line corresponding to the through scratch does not pass through point C. i And terminate the determination of the penetrating scratch at C. i The process of the corresponding straight line region.

[0073] Specifically, when |K ie1 -K ie2 |>K 0 or |L ie1 -L ie2 |>L 0 When, it indicates R ie1 and R ie2 The two corresponding initial scratches belong to C 0 i Two different consecutive scratches in the middle cannot be based on Rie1 and R ie2 Get B i The corresponding through scratch is at C i The corresponding straight line segment; continuous scratches can be understood as linear damage marks that maintain geometric continuity in space without interruption.

[0074] Through the above steps, when the lines corresponding to the two linear functions in the linear function combination are both lines that are not parallel to the y-axis of the pixel coordinate system corresponding to the outer rectangular ring region image, a function corresponding to the penetrating scratch is constructed. The coordinates of the four vertices of the minimum bounding rectangle region image corresponding to the initial character in the pixel coordinate system corresponding to the outer rectangular ring region image are substituted into the calculation to determine the function values ​​corresponding to the four vertices. By utilizing the positive and negative distribution characteristics of the function values, the topological intersection relationship between the line corresponding to the penetrating scratch and the minimum bounding rectangle region image corresponding to the initial character can be quickly determined. This can quickly filter out penetrating scratches corresponding to the initial character that only penetrate the outer rectangular ring region image but not the minimum bounding rectangle region image, and determine the penetrating scratches that truly penetrate the minimum bounding rectangle region image. This can avoid repairing penetrating scratches that do not need to be repaired, thus improving the overall repair efficiency.

[0075] S35, C i The region consisting of pixels on the straight line segment is considered as the penetrating scratch in C. i The corresponding straight line region.

[0076] Through the above steps, a set of linear function combinations from different regions is constructed. When the lines corresponding to the two linear functions in the combination are both lines that are not parallel to the y-axis of the pixel coordinate system corresponding to the outer rectangular ring region image, the slope and intercept of the two linear functions are obtained. Preset slope difference and preset intercept difference are then used for verification. When the absolute value of the slope difference of the two linear functions is not greater than the preset slope difference and the absolute value of the intercept difference of the two linear functions is not greater than the preset intercept difference, it indicates that the two initial scratches corresponding to the two linear functions belong to the outer rectangular region corresponding to the initial character. The same continuous scratch was reconstructed from a local discontinuous scratch to a global through scratch. The average value was used to calculate the parameters of the linear function of the straight line corresponding to the through scratch of the initial character. This further determined the straight line region corresponding to the through scratch in the minimum bounding rectangle region image of the initial character. Even if the through scratch is broken in a local area due to character stroke occlusion, the straight line region corresponding to the through scratch in the minimum bounding rectangle region image can still be identified. This improves the continuity and completeness of through scratch recognition, as well as the accuracy of the straight line region corresponding to the through scratch in the minimum bounding rectangle region image.

[0077] Specifically, after step S32, steps S321-S324 are also included: S321, If ​​R ie1 and R ie2 The corresponding lines are all parallel to D. i The straight line along the y-axis of the corresponding pixel coordinate system then yields R. ie1 The corresponding x-axis coordinate value X ie1 and R ie2 The corresponding x-axis coordinate value X ie2 .

[0078] S322, when |X ie1 -X ie2 |≤X 0 At that time, determine B i The x-axis coordinate value X_G corresponding to the straight line of the penetrating scratch i ;X 0 The preset x-coordinate difference; X_G i The following conditions must be met: X_G i = (X ie1 +X ie2 ) / 2.

[0079] Specifically, after step S322 and before step S323, the following steps are also included: If X_G i Greater than C i The lower left vertex is in D i The corresponding x-axis coordinate value in the pixel coordinate system, and X_G i Less than C i The lower right vertex is in D i The x-axis coordinate value in the corresponding pixel coordinate system determines that the straight line corresponding to the penetrating scratch passes through C. i If the scratch does not pass through point C, proceed to step S323; otherwise, determine that the straight line corresponding to the through scratch does not pass through point C. i And terminate the determination of the penetrating scratch at C. i The process of the corresponding straight line region.

[0080] Specifically, when |X ie1 -X ie2 |>X 0 When, it indicates R ie1 and R ie2 The two corresponding initial scratches belong to C 0 i Two different consecutive scratches in the middle cannot be based on R ie1 and R ie2 Get B i The corresponding through scratch is at C i The corresponding line segment.

[0081] Through the above steps, when the lines corresponding to the two linear functions in the linear function combination are both parallel to the y-axis of the pixel coordinate system corresponding to the outer rectangular ring region image, the x-axis coordinate value corresponding to the line corresponding to the penetrating scratch of the initial character is compared with the x-coordinate of the lower left corner vertex and the lower right corner vertex of the minimum bounding rectangle region image corresponding to the initial character in the pixel coordinate system corresponding to the outer rectangular ring region image. This allows for the rapid filtering out of penetrating scratches that only penetrate the outer rectangular ring region image but not the minimum bounding rectangle region image, thus identifying the penetrating scratches that truly penetrate the minimum bounding rectangle region image. This avoids repairing penetrating scratches that do not need repair, improving the overall repair efficiency.

[0082] S323, Transform the line x=X_G i With C i The intersection line segment serves as the penetrating scratch at C i The corresponding line segment.

[0083] S324, C i The region consisting of pixels on the straight line segment is considered as the penetrating scratch in C. i The corresponding straight line region.

[0084] Through the above steps, when the straight lines corresponding to the two linear functions in the linear function combination are both parallel to the y-axis of the pixel coordinate system corresponding to the outer rectangular ring region image, the x-axis coordinate values ​​corresponding to the two linear functions are obtained. When the absolute value of the difference between the x-axis coordinate values ​​corresponding to the two linear functions is greater than the preset horizontal coordinate difference, it indicates that the two initial scratches corresponding to the two linear functions belong to the same continuous scratch in the outer rectangular region corresponding to the initial character. This realizes the reconstruction from local discontinuous scratches to global through scratches, and the average value is used to calculate the x-axis coordinate value corresponding to the straight line of the through scratch corresponding to the initial character. This further determines the straight line region corresponding to the through scratch in the minimum bounding rectangle region image corresponding to the initial character. Even if the through scratch breaks in a local area due to character stroke occlusion, the straight line region corresponding to the through scratch in the minimum bounding rectangle region image can still be identified, improving the continuity and completeness of through scratch recognition, as well as the accuracy of the straight line region corresponding to the through scratch in the minimum bounding rectangle region image.

[0085] Specifically, if R ie1 and R ie2 The two corresponding lines are one parallel to D. i The corresponding pixel coordinates' y-axis straight line and a line not parallel to D i The straight line along the y-axis corresponding to the pixel coordinates indicates R. ie1 and Rie2 The two corresponding initial scratches belong to C 0 i Two different consecutive scratches in the middle cannot be based on R ie1 and R ie2 Get B i The corresponding through scratch is at C i The corresponding line segment.

[0086] S4, along E ij Preset extension direction K ij , with E ij For reference direction E ij Expand both sides by a pixels to obtain E ij In C i The first image region F corresponding to the middle ij Expand by b pixels to obtain E ij In C i The corresponding second image region G ij ; a is the preset number of first pixels, b is the preset number of second pixels, a < b.

[0087] Specifically, if E ij In C i The two endpoints of the corresponding line segment are located at C. i The left and right edges determine K. ij The vertical direction; if E ij In C i The two endpoints of the corresponding line segment are located at C. i The upper and lower edges determine K. ij For the horizontal direction; if E ij In C i The two endpoints of the corresponding line segment are located at C. i For any two adjacent edges, then based on E ij In C i The slope K of the corresponding straight line segment is determined. ij .

[0088] Optionally, based on E ij In C i The slope K of the corresponding straight line segment is determined. ij Including: when E ij In C i When the absolute value of the slope of the corresponding straight line segment is not greater than 1, determine K. ij For the vertical direction; when E j In C i When the absolute value of the slope of the corresponding straight line segment is greater than 1, K is determined. ij It is in the horizontal direction.

[0089] Specifically, step S4 can be understood as: When K ij When it is in the vertical direction, for E ij For each pixel in the array, the a pixels in the same column above and immediately adjacent to that pixel are designated as the a first-type pixels, and the a pixels in the same column below and immediately adjacent to that pixel are designated as the a second-type pixels; E ij Each pixel in the image, and the region formed by each pixel and its corresponding a first-class pixels and a second-class pixels, are related to C. i The intersection region is used as F ij ; Use the same method to obtain G ij .

[0090] When K ij When it is in the horizontal direction, for E ij For each pixel in the array, the a pixels in the same row as the pixel, to its left and immediately adjacent to the pixel are designated as the a first-type pixels corresponding to that pixel; the a pixels in the same row as the pixel, to its right and immediately adjacent to the pixel are designated as the a second-type pixels corresponding to that pixel; E ij Each pixel in the image, and the region formed by each pixel and its corresponding a first-class pixels and a second-class pixels, are related to C. i The intersection region is used as F ij G is obtained in the same way. ij .

[0091] Specifically, E ij The quotient obtained by dividing the average width of the two initial scratches by 2 is 'a'. Those skilled in the art will know that any method for obtaining the average width of scratches in the prior art is within the protection scope of this invention, such as the scratch width acquisition method based on ImageJ, which will not be described in detail here.

[0092] Specifically, b = a + d, where d is the preset number of third pixels, and the value of d ranges from 2 to 3.

[0093] Through the above steps, a preset first pixel number is determined based on half the average width of the two initial scratches corresponding to the through scratch, and the sum of the preset first pixel number and the preset third pixel number (ranging from 2 to 3) is determined as the preset second pixel number. Using the straight line area as a reference, the preset first pixel number and the preset second pixel number are extended to both sides along a preset expansion direction to obtain a first image area that completely covers the through scratch area and a second image area that completely encompasses the first image area. This allows for updating and repairing pixels in the first image area based on the pixel values ​​of the pixels in the image area obtained by subtracting the first image area from the second image area. This achieves scratch area repair based on background pixels surrounding the scratch area, eliminating interference caused by the line segments of the scratch in the image while preserving the edge features of character strokes to the greatest extent, significantly improving the image quality and text recognition accuracy of the minimum bounding rectangle area corresponding to the initial character area.

[0094] S5, for F ij For each first pixel in the array, replace the pixel value of the first pixel with H. ij The middle is located at the first pixel and is adjacent to K. ij The average pixel value of all second-pixel points on parallel straight lines, such that for C i Update; H ij To make F ij From G ij The image region obtained after subtraction.

[0095] Specifically, step S5 can be understood as: when K ij When it is in the vertical direction, for F ij For each first pixel in each column of the array, replace the pixel value of that first pixel with H. ij The average of the pixel values ​​of all second pixels in the same column as the first pixel, so that for C i Update; when K ij When it is in the horizontal direction, for F ij For each first pixel in each row of the array, replace the pixel value of that first pixel with H. ij The average of the pixel values ​​of all second pixels in the same row as the first pixel, so that for C i Update.

[0096] Specifically, the first pixel is F ij The second pixel is H. ij The pixels in the image.

[0097] Through the above steps, the pixels in the first image region are updated and repaired based on the pixel values ​​of the pixels in the image region obtained after subtracting the first image region from the second image region. This achieves the repair of the scratch region based on the background pixels around the scratch region. While eliminating the interference caused by the line segments of the scratch in the image, it preserves the edge features of the character strokes to the greatest extent, significantly improving the image quality of the minimum bounding rectangle region corresponding to the initial character region.

[0098] S6, in C i After all updates are complete, for C i Perform text recognition to obtain the target characters.

[0099] Specifically, in F i1 F i2 , ..., F ij , ..., F im(i) After the pixel value of each first pixel in the image is replaced, determine C. i All updates complete.

[0100] Specifically, in step S6, while acquiring the target character, the confidence level of the target character is also acquired. When the confidence level of the target character is less than Q, a prompt message is output. The prompt message is used to remind the user that there is a suspected scratch and to check it.

[0101] This application provides a text recognition method that identifies the straight line region corresponding to the scratch that runs through the low-confidence initial character, and expands it into a first image region and a second image region accordingly. The method then uses pixels from the image region obtained by subtracting the first image region from the second image region to update the pixels in the first image region, thereby repairing the scratch region and effectively eliminating the interference caused by the line segments of the scratch in the image, thus improving the image quality of the character region. This allows for more accurate target characters to be obtained during secondary recognition based on the smallest bounding rectangle region image after all updates, significantly improving the accuracy of text recognition.

[0102] In this application embodiment, a non-transitory computer-readable storage medium is also provided. This non-transitory computer-readable storage medium can be disposed in an electronic device to store at least one instruction or at least one program related to implementing the method provided in any embodiment of this application. The at least one instruction or the at least one program is loaded and executed by a processor to implement the method provided in any embodiment of this application, and can achieve the same technical effect. To avoid repetition, further details are omitted here.

[0103] Examples of non-transitory computer-readable storage media include: computer read-only memory (ROM), random access memory (RAM), erasable programmable read-only memory (EPROM), compact disc read-only memory (CD-ROM), flash memory, magnetic disk, optical disk, portable computer disk, hard disk and / or solid-state drive, etc.

[0104] In this application embodiment, an electronic device is also provided, the electronic device including a processor and the non-transitory computer-readable storage medium. The processor loads and executes at least one instruction or at least one program stored in the non-transitory computer-readable storage medium related to implementing the method provided in any embodiment of this application, so as to implement the method provided in the embodiment of this application.

[0105] For example, the electronic device may be a mobile electronic device or a non-mobile electronic device that also includes other functions such as a personal digital assistant and / or music player. Further, the mobile electronic device may be any one of a mobile phone, tablet computer, laptop computer, PDA, in-vehicle electronic device, wearable device, ultra-mobile personal computer (UMPC), netbook, or personal digital assistant (PDA); the non-mobile electronic device includes any one of a server, network attached storage (NAS), personal computer (PC), television (TV), ATM, or self-service machine. No specific limitations are made in the embodiments of this application.

[0106] For example, the processor can be a processor in any electronic device.

[0107] Exemplary embodiments of this application also provide a feasible structure for an electronic device. For example, the electronic device may include a processor, an external memory interface, internal memory, a universal serial bus (USB) interface (hereinafter referred to as a USB interface), a charging management module, a power management module, a battery, a first antenna, a second antenna, a mobile communication module, a wireless communication module, an audio module, a speaker, a receiver, a microphone, a headphone jack, a sensor module, buttons, a motor, an indicator, a camera, a display screen, and a subscriber identification module (SIM) card interface (hereinafter referred to as a SIM card interface), etc. The sensor module may include pressure sensors, gyroscope sensors, barometric pressure sensors, magnetic sensors, accelerometers, distance sensors, proximity sensors, fingerprint sensors, temperature sensors, touch sensors, ambient light sensors, and / or bone conduction sensors, etc.

[0108] It should be understood that the exemplary structures of the embodiments of this application do not constitute a specific limitation on the electronic device. In other embodiments of this application, the electronic device may include more or fewer components than the structure described herein, or combine some components, or split some components, or have different component arrangements. The components may be implemented in hardware, software, or a combination of software and hardware.

[0109] For example, the processor may include one or more processing units, wherein the processing units include: an application processor (AP), a modem processor, a graphics processing unit (GPU), an image signal processor (ISP), a controller, a video codec, a digital signal processor (DSP), a baseband processor, and / or a neural network processing unit (NPU). Different processing units may be independent devices or integrated into one or more processors. The controller may generate operation control signals based on instruction opcodes and timing signals to control instruction fetching and execution.

[0110] For example, the processor may further include a memory for storing instructions and data. In some embodiments of this application, the memory in the processor is a cache memory. The memory can store instructions or data that the processor has just used or that are used repeatedly. If the processor needs to use the instructions or data again, it can directly retrieve them from the memory.

[0111] For example, the processor may also include one or more interfaces. These interfaces include: an inter-integrated circuit (I2C) interface, an inter-integrated circuit sound (I2S) interface, a pulse code modulation (PCM) interface, a universal asynchronous receiver / transmitter (UART) interface, a mobile industry processor interface (MIPI), a general-purpose input / output (GPIO) interface, a SIM card interface, and / or a USB interface, etc.

[0112] The integrated circuit interface is a bidirectional synchronous serial bus, which includes a serial data line (SDA) and a serial clock line (SCL).

[0113] Integrated circuits with built-in audio interfaces can be used for audio communication. In some embodiments of this application, the processor may include multiple sets of integrated circuit-based audio interfaces. The processor can couple with an audio module through the integrated circuit-based audio interface to achieve communication between the processor and the audio module.

[0114] The pulse code modulation interface can also be used for audio communication, specifically for sampling, quantizing, and encoding analog signals. In some embodiments of this application, the audio module and the wireless communication module can be coupled through the pulse code modulation interface.

[0115] A Universal Asynchronous Receiver / Transmitter (UART) is a universal serial data bus interface used for asynchronous communication. This bus can be a bidirectional communication bus interface. It converts the data to be transmitted between serial and parallel communication. In some embodiments of this application, the processor and the wireless communication module can be connected via the UART.

[0116] Mobile industry processor interfaces can be used to connect processors to peripheral devices such as displays and cameras.

[0117] General purpose input / output interfaces can be configured via software.

[0118] Furthermore, the general-purpose input / output interface can be configured as a control signal or a data signal. In some embodiments of this application, the general-purpose input / output interface can be used to connect the processor to a camera, display screen, wireless communication module, audio module, sensor module, etc.

[0119] A USB interface is an interface that conforms to the USB standard specification, specifically including Mini USB, Micro USB, and USB Type-C interfaces. USB interfaces can be used to connect chargers to charge electronic devices, and also for transferring data between electronic devices and peripheral devices.

[0120] It should be understood that the interface connection relationships between the modules illustrated in the embodiments of this application are merely illustrative and do not constitute a limitation on the structure of the electronic device. In other embodiments of this application, the electronic device may also employ different interface connection methods or a combination of multiple interface connection methods as described in the embodiments.

[0121] The charging management module receives charging input from a charger, which can be either a wireless or wired charger. In some wired charging embodiments, the charging management module receives charging input from the wired charger via a USB interface. In some wireless charging embodiments, the charging management module receives wireless charging input via the wireless charging coil of the electronic device. While charging the battery, the charging management module can also supply power to various parts of the electronic device via the power management module.

[0122] The power management module is used to connect the battery, the charging management module, and the processor.

[0123] Wireless communication functionality in electronic devices can be achieved through a first antenna, a second antenna, a mobile communication module, a wireless communication module, a modem processor, and a baseband processor.

[0124] Mobile communication modules can enable wireless communication solutions, including 2G / 3G / 4G / 5G, for use in electronic devices.

[0125] A modem processor may include a modulator and a demodulator. The modulator modulates a low-frequency baseband signal to be transmitted into a mid-to-high frequency signal. The demodulator demodulates a received electromagnetic wave signal into a low-frequency baseband signal. The demodulator then transmits the demodulated low-frequency baseband signal to a baseband processor for processing. After processing by the baseband processor, the low-frequency baseband signal is transmitted to an application processor. The application processor outputs sound signals through audio devices (not limited to speakers, receivers, etc.) or displays images or videos on a display screen. In some embodiments of this application, the modem processor may be a separate device. In other embodiments, the modem processor may be independent of the processor and housed within the same device as the mobile communication module or other functional modules.

[0126] Wireless communication modules can enable solutions for wireless communication applications in electronic devices, including wireless local area networks (WLAN) (such as wireless fidelity (Wi-Fi) networks), Bluetooth (BT), global navigation satellite system (GNSS), frequency modulation (FM), near field communication (NFC), and infrared (IR) technologies.

[0127] In some embodiments of this application, the first antenna of the electronic device is coupled to the mobile communication module, and the second antenna is coupled to the wireless communication module, enabling the electronic device to communicate with networks and other devices via wireless communication technology.

[0128] Electronic devices utilize GPUs, displays, and application processors to achieve their display functions. A GPU is a microprocessor for image processing, connecting the display and the application processor. GPUs perform mathematical and geometric calculations and are used for graphics rendering. A processor may include one or more GPUs, which execute program instructions to generate or modify display information.

[0129] The display screen is used to display images, videos, etc. The display screen includes a display panel. The display panel can be a liquid crystal display (LCD), or a display panel made of materials selected from organic light-emitting diodes (OLEDs), active-matrix organic light-emitting diodes (AMOLEDs), flexible light-emitting diodes (FLEDs), minimized, microLEDs, micro-OLEDs, or quantum dot light-emitting diodes (QLEDs). In some embodiments of this application, the electronic device may include one or more display screens. In some embodiments of this application, the display screen may also integrate touch functionality and may also be referred to as a touch screen.

[0130] Electronic devices can achieve shooting functions through ISPs, cameras, video codecs, GPUs, displays, and application processors.

[0131] External storage interfaces can be used to connect external memory cards, such as Micro SD cards, to expand the storage capacity of electronic devices.

[0132] Internal memory can be used to store executable program code for a computer, which includes instructions. The processor executes the instructions stored in internal memory to perform various functional applications and data processing of electronic devices.

[0133] Electronic devices can implement audio functions through audio modules, speakers, receivers, microphones, headphone jacks, and application processors. Examples include music playback and recording.

[0134] The audio module converts digital audio information into analog audio signals for output, and also converts analog audio input into digital audio signals. The speaker, also called a "horn," converts audio electrical signals into sound signals. The receiver, also called a "handset," converts audio electrical signals into sound signals. The microphone, also called a "microphone" or "voice transducer," converts sound signals into electrical signals. The headphone jack is used to connect wired headphones.

[0135] Pressure sensors are used to sense pressure signals and convert them into electrical signals. In some embodiments of this application, the pressure sensor can be located on the display screen. A gyroscope sensor can be used to determine the motion posture of the electronic device. A barometric pressure sensor is used to measure air pressure. In some embodiments of this application, the electronic device calculates altitude using the air pressure value measured by the barometric pressure sensor, assisting in positioning and navigation. An accelerometer can detect the magnitude of acceleration of the electronic device in various directions (generally three axes). A distance sensor is used to measure distance. A fingerprint sensor is used to collect fingerprints. A touch sensor, also known as a "touch panel," can be located on the display screen, forming a touchscreen, also known as a "touch screen." A bone conduction sensor can acquire vibration signals. In some embodiments of this application, a bone conduction sensor can acquire vibration signals from vibrating bone fragments in the human vocal cords. A bone conduction sensor can also contact the human pulse to receive blood pressure signals.

[0136] The buttons include a power button and volume buttons. A motor can generate vibration alerts. Indicators can be indicator lights, used to show charging status, battery level changes, messages, missed calls, notifications, etc. A SIM card slot is used to connect a SIM card.

[0137] Embodiments of this application also provide a computer program product including program code that, when the program product is run on an electronic device, causes the electronic device to perform the steps of the methods described in this specification according to various exemplary embodiments of this application.

[0138] This application also provides a chip, which includes a processor and a communication interface. The communication interface is used to receive signals and transmit the signals to the processor. The processor processes the signals so that the methods described in the various exemplary embodiments of this application are executed.

[0139] While specific embodiments of this application have been described in detail by way of examples, those skilled in the art should understand that the examples are for illustrative purposes only and not intended to limit the scope of this application. Those skilled in the art should also understand that various modifications can be made to the embodiments without departing from the scope and spirit of this application. The scope of this application is defined by the appended claims.

Claims

1. A text recognition method, characterized in that, The method includes the following steps: S1. Perform text recognition on the text image to be recognized, and obtain the initial characters and their confidence levels; the text image to be recognized is an image of a vehicle identification number with recessed spacing between characters; S2, if A i <Q, then obtain B i The corresponding initial scratch corresponds to a linear function; A i For B i The confidence level; Q is the preset confidence threshold; B i Let be the i-th initial character, 1≤i≤n, where n is the number of initial characters; B i The corresponding initial scratch is obtained by B i The minimum bounding rectangle region image C i The corresponding image D of the outer rectangular ring region i Scratch detection was performed; among them, B 0 i The rectangular region enclosed by the four straight lines corresponding to the four extended boundaries is designated as B. i The corresponding outer rectangular region C 0 i B 0 i From C 0 i Deduct from to obtain B i The corresponding outer rectangular ring region D 0 i And extract D from the text image to be recognized 0 i The corresponding image is D i B 0 i For B i The corresponding minimum bounding rectangle region; S3, based on B i The corresponding initial scratch corresponds to a linear function, determining B. i The corresponding j-th penetrating scratch is at C i The corresponding straight line region E ij ;1≤j≤m(i), m(i) is B i The corresponding number of penetrating scratches; S4, along E ij Preset extension direction K ij , with E ij For reference direction E ij Expand both sides by a pixels to obtain E ij In C i The first image region F corresponding to the middle ij Expand by b pixels to obtain E ij In C i The corresponding second image region G ij ;a is the preset number of first pixels, b is the preset number of second pixels, a < b; S5, for F ij For each first pixel in the array, replace the pixel value of the first pixel with H. ij The middle is located at the first pixel and is adjacent to K. ij The average pixel value of all second-pixel points on parallel straight lines, such that for C i Update; H ij To make F ij From G ij The image region obtained after subtraction; S6, in C i After all updates are complete, for C i Perform text recognition to obtain the target characters.

2. The method according to claim 1, characterized in that, Initial scratches include: initial scratches originating from the left region, initial scratches originating from the right region, initial scratches originating from the upper region, and initial scratches originating from the lower region; B i The corresponding initial scratch is obtained by B i The minimum bounding rectangle region image C i The corresponding image D of the outer rectangular ring region i The scratch detection results include: S01, D i Image D divided into non-overlapping left regions i1 Right region image D i2 Image D of the upper region i3 and the lower region image D i4 ; where D i1 D i2 D i3 and D i4 In D i The corresponding regions are all rectangular regions, and D is... i1 D i2 D i3 and D i4 By piecing them together according to their corresponding positions, a complete D can be formed. i ; S02, D i1 Perform scratch detection to obtain B i The corresponding initial scratches originating from the left region; S03, D i2 Perform scratch detection to obtain B i The corresponding initial scratches originate from the right region; S04, D i3 Perform scratch detection to obtain B i The corresponding initial scratches originate from the upper region; S05, D i4 Perform scratch detection to obtain B i The corresponding initial scratches originate from the lower region.

3. The method according to claim 1, characterized in that, In step S2, obtain B i The corresponding linear function for the initial scratch includes: S21, Regarding B i For each initial scratch, extract the discrete pixel set corresponding to the initial scratch, which includes several discrete pixels. S22. Obtain the value of each discrete pixel in the discrete pixel set in D. i The corresponding pixel coordinates; D i The corresponding pixel coordinate system is based on D i The origin is the lower left corner of the point, the positive x-axis is horizontal to the right, and the positive y-axis is vertical upward. S23. Based on the overall least squares method, according to the discrete pixel point in the set of discrete pixels in D i The coordinates in the corresponding pixel coordinate system are used to perform a linear fit on the discrete pixel set to obtain the linear function corresponding to the initial scratch; where the linear function is presented in the general form.

4. The method according to claim 3, characterized in that, Step S3 includes: S31, Construct B i The corresponding set of linear function combinations R i ={R i1 R i2 , ..., R ie , ..., R if(i) }, R ie =(R ie1 R ie2 ); R ie For B i The corresponding e-th linear function combination, 1≤e≤f, where f is B. i The number of corresponding linear function combinations; R ie1 and R ie2 For B i The corresponding linear function is derived from any two different initial scratches originating from the left, right, upper, and lower regions. S32, if R ie1 and R ie2 The corresponding lines are all not parallel to D. i The straight line along the y-axis of the corresponding pixel coordinate system then yields R. ie1 The corresponding slope K ie1 R ie1 The corresponding intercept L ie1 R ie2 The corresponding slope K ie2 and R ie2 The corresponding intercept L ie2 ; S33, when |K ie1 -K ie2 |≤K 0 And |L ie1 -L ie2 |≤L 0 At that time, obtain B i The slope K_G of the linear function corresponding to the line of the penetrating scratch i and L_G i ;K 0 The preset slope difference value; L 0 The preset intercept difference value; K_G i and L_G i They each meet the following conditions: K_G i =(K ie1 +K ie2 ) / 2;L_G i =(L ie1 +L ie2 ) / 2; S34, based on K_G i and L_G i The penetrating scratch was determined to be at C. i The corresponding line segment; S35, C i The region consisting of pixels on the straight line segment is considered as the penetrating scratch in C. i The corresponding straight line region.

5. The method according to claim 4, characterized in that, The process after step S32 also includes: S321, If ​​R ie1 and R ie2 The corresponding lines are all parallel to D. i The straight line along the y-axis of the corresponding pixel coordinate system then yields R. ie1 The corresponding x-axis coordinate value X ie1 and R ie2 The corresponding x-axis coordinate value X ie2 ; S322, when |X ie1 -X ie2 |≤X 0 At that time, determine B i The x-axis coordinate value X_G corresponding to the straight line of the penetrating scratch i ;X 0 The preset x-coordinate difference; X_G i The following conditions must be met: X_G i =(X ie1 +X ie2 ) / 2; S323, Transform the line x=X_G i With C i The intersection line segment serves as the penetrating scratch at C i The corresponding line segment; S324, C i The region consisting of pixels on the straight line segment is considered as the penetrating scratch in C. i The corresponding straight line region.

6. The method according to claim 5, characterized in that, If E ij In C i The two endpoints of the corresponding line segment are located at C. i The left and right edges determine K. ij The vertical direction; if E ij In C i The two endpoints of the corresponding line segment are located at C. i The upper and lower edges determine K. ij For the horizontal direction; if E ij In C i The two endpoints of the corresponding line segment are located at C. i For any two adjacent edges, then based on E ij In C i The slope K of the corresponding straight line segment is determined. ij .

7. The method according to claim 1, characterized in that, Step S2 also includes: if A i If ≥Q, then B i As the target character.

8. The method according to claim 1, characterized in that, 0.8≤Q≤0.9。 9. A non-transitory computer-readable storage medium, characterized in that, The non-transitory computer-readable storage medium stores at least one instruction or at least one program segment, which is loaded and executed by a processor to implement the method as described in any one of claims 1-8.

10. An electronic device, characterized in that, Includes a processor and the non-transitory computer-readable storage medium as described in claim 9.

Citation Information

Patent Citations

  • Electric vehicle arc frame number identification method

    CN114663642A

  • Image restoration method and device, electronic equipment and storage medium

    CN116739942A