A method and system for extracting, detecting and identifying characters from square name stamps

Through convolutional neural network and optical text recognition technology, combined with image preprocessing and geometric feature analysis, the automatic recognition of square name seals is realized, solving the problem of manual recognition dependence in the existing technology, and improving the recognition efficiency and accuracy.

CN114445830BActive Publication Date: 2025-05-16SHANGHAI SHENBAO INTELLIGENT TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202111069948.9
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-09-13
Publication Date
2025-05-16
Estimated Expiration
2041-09-13

AI Technical Summary

Technical Problem

The existing technology lacks mature text recognition algorithms for square name seals, resulting in severe dependence on manual recognition, low efficiency and accuracy, and inability to achieve automated processing.

Method used

The OCR method based on convolutional neural network is adopted, combined with image preprocessing and geometric feature analysis, and the automatic recognition of square name seals is achieved through color extraction, binarization, maximum connectivity domain extraction, projection transformation and optical text recognition.

Benefits of technology

It improves the accuracy and efficiency of seal text recognition, reduces manpower and material investment, and can be directly applied on existing OCR systems without additional training, and adapts to seal recognition in complex environments.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114445830B_ABST
    Figure CN114445830B_ABST
Patent Text Reader

Abstract

The invention discloses a method for extracting, detecting and identifying characters of a square name seal, which comprises the following steps: extracting a square name seal in a complex environment; obtaining a picture or a document scan containing a square name seal; performing neural network classification on the processed picture or document scan; determining the geometric features of the target to be identified from the result returned by the neural network; obtaining a picture file containing only the square name seal; performing OCR detection on the preliminary corrected picture and the preliminary corrected picture rotated by 90 degrees respectively; comparing the return values ​​of the two pictures after OCR detection in S21; performing OCR detection on the picture with a better return value obtained in S22 and the picture with a better return value rotated by 180 degrees respectively. The invention solves the problem that the square name seal is difficult to identify; the tolerance to the OCR system is very high, no additional training or adjustment is required, manpower and material resources are saved, and work efficiency is greatly improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of seal character recognition methods, and in particular to an OCR character recognition method based on a document scanned image containing a name seal and a corresponding system. Background Art

[0002] With the development of society, seals are used more and more frequently. State organs, social groups, universities, enterprises and institutions at all levels use seals. How to identify the text on seals is becoming more and more important.

[0003] In today's society, there is no mature and universal algorithm for seal text detection. Most existing solutions are based on a given scenario to verify and recognize the text of a specific seal, which places high demands on the text recognition system and generally requires additional training of the text recognition system. Moreover, most of them are for round official seals, and there is no method for forming square name seals and legal person seals.

[0004] In addition, there is currently no OCR and NLP software or algorithm that can directly recognize seals, resulting in the current seal processing strongly relying on manual recognition, which increases manpower and material resources and cannot achieve automated processes. Because seals are mostly single meaningless characters, and the rotation angle of seals is uncertain, coupled with the limited area of ​​seals, even manual recognition cannot achieve high efficiency and accuracy. When a large number of businesses appear, the existing processing methods cannot effectively cope with them. Summary of the invention

[0005] The present application provides a method and system for extracting, detecting and identifying text on a square name seal, which is a method, device, electronic device and computer-readable storage medium for detecting and identifying text on a square name seal in a complex environment, and can identify text and numbers on a seal in the presence of background text or noise.

[0006] The present invention is achieved through the following technical solutions:

[0007] The first object of the present invention is to provide a method for extracting, detecting and identifying square name seal characters, the method comprising the steps of:

[0008] S1. Extraction of square name stamps in complex environments;

[0009] S11. Obtain a picture or document scan containing a square name stamp, perform color extraction and binarization on the picture to obtain a binary image;

[0010] S12. Perform neural network classification on the processed images or document scans to determine whether the seals contained therein are applicable to the present method, and perform subsequent processing on the images or scans for which the classification results are applicable to the present method;

[0011] S13. Determine the geometric features of the target to be identified from the result returned by the neural network, and determine the minimum circumscribed rectangle using the geometric features and color features of the square name stamp;

[0012] S14. Rotate and cut the square name stamp according to the minimum circumscribed rectangle, remap the pixels within the minimum circumscribed rectangle to the new square canvas through projection transformation, and obtain an image file containing only the square name stamp;

[0013] S2. Detection and recognition of square name stamp characters based on OCR return values;

[0014] S21. Perform OCR detection on the initially normalized image and the initially normalized image rotated 90 degrees, respectively, and the two images are referred to as image A and image B;

[0015] S22. Compare the return values ​​of the image A and the image B after OCR detection in S21, including text content, text angle, and confidence, and select the image with longer text content, higher confidence, or other images that can be considered to have better return values ​​as the basis for the next step of processing, and call this image image C;

[0016] S23. The image C obtained in S22 and its recognition result are retained, and the image C is rotated 180 degrees to be called image D. The rotated image D is subjected to OCR detection again;

[0017] S24. Compare the return values ​​of the images C and D after OCR detection in S22 and S23, and select the image with a better return value as the positive image similar to S22, which is called image S, and obtain the digital content of the square name seal from the recognition result of image S;

[0018] S25. Perform a fixed-mode cutting on the normalized image S obtained in S24 to obtain a cut image;

[0019] S26. Perform OCR recognition on the cut images in S25 respectively to obtain a return value;

[0020] S27. The numbers and Chinese characters in the text fields of all the OCR return values ​​(ie the recognized text content) are combined according to the rules corresponding to S25 to obtain the text recognition result of the square name seal.

[0021] As a preferred embodiment, a step is added before S12: performing opening and closing operations on the binary image in S11 to remove small noise points and retain the largest connected domain.

[0022] As a preferred embodiment, the neural network classification in S12 is classified using a convolutional neural network. The model adopts AlexNet, a torch sequential structure, a cross entropy function and SGD stochastic gradient descent. Since AlexNet is designed to classify images of size 224×224, it is necessary to use OpenCV to classify the images. During classification, processing in different dimensions may cause deformation of the original seal, resulting in low classification accuracy. Therefore, spatial pyramid pooling is used to replace part of the pooling layer, thereby greatly improving the classification accuracy.

[0023] As a preferred embodiment, a convolutional neural network CNN is used as a classifier for neural network classification, using the AlexNet network model, the torch sequential structure, the cross entropy function and the SGD stochastic gradient descent. The neural network is trained with a training set of about 4,000 circular, elliptical and rectangular seals, and can accurately classify whether a seal is a rectangular seal.

[0024] As a preferred embodiment, the step S13 performs a projection transformation on the extraction frame and maps it onto a new canvas of 250*250 with a minimum rotation angle, thereby obtaining an extraction image of the target square seal.

[0025] As a preferred embodiment, the preliminary corrected image in S21 is not a 0-degree position image in the general sense, but refers to an image with the best recognition effect for the target OCR system. Since OCR generally takes 0-degree text as a benchmark, it is presumed that the recognition at 0 degrees is the best, and thus the image with the best recognition effect is called the corrected image. However, in actual situations, depending on the differences between the OCR system and the image, there may be other angles where the recognition is better than 0 degrees. In this case, the corrected image is a non-0-degree image with the best recognition effect.

[0026] As a preferred embodiment, if the OCR service is not deployed locally, a remote server needs to be connected to the network, and the OCR service is deployed by the remote server.

[0027] A second object of the present invention is to provide a system for extracting, detecting and identifying square name seal characters, the system comprising:

[0028] An image acquisition module is used to acquire images or document scans containing seals;

[0029] Image processing module, used for color extraction, binarization and maximum connected domain extraction of images;

[0030] A seal classification module is used to classify the above documents or scans, determine whether the seals contained therein are applicable to the present method, and perform subsequent processing on the images or scans whose classification results are applicable to the present method;

[0031] The seal positioning module is used to determine the specific location of the target in the image from the results returned by the neural network, and to determine the minimum circumscribed rectangle using the geometric features of the square;

[0032] The seal extraction module is used to rotate and cut the square seal through projection transformation according to the smallest circumscribed rectangle to obtain an image file containing only the seal;

[0033] An optical character recognition module, used to obtain corresponding text information from an image;

[0034] Image processing module, used for image rotation and cutting;

[0035] The text extraction module is used to extract and regularize the results returned by OCR.

[0036] The third object of the present invention is to provide an electronic device, comprising: a processor and a memory, wherein the processor and the memory each comprise at least one, the processor and the memory are communicatively connected, the memory stores instructions executable by the processor, and the processor executes the instructions to implement the steps of the square name seal text extraction, detection and recognition method as described above.

[0037] The implementation principle of the present invention: One idea of ​​seal recognition is to identify according to the properties of the seal itself. Due to the particularity of the seal color, it can be identified according to the special color in the entire scanned document; it can also be identified by the geometric shape border of the seal. This introduces the technical background of the present invention: ① The system can frame and identify square seals; ② The processing time of the system should be within an acceptable range, at least not less than manual recognition; ③ The accuracy of the text returned by the system should be at a higher level; ④ Since the seal itself has certain specifications, after the seal pattern area is accurately obtained, it is converted into a fixed pattern recognition problem.

[0038] The innovation of the present invention is that it reduces the interference factors in the original image to an acceptable range through a series of preprocessing, and proposes a universal solution for square name seals. The solution provided by the present invention can be applied to most text recognition systems that provide reasonable return values ​​without additional training, realizing the decoupling between modules, solving the recognition order problem caused by the difference between the text order of square name seals and ordinary texts, and returning the name and corresponding numbers in a language order acceptable to natural persons. The algorithm proposed by the present invention solves the problem of computer recognition of square seals, and recognizes the text and numbers of the seal based on the optical text recognition system. This method can solve the problem of uncertain text recognition direction without additional training of the optical text recognition system; it has a good tolerance for noise interference. The overall recognition accuracy is high.

[0039] Beneficial effects: The present invention detects and identifies square name stamps through image preprocessing and text recognition models, has strong robustness against background and noise interference of different colors of the stamp, has good tolerance for discrete noise points of the same color, and can automatically restore the order of text according to the stamp format, solving the problem that square name stamps are difficult to identify; has high tolerance for OCR systems, and can be directly used on deployed OCR systems without additional training or adjustment. The present invention uses artificial intelligence and computer automatic batch processing, and can process stamps of different colors, saving manpower and material resources and greatly improving work efficiency. BRIEF DESCRIPTION OF THE DRAWINGS

[0040] Figure 1 The figure is a flow chart of the method for detecting and recognizing characters on a square name seal of the present invention.

[0041] Figure 2 Schematic diagram of the intermediate process of extracting the square name seal of the present invention (including Figures 2a-2e).

[0042] Figure 3 It is a structural block diagram of the square name seal text detection and recognition method of the present invention.

[0043] Figure 4 It is a schematic diagram of the module structure of the square name seal text detection system of the present invention.

[0044] Figure 5 It is a schematic diagram of the structure of electronic equipment components modules in the square name seal text detection system of the present invention. DETAILED DESCRIPTION

[0045] The following is a detailed description of an embodiment of the present invention in conjunction with the accompanying drawings: This embodiment is implemented on the premise of the technical solution of the present invention, and a detailed implementation method and a specific operation process are given, but the protection scope of the present invention is not limited to the following embodiments.

[0046] like Figure 1 As shown, the basic process of the square name seal text detection and recognition method of the invention is given. In this embodiment, the square name seal text detection and recognition method includes:

[0047] Step 1: Get the stamp image to be processed. The stamp to be identified must be in the image, and the stamp color should be distinguishable from the background color.

[0048] Perform color extraction and adaptive binarization processing. Here we take red as an example: when the color is black or white, the values ​​of the three channels are close. For red points visible to the naked eye, the difference between the red value and the other two color values ​​is large, so we can directly use RB>threshold, RG>threshold to determine whether it is red;

[0049] However, in actual situations, the threshold value may vary depending on the brightness of the captured image. Therefore, for each image, the corresponding [RB, RG] is calculated for each point, and the image is expanded to obtain a list of shape (H*W, 2). After that, a k-means operation is performed on it to obtain a more appropriate threshold value, thereby achieving a better red extraction and binarization effect.

[0050] After obtaining the binary image, the opening and closing operations are performed to remove noise. The operation of first corroding and then dilating is called the opening operation. It has the function of eliminating small objects, separating objects at thin places and smoothing the boundaries of larger objects. The opening operation can eliminate small, discrete noise points, but it will destroy the connectivity of the foreground. A closing operation is required to connect the foreground to be extracted. The operation of first dilating and then corroding is called the closing operation. It has the function of filling small holes in objects, connecting adjacent objects and smoothing boundaries, and obtaining the shape and area of ​​the figure;

[0051] Step 2, find the largest area and exclude small areas, because it is impossible to find a suitable threshold function and kernel size to make all pictures have good effects. Using a smaller kernel can avoid destroying the effective area of ​​the stamp, but the ability to exclude existing noise is low. To solve this problem, it is necessary to extract the largest connected domain. With the help of OpenCV, it is easy to obtain the area of ​​each connected domain. For images with multiple connected domains, after the processing of the above steps, the seal pattern is in the largest connected domain, so it is only necessary to retain the largest connected domain to obtain the position of the seal pattern; in most cases, the image should only have a unique connected domain at this time, and there is no need to perform the maximum connected domain extraction operation;

[0052] If there is no reasonable connected domain on the image after step 1 during the process of extracting connected domains, such as the only connected domain is too small or does not exist, the algorithm will return an error here and will not proceed with subsequent processing. This may be caused by the input of an image without a seal, the low distinction between the seal image and the background, or the wrong color setting.

[0053] Step 3: Classify the seals using a convolutional neural network. The model uses AlexNet, a torch sequential structure, a cross entropy function, and SGD stochastic gradient descent.

[0054] Since AlexNet is designed to classify images of size 224×224, we need to use OpenCV to classify images. When classifying, processing in different dimensions may cause deformation of the original seal, resulting in low classification accuracy. Therefore, SPP (spatial pyramid pooling) is used to replace some pooling layers, which greatly improves the classification accuracy.

[0055] In this embodiment, the classifier adopts a convolutional neural network CNN, uses the AlexNet network model, the torch sequential structure, the cross entropy function and the SGD stochastic gradient descent, and the neural network is trained with a training set of about 4,000 circular, elliptical and rectangular seals, and can accurately classify whether the seal is a rectangular seal;

[0056] For irregular seals that are not applicable to this method, they will not be distinguished in the processing steps 1 and 2 of the method, but when passing through the neural network classifier, 2 will return a non-"rectangular" value. At this time, it can be known that the input image is not applicable to this method. The algorithm will return an error at this time and will not perform subsequent processing;

[0057] Step 4: Determine the target position through the return value of the neural network, and know the specific position of the image to be extracted in the input image. Combine the target area obtained by the previous closing operation and the maximum connected domain extraction operation to obtain the minimum circumscribed rectangle of the area as the target extraction box.

[0058] Perform a projection transformation on the extraction frame and map it to a new canvas of 250*250 with the minimum rotation angle to obtain the extraction image of the target square seal;

[0059] Step 5, performing optical character recognition on the obtained extracted image, performing corresponding rotation and cropping operations on the above image according to the optical character recognition result, selecting an image with better performance for the corresponding system according to different recognition modes of different OCR systems among the four possible rotation angles of the square stamp, performing regional segmentation according to the mode of the name stamp, and then performing optical character recognition respectively, thereby solving the problem of the text order of the name stamp;

[0060] Step 6: Perform optical character recognition, extract and merge characters and numbers according to the different results returned by different slices, and finally obtain the text recognition result;

[0061] In step 5 and step 6, the OCR return value needs to be evaluated. When there are situations including but not limited to the absence of numbers, the length of numbers is too short, the text information cannot be recognized, the OCR request timeout, etc., the execution process can be jumped out and an error is returned. This may be caused by the low quality of the image itself, unreliable connection with the remote server, or low recognition ability of the deployed OCR system.

[0062] like Figure 2 As shown, an example of obtaining a square seal using this method is given: Figure 2 a is the original image of the seal to be extracted. First, color difference k-means color extraction and adaptive binarization processing are performed.

[0063] In this example, the stamp color to be extracted is red, so it can be processed directly in RGB color mode. The red part can be quickly extracted by using the difference between the R channel and the G and B channels. Figure 2 b is correct Figure 2 a The result after channel separation, the left image is the red channel, the middle image is the green channel, and the right image is the difference image, that is, the [RG] value of each pixel is obtained;

[0064] The [RB] value of each pixel can be obtained by the same method as above. Using [RG] as the x-coordinate value and [RB] as the y-coordinate value, the pixel set on the image is clustered by K-means binary classification. The cluster with the center farthest from the origin is the foreground pixel. Figure 2 c shows the binarized image.

[0065] Then, the opening and closing operations are performed on the binary image, the discrete noise is removed by the opening operation, the foreground is connected by the closing operation, and the detection result on the binary image is obtained. The edges of all foregrounds of the binary image are mapped to the original image, that is, Figure 2 d shows the recognition result. The light-colored edge around the seal is the obtained edge. Although this situation does not exist in this example, when the image has a lot of same-color pollution, the discrete large noise points cannot be eliminated by the opening and closing operations. Since the noise points are not the seal images we need to extract, we use the characteristic that the noise points are generally smaller than the seal patterns to extract the largest connected domain. Only the connected foreground with the largest area in the image is retained as the extraction target. Therefore, the independent connected domain where the noise points are located will be discarded, leaving only the largest connected domain containing the seal.

[0066] Finally, knowing the maximum connected domain, we can find the minimum circumscribed rectangle of the maximum connected domain and project the rectangle onto the new square canvas to get the following: Figure 2 e Extraction stamp shown.

[0067] like Figure 3 , 4 As shown in FIG. 1 , an example of the method of performing rotation correction, cutting and recognition returned by the OCR system is given: Image A is an input of this example. Because no further rotation correction is performed in advance, the stamp is rotated 90 degrees clockwise at this time.

[0068] The first step is to rotate image A 90 degrees clockwise to make it 180 degrees rotated, called image B. Perform optical character recognition on image A and image B respectively to obtain the return value;

[0069] In this example, the deployed OCR system uses the DB detection model for text area recognition, the MBV3 direction classification model for text direction classifier, with two classifications of 0 and 180 degrees, and the RCNN recognition model for text recognition. In addition to the return value of the text, it also returns the text angle of 0 or 180 degrees and the four-point annotation of the text area. The return values ​​of image A and image B are judged, including counting the angle values ​​that appear most frequently in the return field, and based on this, fields with different angle values ​​are deleted. The quality of the return value fields is then compared. In this example, the length of the digital field is used as the judgment of OCR quality.

[0070] In this example, image B is selected as the image with better effect as the basis for the next step of processing. Similarly, image B is rotated 180 degrees to obtain image C. Image C is subjected to optical image recognition, and the return value is eliminated as in the previous step. The OCR quality is compared with image B, and the one with higher quality is selected for subsequent processing. Image C is selected in this example;

[0071] Keep the OCR result of image C, use the digital recognition result of image C to crop image C in a fixed format, crop image C into image C_R containing the first half of the text and image C_L containing the second half of the text based on the digital frame and the seal boundary, rotate C_L and C_R according to the angle of image C, and then perform OCR recognition separately to ensure that the directionality of text recognition is consistent with the expected one; in this example, the four-point information of digital position recognition is used for image segmentation. Since the image is already a 250*250 rectangle, the four-point position of the digital frame can be used to know the image rotation at this time, corresponding to different rotation strategies; the most basic, for the 0 degree situation in this example, the cropping strategy is:

[0072] Left half of the image: [[left edge of the digital frame, 0], [middle line of the digital frame, 0], [middle line of the digital frame, bottom edge of the digital frame], [left edge of the digital frame, bottom edge of the digital frame]];

[0073] Right half of the image: [[middle line of the digital frame, 0], [right edge of the digital frame, 0], [right edge of the digital frame, bottom edge of the digital frame], [middle line of the digital frame, bottom edge of the digital frame]];

[0074] After obtaining the cropped image, the image that was not in the 0-degree state during cutting is re-rectified to ensure that the image slices input to the OCR are in the 0-degree rotation state, that is, the normalized image in the general sense, to avoid the occurrence of misrecognition;

[0075] After obtaining the OCR recognition results, angle elimination is also performed to obtain text information from each cropped image, the digital information is deleted, the returned text is sorted in the order of the images, and then merged with the digital information obtained at image C, and finally all the text and digital information of the square name seal are obtained.

[0076] like Figure 3 The figure shows a functional module diagram of the square name seal text detection system of the present invention.

[0077] The seal text detection and recognition device 100 of the present invention can be installed in an electronic device. According to the functions to be implemented, the seal text detection and recognition device can include a seal extraction module 110 and a seal text recognition module 120, which can be further divided into an image acquisition module 111, an image processing module 112, a seal classification module 113, a seal positioning module 114, a seal extraction module 115, an optical text recognition module 121, an image processing module 122, and a text extraction module 123. The module described in the present invention can also be called a unit, which refers to a series of computer program segments that can be executed by an electronic device processor and can complete fixed functions, which are stored in the memory of the electronic device.

[0078] In this embodiment, the functions of each module / unit are as follows:

[0079] The image acquisition module 111 is used to acquire an image or a document scan containing a seal, and the image or the scan should include the seal to be identified;

[0080] The image processing module 112 is used to perform color extraction, binarization processing and maximum connected domain extraction on the image. The color to be extracted can be manually specified or automatically identified;

[0081] The seal classification module 113 is used to classify the above-mentioned documents or scanned copies, determine whether the seals contained therein are applicable to the present method, and perform subsequent processing on the pictures or scanned copies whose classification results are applicable to the present method;

[0082] The seal positioning module 114 is used to determine the specific position of the target in the image from the result returned by the neural network, and determine the minimum circumscribed rectangle using the geometric features of the square;

[0083] The seal extraction module 115 is used to rotate and cut the square seal through projection transformation according to the circumscribed minimum rectangle to obtain an image file containing only the seal;

[0084] The optical character recognition module 121 is used to obtain corresponding characters and corresponding information from the image;

[0085] Image processing module 122, used for image rotation and cutting;

[0086] The text extraction module 123 is used for extracting and regularizing the results returned by OCR.

[0087] like Figure 5 FIG. 1 is a schematic diagram of the structure of the electronic device of the square name seal text detection system of the present invention.

[0088] The electronic device 1 may include a camera / picture source 100 , a computer 200 and a possible remote server 300 .

[0089] The camera / image source 100 may be a hardware image source such as a locally deployed camera or scanner, or a digitized image stored in a removable storage device, or may refer to a remote post request;

[0090] The computer 200 further includes a processor 210 and a memory 220; the processor 210 may refer to a central processing unit (CPU) alone, or may refer to a central processing unit (CPU) and a graphics processing unit (GPU), or may refer to an IC component that provides computing functions in a target scenario; there should be a reliable data link between the processor 210 and the memory 220, and the memory 220 should store a recognition program 221 for the processor to run, and should also be able to store the original image from the image source 100 and the intermediate output of the processing process;

[0091] The remote server 300 should run a complete set of OCR services and have a reliable network link with the computer 200, and be able to make effective and reasonable responses to requests from the computer 200;

[0092] In addition, although not specifically stated, the computer 200 should have other components to support its operations, conform to the von Neumann configuration, have a reliable power input and necessary I / O devices.

[0093] Each functional module in each embodiment of the present invention may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit. The above-mentioned integrated unit may be implemented in the form of hardware or in the form of hardware plus software functional modules.

[0094] The above shows and describes the basic principles and main features of the present invention and the advantages of the present invention. It should be understood by those skilled in the art that the present invention is not limited to the above embodiments. The above embodiments and descriptions are only for explaining the principles of the present invention. Without departing from the spirit and scope of the present invention, the present invention may have various changes and improvements, which fall within the scope of the present invention to be protected. The scope of protection of the present invention is defined by the attached claims and their equivalents.

Claims

1. A method for extracting, detecting and identifying characters from square name stamps, characterized in that: The method comprises the following steps: S1. Extraction of square name stamps in complex environments; S11. Obtain a picture or document scan containing a square name stamp, perform color extraction and binarization on the picture to obtain a binary image; S12. Perform neural network classification on the processed images or document scans to determine whether the seals contained therein are applicable to the present method, and perform subsequent processing on the images or scans for which the classification results are applicable to the present method; S13. Determine the geometric features of the target to be identified from the result returned by the neural network, and determine the minimum circumscribed rectangle using the geometric features and color features of the square name stamp; S14. Rotate and cut the square name stamp according to the minimum circumscribed rectangle, remap the pixels within the minimum circumscribed rectangle to the new square canvas through projection transformation, and obtain an image file containing only the square name stamp; S2. Detection and recognition of square name stamp characters based on OCR return values; S21. Perform OCR detection on the initially normalized image and the initially normalized image rotated 90 degrees, respectively, and the two images are referred to as image A and image B; S22. Compare the return values ​​of the image A and the image B after OCR detection in S21, including text content, text angle, and confidence, and select the image with longer text content, higher confidence, or other images that can be considered to have better return values ​​as the basis for the next step of processing, and call this image image C; S23. The image C and its recognition result obtained in S22 are retained, and the image C is rotated 180 degrees to be called image D. The rotated image D is subjected to OCR detection again; S24. Compare the return values ​​of the images C and D after OCR detection in S22 and S23, and select the image with a better return value as the positive image similar to S22, which is called image S, and obtain the digital content of the square name seal from the recognition result of image S; S25. Perform a fixed-mode cutting on the normalized image S obtained in S24 to obtain a cut image; S26. Perform OCR recognition on the cut images in S25 respectively to obtain a return value; S27. The numbers and Chinese characters in the text field of all the OCR return values ​​are merged according to the rules corresponding to S25 to obtain the text recognition result of the square name seal.

2. A method for extracting, detecting and identifying characters from a square name stamp according to claim 1, characterized in that: Add a step before S12: perform opening and closing operations on the binary image in S11 to remove small noise points and retain the largest connected domain.

3. A method for extracting, detecting and identifying characters from a square name stamp according to claim 1, characterized in that: The neural network classification in S12 uses a convolutional neural network for classification. The model adopts AlexNet, a torch sequential structure, a cross entropy function and SGD stochastic gradient descent. Since AlexNet is designed to classify images of size 224×224, it is necessary to use OpenCV to classify the images. During classification, processing in different dimensions may cause deformation of the original seal, resulting in low classification accuracy. Therefore, spatial pyramid pooling is used to replace some pooling layers, thereby greatly improving the classification accuracy.

4. A method for extracting, detecting and identifying characters from a square name stamp according to claim 3, characterized in that: The classifier for neural network classification adopts convolutional neural network CNN, using AlexNet network model, torch sequential structure, cross entropy function and SGD stochastic gradient descent. The neural network is trained with a training set of 4000 circular, elliptical and rectangular seals, which can accurately classify whether the seal is a rectangular seal.

5. A method for extracting, detecting and identifying characters from square name stamps according to claim 1, characterized in that: The S13 performs a projection transformation on the extraction frame and maps it onto a new canvas of 250*250 with a minimum rotation angle, thereby obtaining an extraction image of the target square seal.

6. A method for extracting, detecting and identifying characters from a square name stamp according to claim 1, characterized in that: The preliminary corrected image in S21 is not a 0-degree position image in the general sense, but refers to an image with the best recognition effect for the target OCR system. Since OCR takes 0-degree text as a benchmark, it is presumed that the recognition at 0 degrees is the best, and thus the image with the best recognition effect is called the corrected image. However, in actual situations, depending on the OCR system and the image, there may be other angles where the recognition is better than 0 degrees. In this case, the corrected image is a non-0-degree image with the best recognition effect.

7. A method for extracting, detecting and identifying characters from square name stamps according to claim 1, characterized in that: If the OCR service is not deployed locally, a remote server must be connected to the network to deploy the OCR service.

8. A system for the method for extracting, detecting and identifying characters in a square name seal as claimed in claim 1, the system comprising: An image acquisition module is used to acquire images or document scans containing seals; Image processing module, used for color extraction, binarization and maximum connected domain extraction of images; A seal classification module is used to classify the above-mentioned pictures or document scans, determine whether the seals contained therein are applicable to this method, and perform subsequent processing on pictures or scans whose classification results are applicable to this method; The seal positioning module is used to determine the specific location of the target in the image from the results returned by the neural network, and to determine the minimum circumscribed rectangle using the geometric features of the square; The seal extraction module is used to rotate and cut the square seal through projection transformation according to the smallest circumscribed rectangle to obtain an image file containing only the seal; An optical character recognition module, used to obtain corresponding text information from an image; Image processing module, used for image rotation and cutting; The text extraction module is used to extract and regularize the results returned by OCR.

9. An electronic device, comprising: A processor and a memory, each of which includes at least one, wherein the processor and the memory are communicatively connected, the memory stores instructions executable by the processor, and the processor executes the instructions to implement the steps of the square name seal text extraction, detection and recognition method as described in any one of claims 1 to 7.

Citation Information

Patent Citations

  • Seal extraction and character recognition method and device

    CN112329756A

  • Seal character detection and recognition method, device, and medium for complex environments

    WO2021115490A1