Dot-inking character recognition method and electronic device
By performing dot character area recognition and gap connection processing on dot inkjet images, combined with multiple expansion processing and pixel shift processing, the problem of low reliability of dot inkjet character recognition is solved and more efficient recognition is achieved. result.
Patent Information
- Application Number
- CN202410931284.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-12
- Publication Date
- 2024-09-20
- Estimated Expiration
- 2044-07-12
AI Technical Summary
The reliability of recognition of dot-shaped inkjet characters in the prior art is low, mainly due to the low recognition efficiency and poor accuracy due to the gaps within the dot-shaped characters.
By performing dot character area recognition processing on the dot inkjet image, including the connection processing of the internal gaps of the characters and the positioning processing of the image area, combined with multiple expansion processing and pixel shift processing, a complete character form is formed, thereby improving Reliability of identification results.
It effectively improves the reliability of dot-coded character recognition, reduces character gap interference, and ensures the accuracy and completeness of the recognition results.
Smart Images

Figure CN118470720B
Abstract
Description
Technical Field
[0001] The present application relates to the field of image processing technology, and in particular to a dot-inkjet character recognition method and electronic device. Background Art
[0002] Inkjet code recognition refers to the technology used to identify and detect information such as inkjet codes and paint sprays on products in industrial production. The traditional method is to check the inkjet code information on products with human eyes. This method has problems such as low efficiency and easy errors, and is gradually being replaced by automation technology. However, the current automation technology mainly recognizes complete inkjet codes. Therefore, the recognition of dot-shaped inkjet codes has a relatively low reliability problem. Summary of the invention
[0003] In view of this, the purpose of the present application is to provide a dot-inkjet coding character recognition method and electronic device to improve the problem of relatively low reliability of dot-inkjet coding character recognition in the prior art.
[0004] To achieve the above objectives, this application adopts the following technical solutions:
[0005] A dot-shaped inkjet character recognition method, comprising:
[0006] Performing dot-shaped character area recognition processing on the dot-shaped inkjet coding image to be processed to obtain a corresponding dot-shaped character area recognition result, wherein the dot-shaped character area positioning processing includes connecting the internal gaps of the dot-shaped characters and positioning the image area where the dot-shaped characters are located, the dot-shaped characters are composed of a plurality of dot-shaped graphics, the internal gaps of the characters refer to the gaps between the dot-shaped graphics, the dot-shaped inkjet coding image to be processed has a target dot-shaped character to be recognized, and the dot-shaped character area recognition result is used to identify the image area where the target dot-shaped character is located;
[0007] Performing regional correction processing on the image area identified by the dot-shaped character area recognition result to obtain a corresponding image area correction result, wherein the regional correction processing includes identifying and correcting the area distribution direction of the image area identified by the dot-shaped character area recognition result;
[0008] Perform character recognition processing on the image area correction result to obtain a corresponding character recognition result, wherein the character recognition result includes the recognized target dot-shaped characters.
[0009] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet coding character recognition method, the step of performing dot-shaped character region recognition processing on the dot-shaped inkjet coding image to be processed to obtain the corresponding dot-shaped character region recognition result includes:
[0010] Performing a first connection process on the internal spaces of the dot-shaped characters in the dot-shaped inkjet coding image to be processed to obtain a corresponding first dot-shaped character connection image;
[0011] Performing a second connection process on the internal spaces of the dot-shaped characters in the first dot-shaped character connection image to obtain a corresponding second dot-shaped character connection image, wherein the processing method of the second connection process is different from the processing method of the first connection process;
[0012] Positioning processing is performed on the image area where the dot-shaped characters in the second dot-shaped character connection image are located to obtain a corresponding dot-shaped character area recognition result.
[0013] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet character recognition method, the step of performing a first connection process on the internal gaps of the dot-shaped characters in the dot-shaped inkjet image to be processed to obtain a corresponding first dot-shaped character connection image includes:
[0014] Determining the character spacing between the dot characters in the dot-shaped inkjet coding image to be processed to obtain a corresponding target character spacing distance;
[0015] Based on the target character spacing distance, connection processing parameters for performing a first connection processing on the internal character gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed are determined, and a first connection processing is performed based on the connection processing parameters to obtain a corresponding first dot-shaped character connection image.
[0016] In a preferred embodiment of the present application, in the above-mentioned dot-printed coding character recognition method, the step of determining the character spacing between the dot-printed characters in the dot-printed coding image to be processed to obtain the corresponding target character spacing distance includes:
[0017] Performing multiple different expansion processes on the dot-shaped inkjet coding image to be processed to obtain multiple corresponding expansion-processed dot-shaped inkjet coding images, and performing quantitative statistical processing on the dot-shaped character contours in each of the expansion-processed dot-shaped inkjet coding images, wherein there is a one-to-one correspondence between the multiple expansion-processed dot-shaped inkjet coding images and the multiple different expansion processes;
[0018] Based on the statistical results of the number of dot-like character contours in each of the expanded dot-like inkjet coding images, a target expanded dot-like inkjet coding image is determined among the multiple expanded dot-like inkjet coding images, and based on the distance between the dot-like character contours in the expanded dot-like inkjet coding images, the corresponding target character spacing distance is determined.
[0019] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet coding character recognition method, the step of performing multiple different expansion processes on the dot-shaped inkjet coding image to be processed to obtain a corresponding plurality of expansion-processed dot-shaped inkjet coding images, and performing quantitative statistical processing on the dot-shaped character contours in each of the expansion-processed dot-shaped inkjet coding images, comprises:
[0020] Using a dilation kernel having a first size, the dot-shaped inkjet coding image to be processed is dilated to obtain a corresponding dilated dot-shaped inkjet coding image, and the dot-shaped character contours in the dilated dot-shaped inkjet coding image are statistically processed to obtain the corresponding first dot-shaped character contour quantity;
[0021] Using a dilation kernel having a second size, the dot-shaped inkjet coding image to be processed is dilated to obtain a corresponding dilated dot-shaped inkjet coding image, and the dot-shaped character contours in the dilated dot-shaped inkjet coding image are statistically processed to obtain the number of corresponding second dot-shaped character contours, wherein the second size is larger than the first size;
[0022] When the number of the first dot-shaped character outlines is greater than the number of the second dot-shaped character outlines, stopping the expansion process of the dot-shaped inkjet coding image to be processed;
[0023] When the number of the first dot-like character contours is not greater than the number of the second dot-like character contours, the dot-like inkjet coding image to be processed is expanded using the expansion kernel having the first size to obtain a corresponding expanded processed dot-like inkjet coding image, and the expanded processed dot-like inkjet coding image is expanded using the expansion kernel having the first size to obtain a new expanded processed dot-like inkjet coding image, and the dot-like character contours in the new expanded processed dot-like inkjet coding image are statistically processed to obtain a corresponding third number of dot-like character contours;
[0024] When the number of the second dot-shaped character outlines is greater than the number of the third dot-shaped character outlines, stopping the expansion process of the dot-shaped inkjet coding image to be processed;
[0025] When the number of the second dot-like character contours is not greater than the number of the third dot-like character contours, the dot-like inkjet coding image to be processed is expanded using the expansion kernel having the first size to obtain a corresponding expanded processed dot-like inkjet coding image, and the expanded processed dot-like inkjet coding image is expanded using the expansion kernel having the second size to obtain a new expanded processed dot-like inkjet coding image, and the dot-like character contours in the new expanded processed dot-like inkjet coding image are statistically processed to obtain a corresponding fourth number of dot-like character contours;
[0026] When the number of the third dot-shaped character contours is greater than the number of the fourth dot-shaped character contours, the expansion process of the dot-shaped inkjet coding image to be processed is stopped.
[0027] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet character recognition method, the step of determining a target expanded dot-shaped inkjet image from the plurality of expanded dot-shaped inkjet images based on the number of dot-shaped character contours in each of the expanded dot-shaped inkjet images, and determining the corresponding target character spacing distance based on the distance between the dot-shaped character contours in the expanded dot-shaped inkjet images includes:
[0028] Based on the number statistics result of the dot character contours in each of the expansion-processed dot-shaped inkjet coding images, a target expansion-processed dot-shaped inkjet coding image having a maximum number statistics result is determined among the multiple expansion-processed dot-shaped inkjet coding images;
[0029] In the target expansion processed dot-shaped inkjet coding image, at least two adjacent dot-shaped character contour center points are determined, and based on the distance between the two adjacent dot-shaped character contour center points, the corresponding target character spacing distance is determined.
[0030] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet character recognition method, the step of determining, based on the target character spacing distance, connection processing parameters for performing a first connection processing on the internal gaps of the dot-shaped characters in the dot-shaped inkjet image to be processed, and performing a first connection processing based on the connection processing parameters to obtain a corresponding first dot-shaped character connection image includes:
[0031] Based on the predetermined mapping relationship and the target character spacing distance, determining a connection processing parameter for performing a first connection processing on the internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed, wherein the connection processing parameter is positively correlated with the target character spacing distance;
[0032] Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed in a first direction to obtain a corresponding first shifted dot-shaped inkjet coding image;
[0033] Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed in a second direction to obtain a corresponding second shifted dot-shaped inkjet coding image;
[0034] Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed in a third direction to obtain a corresponding third shifted dot-shaped inkjet coding image;
[0035] Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the to-be-processed dot-shaped inkjet coding image in a fourth direction to obtain a corresponding fourth shifted dot-shaped inkjet coding image, wherein the first direction, the second direction, the third direction and the fourth direction are different;
[0036] The first shifted dot-shaped coding image, the second shifted dot-shaped coding image, the third shifted dot-shaped coding image and the fourth shifted dot-shaped coding image are subjected to image fusion processing to obtain corresponding target shifted dot-shaped coding images, and based on the target shifted dot-shaped coding images, a corresponding first dot-shaped character connection image is determined.
[0037] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet character recognition method, the step of performing a second connection process on the internal gaps of the dot-shaped characters in the first dot-shaped character connection image to obtain a corresponding second dot-shaped character connection image includes:
[0038] Based on a first dilation parameter, the first dotted character connection image is dilated to obtain a corresponding first dilated connection image; and based on a first erosion parameter, the first dilated connection image is eroded to obtain a corresponding first eroded connection image;
[0039] Based on the first eroded connection image and the first dotted character connection image, determining whether the first eroded connection image satisfies a preset character gap connection condition;
[0040] When the first eroded connection image satisfies the character gap connection condition, using the first eroded connection image as the corresponding second dot character connection image;
[0041] When the first eroded connection image does not meet the character gap connection condition, dilate the first eroded connection image based on a second dilation parameter to obtain a corresponding second dilated connection image, and erode the second dilated connection image based on a second erosion parameter to obtain a corresponding second eroded connection image, wherein the second dilation parameter is less than the first dilation parameter;
[0042] Based on the second eroded connection image and the first dotted character connection image, determining whether the second eroded connection image satisfies the character gap connection condition;
[0043] When the second eroded connection image satisfies the character gap connection condition, the second eroded connection image is used as the corresponding second dot character connection image.
[0044] In a preferred embodiment of the present application, in the above-mentioned dot-shaped inkjet character recognition method, the step of determining whether the first eroded connection image satisfies a preset character gap connection condition based on the first eroded connection image and the first dot-shaped character connection image comprises:
[0045] Performing image subtraction processing on the first eroded connection image and the first dotted character connection image to obtain a corresponding difference image, wherein the first eroded connection image, the first dotted character connection image and the difference image are all binary images;
[0046] Counting the pixel points whose pixel values in the first dot-shaped character connection image are equal to the predetermined target value to obtain the corresponding first pixel point quantity;
[0047] Counting the pixel points whose pixel values in the difference image are equal to the target value to obtain the corresponding second pixel point quantity, wherein the pixel points whose pixel values are equal to the target value are the pixel points belonging to the dot-shaped characters in the corresponding image;
[0048] Determining a quantity ratio between the second number of pixel points and the first number of pixel points;
[0049] When the quantity ratio belongs to a predetermined ratio interval, determining that the first eroded connection image satisfies a preset character gap connection condition;
[0050] When the quantity ratio does not belong to a predetermined ratio interval, it is determined that the first eroded connection image does not meet a preset character gap connection condition.
[0051] Based on the above, the present application also provides an electronic device, including:
[0052] Memory for storing computer programs;
[0053] The processor connected to the memory is used to execute the computer program stored in the memory to implement the above-mentioned dot-shaped inkjet coding character recognition method.
[0054] The dot-shaped inkjet character recognition method and electronic device provided in the present application can, firstly, perform dot-shaped character area recognition processing on the dot-shaped inkjet image to be processed to obtain the corresponding dot-shaped character area recognition result; secondly, perform area correction processing on the image area identified by the dot-shaped character area recognition result to obtain the corresponding image area correction result; then, perform character recognition processing on the image area correction result to obtain the corresponding character recognition result. Based on the above content, since the dot-shaped character area positioning processing includes connecting the internal gaps of the dot-shaped characters, the internal gaps of the dot-shaped characters in the image area identified by the dot-shaped character area recognition result can be connected (it can also be said that the gaps are reduced), thereby forming normal and complete characters. In this way, in the subsequent character recognition, the reliability of recognition can be improved (such as the internal gaps of the dot-shaped characters will interfere with the subsequent recognition, such as a character is recognized as multiple dot-shaped graphics, etc.), therefore, the problem of relatively low reliability of dot-shaped inkjet character recognition in the prior art can be improved. In addition, performing regional correction processing on the image area marked by the point character area recognition result can also further improve the reliability of the object of character recognition processing and avoid the problem of low recognition reliability due to interference information caused by differences in regional distribution directions. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] In order to make the above-mentioned objects, features and advantages of the present application more obvious and easy to understand, preferred embodiments are specifically cited below and described in detail with reference to the attached drawings.
[0056] Figure 1 A structural block diagram of an electronic device provided in an embodiment of the present application.
[0057] Figure 2 A schematic flow chart of a dot-inkjet character recognition method provided in an embodiment of the present application.
[0058] Figure 3 A schematic diagram of dotted characters provided in an embodiment of the present application.
[0059] Figure 4 A schematic diagram of a dot-shaped inkjet coding image to be processed provided in an embodiment of the present application.
[0060] Figure 5 A schematic diagram of an image after connection processing provided in an embodiment of the present application.
[0061] Figure 6 A schematic diagram of over-connecting images provided in an embodiment of the present application.
[0062] Figure 7 A schematic diagram of performing pixel shift processing on an image provided in an embodiment of the present application.
[0063] Figure 8 A block diagram of a dot-inkjet character recognition device provided in an embodiment of the present application. DETAILED DESCRIPTION
[0064] In order to make the purpose, technical solution and advantages of the embodiments of the present application clearer, the technical solution in the embodiments of the present application will be clearly and completely described below in conjunction with the drawings in the embodiments of the present application. Obviously, the described embodiments are only part of the embodiments of the present application, not all of the embodiments. The components of the embodiments of the present application described and shown in the drawings here can be arranged and designed in various different configurations.
[0065] Therefore, the following detailed description of the embodiments of the present application provided in the accompanying drawings is not intended to limit the scope of the present application for which protection is sought, but merely represents selected embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in the field without creative work are within the scope of protection of the present application.
[0066] like Figure 1 As shown, an embodiment of the present application provides an electronic device, wherein the electronic device may include a memory, a processor, and a dot-shaped inkjet character recognition device.
[0067] In detail, the memory and the processor are electrically connected directly or indirectly to achieve data transmission or interaction. For example, the memory and the processor can be electrically connected through one or more communication buses or signal lines. The dot-inking character recognition device includes at least one software function module stored in the memory in the form of software or firmware. The processor is used to execute an executable computer program stored in the memory, for example, the software function module and computer program included in the dot-inking character recognition device, so as to implement the dot-inking character recognition method provided in the embodiment of the present application.
[0068] Optionally, the memory may be, but is not limited to, a random access memory (RAM), a read only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable read-only memory (EEPROM), etc.
[0069] Furthermore, the processor may be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), a system on chip (SoC), etc.; it may also be a digital signal processor (DSP), an application-specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0070] Understandably, Figure 1 The structure shown is for illustration only, and the electronic device may also include Figure 1 More or fewer components as shown, or with Figure 1 The different configurations shown, for example, may also include a communication unit for exchanging information with other devices (such as an image acquisition device, etc.).
[0071] Combination Figure 2 The embodiment of the present application also provides a dot-inkjet character recognition method applicable to the above electronic device, wherein the method steps defined in the process related to the dot-inkjet character recognition method can be implemented by the electronic device.
[0072] The following will Figure 2 The specific process shown is explained in detail.
[0073] Step S110, performing dot-shaped character region recognition processing on the dot-shaped inkjet coding image to be processed to obtain a corresponding dot-shaped character region recognition result.
[0074] In the embodiment of the present application, the electronic device can perform dot character area recognition processing on the dot-shaped inkjet coding image to be processed to obtain the corresponding dot character area recognition result. The dot character area positioning processing includes connecting the internal gaps of the dot characters (for example, at least reducing the internal gaps of the characters) and positioning the image area where the dot characters are located. The dot characters are composed of multiple dot graphics (such as squares or Figure 3 The inner gap of the character refers to the gap between the dot-shaped graphics (see further Figure 3 As shown in FIG. 1 ), the dot-shaped inkjet coding image to be processed has a target dot-shaped character to be identified, such as Figure 4 , the dot character area recognition result is used to identify the image area where the target dot character is located; exemplarily, the dot character area recognition result can identify the image area where the target dot character is located in the dot inkjet image to be processed by a marking box (such as a rectangular box).
[0075] Step S120, performing region correction processing on the image region identified by the dot character region recognition result to obtain a corresponding image region correction result.
[0076] In the embodiment of the present application, after obtaining the dot-like character area recognition result, the electronic device can perform area correction processing on the image area identified by the dot-like character area recognition result to obtain a corresponding image area correction result. The area correction processing includes identifying and correcting the area distribution direction of the image area identified by the dot-like character area recognition result. For example, when the distribution direction of the target dot-like character has an inclination angle (such as not parallel to the horizontal direction, etc.), the distribution direction of the target dot-like character can be adjusted to eliminate the inclination angle.
[0077] Step S130, performing character recognition processing on the image area correction result to obtain a corresponding character recognition result.
[0078] In the embodiment of the present application, after obtaining the image area correction result, character recognition processing can be performed on the image area correction result to obtain a corresponding character recognition result, that is, character recognition processing is performed on the image area identified by the image area correction result. The character recognition result includes the recognized target dot-shaped characters.
[0079] Based on the above content, since the dot character area positioning processing includes connecting the internal gaps of the dot characters, the internal gaps of the dot characters in the image area marked by the dot character area recognition result can be connected (it can also be said that the gaps are reduced), thereby forming a normal and complete character. In this way, in the subsequent character recognition, the reliability of recognition can be improved (such as the internal gaps of the dot characters will interfere with the subsequent recognition, such as a character is recognized as multiple dot graphics, etc.), therefore, the problem of relatively low reliability of dot inkjet character recognition in the prior art can be improved. In addition, performing regional correction processing on the image area marked by the dot character area recognition result can improve the reliability of the object of character recognition processing, avoiding the problem of low recognition reliability due to interference information caused by differences in regional distribution directions.
[0080] Firstly, it should be noted that for step S110, the specific method of performing dot-shaped character area recognition processing on the dot-shaped inkjet coding image to be processed is not limited and can be selected according to actual needs.
[0081] For example, in an alternative embodiment, in order to improve the efficiency of the dot character area recognition processing of the dot inkjet coding image to be processed, the dot inkjet coding image to be processed can be subjected to one (or one) connection processing (which can be any one of the first connection processing and the second connection processing described later, or other connection processing), and then, based on the result of the connection processing, the image area where the dot characters are located is positioned, thereby obtaining the corresponding dot character area recognition result.
[0082] For example, in another alternative embodiment, in order to improve the reliability of the dot character area recognition processing of the dot inkjet coding image to be processed, the above-mentioned step S110 may further include step S111, step S112 and step S113, and the specific content of each step is described as follows.
[0083] Step S111 , performing a first connection process on the internal spaces of the dot-shaped characters in the dot-shaped inkjet coding image to be processed, to obtain a corresponding first dot-shaped character connection image.
[0084] In the embodiment of the present application, after obtaining the dot-shaped inkjet coding image to be processed, the first connection processing can be performed on the internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed to obtain the corresponding first dot-shaped character connection image. The first connection processing can also be called gap reduction processing, wherein the gap reduction can be considered as connecting the dot-shaped graphics in the dot-shaped characters together, for example, Figure 4 The images shown in the figure are connected to obtain Figure 5 The image shown is such that the gaps between the dot patterns (dots) constituting the dot characters are reduced so that the dots are connected together.
[0085] Step S112, performing a second connection process on the internal spaces of the dot-shaped characters in the first dot-shaped character connection image to obtain a corresponding second dot-shaped character connection image.
[0086] In an embodiment of the present application, after obtaining the first dot-shaped character connection image, a second connection process can be further performed on the internal gaps of the dot-shaped characters in the first dot-shaped character connection image to obtain a corresponding second dot-shaped character connection image. The processing method of the second connection process is different from the processing method of the first connection process. That is, in an embodiment of the present application, two different connection processing methods can be used to process the images one after another, so that the effect of the connection processing can be better and the internal gaps of the dot-shaped characters can be effectively reduced.
[0087] Step S113, performing positioning processing on the image area where the dot-shaped characters in the second dot-shaped character connection image are located to obtain a corresponding dot-shaped character area recognition result.
[0088] In an embodiment of the present application, after obtaining a second dot-like character connection image in which the internal gaps of the dot-like characters are sufficiently reduced, the image area where the dot-like characters in the second dot-like character connection image are located can be positioned, so that the corresponding dot-like character area recognition result can be obtained. The specific method of performing the positioning processing is not limited. For example, the neural network models such as Faster R-CNN, R-FCN and SSD can be used to perform target detection (detection of the area where the characters are located) on the second dot-like character connection image to obtain the corresponding dot-like character area recognition result.
[0089] It should be further explained that, in the above step S111, the specific method of performing the first connection processing on the internal spaces of the dot-shaped characters is not limited and can be selected according to actual needs.
[0090] For example, in an alternative embodiment, the first connection processing can be directly performed on the internal gaps of the dot characters in the dot inkjet coding image to be processed. In this way, the efficiency of the first connection processing on the internal gaps of the dot characters can be improved to a certain extent.
[0091] For another example, in another alternative implementation, in order to improve the reliability of the first connection processing of the internal gaps of the dot-shaped characters, the above-mentioned step S111 may further include step S111a and step S111b, and the specific content of each step is described as follows.
[0092] Step S111a, determining the character spacing between the dot characters in the dot inkjet coding image to be processed to obtain a corresponding target character spacing distance.
[0093] In the embodiment of the present application, after obtaining the dot-shaped inkjet image to be processed, the character spacing between the dot-shaped characters in the dot-shaped inkjet image to be processed can be determined and processed to obtain the corresponding target character spacing distance. The target character spacing distance refers to the spacing distance between two adjacent dot-shaped characters, not the distance of the internal gap of the aforementioned characters, such as Figure 5 The “2023” shown may refer to the distance between the first “2” and “0”, the distance between “0” and the second “2”, and the distance between the second “2” and “3”.
[0094] Step S111b, based on the target character spacing distance, determine the connection processing parameters for performing the first connection processing on the internal gaps of the dot characters in the dot inkjet coding image to be processed, and perform the first connection processing based on the connection processing parameters to obtain the corresponding first dot character connection image.
[0095] In the embodiment of the present application, after obtaining the target character interval distance, based on the target character interval distance, connection processing parameters for performing first connection processing on the internal gaps of the dot characters in the to-be-processed dot inkjet image can be determined, and based on these connection processing parameters, the first connection processing is performed to obtain the corresponding first dot character connection image. That is to say, due to different target character interval distances, parameters such as the amplitude of the connection processing that needs to be performed can be different. Therefore, the connection processing parameters can be determined based on the target character interval distance, and then, based on these connection processing parameters, the first connection processing is performed to obtain the corresponding first dot character connection image, so that the internal gaps of the characters in the first dot character connection image can be reduced to achieve connection. For example, if the first connection processing is not performed based on the target character interval distance, it may lead to excessive connection processing and problems such as loss of corresponding information, such as Figure 6 As shown, excessive connection of the character "期" will result in loss of character information, such as character blurring, etc.
[0096] It can be understood that in the above step S111a, in order to ensure that the determined target character interval distance has a high reliability and can truly reflect the actual interval between dot characters, in an alternative embodiment, step S111a can further include step a11 and step a12, and the specific content of each step is as described.
[0097] Step a11: Perform multiple different dilation processes on the to-be-processed dot inkjet image to obtain corresponding multiple dilated dot inkjet images, and respectively perform quantity statistical processing on the dot character contours in each of the dilated dot inkjet images.
[0098] In the embodiment of the present application, after obtaining the to-be-processed dot inkjet image, multiple different dilation processes can be performed on the to-be-processed dot inkjet image. In this way, corresponding multiple dilated dot inkjet images can be obtained, and quantity statistical processing is respectively performed on the dot character contours in each of the dilated dot inkjet images to obtain the corresponding dot character contour quantities. Among them, there is a one-to-one correspondence between the multiple dilated dot inkjet images and the multiple different dilation processes. That is to say, for the first dilation process, the first dilated dot inkjet image can be obtained; for the second dilation process, the second dilated dot inkjet image can be obtained; for the third dilation process, the third dilated dot inkjet image can be obtained.
[0099] Step a12, based on the statistical results of the number of dot-like character contours in each of the expanded dot-like inkjet coding images, a target expanded dot-like inkjet coding image is determined among the multiple expanded dot-like inkjet coding images, and based on the distance between the dot-like character contours in the expanded dot-like inkjet coding images, the corresponding target character spacing distance is determined.
[0100] In an embodiment of the present application, after performing quantitative statistical processing on the dot character contours in each of the expanded dot coding images, a target expanded dot coding image (such as the most representative expanded dot coding image) can be determined among the multiple expanded dot coding images based on the quantitative statistical results of the dot character contours in each of the expanded dot coding images (such as the aforementioned number of dot character contours), and the corresponding target character spacing distance can be determined based on the distance between the dot character contours in the expanded dot coding images. For example, the distance between the dot character contours in the expanded dot coding images can be directly used as the corresponding target character spacing distance.
[0101] For example, in the above step a11, the specific manner of performing multiple different expansion processes is not limited. For example, in an alternative embodiment, in order to determine a representative target expansion-processed dot-shaped inkjet coding image based on multiple different expansion processes, step a11 may further include the following steps:
[0102] On the one hand, the dot-shaped inkjet coding image to be processed can be expanded using an expansion kernel having a first size to obtain a corresponding expanded processed dot-shaped inkjet coding image, and the dot-shaped character contours in the expanded processed dot-shaped inkjet coding image can be quantitatively processed to obtain the corresponding first dot-shaped character contour quantity; illustratively, the first size can be 3*3, and the detection of the dot-shaped character contour can be achieved by existing related detection technologies, such as using the cv2.findContour() function in the OpenCV-Python interface to detect the contour of the dot-shaped character;
[0103] On the other hand, the dot-shaped inkjet coding image to be processed may be expanded using an expansion kernel having a second size to obtain a corresponding expanded processed dot-shaped inkjet coding image, and the dot-shaped character contours in the expanded processed dot-shaped inkjet coding image may be statistically processed to obtain the corresponding number of second dot-shaped character contours, wherein the second size is larger than the first size, for example, the second size may be 5*5;
[0104] Further, when the number of the first dot-like character contours is greater than the number of the second dot-like character contours, the expansion process of the dot-like inkjet coding image to be processed may be stopped. That is, since the number of the first dot-like character contours is greater than the number of the second dot-like character contours, it can be characterized that excessive expansion has occurred when the expansion process is performed using the expansion kernel with the second size, such as connecting different dot-like characters together, that is, excessive connection is achieved, not only connecting the dot-like graphics inside the dot-like characters together, but also connecting the dot-like characters together, so that the character information is lost, and therefore, the expansion process may be stopped;
[0105] On the other hand, when the number of the first dot-like character contours is not greater than the number of the second dot-like character contours, the dot-like inkjet coding image to be processed can be expanded using the expansion kernel having the first size to obtain a corresponding expanded processed dot-like inkjet coding image, and the expanded processed dot-like inkjet coding image can be expanded using the expansion kernel having the first size to obtain a new expanded processed dot-like inkjet coding image, and the dot-like character contours in the new expanded processed dot-like inkjet coding image can be quantitatively processed to obtain a corresponding third number of dot-like character contours. For example, the dot-like inkjet coding image to be processed can be expanded twice using the expansion kernel having a size of 3*3;
[0106] Further, when the number of the second dot-shaped character outlines is greater than the number of the third dot-shaped character outlines, the expansion process of the dot-shaped inkjet coding image to be processed is stopped. As mentioned above, this indicates that excessive expansion has occurred, which not only connects the dot-shaped graphics inside the dot-shaped characters, but also connects the dot-shaped characters together, resulting in loss of character information.
[0107] On the other hand, when the number of the second dot-like character contours is not greater than the number of the third dot-like character contours, the dot-like inkjet coding image to be processed is expanded using the expansion kernel having the first size to obtain a corresponding expanded processed dot-like inkjet coding image, and the expanded processed dot-like inkjet coding image is expanded using the expansion kernel having the second size to obtain a new expanded processed dot-like inkjet coding image, and the dot-like character contours in the new expanded processed dot-like inkjet coding image are quantitatively processed to obtain a corresponding fourth number of dot-like character contours; illustratively, the expansion kernel having a size of 3*3 may be used to first perform the expansion processing, and then the expansion kernel having a size of 5*5 may be used to perform the expansion processing again;
[0108] Furthermore, when the number of the third dot-like character contours is greater than the number of the fourth dot-like character contours, the expansion process of the dot-like inkjet coding image to be processed is stopped. As mentioned above, this indicates that excessive expansion has occurred, which not only connects the dot-like graphics inside the dot-like characters together, but also connects the dot-like characters together, resulting in the loss of character information. In addition, when the number of the third dot-like character contours is not greater than the number of the fourth dot-like character contours, the processing can be continued in the aforementioned manner, such as using a 5*5 expansion kernel to perform two expansion processes on the dot-like inkjet coding image to be processed, and then, it is determined whether it is necessary to continue to perform expansion processing on the dot-like inkjet coding image to be processed. If necessary, a 3*3 expansion kernel can be used to perform three expansion processes on the dot-like inkjet coding image to be processed, and then, it is determined again whether it is necessary to continue to perform expansion processing on the dot-like inkjet coding image to be processed, and so on, until the expansion process is stopped to avoid adhesion between the dot-like characters while maximizing the connection of the internal gaps of the dot-like characters.
[0109] For example, in the above step a12, the specific method of determining the target character spacing distance is not limited. For example, in an alternative implementation, in order to make the determined target character spacing distance more reliable, step a12 may further include the following steps:
[0110] First, based on the number statistics of the dot character outlines in each of the expanded dot coding images, a target expanded dot coding image with the maximum number statistics can be determined among the multiple expanded dot coding images. That is, the target expanded dot coding image is an image with the highest degree of reduction in the internal gap of the dot characters and the lowest degree of adhesion between the dot characters, and therefore can be used as a representative image.
[0111] Secondly, in the target expansion processed dot inkjet coding image, at least two adjacent contour center points of the dot-like character contours can be determined, and based on the distance between the contour center points of the two adjacent dot-like character contours, the corresponding target character spacing distance can be determined; illustratively, the distance between the contour center points of each two adjacent dot-like character contours can be determined separately, and then the maximum value or average value thereof can be used as the target character spacing distance.
[0112] It can be understood that, in the above step S111b, the specific manner of performing the first connection processing based on the determined connection processing parameters is not limited and can be selected according to actual needs.
[0113] For example, in an alternative implementation, in order to achieve a better connection effect of the first connection processing, the above-mentioned step S111b may further include step b11, step b12, step b13, step b14, step b15 and step b16, and the specific content of each step is described as follows.
[0114] Step b11, based on the predetermined mapping relationship and the target character spacing distance, determining connection processing parameters for performing a first connection processing on the internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed.
[0115] In an embodiment of the present application, after obtaining the target character spacing distance, a connection processing parameter for performing a first connection processing on the internal character gaps of the dot characters in the dot inkjet coding image to be processed can be determined based on a predetermined mapping relationship and the target character spacing distance. The connection processing parameter is positively correlated to the target character spacing distance. In other words, the larger the target character spacing distance, the larger the connection processing parameter; the smaller the target character spacing distance, the smaller the connection processing parameter. The specific proportional relationship or other positive correlation relationship can be configured according to actual needs and is not specifically limited here.
[0116] Step b12: Based on the number of pixels represented by the connection processing parameter, pixel shift processing is performed on the dot-shaped inkjet coding image to be processed in a first direction to obtain a corresponding first shifted dot-shaped inkjet coding image.
[0117] In the embodiment of the present application, after obtaining the connection processing parameter, the pixel shift processing can be performed on the to-be-processed dot-shaped inkjet coding image in a first direction based on the number of pixels represented by the connection processing parameter (that is, the connection processing parameter is used to reflect the number of pixels that need to be shifted, such as 1, 2, 3, 4, etc.), to obtain a corresponding first shifted dot-shaped inkjet coding image. Exemplarily, the first direction can refer to the row direction of pixel distribution, such as from left to right. For details, please refer to Figure 7 As shown, in addition, the pixel values of the pixels vacated due to the shift processing at the starting position in the first direction (such as the first n positions in the first direction, n is equal to the connection processing parameter) can be filled with preset values, wherein the preset value can be 0 or 255, and can be specifically determined according to the pixel value of the pixel where the dot-like character is located. For example, when the pixel value of the pixel where the dot-like character is located is 0, the preset value can be 255; when the pixel value of the pixel where the dot-like character is located is 255, the preset value can be 0.
[0118] Step b13: Based on the number of pixels represented by the connection processing parameter, pixel shift processing is performed on the dot-shaped inkjet coding image to be processed in a second direction to obtain a corresponding second shifted dot-shaped inkjet coding image.
[0119] In the embodiment of the present application, after obtaining the connection processing parameters, the pixel shift processing can be performed on the to-be-processed dot-shaped inkjet coding image in a second direction based on the number of pixels represented by the connection processing parameters to obtain a corresponding second shifted dot-shaped inkjet coding image. Exemplarily, the second direction can also refer to the row direction of pixel distribution, such as from right to left. For details, please refer to Figure 7 As shown, in addition, the pixel values of the pixels vacated due to the shifting process at the head position in the second direction (such as the first n positions in the second direction) can be filled with preset values.
[0120] Step b14, based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed along a third direction to obtain a corresponding third shifted dot-shaped inkjet coding image.
[0121] In the embodiment of the present application, after obtaining the connection processing parameters, the pixel shift processing can be performed on the to-be-processed dot-shaped inkjet coding image according to the third direction based on the number of pixels represented by the connection processing parameters to obtain a corresponding third shifted dot-shaped inkjet coding image. Exemplarily, the third direction can also refer to the column direction of pixel distribution, such as from top to bottom. For details, please refer to Figure 7 As shown, in addition, the pixel values of the pixels vacated due to the shifting process at the beginning position in the third direction (such as the first n positions in the third direction) can be filled with preset values.
[0122] Step b15: Based on the number of pixels represented by the connection processing parameter, pixel shift processing is performed on the to-be-processed dot-shaped inkjet coding image in a fourth direction to obtain a corresponding fourth shifted dot-shaped inkjet coding image.
[0123] In the embodiment of the present application, after obtaining the connection processing parameters, the pixel shift processing can be performed on the to-be-processed dot-shaped inkjet coding image according to the fourth direction based on the number of pixels represented by the connection processing parameters to obtain a corresponding fourth shifted dot-shaped inkjet coding image. Exemplarily, the fourth direction can also refer to the column direction of pixel distribution, such as from bottom to top. For details, please refer to Figure 7 As shown, in addition, the pixel values of the pixels vacated due to the shift processing at the beginning position of the fourth direction (such as the first n positions in the fourth direction) can be filled with preset values. That is, the first direction, the second direction, the third direction and the fourth direction are different.
[0124] Step b16, performing image fusion processing on the first shifted dot-shaped inkjet coding image, the second shifted dot-shaped inkjet coding image, the third shifted dot-shaped inkjet coding image and the fourth shifted dot-shaped inkjet coding image to obtain the corresponding target shifted dot-shaped inkjet coding image, and based on the target shifted dot-shaped inkjet coding image, determining the corresponding first dot-shaped character connection image.
[0125] In an embodiment of the present application, after performing multiple pixel shifting processes on the dot-like inkjet coding image to be processed, the first shifted dot-like inkjet coding image, the second shifted dot-like inkjet coding image, the third shifted dot-like inkjet coding image and the fourth shifted dot-like inkjet coding image obtained can be subjected to image fusion processing to obtain the corresponding target shifted dot-like inkjet coding image, and based on the target shifted dot-like inkjet coding image, the corresponding first dot-like character connection image can be determined. Exemplarily, the first shifted dot-shaped inkjet coding image, the second shifted dot-shaped inkjet coding image, the third shifted dot-shaped inkjet coding image and the fourth shifted dot-shaped inkjet coding image can be superimposed, that is, the pixel values of the pixels at the same position are summed to obtain the corresponding target shifted dot-shaped inkjet coding image, and then the target shifted dot-shaped inkjet coding image can be binarized so that the pixel values in the obtained first dot-shaped character connection image are 0 or 255, wherein the specific method of binarization is not limited, for example, the pixel values equal to 0 in the target shifted dot-shaped inkjet coding image can be maintained, and the pixel values not equal to 0 can be set to 255, or, it can also be processed in other ways, such as setting the pixel values less than the threshold to 0, and setting the pixel values not less than the threshold to 255.
[0126] It should be further explained that, in the above step S112, the specific method of performing the second connection processing on the internal spaces of the dot-shaped characters is not limited and can be selected according to actual needs.
[0127] For example, in an alternative embodiment, in order to improve the efficiency of the second connection processing of the internal gaps of dot-like characters, the first dot-like character connection image can be directly subjected to corresponding expansion processing and erosion processing according to the expansion kernel and erosion kernel of preset sizes to obtain the corresponding second dot-like character connection image.
[0128] For example, in another alternative implementation, in order to ensure the reliability of the second connection processing of the internal gaps of dotted characters, the above-mentioned step S112 may further include step S112a, step S112b, step S112c, step S112d, step S112e and step S112f, and the specific content of each step is described as follows.
[0129] Step S112a, based on a first expansion parameter, dilate the first dotted character connection image to obtain a corresponding first expanded connection image, and based on a first erosion parameter, erode the first expanded connection image to obtain a corresponding first eroded connection image.
[0130] In an embodiment of the present application, the first dotted character connection image can be firstly dilated based on a first dilation parameter, so that a corresponding first dilated connection image can be obtained, and then the first dilated connection image can be eroded based on a first erosion parameter, so that a corresponding first eroded connection image can be obtained. Among them, the first dilation parameter can refer to the size of the dilation kernel for dilation processing, such as 5*5. The first erosion parameter can refer to the size of the erosion kernel for erosion processing, such as 3*3. In the dilation process, the role of the kernel is to expand the size of the target object (white area) in the image, while reducing or filling the gap between the target objects. The kernel is usually a small rectangular or circular area, and its size and shape can vary according to the needs of the specific application. The dilation operation convolves the kernel with the image. When the center of the kernel covers the pixel on the image, the pixel value at the corresponding position in the output image will become matched with the maximum value of all elements in the kernel (such as white pixels). In the erosion process, the role of the kernel is to reduce the size of the target objects in the image while increasing the gaps between the target objects. Similar to the dilation process, the kernel is usually also a small rectangular or circular area, and its size and shape can vary according to the needs of the specific application. The erosion operation convolves the kernel with the image. When the center of the kernel covers the pixels on the image, the pixel value at the corresponding position in the output image will become matched with the minimum value of all elements in the kernel (such as black pixels).
[0131] Step S112b: determining whether the first eroded connection image satisfies a preset character gap connection condition based on the first eroded connection image and the first dotted character connection image.
[0132] In an embodiment of the present application, after obtaining the first eroded connection image, it can be determined based on the first eroded connection image and the first dotted character connection image whether the first eroded connection image satisfies a preset character gap connection condition, that is, whether the internal gaps of the characters in the first eroded connection image have been connected or reduced to a certain extent.
[0133] Step S112c: when the first eroded connection image satisfies the character gap connection condition, the first eroded connection image is used as the corresponding second dot character connection image.
[0134] In an embodiment of the present application, when the first eroded connection image satisfies the character gap connection condition, that is, the internal gaps of the characters in the first eroded connection image have been connected or reduced to a certain extent, the first eroded connection image can be used as the second dotted character connection image.
[0135] Step S112d, when the first eroded connection image does not meet the character gap connection condition, based on the second expansion parameter, the first eroded connection image is expanded to obtain a corresponding second expanded connection image, and based on the second erosion parameter, the second expanded connection image is eroded to obtain a corresponding second eroded connection image.
[0136] In an embodiment of the present application, when the first eroded connection image does not meet the character gap connection condition, that is, the internal gaps of the characters in the first eroded connection image are not connected or are not reduced to a certain extent, the first eroded connection image can be firstly dilated based on the second dilation parameter, so that the corresponding second dilated connection image can be obtained, and then the second dilated connection image can be eroded based on the second erosion parameter, so that the corresponding second eroded connection image can be obtained. The second dilation parameter is smaller than the first dilation parameter. Exemplarily, the second dilation parameter can be 3*3, and the second erosion parameter can also be 3*3.
[0137] Step S112e: determining whether the second eroded connection image satisfies the character gap connection condition based on the second eroded connection image and the first dotted character connection image.
[0138] In an embodiment of the present application, after obtaining the second eroded connection image, it can be determined whether the second eroded connection image satisfies the character gap connection condition based on the second eroded connection image and the first dotted character connection image, as described above.
[0139] Step S112f: when the second eroded connection image satisfies the character gap connection condition, use the second eroded connection image as the corresponding second dot character connection image.
[0140] In the embodiment of the present application, when the second eroded connection image satisfies the character gap connection condition, the second eroded connection image can be used as the corresponding second dot character connection image. When the second eroded connection image does not meet the character gap connection condition, the second eroded connection image can continue to be expanded and eroded according to the second expansion coefficient and the second erosion parameter to obtain a third eroded connection image and a fourth eroded connection image, until the last eroded connection image meets the character gap connection condition or the number of expansions and erosions reaches a preset value.
[0141] It can be understood that, in the above-mentioned step S112b, the specific method of determining whether the first eroded connection image satisfies the preset character gap connection conditions is not limited and can be selected according to actual needs. For example, in an alternative embodiment, in order to make the determination result of whether the first eroded connection image satisfies the preset character gap connection conditions have a higher reliability, step S112b can further include step b21, step b22, step b23, step b24 and step b25, and the specific content of each step is described as follows.
[0142] Step b21, performing image subtraction processing on the first eroded connection image and the first dotted character connection image to obtain a corresponding difference image.
[0143] In an embodiment of the present application, after obtaining the first eroded connection image, the first eroded connection image and the first dotted character connection image may be subjected to image subtraction processing, so that a corresponding difference image may be obtained. For example, the pixel values of the pixels at the same position between the first eroded connection image and the first dotted character connection image may be subjected to difference calculation, such as calculating the absolute difference, and then a corresponding difference image may be obtained. The first eroded connection image, the first dotted character connection image and the difference image are all binary images, that is, the pixel values of the pixels in the images are all 0 or 255.
[0144] Step b22, counting the pixel points whose pixel values in the first dot-shaped character connection image are equal to the predetermined target value to obtain the corresponding first pixel point number.
[0145] In the implementation of the present application, the pixel points in the first dotted character connection image whose pixel values are equal to a predetermined target value can also be counted, so that the corresponding first pixel point quantity can be obtained. For example, the pixel points with a pixel value equal to 255 can be counted.
[0146] Step b23, counting the pixel points in the difference image whose pixel values are equal to the target value to obtain the corresponding number of second pixel points.
[0147] In the embodiment of the present application, the pixel points whose pixel values in the difference image are equal to the target value can also be counted, so that the corresponding second pixel number can be obtained. For example, the pixel points whose pixel values are equal to 255 can be counted. The pixel points whose pixel values are equal to the target value refer to the pixel points in the corresponding image that belong to the dot-shaped characters, such as 255.
[0148] Step b24, determining the ratio between the number of the second pixel points and the number of the first pixel points.
[0149] In an embodiment of the present application, after obtaining the second number of pixels and the first number of pixels, the quantity ratio between the second number of pixels and the first number of pixels can be determined. For example, the former can be divided by the latter to obtain the corresponding quantity ratio.
[0150] Step b25, when the quantity ratio belongs to a predetermined ratio interval, it is determined that the first eroded connection image satisfies a preset character gap connection condition; when the quantity ratio does not belong to the predetermined ratio interval, it is determined that the first eroded connection image does not satisfy the preset character gap connection condition.
[0151] In an embodiment of the present application, after obtaining the quantity ratio, the quantity ratio can be compared with a predetermined ratio interval, wherein when the quantity ratio belongs to the predetermined ratio interval, it can be determined that the first eroded connection image satisfies the preset character gap connection condition, and when the quantity ratio does not belong to the predetermined ratio interval, it can be determined that the first eroded connection image does not satisfy the preset character gap connection condition. Exemplarily, the ratio interval can be (1 / 3, 1 / 2). That is to say, in the process of expansion and erosion cycle, when the current eroded connection image and the first dot character connection image are subtracted, and the number of remaining font pixels (pixel value equal to 255) belongs to 1 / 3 to 1 / 2 of the number of font pixels in the first dot character connection image, it can be considered that the internal gap of the dot character is connected (filled).
[0152] On the second aspect, it should be noted that for step S120, the specific method of performing regional correction processing on the image area identified by the dot character area recognition result is not limited and can be selected according to actual needs. For example, in an alternative implementation, the MobileNetV2 classification network can be used as a rotation model to perform regional correction processing on the image area identified by the dot character area recognition result, wherein MobileNetV2 is a lightweight deep learning model, which is usually used for image classification tasks. It is designed for efficient image recognition and classification on resource-constrained devices. For example, the input image (such as the image area identified by the dot character area recognition result) can be subjected to three rotation judgments: 180 degrees, positive 90 degrees and negative 90 degrees. In this way, after determining the angle of the character distribution direction in the input image, a corresponding rotation can be performed so that the angle of the rotated character distribution direction can be consistent with the normal character distribution direction, so as to facilitate subsequent reliable character recognition. In addition, MobileNetV2 provides multiple predefined size ratios, such as 0.25, 0.5, 0.75 and 1.0, which respectively represent the ratio of the model to the standard size. A smaller model size ratio usually means a lighter model. Therefore, in the embodiment of the present application, the size ratio can be 0.25.
[0153] On the third aspect, it should be noted that for step S130, the specific method of performing character recognition processing on the image area correction result is not limited and can be selected according to actual needs. For example, in an alternative implementation, CRNN (Convolutional Recurrent Neural Network) can be used to perform character recognition processing on the input image (such as the image area represented by the image area correction result). Among them, CRNN is a deep learning model that combines convolutional neural network (CNN) and recurrent neural network (RNN) for sequence recognition tasks, such as character recognition in images. The following is a detailed explanation of character recognition based on CRNN:
[0154] Convolutional Neural Network (CNN): The first part of a CRNN is a CNN, which is used to extract features from the input image. The CNN is responsible for capturing local features in the image and converting them into a form suitable for input to the RNN. Typically, the convolutional layer of a CNN is used to extract feature maps, while the pooling layer is used to reduce the size of the feature map and extract higher-level features.
[0155] Recurrent Neural Network (RNN): The second part of CRNN is an RNN, usually a long short-term memory (LSTM) or a gated recurrent unit (GRU). RNN is responsible for modeling the feature sequence extracted by CNN to capture the temporal information and contextual relationships in the sequence. This sequence modeling makes CRNN suitable for processing sequence data of indefinite length, such as the sequence of characters in a text line;
[0156] Sequence recognition: CRNN combines the advantages of CNN and RNN and can process local features and global context information at the same time. In the character recognition task, CRNN accepts the entire image as input and outputs the prediction results for the character at each position. Through the training process, CRNN learns how to extract features from the image and how to predict characters based on these features.
[0157] Combination Figure 8 The embodiment of the present application also provides a dot-printing character recognition device applicable to the above electronic device. The dot-printing character recognition device may include a character region recognition module, a region correction processing module and a character recognition processing module.
[0158] In detail, the character area recognition module can be used to perform dot character area recognition processing on the dot inkjet coding image to be processed to obtain the corresponding dot character area recognition result, wherein the dot character area positioning processing includes connecting the internal gaps of the dot characters and positioning the image area where the dot characters are located, the dot characters are composed of multiple dot graphics, the internal gaps of the characters refer to the gaps between the dot graphics, the dot inkjet coding image to be processed has the target dot characters to be identified, and the dot character area recognition result is used to identify the image area where the target dot characters are located. In the embodiment of the present application, the character area recognition module can be used to perform Figure 2 As shown in step S110, the relevant contents of the character area recognition module can refer to the above description of step S110.
[0159] In detail, the region correction processing module can be used to perform region correction processing on the image region identified by the dot character region recognition result to obtain a corresponding image region correction result, wherein the region correction processing includes identifying and correcting the region distribution direction of the image region identified by the dot character region recognition result. Figure 2 As shown in step S120, the relevant contents of the regional correction processing module can refer to the above description of step S120.
[0160] In detail, the character recognition processing module can be used to perform character recognition processing on the image area correction result to obtain a corresponding character recognition result, wherein the character recognition result includes the recognized target dot-shaped characters. Figure 2 As shown in step S130, the relevant contents of the character recognition processing module can refer to the above description of step S130.
[0161] In the embodiment of the present application, corresponding to the above-mentioned dot-inkjet character recognition method applied to the electronic device, a computer-readable storage medium is also provided, in which a computer program is stored, and when the computer program is run, each step of the dot-inkjet character recognition method is executed. Among them, each step executed when the aforementioned computer program is run will not be repeated here one by one, and reference can be made to the above explanation of the dot-inkjet character recognition method.
[0162] In summary, the dot-like inkjet character recognition method and electronic device provided by the present application can, first, perform dot-like character area recognition processing on the dot-like inkjet image to be processed to obtain the corresponding dot-like character area recognition result; secondly, perform area correction processing on the image area identified by the dot-like character area recognition result to obtain the corresponding image area correction result; then, perform character recognition processing on the image area correction result to obtain the corresponding character recognition result. Based on the above content, since the dot-like character area positioning processing includes connecting the internal gaps of the dot-like characters, the internal gaps of the dot-like characters in the image area identified by the dot-like character area recognition result can be connected (it can also be said that the gaps are reduced), thereby forming normal and complete characters. In this way, in the subsequent character recognition, the reliability of recognition can be improved (such as the internal gaps of the dot-like characters will interfere with the subsequent recognition, such as a character is recognized as multiple dot-like graphics, etc.), therefore, the problem of relatively low reliability of dot-like inkjet character recognition existing in the prior art can be improved. In addition, performing regional correction processing on the image area marked by the point character area recognition result can also further improve the reliability of the object of character recognition processing and avoid the problem of low recognition reliability due to interference information caused by differences in regional distribution directions.
[0163] In several embodiments provided in the embodiments of the present application, it should be understood that the disclosed device and method can also be implemented in other ways. The device and method embodiments described above are merely schematic, for example, the flowcharts and block diagrams in the accompanying drawings show the possible architecture, functions and operations of the device, method and computer program product according to multiple embodiments of the present application. In this regard, each box in the flowchart or block diagram can represent a module, a program segment or a part of a code, and the module, a program segment or a part of a code contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order from the order marked in the accompanying drawings. For example, two consecutive boxes can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of boxes in the block diagram and / or flowchart can be implemented with a dedicated hardware-based system that performs a specified function or action, or can be implemented with a combination of dedicated hardware and computer instructions.
[0164] In addition, the functional modules in the various embodiments of the present application may be integrated together to form an independent part, or each module may exist separately, or two or more modules may be integrated to form an independent part.
[0165] If the function is implemented in the form of a software function module and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application is essentially or the part that contributes to the prior art or the part of the technical solution can be embodied in the form of a software product, which is stored in a storage medium, including several instructions to enable a computer device (which can be a personal computer, electronic device, or network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program code. It should be noted that in this article, the term "include", "include" or any other variant thereof is intended to cover non-exclusive inclusion, so that the process, method, article or device including a series of elements includes not only those elements, but also includes other elements that are not explicitly listed, or also includes elements inherent to such process, method, article or device. Without more constraints, an element defined by the phrase "comprising a..." does not exclude the existence of other identical elements in the process, method, article or apparatus comprising the element.
[0166] The above description is only the preferred embodiment of the present application and is not intended to limit the present application. For those skilled in the art, the present application may have various modifications and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application shall be included in the protection scope of the present application.
Claims
1. A dot-inkjet character recognition method, characterized in that: include: Performing dot-shaped character area recognition processing on the dot-shaped inkjet coding image to be processed to obtain a corresponding dot-shaped character area recognition result, wherein the dot-shaped character area positioning processing includes connecting the internal gaps of the dot-shaped characters and positioning the image area where the dot-shaped characters are located, the dot-shaped characters are composed of a plurality of dot-shaped graphics, the internal gaps of the characters refer to the gaps between the dot-shaped graphics, the dot-shaped inkjet coding image to be processed has a target dot-shaped character to be recognized, and the dot-shaped character area recognition result is used to identify the image area where the target dot-shaped character is located; Performing regional correction processing on the image area identified by the dot-shaped character area recognition result to obtain a corresponding image area correction result, wherein the regional correction processing includes identifying and correcting the area distribution direction of the image area identified by the dot-shaped character area recognition result; Performing character recognition processing on the image area correction result to obtain a corresponding character recognition result, wherein the character recognition result includes the recognized target dot-shaped characters; The step of performing dot-shaped character area recognition processing on the dot-shaped inkjet coding image to be processed to obtain the corresponding dot-shaped character area recognition result includes: Performing a first connection process on the internal spaces of the dot-shaped characters in the dot-shaped inkjet coding image to be processed to obtain a corresponding first dot-shaped character connection image; Performing a second connection process on the internal spaces of the dot-shaped characters in the first dot-shaped character connection image to obtain a corresponding second dot-shaped character connection image, wherein the processing method of the second connection process is different from the processing method of the first connection process; Performing positioning processing on the image region where the dot-shaped characters in the second dot-shaped character connection image are located to obtain a corresponding dot-shaped character region recognition result; The step of performing a first connection process on the internal spaces of the dot-shaped characters in the dot-shaped inkjet coding image to be processed to obtain a corresponding first dot-shaped character connection image includes: Determining the character spacing between the dot characters in the dot-shaped inkjet coding image to be processed to obtain a corresponding target character spacing distance; Based on the target character spacing distance, determining connection processing parameters for performing a first connection processing on the character internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed, and performing a first connection processing based on the connection processing parameters to obtain a corresponding first dot-shaped character connection image, wherein the first connection processing includes: based on a predetermined mapping relationship and the target character spacing distance, determining connection processing parameters for performing a first connection processing on the character internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed, wherein the connection processing parameters are positively correlated with the target character spacing distance; The step of determining the character spacing between the dot characters in the dot inkjet coding image to be processed to obtain the corresponding target character spacing distance includes: Performing multiple different expansion processes on the dot-shaped inkjet coding image to be processed to obtain multiple corresponding expansion-processed dot-shaped inkjet coding images, and performing quantitative statistical processing on the dot-shaped character contours in each of the expansion-processed dot-shaped inkjet coding images, wherein there is a one-to-one correspondence between the multiple expansion-processed dot-shaped inkjet coding images and the multiple different expansion processes; Based on the statistical results of the number of dot-like character contours in each of the expanded dot-like inkjet coding images, a target expanded dot-like inkjet coding image is determined among the multiple expanded dot-like inkjet coding images, and based on the distance between the dot-like character contours in the expanded dot-like inkjet coding images, the corresponding target character spacing distance is determined.
2. The dot-shaped inkjet character recognition method according to claim 1, characterized in that: The step of performing multiple different expansion processes on the dot-shaped inkjet coding image to be processed to obtain a corresponding plurality of expansion-processed dot-shaped inkjet coding images, and performing quantitative statistical processing on the dot-shaped character contours in each of the expansion-processed dot-shaped inkjet coding images, comprises: Using a dilation kernel having a first size, the dot-shaped inkjet coding image to be processed is dilated to obtain a corresponding dilated dot-shaped inkjet coding image, and the dot-shaped character contours in the dilated dot-shaped inkjet coding image are statistically processed to obtain the corresponding first dot-shaped character contour quantity; Using a dilation kernel having a second size, the dot-shaped inkjet coding image to be processed is dilated to obtain a corresponding dilated dot-shaped inkjet coding image, and the dot-shaped character contours in the dilated dot-shaped inkjet coding image are statistically processed to obtain the number of corresponding second dot-shaped character contours, wherein the second size is larger than the first size; When the number of the first dot-shaped character outlines is greater than the number of the second dot-shaped character outlines, stopping the expansion process of the dot-shaped inkjet coding image to be processed; When the number of the first dot-like character contours is not greater than the number of the second dot-like character contours, the dot-like inkjet coding image to be processed is expanded using the expansion kernel having the first size to obtain a corresponding expanded processed dot-like inkjet coding image, and the expanded processed dot-like inkjet coding image is expanded using the expansion kernel having the first size to obtain a new expanded processed dot-like inkjet coding image, and the dot-like character contours in the new expanded processed dot-like inkjet coding image are statistically processed to obtain a corresponding third number of dot-like character contours; When the number of the second dot-shaped character outlines is greater than the number of the third dot-shaped character outlines, stopping the expansion process of the dot-shaped inkjet coding image to be processed; When the number of the second dot-like character contours is not greater than the number of the third dot-like character contours, the dot-like inkjet coding image to be processed is expanded using the expansion kernel having the first size to obtain a corresponding expanded processed dot-like inkjet coding image, and the expanded processed dot-like inkjet coding image is expanded using the expansion kernel having the second size to obtain a new expanded processed dot-like inkjet coding image, and the dot-like character contours in the new expanded processed dot-like inkjet coding image are statistically processed to obtain a corresponding fourth number of dot-like character contours; When the number of the third dot-shaped character contours is greater than the number of the fourth dot-shaped character contours, the expansion process of the dot-shaped inkjet coding image to be processed is stopped.
3. The dot-shaped inkjet character recognition method according to claim 1, characterized in that: The step of determining a target expanded dot-shaped inkjet coding image from the plurality of expanded dot-shaped inkjet coding images based on the number of dot-shaped character contours in each of the expanded dot-shaped inkjet coding images, and determining a corresponding target character spacing distance based on the distance between the dot-shaped character contours in the expanded dot-shaped inkjet coding images comprises: Based on the number statistics result of the dot character contours in each of the expansion-processed dot-shaped inkjet coding images, a target expansion-processed dot-shaped inkjet coding image having a maximum number statistics result is determined among the multiple expansion-processed dot-shaped inkjet coding images; In the target expansion processed dot-shaped inkjet coding image, at least two adjacent dot-shaped character contour center points are determined, and based on the distance between the two adjacent dot-shaped character contour center points, the corresponding target character spacing distance is determined.
4. The dot-inking character recognition method according to claim 1, characterized in that: The step of determining connection processing parameters for performing a first connection processing on the internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed based on the target character spacing distance, and performing a first connection processing based on the connection processing parameters to obtain a corresponding first dot-shaped character connection image includes: Based on the predetermined mapping relationship and the target character spacing distance, determining a connection processing parameter for performing a first connection processing on the internal gaps of the dot-shaped characters in the dot-shaped inkjet coding image to be processed, wherein the connection processing parameter is positively correlated with the target character spacing distance; Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed in a first direction to obtain a corresponding first shifted dot-shaped inkjet coding image; Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed in a second direction to obtain a corresponding second shifted dot-shaped inkjet coding image; Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the dot-shaped inkjet coding image to be processed in a third direction to obtain a corresponding third shifted dot-shaped inkjet coding image; Based on the number of pixels represented by the connection processing parameter, pixel shifting processing is performed on the to-be-processed dot-shaped inkjet coding image in a fourth direction to obtain a corresponding fourth shifted dot-shaped inkjet coding image, wherein the first direction, the second direction, the third direction and the fourth direction are different; The first shifted dot-shaped coding image, the second shifted dot-shaped coding image, the third shifted dot-shaped coding image and the fourth shifted dot-shaped coding image are subjected to image fusion processing to obtain corresponding target shifted dot-shaped coding images, and based on the target shifted dot-shaped coding images, a corresponding first dot-shaped character connection image is determined.
5. The dot-inking character recognition method according to any one of claims 1 to 4, characterized in that: The step of performing a second connection process on the internal spaces of the dot-shaped characters in the first dot-shaped character connection image to obtain a corresponding second dot-shaped character connection image includes: Based on a first dilation parameter, the first dotted character connection image is dilated to obtain a corresponding first dilated connection image; and based on a first erosion parameter, the first dilated connection image is eroded to obtain a corresponding first eroded connection image; Based on the first eroded connection image and the first dotted character connection image, determining whether the first eroded connection image satisfies a preset character gap connection condition; When the first eroded connection image satisfies the character gap connection condition, using the first eroded connection image as the corresponding second dot character connection image; When the first eroded connection image does not meet the character gap connection condition, dilate the first eroded connection image based on a second dilation parameter to obtain a corresponding second dilated connection image, and erode the second dilated connection image based on a second erosion parameter to obtain a corresponding second eroded connection image, wherein the second dilation parameter is less than the first dilation parameter; Based on the second eroded connection image and the first dotted character connection image, determining whether the second eroded connection image satisfies the character gap connection condition; When the second eroded connection image satisfies the character gap connection condition, the second eroded connection image is used as the corresponding second dot character connection image.
6. The dot-inking character recognition method according to claim 5, characterized in that: The step of determining whether the first eroded connection image satisfies a preset character gap connection condition based on the first eroded connection image and the first dotted character connection image comprises: Performing image subtraction processing on the first eroded connection image and the first dotted character connection image to obtain a corresponding difference image, wherein the first eroded connection image, the first dotted character connection image and the difference image are all binary images; Counting the pixel points whose pixel values in the first dot-shaped character connection image are equal to a predetermined target value to obtain the corresponding first pixel point quantity; Counting the pixel points whose pixel values in the difference image are equal to the target value to obtain the corresponding second pixel point quantity, wherein the pixel points whose pixel values are equal to the target value are the pixel points belonging to the dot-shaped characters in the corresponding image; Determining a quantity ratio between the second number of pixel points and the first number of pixel points; When the quantity ratio belongs to a predetermined ratio interval, determining that the first eroded connection image satisfies a preset character gap connection condition; When the quantity ratio does not belong to a predetermined ratio interval, it is determined that the first eroded connection image does not meet a preset character gap connection condition.
7. An electronic device, characterized in that: include: Memory for storing computer programs; A processor connected to the memory is used to execute the computer program stored in the memory to implement the dot-inkjet character recognition method described in any one of claims 1 to 6.
