Method, apparatus, computer device, and storage medium for generating pin-printed bills
By adjusting the printing needle point properties of the needle printer, high-resolution needle printing tickets are generated, which solves the problem of low bill resolution in the prior art and improves the recognition accuracy of the OCR recognition model.
Patent Information
- Application Number
- CN202111369536.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-16
- Publication Date
- 2025-06-24
- Estimated Expiration
- 2041-11-16
AI Technical Summary
In the prior art, the resolution of needle-printed bills is low, which leads to the OCR recognition model being unable to fully identify the real information in the bills, which leads to inaccurate recognition results.
By acquiring the first attribute information of the first printing needle point in the needle printer, the second attribute information of the second printing needle point is determined, wherein the second side length is greater than the first side length and the second distance is less than the first distance, thereby generating a needle printing ticket with high resolution.
The resolution of the needle-type printing bill is improved, making the recognition results more accurate and can fully reflect the real information of the bill.
Smart Images

Figure CN114092685B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of dot matrix printers, and particularly to a method, device, computer device, and storage medium for generating dot matrix printed bills. Background Art
[0002] A dot matrix printer, also known as a matrix printer, is a printer that forms a larger image by relying on a matrix combination of a group of pixels. The bill generated through the above mechanism is called a dot matrix printed bill. Enterprises hope to use dot matrix printed bills to construct a training set to train an OCR recognition model so that the trained OCR recognition model can recognize the information in the dot matrix printed bill. However, the premise for training the OCR recognition model is the need for a large number of dot matrix printed bills. However, due to the relatively backward dot matrix printer and the possible privacy-related situations of dot matrix printed bills, the existing number of dot matrix printed bills is small and it is difficult to obtain.
[0003] Based on this, the existing technology generates a large number of dot matrix printed bills by printing bills with a dot matrix printer. However, the inventor has found through research that: due to the fixed size of the printing dots on the dot matrix printer and the fixed distance between the printing dots, the dot matrix printed bills generated by the dot matrix printer may have the problem of insufficiently dense pixel points, that is, the resolution is relatively low. Then, the OCR recognition model trained with dot matrix printed bills with a relatively low resolution cannot completely recognize the true information of the dot matrix printed bill, resulting in inaccurate recognition results.
[0004] Regarding the technical problem of relatively low resolution of dot matrix printed bills in the existing technology, there is currently no effective solution. Summary of the Invention
[0005] The purpose of the present invention is to provide a technical solution for bill printing with high resolution to solve the above problems existing in the existing technology.
[0006] To achieve the above purpose, the present invention provides a method for generating a dot matrix printed bill, including the following steps:
[0007] Obtain first attribute information of a first printing needle point in a dot matrix printer, where the first attribute information includes a first side length of each first printing needle point and a first distance between every two adjacent first printing needle points;
[0008] Determine second attribute information of a second printing needle point according to the first attribute information. In the second attribute information: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance;
[0009] Perform a simulated printing operation on a preset basic bill according to the second attribute information of the second printing needle point to generate a dot matrix printed bill.
[0010] According to the method for generating a pin - printed bill provided by the present invention, the step of determining the second attribute information of the second printing needle points according to the first attribute information includes:
[0011] Obtain a preset basic bill and determine the size of the preset basic bill;
[0012] Generate a constraint condition according to the size of the preset basic bill and the first attribute information, and determine the second attribute information of the second printing needle points according to the constraint condition.
[0013] According to the method for generating a pin - printed bill provided by the present invention, the step of determining the second attribute information of the second printing needle points according to the constraint condition includes:
[0014] Screen the attribute information in each second printing needle point where the second side length is greater than the first side length, the second distance between every two adjacent second printing needle points is less than the first distance, and the size of the preset basic bill can be divided evenly by the sum of the second side length and the second distance;
[0015] Take the attribute information that meets the conditions as the second attribute information of the second printing needle points.
[0016] According to the method for generating a pin - printed bill provided by the present invention, the step of performing a simulated printing operation on the preset basic bill according to the second attribute information of the second printing needle points to generate a pin - printed bill includes:
[0017] Create an occlusion template for setting the pixel values of the preset basic bill according to the second attribute information of the second printing needle points and the size of the preset basic bill;
[0018] Set the pixel values of the preset basic bill according to the occlusion template to obtain an intermediate bill;
[0019] Set the background of the intermediate bill according to a preset background image to generate the pin - printed bill.
[0020] According to the method for generating a pin - printed bill provided by the present invention, the step of creating an occlusion template for setting the pixel values of the preset basic bill according to the second attribute information of the second printing needle points and the size of the preset basic bill includes:
[0021] Create an image with the same size as the preset basic bill and pixel value of 0;
[0022] Divide the image into a plurality of square grids, and the side length of each square grid is the sum of the second side length and the second distance;
[0023] Divide each square grid into four rectangular sub - grids. Among them, with the upper - left corner of the square grid as a reference, the four rectangular sub - grids divided clockwise from the square grid are successively: a first square sub - grid with side lengths all being the second distance, a first rectangular sub - grid with two side lengths all being the second side length and the other two side lengths all being the second distance, a second square sub - grid with side lengths all being the second side length, and a second rectangular sub - grid with two side lengths all being the second distance and the other two side lengths all being the second side length;
[0024] In the image, change the pixel values of each first square sub - grid, each first rectangular sub - grid, and each second rectangular sub - grid to 255 to obtain the occlusion template.
[0025] According to the method for generating a pin - type printed bill provided by the present invention, the step of setting the pixel values of the preset basic bill according to the occlusion template to obtain the intermediate bill includes:
[0026] I (i,j) ′=max(I (i,j) ,M (i,j) )
[0027] where (i,j) is the position of a pixel point, I (i,j) ′ is the pixel value of the pixel point (i,j) in the intermediate bill, I (i,j) is the pixel value of the pixel point (i,j) in the preset basic bill, and M′ is the pixel value of the pixel point (i,j) in the occlusion template.
[0028] According to the method for generating a pin - type printed bill provided by the present invention, the step of setting the background of the intermediate bill according to a preset background picture to generate the pin - type printed bill includes:
[0029] Determine all pixel points in the intermediate bill with pixel values of 255;
[0030] In the intermediate bill, replace the pixel values of the determined pixel points with the pixel values of the corresponding pixel points in the background picture to obtain the pin - type printed bill.
[0031] To achieve the above object, the present invention also provides a device for generating a pin - type printed bill, including:
[0032] A first attribute acquisition unit, adapted to acquire first attribute information of the first printing needle points in a pin - type printer, where the first attribute information includes the first side length of each first printing needle point and the first distance between every two adjacent first printing needle points;
[0033] A second attribute determination unit, applicable to determine second attribute information of second printing needle points according to the first attribute information, wherein in the second attribute information: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance;
[0034] A printing unit, applicable to perform a preset basic bill simulation printing operation according to the second attribute information of the second printing needle points to generate a dot matrix printing bill.
[0035] To achieve the above object, the present invention further provides a computer device, including a memory, a processor, and a computer program stored on the memory and executable on the processor, wherein when the processor executes the computer program, the steps of the above method are implemented.
[0036] To achieve the above object, the present invention further provides a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, the steps of the above method are implemented.
[0037] The present invention determines the constraint conditions of the second printing needle points based on the first attribute information of the first printing needle points. In the second attribute information of the second printing needle points determined based on the constraint conditions, the second side length of each second printing needle point is greater than the first side length of the first printing needle point, and the second distance between every two adjacent second printing needle points is less than the first distance of the first printing needle point. Therefore, the resolution of the dot matrix printing bill generated based on the second attribute information of the second printing needle points is necessarily higher than that of the dot matrix printing bill generated by a dot matrix printer. Description of the Drawings
[0038] Figure 1 It is a flowchart of the first embodiment of the method for generating a dot matrix printing bill of the present invention;
[0039] Figure 2 It is a schematic flowchart of determining the second attribute information in the first embodiment of the present invention;
[0040] Figure 3 It is a schematic flowchart of generating a dot matrix printing bill in the embodiment of the present invention;
[0041] Figure 4 It is a schematic diagram of the program module of the first embodiment of the device for generating a dot matrix printing bill of the present invention;
[0042] Figure 5 It is a schematic diagram of the hardware structure of the first embodiment of the device for generating a dot matrix printing bill of the present invention. Detailed Embodiments
[0043] In order to make the objectives, technical solutions and advantages of the present invention clearer and more understandable, the present invention will be further described in detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present invention and are not used to limit the present invention. All other embodiments obtained by those of ordinary skill in the art based on the embodiments of the present invention without creative efforts shall fall within the protection scope of the present invention.
[0044] The method for generating a dot matrix printed bill provided by the present invention obtains the first attribute information of the first printing dot, and the first attribute information includes the first side length of each first printing dot and the first distance between every two adjacent first printing dots. Then, the second attribute information of the appropriate second printing dot is determined according to the first attribute information, and the constraint condition for screening the second printing dot is formulated through the first attribute information. The constraint condition is that in the second attribute information, the second side length of each second printing dot is greater than the first side length of the first printing dot, and the second distance between every two adjacent second printing dots is less than the first distance of the first printing dot. Finally, the corresponding simulation printing operation is performed on the preset basic bill according to the obtained second attribute information of the second printing dot to generate a dot matrix printed bill. In this embodiment, the constraint condition of the second printing dot is determined based on the first attribute information of the first printing dot. In the second attribute information of the second printing dot determined based on this constraint condition, the second side length of each second printing dot is greater than the first side length of the first printing dot, and the second distance between every two adjacent second printing dots is less than the first distance of the first printing dot. Therefore, the resolution of the dot matrix printed bill generated based on the second attribute information of the second printing dot must be higher than that of the dot matrix printed bill generated by the dot matrix printer. Based on the present application, the technical problem of low resolution of dot matrix printed bills in the prior art is solved.
[0045] Embodiment 1
[0046] Please refer to Figure 1 , this embodiment proposes a method for generating a dot matrix printed bill, and this method may include steps S1 to S3, where:
[0047] Step S1, obtain the first attribute information of the first printing dot in the dot matrix printer, and the first attribute information includes the first side length of each first printing dot and the first distance between every two adjacent first printing dots.
[0048] Since the size and distance of the printing dots of the dot matrix printer are fixed, the dot matrix printed bills generated by the dot matrix printer have the defects of insufficiently dense pixel points and low resolution. When training the OCR recognition model based on these dot matrix printed bills, the final recognition results cannot fully reflect the true information of the bills.
[0049] In order to improve the resolution of the needle - printed bills, the present application makes corresponding adjustments to the printing needle points of a conventional dot - matrix printer. Therefore, obtaining the attribute information of the printing needle points of a conventional dot - matrix printer is a prerequisite for solving the resolution problem. Define the printing needle points of the conventional dot - matrix printer as the first printing needle points, and obtain the first attribute information of the first printing needle points. The first attribute information includes the first side length of each first printing needle point and the first distance between every two adjacent first printing needle points.
[0050] Step S2: Determine the second attribute information of the second printing needle points according to the first attribute information. In the second attribute information: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance.
[0051] After obtaining the first attribute information of the first printing needle points, since the resolution of the bills printed with the current first attribute information is low and cannot be accurately scanned by the recognition model, it is necessary to make corresponding adjustments to the first attribute information, and then determine the second attribute information of the second printing needle points. The resolution of the bills printed by the second printing needle points is relatively high and can meet the scanning conditions of the recognition model. Among them, the adjustment process follows the following constraint conditions: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance.
[0052] Figure 2 It is a schematic flowchart for determining the second attribute information in the first embodiment of the present invention. As Figure 2 shown, step S2 includes steps S21 to S22, where:
[0053] Step S21: Obtain a preset basic bill and determine the size of the preset basic bill;
[0054] Step S22: Determine the second attribute information of the second printing needle points according to the size of the preset basic bill and the first attribute information;
[0055] Among them, in the second attribute information: the second side length of each second printing needle point is greater than the first side length, the second distance between every two adjacent second printing needle points is less than the first distance, and the size of the preset basic bill can be divided evenly by the sum of the second side length and the second distance.
[0056] It should be noted that the training premise of the OCR recognition model requires a large number of dot matrix printed bills. However, due to the relative backwardness of dot matrix printers and the possibility that dot matrix printed bills may involve privacy, the existing dot matrix printed bills are few in number and difficult to obtain. Based on this, the prior art generates a large number of dot matrix printed bills by constructing a data amplification method for a dot matrix printed font library. However, the inventors have found that the construction of a dot matrix printed font library requires the design of a cumbersome running program, and there are time-consuming and labor-intensive problems when relying on the dot matrix printed font library to train the OCR model. Therefore, this embodiment simulates the working principle of a dot matrix printer by computer, which can not only generate dot matrix printed bills in batches, but also save the manpower and material costs of constructing a dot matrix font library of different printing fonts. At the same time, due to the improvement of the attribute information of the printing pin point, the obtained dot matrix printed bills also have the characteristics of high resolution.
[0057] Specifically, this embodiment first obtains a preset basic ticket, which refers to a printed ticket image of a conventional printing device, wherein the preset basic ticket can be obtained by directly importing it with a digital camera (including taking photos with film for copying), searching a photography website, obtaining a slide show, obtaining a picture material CD or network disk, obtaining it from an Email forum or blog, taking a screenshot using a browser or Sogou Pinyin input with a screenshot function to upload the picture, or drawing the picture yourself using the drawing software Photoshop.
[0058] After obtaining a preset basic bill for generating a dot matrix printing bill, the size corresponding to the preset basic bill is determined. The preset basic bill includes a text area and a non-text area, the pixel value of the text area is 0, and the pixel value of the non-text area is 255.
[0059] The method of obtaining the preset basic bills in this embodiment is more convenient than the method of constructing a dot matrix font library. There is no need to design a corresponding cumbersome programming language for each printing font. At the same time, the way to obtain the preset basic bills is not limited to a single search path or means, which makes the process of searching for the preset basic bills faster and the preset basic bill sample data richer.
[0060] After obtaining the size of the preset basic bill and the first attribute information of the first printing pin point, a constraint condition is generated. The constraint condition is used to screen out the second attribute information of the second printing pin point suitable for scanning by the OCR recognition model. Specifically, the second side length of each second printing pin point is greater than the first side length, the second distance between every two adjacent second printing pin points is less than the first distance, and the size of the preset basic bill can be divided by the sum of the second side length and the second distance. The attribute information that meets the constraint condition is used as the second attribute information of the second printing pin point.
[0061] In this embodiment, by generating constraint conditions based on the size of the preset basic bill and the first attribute information of the first printing pin point, the second attribute information of the second printing pin point that meets the scanning conditions of the recognition model is obtained. The entire data table processing process is simple and fast. Compared with the method of constructing a dot matrix font library, it can effectively control the size and distance of the printing pin points, generate a dot matrix printing bill with higher resolution. When scanned by the convolutional neural network of the OCR recognition model, the real information of the generated dot matrix printing bill can be accurately scanned, thereby improving the effective recognition rate of the OCR recognition model.
[0062] Step S3: Perform a simulated printing operation on the preset basic bill according to the second attribute information of the second printing pin point to generate a dot matrix printing bill.
[0063] The simulated printing operation specifically means generating a corresponding algorithm based on the working principle of a dot matrix printer to obtain a bill with a dot matrix printing effect. After determining the second attribute information of the second printing pin point, substitute the second attribute information of the second printing pin point into the generation algorithm to perform a simulated printing operation on the preset basic bill and generate a dot matrix printing bill.
[0064] Figure 3 It is a schematic flowchart of generating a dot matrix printing bill in an embodiment of the present invention. As Figure 3 shown, step S3 includes steps S31 to S33, where:
[0065] Step S31: Create an occlusion template for setting the pixel values of the preset basic bill according to the second attribute information of the second printing pin point and the size of the preset basic bill;
[0066] Step S32: Set the pixel values of the preset basic bill according to the occlusion template to obtain an intermediate bill;
[0067] Step S33: Set the background of the intermediate bill according to a preset background picture to generate the dot matrix printing bill.
[0068] After preparing the attribute information of the second printing pin point, start the simulated printing operation. First, create an occlusion template for setting the pixel values of the preset basic bill, then perform a fusion process on the occlusion template and the preset basic bill to generate an intermediate bill, and finally obtain a preset background picture and perform a superimposing operation on the intermediate bill to generate a dot matrix printing bill.
[0069] Optionally, step S31 includes steps A1 to A4, where:
[0070] Step A1: Create an image with the same size as the preset basic bill and pixel value of 0;
[0071] Step A2: Divide the image into multiple square grids, where the side length of each square grid is the sum of the second side length and the second distance;
[0072] Step A3: Divide each square grid into four rectangular sub - grids. Among them, with the upper - left corner of the square grid as the reference, in a clockwise direction, the four rectangular sub - grids divided from the square grid are successively: a first square sub - grid with side lengths both equal to the second distance, two first rectangular sub - grids with two side lengths both equal to the second side length and the other two side lengths both equal to the second distance, a second square sub - grid with side lengths both equal to the second side length, and two second rectangular sub - grids with two side lengths both equal to the second distance and the other two side lengths both equal to the second side length;
[0073] Step A4: In the image, change the pixel values of each first square sub - grid, each first rectangular sub - grid, and each second rectangular sub - grid to 255 to obtain the occlusion template.
[0074] Generally, during the printing process, an occlusion template needs to be created to set the pixel values of a preset basic bill. After obtaining the size of the preset basic bill, an image with the same size is created, and the initial pixel values of this image are set to 0. The attribute information screened using the constraint conditions is used as the second attribute information corresponding to the second printing pinpoints of this image. The second attribute information includes the second side length and the second distance of the second printing pinpoints. The image is evenly divided in units of the sum of the second side length and the second distance to generate multiple grids of the same size. Then, with the vertex of the upper - left corner of each grid as the reference, each grid is divided to the right and down in units of the second distance. Each grid is divided into four rectangular sub - grids, which are successively, in a clockwise direction: a first square sub - grid with side lengths both equal to the second distance, two first rectangular sub - grids with two side lengths both equal to the second side length and the other two side lengths both equal to the second distance, a second square sub - grid with side lengths both equal to the second side length, and two second rectangular sub - grids with two side lengths both equal to the second distance and the other two side lengths both equal to the second side length. Then, change the pixel values of each first square sub - grid, each first rectangular sub - grid, and each second rectangular sub - grid to 255, and the occlusion template is created.
[0075] Optionally, step S32 includes: I (i,j) ′ = max(I (i,j) , M (i,j) )
[0076] where (i, j) is the position of a pixel point, I (i,j) ′ is the pixel value of the pixel point (i, j) in the intermediate bill, I (i,j) is the pixel value of the pixel point (i, j) in the preset basic bill, and M′ is the pixel value of the pixel point (i, j) in the occlusion template.
[0077] After the occlusion template is created, it needs to be fused with the preset basic bill. The pixel values of the same pixel points of the preset basic bill and the occlusion template are obtained according to the preset formula and compared, and the larger pixel value of the same pixel point is determined as the pixel value of the generated intermediate bill. After all pixel points are compared, the intermediate bill is generated.
[0078] Optionally, step S33 includes steps B1 to B2, where:
[0079] Step B1, determining all pixel points with a pixel value of 255 in the intermediate bill;
[0080] Step B2, in the intermediate bill, replacing the pixel values of the determined pixel points with the pixel values of the corresponding pixel points in the background picture to obtain the dot matrix printed bill.
[0081] Generally, for different scenarios, the forms of dot matrix printed bills will be different. Currently, the generated fused bill is in the form of a white background with black characters, which cannot meet personalized needs. Therefore, after obtaining the preset background picture, the intermediate bill needs to be overlaid to generate dot matrix printed bills with different effects.
[0082] In addition, the training process of the OCR recognition model is divided into two stages: data loading and model training. Among them, the data loading stage is executed on the CPU, and the model training stage is executed on the CPU. Only when all the dot matrix printed bill samples in the data loading stage are completely prepared can the model training stage start. The entire training process is serial processing. During the data loading stage, the CPU is always in a waiting state, wasting system resources. In this embodiment, a simple and convenient algorithm is used to generate dot matrix printed bills. This method has low complexity. The entire data loading process only takes 0.1 s and can be used in parallel in the model training stage. There is no need to pre-generate a training set of dot matrix printed bills, saving storage space and not wasting system resources.
[0083] Please continue to refer to Figure 4 , which shows a device for generating a dot matrix printed bill. In this embodiment, the device 40 for generating a dot matrix printed bill may include or be divided into one or more program modules. One or more program modules are stored in a storage medium and executed by one or more processors to complete the present invention and implement the above method for generating a dot matrix printed bill. The program modules referred to in the present invention refer to a series of computer program instruction segments that can complete specific functions and are more suitable for describing the execution process of the device 40 for generating a dot matrix printed bill in the storage medium than the program itself. The following description will specifically introduce the functions of each program module in this embodiment:
[0084] The first attribute acquisition unit 41 is adapted to acquire first attribute information of the first printing needle points in a dot matrix printer, where the first attribute information includes the first side length of each first printing needle point and the first distance between every two adjacent first printing needle points;
[0085] The second attribute determination unit 42 is adapted to determine second attribute information of second printing needle points according to the first attribute information. In the second attribute information: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance;
[0086] The printing unit 43 is adapted to perform a preset basic bill simulation printing operation according to the second attribute information of the second printing needle points to generate a dot matrix printed bill.
[0087] This embodiment further provides a computer device, such as a smart phone, a tablet computer, a notebook computer, a desktop computer, a rack server, a blade server, a tower server or a cabinet server (including an independent server, or a server cluster composed of multiple servers) that can execute programs. The computer device 50 of this embodiment at least includes, but is not limited to: a memory 51 and a processor 52 that can communicate with each other through a system bus, as Figure 5 shown. It should be noted that Figure 5 only the computer device 50 with components 51-52 is shown, but it should be understood that it is not required to implement all the shown components, and more or fewer components can be alternatively implemented.
[0088] In this embodiment, the memory 51 (i.e., the readable storage medium) includes flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, etc. In some embodiments, the memory 51 may be an internal storage unit of the computer device 50, such as the hard disk or memory of the computer device 50. In other embodiments, the memory 51 may also be an external storage device of the computer device 50, such as a plug-in hard disk, Smart Media Card (SMC), Secure Digital (SD) card, Flash Card, etc. equipped on the computer device 50. Of course, the memory 51 may also include both the internal storage unit and the external storage device of the computer device 50. In this embodiment, the memory 51 is generally used to store the operating system installed on the computer device 50 and various application software, such as the program code of the pin-printing ticket generation device 40 in Embodiment 1. In addition, the memory 51 may also be used to temporarily store various types of data that have been output or will be output.
[0089] In some embodiments, the processor 52 may be a central processing unit (CPU), controller, microcontroller, microprocessor, or other data processing chip. The processor 52 is generally used to control the overall operation of the computer device 50. In this embodiment, the processor 52 is used to run the program code stored in the memory 51 or process data, such as running the pin-printing ticket generation device 40 to implement the pin-printing ticket generation method in Embodiment 1.
[0090] This embodiment also provides a computer-readable storage medium, such as flash memory, hard disk, multimedia card, card-type memory (e.g., SD or DX memory, etc.), random access memory (RAM), static random access memory (SRAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), programmable read-only memory (PROM), magnetic memory, magnetic disk, optical disk, server, App application mall, etc., on which a computer program is stored, and when the program is executed by the processor, the corresponding functions are implemented. The computer-readable storage medium of this embodiment is used to store the pin-printing ticket generation device 40, and when executed by the processor, the pin-printing ticket generation method in Embodiment 1 is implemented.
[0091] The serial numbers of the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.
[0092] Any process or method description depicted in a flowchart or otherwise described herein can be understood to represent a module, segment, or portion of code that includes one or more executable instructions for implementing a specific logical function or process. The scope of the preferred embodiments of the present invention includes additional implementations where functions may be performed in a substantially simultaneous manner or in a reverse order according to the functions involved, rather than in the order shown or discussed, which should be understood by those skilled in the art to which the embodiments of the present invention pertain.
[0093] Those of ordinary skill in the art can understand that all or part of the steps carried out in the methods of the above embodiments can be completed by instructing relevant hardware through a program. The program can be stored in a computer-readable medium. When the program is executed, it includes one or a combination of the steps of the method embodiments.
[0094] In the description of this specification, the description with reference to terms such as "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials, or characteristics described in connection with the embodiment or example are included in at least one embodiment or example of the present invention. In this specification, the schematic representations of the above terms do not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials, or characteristics described can be combined in a suitable manner in any one or more embodiments or examples.
[0095] Through the description of the above embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus a necessary general hardware platform. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation.
[0096] The above are only the preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or equivalent process transformation made by using the content of the specification and drawings of the present invention, or directly or indirectly applied in other related technical fields, are equally included in the patent protection scope of the present invention.
Claims
1. A method for generating a pin-printed bill, characterized in that, Including the following steps: Obtain first attribute information of the first printing needle points in a dot matrix printer, where the first attribute information includes the first side length of each first printing needle point and the first distance between every two adjacent first printing needle points; Determine second attribute information of second printing needle points according to the first attribute information. In the second attribute information: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance; Perform a preset basic bill simulation printing operation according to the second attribute information of the second printing needle points to generate a dot matrix printed bill; The step of performing a preset basic bill simulation printing operation according to the second attribute information of the second printing needle points to generate a dot matrix printed bill includes: Create an occlusion template for setting pixel values of the preset basic bill according to the second attribute information of the second printing needle points and the size of the preset basic bill; Set the pixel values of the preset basic bill according to the occlusion template to obtain an intermediate bill; Set the background of the intermediate bill according to a preset background picture to generate the dot matrix printed bill; The step of creating an occlusion template for setting pixel values of the preset basic bill according to the second attribute information of the second printing needle points and the size of the preset basic bill includes: Create an image with the same size as the preset basic bill and pixel value of 0; Divide the image into a plurality of square grids, and the side length of each square grid is the sum of the second side length and the second distance; Divide each square grid into four rectangular sub-grids. Among them, based on the upper left corner of the square grid, in a clockwise direction, the four rectangular sub-grids divided from the square grid are: a first square sub-grid with side lengths both being the second distance, two first rectangular sub-grids with two side lengths both being the second side length and the other two side lengths both being the second distance, a second square sub-grid with side lengths both being the second side length, and two second rectangular sub-grids with two side lengths both being the second distance and the other two side lengths both being the second side length; In the image, change the pixel values of each first square sub-grid, each first rectangular sub-grid, and each second rectangular sub-grid to 255 to obtain the occlusion template.
2. The method for generating a pin-printed bill according to claim 1, characterized in that, The step of determining second attribute information of second printing needle points according to the first attribute information includes: Obtain a preset basic bill and determine the size of the preset basic bill; Generate a constraint condition according to the size of the preset basic bill and the first attribute information, and determine the second attribute information of the second printing needle points according to the constraint condition.
3. The method for generating a pin-printed bill according to claim 2, wherein The step of determining the second attribute information of the second printing needle points according to the constraint condition includes: Screen the attribute information in which the second side length of each second printing needle point is greater than the first side length, the second distance between every two adjacent second printing needle points is less than the first distance, and the size of the preset basic bill can be divided evenly by the sum of the second side length and the second distance; Use the qualified attribute information as the second attribute information of the second printing needle points.
4. The method for generating a pin-printed bill according to claim 1, wherein The step of setting the pixel values of the preset basic bill according to the occlusion template to obtain an intermediate bill includes: wherein, is the position of a pixel point, is the pixel value of the pixel point in the intermediate bill, is the pixel value of the pixel point in the preset basic bill, is the pixel value of the pixel point in the occlusion template.
5. The method for generating a pin-printed bill according to claim 1, characterized in that, The step of setting the background of the intermediate bill according to a preset background image to generate the pin - type printed bill includes: Determine the pixel points in the intermediate bill whose pixel values are 255; In the intermediate bill, replace the pixel values of the determined pixel points with the pixel values of the corresponding pixel points in the background image to obtain the pin - type printed bill.
6. A generating device for pin - printed bills, characterized in that, It includes: A first attribute acquisition unit, applicable to acquire first attribute information of the first printing needle points in a pin - type printer, where the first attribute information includes the first side length of each first printing needle point and the first distance between every two adjacent first printing needle points; A second attribute determination unit, applicable to determine second attribute information of second printing needle points according to the first attribute information, where in the second attribute information: the second side length of each second printing needle point is greater than the first side length, and the second distance between every two adjacent second printing needle points is less than the first distance; A printing unit, applicable to perform a simulation printing operation on a preset basic bill according to the second attribute information of the second printing needle points to generate a pin - type printed bill; The printing unit is further applicable to create an occlusion template for setting the pixel values of the preset basic bill according to the second attribute information of the second printing needle points and the size of the preset basic bill; Set the pixel values of the preset basic bill according to the occlusion template to obtain an intermediate bill; Set the background of the intermediate bill according to a preset background image to generate the pin - type printed bill; The printing unit is further applicable to create an image with the same size as the preset basic bill and pixel values of 0; divide the image into a plurality of square grids, and the side length of each square grid is the sum of the second side length and the second distance; Divide each square grid into four rectangular sub - grids. Among them, with the upper - left corner of the square grid as the reference, in the clockwise direction, the four rectangular sub - grids divided from the square grid are: a first square sub - grid with side lengths both being the second distance, two first rectangular sub - grids with two side lengths both being the second side length and the other two side lengths both being the second distance, a second square sub - grid with side lengths both being the second side length, and two second rectangular sub - grids with two side lengths both being the second distance and the other two side lengths both being the second side length; in the image, change the pixel values of each first square sub - grid, each first rectangular sub - grid, and each second rectangular sub - grid to 255 to obtain the occlusion template.
7. A computer device, comprising a memory, a processor, and a computer program stored on the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the steps of the method according to any one of claims 1 to 5.
8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the steps of the method according to any one of claims 1 to 5.
Citation Information
Patent Citations
Method and equipment for printing images
CN101518982A
Method for printing two-dimensional bar code on multi-copy bill by stylus printer
CN102806776A