Method, device and storage medium for recognizing crown code numbers
By using an architecture of convolutional neural network-bidirectional long short-term memory network-linear mapping layer, the problem that serial number recognition technology cannot adapt to different types and variable length formats is solved, and efficient recognition of serial numbers is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CREATOR CHINA TCH CO
- Filing Date
- 2026-05-06
- Publication Date
- 2026-06-02
AI Technical Summary
Existing serial number recognition technologies cannot adapt to different types and variable-length serial number formats, resulting in poor recognition performance.
A network architecture consisting of a convolutional neural network, a bidirectional long short-term memory network, and a linear mapping layer is adopted. By learning deep features from the original image and capturing the contextual dependencies between characters, the prediction score at each time step is output, which adapts to the format and length variations of different types of serial numbers.
It improves the generalization ability of serial number recognition, enabling it to adapt to different types of serial number formats and length variations, thereby enhancing the accuracy and robustness of recognition.
Smart Images

Figure CN122135378A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of image recognition technology, and in particular to methods, devices and storage media for serial number recognition. Background Technology
[0002] Currently, serial number recognition technology mainly relies on traditional image processing methods to identify characters, and then uses template matching after character segmentation to identify the serial number. However, the length and spatial distribution of serial numbers vary across different types of documents, such as tickets or lottery tickets, making the aforementioned methods unable to adapt to different serial number formats.
[0003] The above content is only used to help understand the technical solution of this application and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main purpose of this application is to provide a serial number recognition method, device and storage medium, which aims to solve the technical problem that current serial number recognition methods cannot adapt to multiple types and variable length serial number formats.
[0005] To achieve the above objectives, this application proposes a serial number identification method, which includes the following steps:
[0006] Obtain a serial number image, input the serial number image into a convolutional neural network, and increase the dimensionality of the image channels of the serial number image through the convolutional neural network to obtain a feature map; The feature map is input into a bidirectional long short-term memory network, and the bidirectional temporal feature sequence corresponding to the feature map is determined through the bidirectional long short-term memory network. The bidirectional temporal feature sequence is input into a linear mapping layer, and the prediction score of the bidirectional temporal feature sequence for each character category is determined by the linear mapping layer. The prefix character corresponding to the prefix image is determined based on the prediction score.
[0007] In one embodiment, after the step of inputting the feature map into a bidirectional long short-term memory network and determining the bidirectional temporal feature sequence corresponding to the feature map through the bidirectional long short-term memory network, the method further includes: The feature vector and context summary vector corresponding to each time step in the bidirectional temporal feature sequence are input into the alignment model. The alignment model performs nonlinear transformation on the feature vector and the context summary vector to obtain the attention score of the feature vector corresponding to each time step. The attention scores of the feature vectors corresponding to each time step are normalized to obtain the attention weight distribution; The context vector is obtained by weighted summation of the bidirectional temporal feature sequence and the attention weight distribution; The context vector is concatenated with the bidirectional temporal feature sequence to obtain a new bidirectional temporal feature sequence.
[0008] In one embodiment, before the step of inputting the feature vector and context summary vector corresponding to each time step in the bidirectional temporal feature sequence into the alignment model, the method further includes: Determine the average pooling vector of the bidirectional temporal feature sequence; The average pooling vector is input into a feedforward neural network, and the average pooling vector is weighted and summed through the fully connected layer of the feedforward neural network. The context summary vector is obtained by nonlinearly transforming the weighted average pooling vector using the nonlinear activation function of the feedforward neural network.
[0009] In one embodiment, the step of determining the prefix character corresponding to the serial number image based on the prediction score includes: The predicted score is used as the input parameter of a preset Softmax function, and the character probability distribution at each time step is calculated by the Softmax function. Obtain the character with the highest probability at each time step to get the initial character sequence; By merging duplicate characters in the initial character sequence and removing whitespace characters from the initial character sequence, a character sequence is obtained; The character sequence is compared with the character rules corresponding to different recognition targets. When the character sequence satisfies any of the character rules, the character sequence and the recognition target type corresponding to the character sequence are determined and output.
[0010] In one embodiment, before the step of acquiring the serial number image and inputting the serial number image into a convolutional neural network, the method further includes: Obtain a binarized target image for recognition, and determine the region of interest for the serial number in the target image for recognition. The number of pixels in the region of interest whose pixel value is the first pixel value is counted by row and column respectively, to obtain a horizontal projection array and a vertical projection array, wherein the first pixel value represents a character; Based on the horizontal projection array and the vertical projection array, the orientation of the serial number in the target image is determined, and the orientation is marked in the region of interest to obtain an orientation label; The serial number region image in the region of interest is determined by a pre-trained image recognition model; The serial number region image is corrected according to the orientation label so that the serial number is located in a preset orientation, thereby obtaining the serial number image.
[0011] In one embodiment, the step of determining the orientation of the serial number in the target image based on the horizontal projection array and the vertical projection array includes: The variance of the number of pixels in each row of the horizontal projection array is determined to obtain the horizontal projection variance; The variance of the number of pixels in each column of the vertical projection array is determined to obtain the vertical projection variance. If the horizontal projection variance is greater than the vertical projection variance, then the orientation of the serial number is determined to be horizontal. After determining that the orientation of the serial number is horizontal, the sum of the number of pixels in the first preset row and the number of pixels in the last preset row of the horizontal projection array is determined; If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the first horizontal direction. If the sum of the number of pixels in the preceding preset rows is less than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the second horizontal direction, wherein the preset number of rows is less than half of the total number of rows in the region of interest, and the first horizontal direction is parallel to and opposite to the second horizontal direction.
[0012] In one embodiment, after determining the variance of the number of pixels in each column of the vertical projection array to obtain the vertical projection variance, the method further includes: If the horizontal projection variance is less than the vertical projection variance, then the orientation of the serial number is determined to be vertical. After determining that the orientation of the serial number is vertical, the sum of the number of pixels in the first preset row and the number of pixels in the last preset row of the vertical projection array is determined; If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is perpendicular to the first direction. If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the vertical second direction, wherein the vertical first direction is parallel to and opposite to the vertical second direction.
[0013] In one embodiment, before the steps of acquiring the binarized target image and determining the region of interest for the serial number in the target image, the method further includes: Acquire a scanned image of the target to be identified, and binarize the scanned image; Edge detection is performed on the binarized scanned image to obtain the minimum outer bounding box corresponding to the target contour; The rotation angle of the scanned image is determined based on the minimum bounding rectangle. After the scanned image is rotated and corrected according to the rotation angle, the corrected binarized target image is cropped according to the target contour.
[0014] In addition, to achieve the above objectives, this application also proposes a serial number recognition device, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the serial number recognition method as described above.
[0015] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the serial number recognition method described above.
[0016] This application provides a method for recognizing serial numbers. The method involves acquiring a serial number image, inputting the image into a convolutional neural network (CNN), increasing the dimensionality of the image channels through the CNN to obtain a feature map, inputting the feature map into a bidirectional long short-term memory (LSTM) network, determining the corresponding bidirectional temporal feature sequence, inputting the bidirectional temporal feature sequence into a linear mapping layer, determining the prediction score of the bidirectional temporal feature sequence for each character category, and finally determining the serial number character corresponding to the serial number image based on the prediction score.
[0017] The above method automatically learns and extracts deep features related to character recognition from the original image through a network architecture of convolutional neural network-bidirectional long short-term memory network-linear mapping layer. At the same time, it learns the contextual dependencies between characters from both positive and negative directions. Then, the linear mapping layer outputs the prediction score for each time step. Based on the prediction score, the time-series output of variable length is converted into a character sequence of corresponding length. It can adapt to the format and length changes of different types of serial numbers, thereby improving the generalization ability of serial number recognition. Attached Figure Description
[0018] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0019] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0020] Figure 1 This is a flowchart illustrating an embodiment of the serial number recognition method of this application. Figure 2 This is a flowchart illustrating Embodiment 2 of the serial number recognition method of this application; Figure 3 This is a flowchart illustrating Embodiment 3 of the serial number recognition method of this application; Figure 4 This is a schematic diagram of the serial number recognition process provided in Embodiment 3 of this application; Figure 5 This is a schematic diagram of the overall process for Embodiment 4 of the serial number recognition method of this application; Figure 6 This is a schematic diagram of the overall process for Embodiment 5 of the serial number recognition method of this application; Figure 7 This is a schematic diagram of the device structure of the hardware operating environment involved in the serial number recognition method in this application embodiment.
[0021] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation
[0022] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of this application and are not intended to limit this application.
[0023] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific embodiments. It should be noted that all actions involving the acquisition of signals, information, or data in this application are performed in accordance with the relevant data protection laws and regulations of the country where the application is located, and with authorization from the owner of the corresponding device.
[0024] Currently, serial number recognition technology mainly relies on traditional image processing methods to identify characters, and then uses template matching after character segmentation to identify the serial number. However, the length and spatial distribution of serial numbers vary across different types of documents, such as tickets or lottery tickets, making the aforementioned methods unable to adapt to different serial number formats.
[0025] In view of the above problems, this application proposes a serial number recognition method. The method involves acquiring a serial number image, inputting the image into a convolutional neural network (CNN), increasing the dimensionality of the image channels to obtain a feature map; inputting the feature map into a bidirectional long short-term memory (LSTM) network to determine the corresponding bidirectional temporal feature sequence; inputting the bidirectional temporal feature sequence into a linear mapping layer to determine the prediction score of the bidirectional temporal feature sequence for each character category; and determining the serial number character corresponding to the serial number image based on the prediction score.
[0026] The above method automatically learns and extracts deep features related to character recognition from the original image through a network architecture of convolutional neural network-bidirectional long short-term memory network-linear mapping layer. At the same time, it learns the contextual dependencies between characters from both positive and negative directions. Then, the linear mapping layer outputs the prediction score for each time step. Based on the prediction score, the time-series output of variable length is converted into a character sequence of corresponding length. It can adapt to the format and length changes of different types of serial numbers, thereby improving the generalization ability of serial number recognition.
[0027] It should be noted that the executing entity in this embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, and mobile phone, or an electronic device or serial number recognition system capable of performing the above functions. The following description uses a serial number recognition system as an example to illustrate this embodiment and the subsequent embodiments.
[0028] Based on this, the first embodiment of this application provides a method for identifying serial number prefixes, referring to... Figure 1 In this embodiment, the serial number identification method includes steps S10 to S40: Step S10: Obtain the serial number image, input the serial number image into a convolutional neural network, and increase the dimensionality of the image channels of the serial number image through the convolutional neural network to obtain a feature map.
[0029] It should be noted that the serial number image refers to a grayscale or color image containing only the serial number region, which is located and cropped from the target image. The target image refers to an object with the serial number to be identified, such as banknotes, tickets, or lottery tickets. In this embodiment, the number of image channels of the serial number image is expanded using a convolutional neural network to enhance the image feature representation capability. The number of channels represents the number of feature dimensions of the feature map. The feature map is a two-dimensional feature matrix obtained by the convolutional neural network through layer-by-layer convolution, activation, and pooling of the input image, where each element represents the image feature value at the corresponding location.
[0030] Optionally, before inputting the serial number image into the convolutional neural network, the serial number image is preprocessed to normalize its size to the fixed size required by the convolutional neural network and to normalize its pixel values. The preprocessed serial number image is then input into the convolutional neural network, passing through multiple convolutional layers, activation layers, and pooling layers sequentially. Specifically, the convolutional layers extract low-level visual features such as edges and textures by performing convolution operations between the convolutional kernel and local image regions; the activation layers introduce nonlinear transformations to enhance feature representation; and the pooling layers downsample the feature map to reduce dimensionality while preserving key features.
[0031] Preferably, in this embodiment, a convolutional neural network with 7 convolutional layers can be used, and the number of image channels can be increased to 512 dimensions by increasing the number of convolutional kernels in the back-end convolutional layers of the convolutional neural network, that is, the feature dimension of the feature map is 512 dimensions.
[0032] It should be noted that in other embodiments, the number of convolutional layers and the number of image channels can also be customized by the user according to the application scenario.
[0033] Step S20: Input the feature map into a bidirectional long short-term memory network, and determine the bidirectional temporal feature sequence corresponding to the feature map through the bidirectional long short-term memory network.
[0034] It is understandable that serial numbers are ordered character sequences, and their recognition is essentially a problem of recognizing indeterminate temporal sequences. The temporal feature sequence formed after dimensionality transformation of the feature map exhibits contextual relationships between preceding and following characters. Traditional recurrent neural networks are prone to gradient vanishing or gradient exploding when processing longer temporal sequences, failing to effectively capture long-distance character association information. In contrast, Long Short-Term Memory (LSTM) networks, through gating mechanisms such as input gates, forget gates, and output gates, can selectively retain useful historical features and forget invalid features, stably capturing long temporal dependencies and adapting to the feature mining needs of different types of serial numbers with varying lengths. Furthermore, after dimensional transformation, the serial number feature map forms a one-dimensional temporal feature sequence with the width direction as the time step. Each time step corresponds to the spatial features of a character position in the serial number. The bidirectional long short-term memory network can directly process this temporal sequence step by step. The bidirectional long short-term memory network can simultaneously capture forward and backward temporal dependencies. By fusing the temporal correlation information of the bidirectional context, it can assist in the determination of blurred or deformed serial number characters, reduce misidentification of single characters due to image quality issues, and improve the accuracy of character recognition.
[0035] Optionally, the feature map is first transformed in dimension, converting the two-dimensional feature map into a one-dimensional temporal feature input. For example, the feature map is divided into multiple time steps along its width, with each time step corresponding to all channel features in one column of the feature map, forming an initial temporal feature sequence. This initial temporal feature sequence is then input into a bidirectional long short-term memory (LSTM) network. This bidirectional LSM network consists of two branches: a forward LSM network and a backward LSM network. The forward LSM network processes the initial temporal feature sequence sequentially from the first element to the last element, extracting forward temporal features; the backward LSM network processes the initial temporal feature sequence sequentially from the last element to the first element, extracting backward temporal features. Then, the temporal features output by the forward and backward LSM networks are concatenated, fusing the forward and backward contextual information to generate a bidirectional temporal feature sequence containing bidirectional temporal correlation information.
[0036] For example, suppose the initial time series feature sequence is ,in T represents the spatial features at one time step in the serial number image, where T is the sequence length, determined by the width of the feature map.
[0037] In forward temporal modeling, the forward LSTM processes the initial temporal feature sequence X sequentially from t=1 to t=T, step by step. At time step t, its hidden state... From the current input The hidden state of the previous time step Joint decision, that is When expanded, it can be represented as This indicates It accumulates all positive contextual information from time step 1 to t. In reverse temporal modeling, the reverse LSTM processes the initial temporal feature sequence X sequentially from t=T to t=1. Similarly, its hidden state at time step t... It accumulates all the reverse context information from time step T to t, i.e. The hidden states output by the forward LSTM and the backward LSTM at the same time step t. and By concatenating the two states, we obtain the final hidden state that incorporates bidirectional contextual information. .at this time, It also includes contextual information from both the preceding and following time steps t. The bidirectional fused hidden states from all time steps together constitute the final bidirectional temporal feature sequence. This bidirectional temporal feature sequence not only preserves the spatial characteristics of the serial number but also implies a bidirectional temporal correlation between characters.
[0038] Step S30: Input the bidirectional temporal feature sequence into the linear mapping layer, and determine the prediction score of the bidirectional temporal feature sequence for each character category through the linear mapping layer.
[0039] The predicted score is the output of the linear mapping layer, representing the numerical value of each time position across all preset character categories. The magnitude of the value indicates the probability that the position belongs to the corresponding character category. Character categories are a preset set of character categories for serial numbers, including digits 0-9, letters A, Z, and special symbols. The aforementioned bidirectional temporal feature sequence is input into the linear mapping layer. This layer performs a linear transformation on each time step feature in the bidirectional temporal feature sequence using a weight matrix, mapping the high-dimensional temporal features to a space consistent with the dimension of the total number of character categories, and outputting the original numerical value for each time step across all character categories.
[0040] For example, for any time step t, its bidirectional temporal characteristics It can be calculated via a linear mapping:
[0041] in, Indicates time step Predicted scores for each character category, This represents the weight matrix of the linear mapping layer. This is the bias vector.
[0042] Step S40: Determine the serial number character corresponding to the serial number image based on the prediction score.
[0043] For example, the prediction score at each time step is normalized and converted into the probability value of each character category, so that the sum of the probabilities of all character categories at each time step is 1; a temporal decoding method is used to decode the probability values of all time steps, and the candidate character sequence obtained by decoding is validated according to rules, so as to finally determine the character sequence corresponding to the serial number image.
[0044] Optionally, step S40 above includes steps S41 to S44: Step S41: The predicted score is used as the input parameter of the preset Softmax function, and the character probability distribution at each time step is calculated by the Softmax function.
[0045] For example, in order to obtain the prediction results for each character category at each time step, the prediction scores are... Perform Softmax normalization:
[0046] in, The total number of character categories, For a certain character category, For time steps In category The predicted score on the screen For time steps Belongs to the character category The probability of the time step is obtained. Character probability distribution :
[0047] Step S42: Obtain the character with the highest probability at each time step to obtain the initial character sequence.
[0048] Step S43: Merge duplicate characters in the initial character sequence and remove whitespace characters from the initial character sequence to obtain a character sequence.
[0049] For example, using the greedy decoding logic of the connection-based temporal classification algorithm, all time steps t are traversed. For the character probability distribution Pt at each time step, the character category with the highest probability value is selected. The highest probability characters selected from all time steps are then concatenated in chronological order to form the initial character sequence. Because temporal modeling methods may output the same prediction at multiple time steps corresponding to a single character, consecutive identical characters in the initial character sequence are merged into a single character. All whitespace characters in the initial character sequence are removed. Here, whitespace characters are used by the connection-based temporal classification algorithm to solve the alignment problem where the number of time steps output by the model does not match the actual number of characters. For example, when the actual number of characters in a serial number is much smaller than the number of time steps output by the model, the connection-based temporal classification algorithm allows one real character to correspond to multiple consecutive time steps. Whitespace characters are used to separate these consecutive time steps to avoid incorrectly merging different characters.
[0050] In other alternative embodiments, beam search decoding logic can also be used to obtain a preset beamwidth B, and the initial character sequence can be determined based on the beamwidth and the character probability distribution.
[0051] For example, at time step t=1, calculate the probability of all character categories, select the B characters with the highest probabilities as initial candidate sequences, and determine the sequence content and cumulative probability of each initial candidate sequence. At time step t=1, the cumulative probability is equal to the probability of that character. For time steps t from 2 to T, iterate through each sequence S in the current candidate sequence set, expanding sequence S with all character categories c at time t, generating a new sequence S'. If c is the same as the last character of S and is not a whitespace character, then S'=S; if c is a whitespace character, S'=S; if c is a new character, S'=S+c; then calculate the cumulative probability of the new sequence S': Cumulative probability = Cumulative probability of the original sequence × P( ), P( Let represent the probability that the character category is c at time t. Iterate through all expanded candidate sequences, retaining the B sequences with the highest cumulative probabilities, and use these as the candidate sequence set at time t. After time step T is completed, the candidate sequence set retains B candidate sequences with the highest cumulative probabilities. Select the candidate sequence with the highest cumulative probability as the initial character sequence.
[0052] Step S44: Compare the character sequence with the character rules corresponding to different recognition targets. When the character sequence satisfies any of the character rules, determine and output the character sequence and the recognition target type corresponding to the character sequence.
[0053] The character rules corresponding to different recognition targets refer to the inherent format specifications of the serial numbers for different types of recognition targets, including but not limited to the total character length, the type of the first character, and the combination pattern of letters and numbers, which are used to verify the validity of the recognition results. By comparing with the predefined character rules for different types of recognition targets, invalid or erroneous recognition results caused by image noise, character deformation, or model bias can be effectively filtered out. For example, if the recognized sequence length and character combination pattern do not match the serial number rules for any known recognition target type, it can be determined as a recognition anomaly, triggering a re-recognition process. When a character sequence satisfies the character rules for any recognition target type, the character sequence is determined to be a valid serial number, and the character sequence and its corresponding recognition target type information are output.
[0054] This embodiment automatically learns and extracts deep features related to character recognition from the original image through a network architecture of convolutional neural network-bidirectional long short-term memory network-linear mapping layer. At the same time, it learns the contextual dependencies between characters from both positive and negative directions. Then, the linear mapping layer outputs the prediction score for each time step. Based on the prediction score, the time-series output of variable length is converted into a character sequence of corresponding length. It can adapt to the format and length changes of different types of serial numbers, thereby improving the generalization ability of serial number recognition.
[0055] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 After step S20, the serial number identification method further includes steps S50 to S80: Step S50: Input the feature vector and context summary vector corresponding to each time step in the bidirectional temporal feature sequence into the alignment model, and perform nonlinear transformation on the feature vector and the context summary vector through the alignment model to obtain the attention score of the feature vector corresponding to each time step.
[0056] It should be noted that the context summary vector is a condensed representation of the global context information of the bidirectional temporal feature sequence. It can be generated by pooling such as mean pooling, max pooling, or fully connected layers, and is used to reflect the overall features of the serial number sequence. The alignment model is the core network module for implementing the attention mechanism, usually a multilayer perceptron (MLP), used to calculate the degree of association between the feature vector at each time step and the global context. The attention score of the feature vector corresponding to each time step is a numerical value that measures the matching degree between the feature vector at a single time step and the global context summary vector. The higher the score, the greater the contribution of the feature vector at that time step to the final recognition.
[0057] For example, the feature vector at each time step t ,Will The fused feature is concatenated with the context summary vector C. [C], the input is fed into an alignment model consisting of fully connected layers and nonlinear activation functions. The alignment model performs a nonlinear transformation on the fused features and outputs the feature vector for that time step. Attention score This score reflects The degree of relevance to the global context.
[0058] Step S60: Normalize the attention scores of the feature vectors corresponding to each time step to obtain the attention weight distribution.
[0059] Step S70: The bidirectional temporal feature sequence and the attention weight distribution are weighted and summed to obtain the context vector.
[0060] For example, the attention scores at all time steps are input into the Softmax function, using the formula... Calculate the attention weights at each time step Traverse the feature vector at each time step of the bidirectional time series feature sequence. ,Will With the corresponding attention weights Multiplying them together yields a weighted eigenvector. The weighted feature vectors at all time steps are summed to obtain a context vector that incorporates key global information. .
[0061] Step S80: Concatenate the context vector with the bidirectional temporal feature sequence to obtain a new bidirectional temporal feature sequence.
[0062] context vector Copy the original bidirectional time-series feature sequence into a vector sequence of the same length as the original. For each time step t, copy the original feature vector... With the copied context vector Perform dimensional concatenation to obtain a new feature vector. .
[0063] In this embodiment, global sequence information is integrated into the feature vector of each time step through context summary vectors and weighted summation. This ensures that the features of a single character not only contain local temporal correlations but also possess semantic information of the global sequence, further improving the accuracy of character classification. Furthermore, the attention mechanism can dynamically adjust feature weights, allowing for the completion of incomplete character features using global context information, thus enhancing the robustness of the solution.
[0064] Based on the above embodiments of this application, in the third embodiment of this application, the same or similar content as the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 3 Before step S50, the serial number identification method further includes steps S90 to S110: Step S90: Determine the average pooling vector of the bidirectional temporal feature sequence.
[0065] Step S100: Input the average pooling vector into the feedforward neural network, and perform weighted summation on the average pooling vector through the fully connected layer of the feedforward neural network.
[0066] Step S110: The average pooling vector after weighted summation is nonlinearly transformed by the nonlinear activation function of the feedforward neural network to obtain the context summary vector.
[0067] The average pooling vector is a fixed-dimensional vector obtained by averaging the feature vectors of all time steps in a bidirectional temporal feature sequence. It is a preliminary condensation of the global features of the entire temporal sequence, preserving the overall feature information of the sequence. The feedforward neural network is a multi-layer neural network composed of fully connected layers and nonlinear activation functions. It has no recurrent or feedback connections and only performs forward feature transformation and dimension mapping. In this embodiment, it is used to refine the feature extraction of the average pooling vector to generate a more representative context summary vector.
[0068] For example, traversing the feature vectors of all time steps in the bidirectional temporal feature sequence. to The process involves calculating the element-wise mean of all feature vectors, using the feature vector's dimension as a baseline. The value in each dimension is the arithmetic mean of the values in that dimension across all time steps, ultimately generating a fixed-dimensional vector identical to the feature vector at a single time step—the average pooling vector. This average pooling vector is then input into the fully connected layer of the feedforward neural network. The fully connected layer performs matrix multiplication with the average pooling vector using a predefined weight matrix. The result of the matrix multiplication is superimposed with the bias vector of the fully connected layer, completing a linear weighted summation of the average pooling vector. This achieves a linear transformation and dimensional reconstruction of the features, resulting in a weighted, linearly transformed feature vector. Finally, the linearly transformed feature vector output from the fully connected layer is input into a predefined nonlinear activation function. This activation function performs nonlinear operations on each element of the linearly transformed feature vector, breaking the limitations of linear features and uncovering the nonlinear global feature associations inherent in the average pooling vector, thus obtaining the aforementioned context summary vector.
[0069] This embodiment first extracts the global mean of the bidirectional temporal feature sequence through average pooling, avoiding the locality of features at a single time step, and fully preserving the overall feature information of the entire serial number temporal sequence. This lays the foundation for the accurate calculation of the attention score in the subsequent process, and indirectly improves the overall accuracy of serial number recognition.
[0070] For example, to help understand the implementation process of the serial number recognition method obtained by combining this embodiment with the above embodiments, please refer to... Figure 4 , Figure 4 A simplified flowchart of a serial number recognition method is provided, specifically: Using standardized serial number images as the sole input, a convolutional neural network (CNN) is first used to extract features from the image and increase the dimensionality of the image channels, outputting a feature map containing spatial features of the serial number, laying the foundation for subsequent temporal modeling. The feature map is then fed into a bidirectional long short-term memory (LSTM) network. Through forward and backward temporal learning, it mines contextual relationships between characters, generating a bidirectional temporal feature sequence, thus transforming spatial features into temporal features. The bidirectional temporal feature sequence is first input into a feedforward neural network. The pooling layer of the feedforward neural network performs average pooling on the bidirectional temporal feature sequence to obtain an average pooling vector. This average pooling vector is then weighted and summed by the fully connected layer of the feedforward neural network and subjected to nonlinear activation transformation to generate a context summary vector that condenses global features. The feature vectors at each time step of the bidirectional temporal feature sequence and the context summary vector are input into an alignment model. After nonlinear transformation, attention scores are obtained, normalized, and then the attention weight distribution is generated. This distribution is then weighted and summed with the bidirectional temporal feature sequence to obtain a context vector. Finally, the context vector is concatenated with the original bidirectional temporal feature sequence to output a new bidirectional temporal feature sequence, achieving the fusion of local temporal features and global key information. The optimized new bidirectional temporal feature sequence is input into the linear mapping layer and mapped to the preset character category space, outputting the prediction score of each time step on different character categories; finally, based on the prediction score, the corresponding serial number image is determined and output, completing the entire recognition process.
[0071] Based on the above embodiments of this application, in the fourth embodiment of this application, the same or similar content as the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 5 Before step S10, the serial number identification method further includes steps S120 to S160: Step S120: Obtain the binarized target image for recognition and determine the region of interest for the serial number in the target image for recognition.
[0072] Binarized target images are images obtained by thresholding the original grayscale or color target images. They contain only two pixel values, which can eliminate background noise and enhance the contrast between characters and the background.
[0073] For example, the original target image is binarized, a pixel threshold is set, and regions with pixel values greater than the threshold are set as background pixel values (i.e., the second pixel value), while regions with pixel values less than or equal to the threshold are set as character pixel values (i.e., the first pixel value). The output is a binarized target image containing only these two pixel values. A preset target detection algorithm, such as the YOLO lightweight detection network, is used to detect the binarized target image and locate the bounding box coordinates of the region of interest containing the serial number. The binarized image is then cropped based on the bounding box coordinates to obtain the region of interest containing only the serial number.
[0074] Step S130: Count the number of pixels in the region of interest whose pixel value is the first pixel value by row and column respectively, to obtain a horizontal projection array and a vertical projection array, wherein the first pixel value represents a character.
[0075] It should be noted that the horizontal projection array is a one-dimensional array obtained by counting the number of pixels with the first pixel value within the region of interest along the row dimension, reflecting the distribution characteristics of characters in the row dimension, i.e., the vertical direction. The vertical projection array is a one-dimensional array obtained by counting the number of pixels with the first pixel value within the region of interest along the column dimension, i.e., the horizontal direction.
[0076] Iterate through each row of the region of interest (ROI) image, counting the total number of pixels in that row whose pixel value is the first pixel value. Arrange the results of each row in row order to form a horizontal projection array. The length of the horizontal projection array is equal to the number of rows in the ROI. Iterate through each column of the ROI image, counting the total number of pixels in that column whose pixel value is the first pixel value. Arrange the results of each column in column order to form a vertical projection array. The length of the vertical projection array is equal to the number of columns in the ROI.
[0077] Step S140: Determine the orientation of the serial number in the target image based on the horizontal projection array and the vertical projection array, and mark the orientation in the region of interest to obtain an orientation label.
[0078] Orientation labels are standardized labels used to identify the direction of the area of interest in a serial number. Preferably, in this embodiment, the orientation is divided into a horizontal first direction of 0°, a vertical first direction of 90°, a horizontal second direction of 180°, and a vertical second direction of 270°, etc. Optionally, the above step S140 includes steps S141 to S146: Step S141: Determine the variance of the number of pixels in each row of the horizontal projection array to obtain the horizontal projection variance.
[0079] Step S142: Determine the variance of the number of pixels in each column of the vertical projection array to obtain the vertical projection variance.
[0080] Step S143: If the horizontal projection variance is greater than the vertical projection variance, then the orientation of the serial number is determined to be horizontal.
[0081] It is understandable that the characters in a serial number have fixed geometric morphological characteristics: when arranged horizontally, the characters extend along the width direction, and when arranged vertically, they extend along the height direction. The variance of the number of pixels in the projected array can measure the degree of data dispersion; the larger the variance, the more concentrated the data distribution, i.e., the greater the numerical differences; the smaller the variance, the more uniform the data distribution.
[0082] For example, when serial numbers are arranged horizontally at angles such as 0° or 180°: characters are arranged along the width of the region of interest, i.e., the column direction, while only a few rows are arranged vertically, i.e., the row direction. In this case, counting the number of pixels row by row reveals that only the rows containing the characters have a high pixel count, while the remaining rows have zero pixels. The values in the horizontal projection array show extreme differences and a large variance. However, when counting columns by column, each column contains character pixels, resulting in a relatively uniform distribution of values and a small variance. Therefore, by comparing the variances of the horizontal and vertical projections, we can distinguish whether the characters are arranged horizontally (extending along the width) or vertically (extending along the height).
[0083] For example, the variance of the horizontal projection array and the variance of the vertical projection array are calculated. If the variance of the horizontal projection array is greater than the variance of the vertical projection array, it is determined that the serial number is arranged horizontally and the orientation is horizontal.
[0084] Step S144: After determining that the orientation of the serial number is horizontal, determine the sum of the number of pixels in the preset number of rows before and the preset number of rows after the horizontal projection array.
[0085] Step S145: If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the first horizontal direction.
[0086] Step S146: If the sum of the number of pixels in the preceding preset rows is less than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the second horizontal direction, wherein the preset row number is less than half of the total number of rows in the region of interest, and the first horizontal direction is parallel to and opposite to the second horizontal direction.
[0087] It is understandable that when the serial number is arranged at a first angle, such as 0° or 90°, the starting end of the character, such as the upper half of the number "8" or the left side of the letter "A," faces the front of the region of interest. This front side is the top when arranged horizontally and the left side when arranged vertically. Therefore, the total number of character pixels in the preset number of rows before the region of interest is much higher than the preset number of rows after. Similarly, when the serial number is arranged at a second angle, such as 180° or 270°, the starting end of the character faces the back of the region of interest. This back side is the bottom when arranged horizontally and the right side when arranged vertically. Therefore, the total number of character pixels in the preset number of rows after the region of interest is higher than the preset number of rows before. The aforementioned preset number of rows is less than half the total number of rows in the region of interest; preferably, it can be 1 / 4.
[0088] Therefore, after determining that the orientation of the serial number is horizontal, the sum of the number of pixels in the preset number of rows before and the preset number of rows after the horizontal projection array are determined, and the two are compared to determine the specific orientation of the serial number in the region of interest.
[0089] Optionally, after step S143 above, the serial number recognition method further includes steps S147 to S1410: Step S147: If the horizontal projection variance is less than the vertical projection variance, then the orientation of the serial number is determined to be vertical.
[0090] Step S148: After determining that the orientation of the serial number is vertical, determine the sum of the number of pixels in the preset number of rows before and the preset number of rows after the vertical projection array.
[0091] Step S149: If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is perpendicular to the first direction.
[0092] Step S1410: If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the vertical second direction, wherein the vertical first direction is parallel to and opposite to the vertical second direction.
[0093] The above steps are similar. For example, when the orientation of the serial number is determined to be vertical, that is, vertically arranged, the total number of pixels in the first 1 / 4 and the last 1 / 4 of the vertical projection array is extracted. If the total number of pixels in the first 1 / 4 is greater than the total number of pixels in the last 1 / 4, the orientation is determined to be 90° vertical to the first direction; otherwise, it is 270° vertical to the second direction.
[0094] Step S150: Determine the serial number region image in the region of interest using a pre-trained image recognition model.
[0095] For example, the region of interest (ROI) image is input into a pre-trained image recognition model. Based on the learned morphological features of serial number characters, the model performs region-by-region matching of pixel features within the ROI. Then, the model outputs the precise bounding box coordinates of the serial number characters within the ROI; this bounding box is the smallest rectangle that encloses only the serial number characters. Based on these precise bounding box coordinates, a sub-image containing only the serial number characters is cropped from the ROI image; this is the serial number region image.
[0096] Step S160: Correct the serial number region image according to the orientation label so that the serial number is located in a preset orientation, thereby obtaining the serial number image.
[0097] For example, assuming the preset orientation is 0°, if the orientation label is 0°, no rotation is needed, and the original serial number area image is directly preserved. If the orientation label is 90°, the serial number area image is rotated 90° counterclockwise. If the orientation label is 180°, the serial number area image is rotated 180°. If the orientation label is 270°, the serial number area image is rotated 90° clockwise. Based on these rules, an affine transformation is performed on the serial number area image, maintaining the image pixel ratio during the transformation to avoid character stretching and distortion, thus obtaining the serial number image.
[0098] This embodiment first coarsely locates the region of interest (ROI) for serial numbers in the binarized target image, then accurately extracts the smallest region of serial numbers using a pre-trained model. It gradually removes irrelevant and redundant information such as background, texture, and dirt from the target image, ensuring that all subsequent feature processing and recognition operations focus solely on the serial number characters themselves. This significantly reduces the feature extraction difficulty of the backend network and minimizes recognition errors caused by invalid information. Next, the orientation label of the serial number is determined by comparing the variance of pixel projection with the total number of pixels. Geometric correction is then performed on the serial number region based on the orientation label, unifying images with different orientations to a preset orientation. This ensures that all serial number images input to the convolutional neural network are of a standardized format with uniform orientation and size, guaranteeing the accuracy of subsequent temporal modeling and character recognition from the input level.
[0099] Based on the above embodiments of this application, in the fifth embodiment of this application, the same or similar content as the above embodiments can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 6 Before step S120, the serial number identification method further includes steps S170 to S1100: Step S170: Obtain the scanned image of the target to be identified, and binarize the scanned image.
[0100] Step S180: Perform edge detection on the binarized scanned image to obtain the minimum outer bounding box corresponding to the target contour.
[0101] Step S190: Determine the rotation angle of the scanned image based on the minimum bounding rectangle.
[0102] Step S1100: After rotating the scanned image according to the rotation angle, the corrected binarized target image is cropped according to the target contour.
[0103] Scanned images refer to the original images of the target to be identified, acquired by the image acquisition module. These images may contain non-standardized issues such as tilting or background noise. Therefore, preprocessing of scanned images is necessary.
[0104] For example, a scanned image of the target is acquired through the image sensor of a financial device, the scanned image is converted to grayscale to obtain a grayscale image, and the grayscale values are then converted to grayscale. Figure 2 The binarized scanned image undergoes edge detection, firstly through Gaussian filtering for noise reduction, then by calculating pixel gradients to locate edge points, and finally by non-maximum suppression and double thresholding to obtain clear target contour edges. Contour extraction is performed on the detected edge points, selecting the contour with the largest area and the target contour, and calculating the minimum bounding rectangle of the target contour, outputting the rectangle's coordinates, size, and angle. Next, the angle between the minimum bounding rectangle of the target contour and the image's horizontal axis is extracted and determined as the image's rotation correction angle. Rotation correction is performed on the binarized scanned image based on this angle, maintaining the image's pixel ratio during rotation to avoid distortion of the target image. Using the corrected minimum bounding rectangle as the boundary, redundant background outside the rectangle is cropped, outputting a standardized binarized image of the target object.
[0105] The original scanned image is prone to tilting due to the target being misaligned. However, this embodiment determines the rotation angle and corrects it by using the minimum bounding rectangle, so that the target image is returned to a horizontal orientation. This avoids the tilt from causing the subsequent positioning of the serial number interest region to be misaligned, thus ensuring the accuracy of subsequent region processing from a global perspective.
[0106] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the serial number identification method of this application. Any simple modifications based on this technical concept are within the protection scope of this application.
[0107] This application provides a serial number recognition device, which includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the serial number recognition method in the above embodiment 1.
[0108] The following is for reference. Figure 7 The diagram illustrates a structural schematic suitable for implementing serial number recognition devices according to embodiments of this application. The serial number recognition devices in these embodiments may include, but are not limited to, mobile terminals such as laptops and tablets (PADs), and fixed terminals such as banknote counters, sorting machines, self-service terminals, and desktop computers. Figure 7 The serial number recognition device shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.
[0109] like Figure 7As shown, the serial number recognition device may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 1002 or a program loaded from a storage device 1003 into a random access memory (RAM) 1004. The RAM 1004 also stores various programs and data required for the operation of the serial number recognition device. The processing unit 1001, the read-only memory 1002, and the RAM 1004 are interconnected via a bus 1005. An input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, liquid crystal displays (LCDs), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the serial number recognition device to communicate wirelessly or wiredly with other devices to exchange data. Although serial number recognition devices with various systems are shown in the figures, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems may be implemented alternatively.
[0110] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from read-only memory 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.
[0111] The serial number recognition device provided in this application, employing the serial number recognition method in the above embodiments, can solve the technical problem that current serial number recognition methods cannot adapt to different types and variable-length serial number formats. Compared with the prior art, the beneficial effects of the serial number recognition device provided in this application are the same as those of the serial number recognition method provided in the above embodiments, and other technical features in this serial number recognition device are the same as those disclosed in the previous embodiment method, and will not be repeated here.
[0112] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.
[0113] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
[0114] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, which are used to execute the serial number recognition method in the above embodiments.
[0115] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory, optical fiber, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination thereof.
[0116] The aforementioned computer-readable storage medium may be included in the serial number recognition device; or it may exist independently and not assembled into the serial number recognition device.
[0117] The aforementioned computer-readable storage medium carries one or more programs that, when executed by a serial number identification device, enable the serial number identification device to write computer program code for performing the operations of this application in one or more programming languages or a combination thereof. These programming languages include object-oriented programming languages—such as Java, Smalltalk, and C++—and conventional procedural programming languages—such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, or as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including a local area network (LAN) or a wide area network (WAN)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).
[0118] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, may be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.
[0119] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.
[0120] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described serial number recognition method. This solves the technical problem that current serial number recognition methods cannot adapt to different types and variable-length serial number formats. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the serial number recognition method provided in the above embodiments, and will not be repeated here.
[0121] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the serial number recognition method described above.
[0122] The computer program product provided in this application can solve the technical problem that current serial number recognition methods cannot adapt to different types and variable-length serial number formats. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the serial number recognition method provided in the above embodiments, and will not be repeated here.
[0123] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.
Claims
1. A method for identifying serial number prefixes, characterized in that, The serial number identification method includes the following steps: Obtain a serial number image, input the serial number image into a convolutional neural network, and increase the dimensionality of the image channels of the serial number image through the convolutional neural network to obtain a feature map; The feature map is input into a bidirectional long short-term memory network, and the bidirectional temporal feature sequence corresponding to the feature map is determined through the bidirectional long short-term memory network. The bidirectional temporal feature sequence is input into a linear mapping layer, and the prediction score of the bidirectional temporal feature sequence for each character category is determined by the linear mapping layer. The prefix character corresponding to the prefix image is determined based on the prediction score.
2. The serial number recognition method as described in claim 1, characterized in that, After the step of inputting the feature map into a bidirectional long short-term memory network and determining the bidirectional temporal feature sequence corresponding to the feature map through the bidirectional long short-term memory network, the method further includes: The feature vector and context summary vector corresponding to each time step in the bidirectional temporal feature sequence are input into the alignment model. The alignment model performs nonlinear transformation on the feature vector and the context summary vector to obtain the attention score of the feature vector corresponding to each time step. The attention scores of the feature vectors corresponding to each time step are normalized to obtain the attention weight distribution; The context vector is obtained by weighted summation of the bidirectional temporal feature sequence and the attention weight distribution; The context vector is concatenated with the bidirectional temporal feature sequence to obtain a new bidirectional temporal feature sequence.
3. The serial number recognition method as described in claim 2, characterized in that, Before the step of inputting the feature vector and context summary vector corresponding to each time step in the bidirectional temporal feature sequence into the alignment model, the method further includes: Determine the average pooling vector of the bidirectional temporal feature sequence; The average pooling vector is input into a feedforward neural network, and the average pooling vector is weighted and summed through the fully connected layer of the feedforward neural network. The context summary vector is obtained by nonlinearly transforming the weighted average pooling vector using the nonlinear activation function of the feedforward neural network.
4. The serial number recognition method as described in claim 1, characterized in that, The step of determining the prefix character corresponding to the serial number image based on the prediction score includes: The predicted score is used as the input parameter of a preset Softmax function, and the character probability distribution at each time step is calculated by the Softmax function. Obtain the character with the highest probability at each time step to get the initial character sequence; By merging duplicate characters in the initial character sequence and removing whitespace characters from the initial character sequence, a character sequence is obtained; The character sequence is compared with the character rules corresponding to different recognition targets. When the character sequence satisfies any of the character rules, the character sequence and the recognition target type corresponding to the character sequence are determined and output.
5. The serial number recognition method as described in claim 1, characterized in that, Before the step of acquiring the serial number image and inputting the serial number image into the convolutional neural network, the method further includes: Obtain a binarized target image for recognition, and determine the region of interest for the serial number in the target image for recognition. The number of pixels in the region of interest whose pixel value is the first pixel value is counted by row and column respectively, to obtain a horizontal projection array and a vertical projection array, wherein the first pixel value represents a character; Based on the horizontal projection array and the vertical projection array, the orientation of the serial number in the target image is determined, and the orientation is marked in the region of interest to obtain an orientation label; The serial number region image in the region of interest is determined by a pre-trained image recognition model; The serial number region image is corrected according to the orientation label so that the serial number is located in a preset orientation, thereby obtaining the serial number image.
6. The serial number recognition method as described in claim 5, characterized in that, The step of determining the orientation of the serial number in the target image based on the horizontal projection array and the vertical projection array includes: The variance of the number of pixels in each row of the horizontal projection array is determined to obtain the horizontal projection variance; The variance of the number of pixels in each column of the vertical projection array is determined to obtain the vertical projection variance. If the horizontal projection variance is greater than the vertical projection variance, then the orientation of the serial number is determined to be horizontal. After determining that the orientation of the serial number is horizontal, the sum of the number of pixels in the first preset row and the number of pixels in the last preset row of the horizontal projection array is determined; If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the first horizontal direction. If the sum of the number of pixels in the preceding preset rows is less than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the second horizontal direction, wherein the preset number of rows is less than half of the total number of rows in the region of interest, and the first horizontal direction is parallel to and opposite to the second horizontal direction.
7. The serial number recognition method as described in claim 6, characterized in that, After determining the variance of the number of pixels in each column of the vertical projection array and obtaining the vertical projection variance, the method further includes: If the horizontal projection variance is less than the vertical projection variance, then the orientation of the serial number is determined to be vertical. After determining that the orientation of the serial number is vertical, the sum of the number of pixels in the first preset row and the number of pixels in the last preset row of the vertical projection array is determined; If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is perpendicular to the first direction. If the sum of the number of pixels in the preceding preset rows is greater than the sum of the number of pixels in the following preset rows, then the orientation of the serial number is determined to be the vertical second direction, wherein the vertical first direction is parallel to and opposite to the vertical second direction.
8. The serial number recognition method as described in claim 5, characterized in that, Before the step of acquiring the binarized target image and determining the region of interest for the serial number in the target image, the method further includes: Acquire a scanned image of the target to be identified, and binarize the scanned image; Edge detection is performed on the binarized scanned image to obtain the minimum outer bounding box corresponding to the target contour; The rotation angle of the scanned image is determined based on the minimum bounding rectangle. After the scanned image is rotated and corrected according to the rotation angle, the corrected binarized target image is cropped according to the target contour.
9. A serial number recognition device, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the serial number recognition method as described in any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the serial number recognition method as described in any one of claims 1 to 8.