OCR (Optical Character Recognition) mobile phone number and name recognition detection method for express sheet
By performing image preprocessing and deep learning model training on express delivery pages, combining convolutional neural networks and attention mechanisms, and integrating text detection algorithms, the problem of low accuracy and efficiency of express delivery pages in the existing technology is solved, and the effect of efficient identification of mobile phone numbers and names is achieved.
Patent Information
- Application Number
- CN202411842052.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-12-13
- Publication Date
- 2025-03-28
AI Technical Summary
When processing express delivery bills, in the prior art, it is difficult to identify mobile phone numbers and name information in the face of diverse fonts, typesettings and possible tilt angles, especially when the picture quality is poor or the text direction is inconsistent, the recognition accuracy and efficiency are significantly reduced.
Through image preprocessing, deep learning model training and text detection algorithm integration, efficient identification of mobile phone numbers and names in express delivery orders is achieved. Specific steps include image preprocessing (clearity filtering and grayscale), deep learning model training (combining convolutional neural networks and attention mechanisms), and text detection and correction.
It improves the accuracy and efficiency of identifying mobile phone numbers and names in express delivery slips, can quickly determine the location of mobile phone numbers and names, reduces the time spent on subsequent OCR recognition, and significantly improves processing efficiency.
Smart Images

Figure CN119723592A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of express delivery bill recognition, and in particular relates to an OCR mobile phone number and name recognition detection method for express delivery bills. Background Art
[0002] In recent years, the rapid development of e-commerce in today's society has greatly promoted the rapid development of the express logistics industry. With the sharp increase in the number of parcels every year, it has posed a great challenge to the express logistics industry. In the entire express logistics industry, terminal delivery has always been the link with the highest cost, the longest time and the lowest efficiency. With the increase in the number of parcels, the problem of terminal delivery in the "last mile" of the express logistics industry has gradually become the main bottleneck restricting the development of the express logistics industry.
[0003] When processing express delivery labels, the OCR system of the existing technology still faces certain challenges in identifying mobile phone numbers and name information in the face of various fonts, layouts and possible tilt angles. The existing technology often cannot meet the needs of efficiently and accurately identifying these key information in express delivery labels, especially when dealing with poor image quality or inconsistent text direction, the recognition accuracy and efficiency are significantly reduced. Summary of the invention
[0004] The purpose of the present invention is to provide an OCR mobile phone number and name recognition detection method for express delivery bills, which solves the problem that the existing technology cannot meet the needs of efficiently and accurately identifying these key information in express delivery bills by improving the automation and accuracy of post station warehousing scanning.
[0005] To solve the above technical problems, the present invention is achieved through the following technical solutions:
[0006] The present invention is a method for detecting an OCR mobile phone number and a name for an express delivery bill, the detection method comprising:
[0007] Step S1, image preprocessing, clarity filtering: preprocess the input express delivery bill image, and apply the Laplace algorithm to calculate the image clarity;
[0008] Step S2, dynamically adjust the image size: dynamically adjust the image size according to the actual size of the express delivery bill;
[0009] Step S3, grayscale algorithm optimization: using an optimized grayscale algorithm to retain edge details and provide a high-quality input image;
[0010] Step S4, deep learning model training: Based on a large number of express delivery bill samples, a deep learning model for identifying the recipient's mobile phone number and name is trained. The model combines a convolutional neural network and an attention mechanism.
[0011] In step S4, the deep learning model training process is as follows:
[0012] Step S41: Collect a large number of express delivery bill samples and mark the mobile phone number area and name area information;
[0013] Step S42: A model is constructed based on ResNet-50 combined with a spatial attention mechanism, and a vector is obtained by global average pooling and maximum pooling of the feature map. The attention weight map is obtained through a fully connected layer and a Sigmad function, and is multiplied with the original feature map.
[0014] Step S43: using the SGD optimization algorithm, combining the cross entropy loss function for text classification and the mean square error loss function for position regression training;
[0015] Step S5, key information area segmentation: During the recognition process, the model detects the key information area and divides the key information area;
[0016] Step S6, text detection algorithm integration: integrating text detection algorithms to automatically identify multi-directional text areas in the image, including horizontal, vertical and tilted text;
[0017] Step S7, text correction and recognition: For the detected text lines, perform direction correction to ensure that the text is horizontal, and use the OCR engine to perform text recognition.
[0018] Furthermore, the specific process of step S1, image preprocessing, is as follows:
[0019] Step S11: Convert the color image to grayscale image, and calculate the grayscale value as Gr = A 1 R+A 2 G+A 3 B, where R, G, and B represent the values of the red, green, and blue color channels respectively. 1 ,A 2 ,A 3 They are weight coefficients for converting the three color channels R, G, and B in the RGB color space into grayscale values;
[0020] Step S12: Calculate pixel R=C 1 ,G=C 2 ,B=C 3 , then Gr=A 1 C 1 +A 2 C 2 +A 3 C 3 , calculate the variance to judge the clarity, and set a threshold. Images with variance less than the threshold are filtered.
[0021] Furthermore, the specific formula for calculating the variance to judge the clarity in step S12 is:
[0022] In the formula, f is a function of variables x and y, representing the object being operated. is the Laplace operator, which means the second-order partial derivative operation of the function. represents the second-order partial derivative of function f with respect to x, Represents the second-order partial derivative of the function f with respect to y.
[0023] Furthermore, the specific process of step S2, dynamic adjustment of image size, is as follows:
[0024] Step S21: Detect the key feature points of the express delivery bill, calculate the actual size of the bill based on the feature points, and set the coordinates of the triangular feature points to be (x 1 ,y 1 )、(x 11 ,y 11 ) and (x 2 ,y 2 ),but Calculate the scaling factor based on the target size and the actual size Among them, M 1 is the length of the target image, N 1 is the width of the target image, M 2 is the actual image length, N 2 is the actual image width;
[0025] Step S22: Use the bilinear interpolation algorithm to scale the image, and set the coordinates of the target pixel point to (x v ,y v ), whose corresponding coordinates in the original image are (x 0 ,y 0 ), then the value of the target pixel is: K(x v ,y v )=(1-j)(1-l)K(x 0 ,y 0 )+j(1-l)K(x 0 +1,y 0 )+(1-j)lK(x 0 ,y 0 +1)+jlK(x 0 +1,y 0 +1), where j = xx 0 ,l=yy 0 ,K(x 0 ,y 0 ) represents the value of the corresponding pixel in the original image.
[0026] Furthermore, the specific process of step S3, grayscale algorithm optimization, is as follows:
[0027] The image is divided into small areas, and the local average gray value G of the area is calculated r,t and the local standard deviation σ r,t , where r and t represent the row and column indices of the region, for each pixel point K(x v ,y v ), pixel target grayscale value O(x 3 ,y 3 ) = g 1 (K(x,y)-G r,t )+g 2 σ r,t +G r,t , where g 1 and g 2 is an adjustable coefficient.
[0028] Furthermore, the specific process of step S41 is as follows:
[0029] Step S411: extract and sort the layout information of the express delivery bills of different express companies, make different layout information into a set, use the set as a data source for determining the area where the name and mobile phone number are located, and set a scheduled task to regularly update the local data source content;
[0030] Step S412: Scan and identify the barcode on the express delivery bill, and determine the specific name of the express delivery company based on the scanned express delivery bill number;
[0031] Step S413: Determine the area where the name and telephone number in the express delivery bill are located according to the layout of the express delivery bill of the express company in the data source.
[0032] Furthermore, the specific process of step S5, key information area segmentation is as follows:
[0033] The model output layer adds a regional segmentation module, and the segmented area is determined by calculating the outer rectangular box based on the recognized mobile phone number and name results.
[0034] Furthermore, the specific process of step S6, text detection algorithm integration, is as follows:
[0035] Use the EAST algorithm to extract multi-scale feature map fusion through the FPN structure, predict the text area score map, geometric shape, including angle β information, and use a two-dimensional rotation affine transformation matrix for tilted text Correction, non-maximum suppression to handle redundant detection boxes.
[0036] Furthermore, the specific process of step S7, text correction and recognition, is as follows:
[0037] The text lines are corrected using a two-dimensional rotational affine transformation matrix according to the tilt angle β, and the CRNN model is used to recognize text, which combines convolutional neural network feature extraction with recurrent neural network to recognize mobile phone numbers and names.
[0038] The present invention has the following beneficial effects:
[0039] 1. By training a deep learning model, the present invention can quickly determine the location of the mobile phone number and the name on the express delivery bill, and then quickly divide the location of the mobile phone number and the name into regions, thereby reducing the time used for subsequent OCR to recognize the name and mobile phone number, and improving the processing efficiency of the express delivery bill.
[0040] 2. The present invention accurately identifies the mobile phone number and name information in the express delivery label by optimizing the barcode recognition mechanism, calculating the tilt angle of the image, and correcting it using a two-dimensional rotational affine transformation matrix. By integrating barcode detection, image rotation, target detection and OCR recognition into a set of automated processes, the processing efficiency and recognition accuracy are significantly improved.
[0041] Of course, any product implementing the present invention does not necessarily need to achieve all of the advantages described above at the same time. BRIEF DESCRIPTION OF THE DRAWINGS
[0042] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for describing the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative work.
[0043] Figure 1 A schematic diagram of a flow chart of an OCR mobile phone number and name recognition detection method for express delivery labels of the present invention;
[0044] Figure 2 The present invention is a flow chart of marking the mobile phone number area and name area information. DETAILED DESCRIPTION
[0045] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0046] See also Figure 1-2 As shown, the present invention is a method for detecting an OCR mobile phone number and a name for an express delivery bill, and the detection method comprises:
[0047] Step S1, image preprocessing, clarity filtering: preprocess the input express delivery bill image, and apply the Laplace algorithm to calculate the image clarity;
[0048] Step S2, dynamically adjust the image size: dynamically adjust the image size according to the actual size of the express delivery bill;
[0049] Step S3, grayscale algorithm optimization: using an optimized grayscale algorithm to retain edge details and provide a high-quality input image;
[0050] Step S4, deep learning model training: Based on a large number of express delivery bill samples, a deep learning model for identifying the recipient's mobile phone number and name is trained. The model combines a convolutional neural network and an attention mechanism.
[0051] In step S4, the deep learning model training process is as follows:
[0052] Step S41: Collect a large number of express delivery bill samples and mark the mobile phone number area and name area information;
[0053] Step S42: A model is constructed based on ResNet-50 combined with a spatial attention mechanism, and a vector is obtained by global average pooling and maximum pooling of the feature map. The attention weight map is obtained through a fully connected layer and a Sigmad function, and is multiplied with the original feature map.
[0054] Step S43: using the SGD optimization algorithm, combining the cross entropy loss function for text classification and the mean square error loss function for position regression training;
[0055] Step S5, key information area segmentation: During the recognition process, the model detects the key information area and divides the key information area;
[0056] Step S6, text detection algorithm integration: integrating text detection algorithms to automatically identify multi-directional text areas in the image, including horizontal, vertical and tilted text;
[0057] Step S7, text correction and recognition: For the detected text lines, perform direction correction to ensure that the text is horizontal, and use the OCR engine to perform text recognition.
[0058] The specific process of step S1, image preprocessing is as follows:
[0059] Step S11: Convert the color image to grayscale image, and calculate the grayscale value as Gr = A 1 R+A 2 G+A 3 B, where R, G, and B represent the values of the red, green, and blue color channels respectively. 1 ,A 2 ,A3 They are weight coefficients for converting the three color channels R, G, and B in the RGB color space into grayscale values;
[0060] Step S12: Calculate pixel R=C 1 ,G=C 2 ,B=C 3 , then Gr=A 1 C 1 +A 2 C 2 +A 3 C 3 , calculate the variance to judge the clarity, and set a threshold. Images with variance less than the threshold are filtered.
[0061] The specific formula for calculating the variance to judge the clarity in step S12 is:
[0062] In the formula, f is a function of variables x and y, representing the object being operated. is the Laplace operator, which means the second-order partial derivative operation of the function. represents the second-order partial derivative of function f with respect to x, Represents the second-order partial derivative of the function f with respect to y.
[0063] The specific process of step S2, dynamic adjustment of image size is as follows:
[0064] Step S21: Detect the key feature points of the express delivery bill, calculate the actual size of the bill based on the feature points, and set the coordinates of the triangular feature points to be (x 1 ,y 1 )、(x 11 ,y 11 ) and (x 2 ,y 2 ), then long Calculate the scaling factor based on the target size and the actual size Among them, M 1 is the length of the target image, N 1 is the width of the target image, M 2 is the actual image length, N 2 is the actual image width;
[0065] Step S22: Use the bilinear interpolation algorithm to scale the image, and set the coordinates of the target pixel point to (x v ,y v ), whose corresponding coordinates in the original image are (x 0 ,y 0 ), then the value of the target pixel is:
[0066] K(x v ,y v)=(1-j)(1-l)K(x 0 ,y 0 )+j(1-l)K(x 0 +1,y 0 )+(1-j)lK(x 0 ,y 0 +1)+jlK(x 0 +1,y 0 +1), where j = xx 0 ,l=yy 0 ,K(x 0 ,y 0 ) represents the value of the corresponding pixel in the original image.
[0067] The specific process of step S3, grayscale algorithm optimization is as follows:
[0068] The image is divided into small areas, and the local average gray value G of the area is calculated r,t and the local standard deviation σ r,t , where r and t represent the row and column indices of the region. For each pixel point K(x,y) in the region, the pixel target grayscale value O(x 3 ,y 3 ) = g 1 (K(x,y)-G r,t )+g 2 σ r,t +G r,t , where g 1 and g 2 is an adjustable coefficient.
[0069] The specific process of step S41 is as follows:
[0070] Step S411: extract and sort the layout information of the express delivery bills of different express companies, make different layout information into a set, use the set as a data source for determining the area where the name and mobile phone number are located, and set a scheduled task to regularly update the local data source content;
[0071] Step S412: Scan and identify the barcode on the express delivery bill, and determine the specific name of the express delivery company based on the scanned express delivery bill number;
[0072] Step S413: Determine the area where the name and telephone number in the express delivery bill are located according to the layout of the express delivery bill of the express company in the data source.
[0073] Step S5: The specific process of key information area segmentation is as follows:
[0074] The model output layer adds a regional segmentation module, and the segmented area is determined by calculating the outer rectangular box based on the recognized mobile phone number and name results.
[0075] The specific process of step S6, text detection algorithm integration is as follows:
[0076] Use the EAST algorithm to extract multi-scale feature map fusion through the FPN structure, predict the text area score map, geometric shape, including angle β information, and use a two-dimensional rotation affine transformation matrix for tilted text Correction, non-maximum suppression to handle redundant detection boxes.
[0077] The specific process of step S7, text correction and recognition is as follows:
[0078] The text lines are corrected using a two-dimensional rotational affine transformation matrix according to the tilt angle β, and the CRNN model is used to recognize text, which combines convolutional neural network feature extraction with recurrent neural network to recognize mobile phone numbers and names.
[0079] A specific application of this embodiment is:
[0080] Step S1, image preprocessing, clarity filtering: First, convert the input express delivery bill image into a grayscale image. This step can adopt the weighted average method. For example, for each pixel of the color image, its grayscale value Gr = 0.299R + 0.587G + 0.114B, where R, G, and B represent the values of the three color channels of red, green, and blue, respectively. Such weighting coefficients are set based on the study of the sensitivity of the human eye to different colors, and can better retain the brightness information of the image and convert it into a grayscale image. For example, a color image containing an express delivery bill, a certain pixel of which has R = 100, G = 150, and B = 80. According to this formula, the grayscale value is calculated to be G = 0.299 × 100 + 0.587 × 150 + 0.114 × 80 ≈ 120;
[0081] Using the formula Calculate the clarity of the image, where f is a function of variables x and y, representing the object being operated on, is the Laplace operator, which means the second-order partial derivative operation of the function. represents the second-order partial derivative of function f with respect to x, Represents the second-order partial derivative of function f with respect to y. For discrete images, an approximate convolution kernel form can be used, such as a 3x3 convolution kernel with a central coefficient of -4 and a coefficient of 1 for the surrounding adjacent pixels: Convolve this convolution kernel with the grayscale image to obtain the Laplace transform result of the image, and then calculate the variance of the image. The larger the variance, the higher the clarity of the image. Set a clarity threshold. If the calculated variance is less than the threshold, the image quality is judged to be poor and filtered out. Otherwise, proceed to the next step. The threshold here can be determined by statistical analysis of a large number of express delivery bill image samples. For example, a value that makes the variance of 90% of the clear images greater than this value is taken as the threshold. Suppose we have 1,000 clear express delivery bill images. After calculating their variances, it is found that the variances of 900 of the images are greater than 50. Then the threshold can be set to 50. If the variance of an image to be processed is 30, the image will be judged to be of poor quality and filtered out.
[0082] Step S2, dynamic adjustment of image size: Detect key feature points in the express delivery bill image, such as the four corner points of the express delivery bill or a specific logo pattern (such as the logo of the express company). A feature-based detection algorithm can be used, such as the scale-invariant feature transform (SI FT) algorithm. The SI FT algorithm detects extreme points in different scale spaces and describes the features of these extreme points to find stable feature points in the image. For example, for an express delivery bill image, the feature points of the four corner points of the express delivery bill can be detected by the SIFT algorithm. These feature points have relatively stable feature descriptions at different scales, so that the position and range of the bill can be accurately determined.
[0083] Determine the actual size range of the express delivery bill based on the detected key feature points. For example, the length and width of the bill can be estimated by calculating the distance between the diagonal feature points. If the coordinates of the lower left corner, upper left corner, and lower right corner feature points are (x 1 ,y 1 )、(x 11 ,y 11 ) and (x 2 ,y 2 ), then we can calculate the length of the shipping order to be approximately Width is about
[0084] According to the preset target size ratio, combined with the actual size of the express delivery label, the image scaling factor is calculated. For example, if the length and width of the target image are M respectively 1 =500 and N 1 =300, the actual length and width of the express delivery bill detected are M 2 =290 and N 2 =290, then the scaling factor
[0085] Use the bilinear interpolation algorithm to scale the image. The bilinear interpolation algorithm calculates the value of the target pixel by taking a weighted average of the values of four adjacent pixels. Suppose the coordinates of the target pixel are (x v ,y v ), whose corresponding coordinates in the original image are (x 0 ,y 0 ), then the value of the target pixel point K(x v ,y v )=(1-j)(1-l)K(x 0 ,y 0 )+j(1-l)K(x 0 +1,y 0 )+(1-j)lK(x 0 ,y 0 +1)+jlK(x 0 +1,y 0 +1), where j = xx 0 ,l=yy 0 ,K(x 0 ,y 0 ) represents the value of the corresponding pixel in the original image. For example, the values of the four pixels with coordinates (10,10), (11,10), (10,11), and (11,11) in the original image are 50, 60, 70, and 80 respectively. The coordinate of the target pixel is (10.5,10.5). Then, we can calculate j=0.5, l=0.5, K(10.5,10.5)=(1-0.5)(1-0.5)×50+0.5(1-0.5)×60+(1-0.5)×0.5×40+0.5×0.5×70=57.5. This can reduce the amount of calculation while better retaining the details of the image and ensuring the clarity of the key information.
[0086] Step S3, grayscale algorithm optimization: Use a grayscale algorithm based on local contrast enhancement to divide the image into several small areas (e.g., 8x8 pixel blocks); for each small area, calculate its local average grayscale value G r,t and the local standard deviation σ r,t , where r and t represent the row and column indexes of the region. For example, for an 8x8 pixel block, the average grayscale value of all pixels is calculated as the local average grayscale value, and the standard deviation of the grayscale value is calculated as the local standard deviation. If the grayscale values of the pixels in the region are [30, 35, 40, 32, 38, 45, 36, 33] respectively, the local average grayscale value is about 36 and the local standard deviation is about 4.5;
[0087] For each pixel point K(x v ,y v ), its new gray value O(x3 ,y 3 ) = g 1 (K(x,y)-G r,t )+g 2 σ r,t +G r,t , where g 1 and g 2 is an adjustable coefficient. In this way, the pixel grayscale value can be adjusted according to the contrast of each area, so as to retain more edge details and provide a higher quality input image for the subsequent detection stage. The coefficient g 1 and g 2 This can be determined by conducting experiments on a large number of express delivery images. For example, a set of initial values is first set, such as g 1 =0.5,g 2 = 0.3, and then fine-tune according to the edge detail preservation effect and the overall image quality until a better effect is achieved. For example, for an area with low edge contrast, after adjustment by this algorithm, the grayscale value of the edge pixel changes more obviously, making the edge details more prominent;
[0088] Step S4: Deep learning model training:
[0089] Step S41: Collect a large number of express delivery order sample images;
[0090] Step S411: extract and sort the layout information of the express delivery bills of different express companies, make the layout information into a set, use the set as the data source for determining the area where the name and mobile phone number are located, and set a scheduled task to regularly update the local data source content;
[0091] Step S412: Scan and identify the barcode on the express delivery bill, and determine the express delivery company by the scanned express delivery bill number;
[0092] Step S413: determining the area where the name and telephone number in the express delivery form are located according to the layout of the express delivery form of the express delivery company in the data source;
[0093] Step S42: construct a deep learning model architecture combining a convolutional neural network (CNN) and an attention mechanism. The CNN part can adopt a classic structure, such as a ResNet network structure as a basic feature extractor. ResNet effectively solves the gradient vanishing problem when the network depth increases by introducing residual blocks, and can extract richer image features. Taking ResNet-50 as an example, it contains multiple residual blocks, each of which is composed of a convolution layer, a batch normalization layer, an activation function layer, etc., and can gradually extract image features from low-level to high-level, such as edge, texture, shape and other features;
[0094] On the basis of ResNet, an attention mechanism is added, such as the spatial attention mechanism. By calculating the attention weight of each feature map position, the model can pay more attention to the areas related to the mobile phone number and name. The specific calculation method is: first, perform global average pooling and global maximum pooling operations on the feature map to obtain two vectors that describe the overall information of the feature map, and then input these two vectors into a fully connected layer. After an activation function (such as the Sigmoi d function), the attention weight map is obtained. The attention weight map is multiplied by the original feature map to obtain a weighted feature map, which is then input into the subsequent network layer for classification and regression tasks to determine the location of the mobile phone number and name area and identify the text content, thereby improving the detection accuracy and robustness. Assuming that the size of the original feature map is 256x256x64 (width x height x number of channels), two 1x1 x64 vectors are obtained after global average pooling and global maximum pooling. After the fully connected layer and Sigmoi After the d function, a 256x256 attention weight map is obtained, which is multiplied with the original feature map to obtain a weighted feature map, so that the model can focus more on the key areas in subsequent processing;
[0095] Step S43: Use the labeled express delivery order samples to train the model. During the training process, the stochastic gradient descent (SGD) optimization algorithm is used, combined with the cross entropy loss function for text classification tasks (determining whether it is a mobile phone number or a name), and the mean square error loss function is used for the location regression task (determining the regional coordinates). During the training process, the learning rate is dynamically adjusted according to the change of the loss value. For example, a learning rate decay strategy is adopted to gradually reduce the learning rate as the number of training rounds increases to ensure that the model can converge stably and achieve better training results. For example, the initial learning rate is set to 0.01. After every 10 training rounds, the learning rate decays to 0.9 times the original. After 100 rounds of training, the accuracy and recall of the model on the test set have reached a high level.
[0096] Step S5, key information area segmentation: Add a region segmentation module to the output layer of the deep learning model, which further analyzes the feature distribution in the region based on the preliminary detection results of the model on the key information area;
[0097] According to the results of mobile phone number and name recognition, determine the subdivision boundaries of the mobile phone number and name areas. For example, calculate the bounding rectangles of each mobile phone number and name, and use these rectangles as the subdivided mobile phone number and name areas, thereby reducing the complexity and error of subsequent OCR processing. If the coordinates of the bounding rectangle obtained by clustering the mobile phone number digits are (100, 200, 50, 30), (upper left corner coordinates (100, 200), width 50, height 30), and the coordinates of the bounding rectangle obtained by clustering the name area are (180, 200, 80, 30), then the subsequent OCR processing can be performed on these two areas separately to improve accuracy;
[0098] Step S6, text detection algorithm integration: using a text detection algorithm based on deep learning, such as the EAST algorithm. The EAST algorithm directly predicts the text area without the need for complex operations such as character segmentation like traditional methods;
[0099] Multi-scale feature extraction is performed on the express delivery bill image. First, feature maps of different scales are constructed through convolutional neural networks. For example, the feature pyramid network (FPN) structure is used to fuse the underlying high-resolution feature map and the high-level semantically rich feature map to obtain image information at different scales. For example, for an express delivery bill image, the underlying feature map can clearly display the details and edge information of the text, while the high-level feature map contains the semantic category information of the text (such as whether the text belongs to a name or an address). After FPN fusion, the text area can be accurately detected at different scales.
[0100] On the fused feature map, the score map of the text area, the geometric shape of the text box (including the coordinates, angles and other information of the bounding box), and the direction information of the text are predicted. The detection of horizontal, vertical and inclined text is achieved by predicting the angle information of the text box. For example, for inclined text, its inclination angle β is predicted, and then the text area is rotated and corrected according to the angle to convert it to a horizontal or vertical direction for subsequent processing. If a text area is detected to have an inclination angle of 30 degrees, a two-dimensional rotational affine transformation matrix can be constructed: The pixel coordinates in the text area are transformed by the matrix to achieve rotation correction;
[0101] Step S7, text correction and recognition: For the detected text line, the direction correction is performed according to its direction information. If the tilt angle of the text line is β, a two-dimensional rotation affine transformation matrix is constructed: The coordinates of each pixel in the text line are transformed through the matrix to achieve text rotation correction and ensure that the text is horizontal. For example, for a text line with a tilt angle of 45 degrees, construct the matrix After transforming the pixel coordinates in the text line, the text becomes horizontal;
[0102] Use an efficient OCR engine for text recognition, for example, an OCR model based on deep learning, such as the CRNN model. The CRNN model combines a convolutional neural network with a recurrent neural network. The convolutional neural network is used to extract features of text images, and the recurrent neural network (such as LSTM) is used to perform sequence modeling on the extracted feature sequence to identify the text content. The model supports multiple fonts and typesetting formats. By training on a large number of text samples in different fonts and typesettings, it can adapt to various text presentation forms on express delivery labels, and ultimately achieve accurate text recognition of mobile phone numbers and names.
[0103] In the description of this specification, the description with reference to the terms "one embodiment", "example", "specific example", etc. means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described can be combined in any one or more embodiments or examples in a suitable manner.
[0104] The preferred embodiments of the present invention disclosed above are only used to help illustrate the present invention. The preferred embodiments do not describe all the details in detail, nor do they limit the invention to the specific implementation methods described. Obviously, many modifications and changes can be made according to the content of this specification. This specification selects and specifically describes these embodiments in order to better explain the principles and practical applications of the present invention, so that those skilled in the art can understand and use the present invention well. The present invention is limited only by the claims and their full scope and equivalents.
Claims
1. A method for OCR mobile phone number and name recognition detection for express delivery labels, characterized by: Detection methods include: Step S1, image preprocessing: preprocess the input express delivery bill image and calculate the image clarity using the Laplace algorithm; Step S2, dynamically adjust the image size: dynamically adjust the image size according to the actual size of the express delivery bill; Step S3, grayscale algorithm optimization: using an optimized grayscale algorithm to retain edge details and provide a high-quality input image; Step S4, deep learning model training: Based on a large number of express delivery bill samples, a deep learning model for identifying the recipient's mobile phone number and name is trained. The model combines a convolutional neural network and an attention mechanism. In step S4, the deep learning model training process is as follows: Step S41: Collect a large number of express delivery bill samples and mark the mobile phone number area and name area information; Step S42: A model is constructed based on ResNet-50 combined with a spatial attention mechanism. The feature map is globally averaged and max-pooled to obtain a vector. The attention weight map is obtained through a fully connected layer and a Sigmoid function, and then multiplied with the original feature map. Step S43: using the SGD optimization algorithm, combining the cross entropy loss function for text classification and the mean square error loss function for position regression training; Step S5, key information area segmentation: During the recognition process, the model detects the key information area and divides the key information area; Step S6, text detection algorithm integration: integrating text detection algorithms to automatically identify multi-directional text areas in the image, including horizontal, vertical and tilted text; Step S7, text correction and recognition: For the detected text lines, perform direction correction to ensure that the text is horizontal, and use the OCR engine to perform text recognition.
2. According to claim 1, a method for OCR mobile phone number and name recognition detection for express delivery bills is characterized in that: The specific process of step S1, image preprocessing is as follows: Step S11: convert the color image into a grayscale image, and the grayscale value is calculated as Gr=A1R+A2G+A3B, where R, G, and B represent the values of the three color channels of red, green, and blue, respectively, and A1, A2, and A3 are weight coefficients for converting the three color channels of R, G, and B in the RGB color space into grayscale values; Step S12: Calculate the pixel points R=C1, G=C2, B=C3, then Gr=A1C1+A2C2+A3C3, calculate the variance to determine the clarity, and set a threshold. Images with variances less than the threshold are filtered.
3. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 2 is characterized in that: The specific formula for calculating the variance to judge the clarity in step S12 is: In the formula, f is a function of variables x and y, representing the object being operated. is the Laplace operator, which means the second-order partial derivative operation of the function. represents the second-order partial derivative of function f with respect to x, Represents the second-order partial derivative of the function f with respect to y.
4. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 1, characterized in that: The specific process of step S2, dynamic adjustment of image size, is as follows: Step S21: Detect the key feature points of the express delivery bill, calculate the actual size of the bill based on the feature points, and set the coordinates of the triangular feature points to be (x1, y1), (x 11 ,y 11 ) and (x2,y2), then Calculate the scaling factor based on the target size and the actual size Where M1 is the length of the target image, N1 is the width of the target image, M2 is the length of the actual image, and N2 is the width of the actual image; Step S22: Use the bilinear interpolation algorithm to scale the image, and set the coordinates of the target pixel point to (x v ,y v ), the corresponding coordinates in the original image are (x0, y0), then the value of the target pixel is: K(x v ,y v )=(1-j)(1-l)K(x0,y0)+j(1-l)K(x0+1,y0)+(1-j)lK(x0,y0+1)+jlK(x0+1,y0+1), where j=x-x0, l=y-y0, K(x0,y0) represents the value of the corresponding pixel in the original image.
5. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 1, characterized in that: The specific process of step S3, grayscale algorithm optimization, is as follows: The image is divided into small areas, and the local average gray value G of the area is calculated r,t and the local standard deviation σ r,t , where r and t represent the row and column indices of the region, for each pixel point K(x v ,y v ), pixel target grayscale value O(x3,y3)=g1(K(x,y)-G r,t )+g2σ r,t +G r,t , where g1 and g2 are adjustable coefficients.
6. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 1, characterized in that: The specific process of step S41 is as follows: Step S411: extract and sort the layout information of the express delivery bills of different express companies, make different layout information into a set, use the set as a data source for determining the area where the name and mobile phone number are located, and set a scheduled task to regularly update the local data source content; Step S412: Scan and identify the barcode on the express delivery bill, and determine the specific name of the express delivery company based on the scanned express delivery bill number; Step S413: Determine the area where the name and telephone number in the express delivery bill are located according to the layout of the express delivery bill of the express company in the data source.
7. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 1, characterized in that: The specific process of step S5, key information area segmentation is as follows: The model output layer adds a regional segmentation module, and the segmented area is determined by calculating the outer rectangular box based on the recognized mobile phone number and name results.
8. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 1, characterized in that: The specific process of step S6, text detection algorithm integration, is as follows: Use the EAST algorithm to extract multi-scale feature map fusion through the FPN structure to predict the text area score map, geometric shape, including angle β information, and use a two-dimensional rotation affine transformation matrix for tilted text Correction, non-maximum suppression to handle redundant detection boxes.
9. The OCR mobile phone number and name recognition detection method for express delivery labels according to claim 1, characterized in that: The specific process of step S7, text correction and recognition, is as follows: The text lines are corrected using a two-dimensional rotational affine transformation matrix according to the tilt angle β, and the CRNN model is used to recognize text, which combines convolutional neural network feature extraction with recurrent neural network to recognize mobile phone numbers and names.
Citation Information
Cited By
License plate recognition system based on deep learning
CN120071321A