Handwritten chess record input method and device
The interactive area growth algorithm is used to segment the handwritten chess score images, and each table area is processed using the stack module, which solves the problem of difficult to identify multiple handwritten chess score tables in the prior art, and realizes efficient handwritten chess score entry.
Patent Information
- Application Number
- CN202111602980.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-12-24
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2041-12-24
AI Technical Summary
It is difficult for the prior art to segment, sort and identify multiple handwritten chess tables in handwritten chess pictures.
The interactive area growth algorithm is used to segment the handwritten chess score images in an orderly manner, generate multiple independent table areas, and extract and process each table area in sequence through the stack module to obtain its character information.
The orderly segmentation and separate recognition of multiple handwritten chess score tables is realized, which improves the efficiency and accuracy of handwritten chess score entry.
Smart Images

Figure CN114299526B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the technical field of image data processing, and in particular to a method and device for inputting handwritten chess records. Background Art
[0002] In some international chess competitions, the on-site games are recorded by handwriting chess records on pre-prepared chess record tables. The handwritten chess records need to be uploaded later through image recognition technology. However, if the handwritten chess record image to be recognized contains multiple handwritten chess record tables, it is difficult to segment, sort and separately recognize the multiple handwritten chess record tables in the handwritten chess record image. Summary of the invention
[0003] In order to at least to some extent overcome the problem in the related art that it is difficult to segment, sort and individually identify multiple handwritten chess game tables in a handwritten chess game image, the present application provides a handwritten chess game entry method and device.
[0004] The scheme of this application is as follows:
[0005] According to a first aspect of an embodiment of the present application, a method for inputting handwritten chess records is provided, comprising:
[0006] Get handwritten chess game images;
[0007] Based on an interactive region growing algorithm, the handwritten chess record image is orderly divided into a plurality of independent table regions; each of the independent table regions corresponds to a handwritten chess record table;
[0008] Pushing each of the independent table areas obtained by segmentation into a first stack;
[0009] extracting the independent table areas from the first stack in sequence and acquiring character information corresponding to the independent table areas;
[0010] The character information corresponding to each of the independent table areas is marked and saved.
[0011] Preferably, in an achievable manner of the present application, the method of orderly dividing the handwritten chess game image into a plurality of independent table regions based on an interactive region growing algorithm includes:
[0012] Acquire the seed points entered by the user in the handwritten chess game image, or generate seed points in the handwritten chess game image based on a feature point detection algorithm;
[0013] Push all seed points into the second stack;
[0014] Taking the grayscale value of the initial position of the seed point as the initial grayscale value of the seed point;
[0015] Acquire the size of the handwritten chess record table, and use the size of the handwritten chess record table as an edge threshold;
[0016] Taking the initial grayscale value and the edge threshold as constraint conditions, traversing the seed points in the queue in sequence according to the compression order of the second stack, so that each seed point performs regional growth diffusion;
[0017] When all the seed points in the queue are traversed, the coordinates of the vertex positions of the fusion area obtained by performing regional growth diffusion on all the seed points are obtained as the range of the independent table area;
[0018] Each independent table area in the handwritten chess record image is segmented.
[0019] Preferably, in an implementable manner of the present application, the step of obtaining character information corresponding to the independent table area includes:
[0020] Extracting outline information of each cell in the independent table area;
[0021] Obtaining the centroid coordinates, length and width of the cell according to the outline information of the cell;
[0022] sorting the cells in the independent table area according to the centroid coordinates of the cells;
[0023] Segment the cells in the independent table area according to the centroid coordinates, length and width of the cells;
[0024] The images in each cell are sequentially input into a pre-trained image character string recognition model to obtain character information corresponding to the image in each cell.
[0025] Preferably, in an achievable manner of the present application, the step of causing each of the seed points to perform regional growth diffusion includes:
[0026] Each of the seed points is allowed to perform regional growth diffusion within an 8-neighborhood range.
[0027] Preferably, in an achievable manner of the present application, the step of causing each of the seed points to perform regional growth diffusion further includes:
[0028] Each pixel to be fused in the neighborhood of the seed point 8 is given two probes, and the probes are used to explore the lengths in the horizontal direction and the vertical direction respectively;
[0029] The empirical threshold assigned by the probe is the edge threshold.
[0030] Preferably, in an achievable manner of the present application, after obtaining the handwritten chess record image, the method further includes:
[0031] grayscale the handwritten chess record image;
[0032] Based on the minimum rectangle and affine matrix algorithm, correction parameters are obtained and correction processing is performed on the handwritten chess record image after grayscale processing to align the row and column spatial positions of the table in the handwritten chess record image.
[0033] Preferably, in an achievable manner of the present application, extracting the outline information of each cell in the independent table area includes:
[0034] Reverse mapping is performed on the independent table area, and contour information of each cell in the reverse-mapped independent table area is extracted.
[0035] Preferably, in an implementable manner of the present application, sorting the cells in the independent table area according to the centroid coordinates of the cells includes:
[0036] The cells in the independent table area are sorted in the order of rows first and columns later according to the centroid coordinates of the cells.
[0037] Preferably, in an achievable manner of the present application, after sorting the cells in the independent table area according to the centroid coordinates of the cells, the method further includes:
[0038] A row and column error threshold is set, and whether the adjacent cells are in the same row or column is determined based on the row and column error threshold.
[0039] According to a second aspect of an embodiment of the present application, a handwritten chess record recording device is provided, comprising:
[0040] Processor and memory;
[0041] The processor is connected to the memory via a communication bus;
[0042] Wherein, the processor is used to call and execute the program stored in the memory;
[0043] The memory is used to store a program, and the program is at least used to execute a method for recording handwritten chess records as described in any one of the above items.
[0044] The technical solution provided by the present application may include the following beneficial effects: The method for entering handwritten chess records in the present application includes: obtaining a handwritten chess record image; orderly dividing the handwritten chess record image into multiple independent table areas based on an interactive region growing algorithm, pressing each independent table area obtained by division into a first stack, extracting the independent table areas from the first stack in turn and obtaining the character information corresponding to the independent table areas, and marking and saving the character information corresponding to each independent table area. Since each independent table area corresponds to a handwritten chess record table, in the present application, when a handwritten chess record image to be identified contains multiple handwritten chess record tables, the multiple handwritten chess record tables are orderly divided and identified separately in turn based on an interactive region growing algorithm. Since the handwritten chess record tables are orderly divided, the identified character information can be subsequently marked according to the corresponding handwritten chess record tables and saved.
[0045] It should be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present application. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present application and, together with the description, serve to explain the principles of the present application.
[0047] Figure 1 This is a flowchart of a method for inputting handwritten chess records provided by an embodiment of the present application;
[0048] Figure 2 It is a partial schematic diagram of a handwritten chess record table in a handwritten chess record input method provided in one embodiment of the present application;
[0049] Figure 3 It is a structural diagram of a handwritten chess record input device provided by an embodiment of the present application.
[0050] Reference numerals: processor-21; memory-22. DETAILED DESCRIPTION
[0051] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, unless otherwise indicated, the same numbers in different drawings represent the same or similar elements. The implementations described in the following exemplary embodiments do not represent all implementations consistent with the present application. Instead, they are merely examples of devices and methods consistent with some aspects of the present application as detailed in the appended claims.
[0052] A method for inputting handwritten chess records, referring to Figure 1 ,include:
[0053] S11: Obtaining a handwritten chess record image;
[0054] The handwritten chess record image may include multiple handwritten chess record tables. Some schematic diagrams of the handwritten chess record tables are as follows: Figure 2 As shown, some cells contain handwritten character information.
[0055] S12: Separate the handwritten chess record image into multiple independent table regions in an orderly manner based on an interactive region growing algorithm; each independent table region corresponds to a handwritten chess record table;
[0056] include:
[0057] Obtaining seed points entered by the user in the handwritten chess game image, or generating seed points in the handwritten chess game image based on a feature point detection algorithm;
[0058] Push all seed points into the second stack;
[0059] The grayscale value of the initial position of the seed point is used as the initial grayscale value of the seed point;
[0060] Obtain the size of the handwritten chess record table, and use the size of the handwritten chess record table as the edge threshold;
[0061] Taking the initial gray value and edge threshold as constraints, various sub-points in the queue are traversed in sequence according to the compression order of the second stack, so that various sub-points perform regional growth diffusion;
[0062] When all seed points in the queue are traversed, the coordinates of the vertex positions of the fusion area obtained by performing regional growth diffusion on all seed points are obtained as the range of the independent table area;
[0063] Segment each independent table area in the handwritten chess record image.
[0064] Among them, various sub-points are made to perform regional growth diffusion, including:
[0065] Make various sub-points perform regional growth diffusion within the range of 8 neighborhoods;
[0066] Each pixel to be fused in the 8-neighborhood of the seed point is given two probes, which are used to explore the length in the horizontal and vertical directions respectively;
[0067] The empirical threshold assigned by the probe is the edge threshold.
[0068] In this embodiment, the handwritten chess record image is sequentially segmented into a plurality of independent table regions based on an interactive region growing algorithm, and interactive setting of seed points is first performed.
[0069] The interactive setting of seed points can obtain the seed points entered by the user in the handwritten chess image. In this way, the user needs to click several points in the handwritten chess image through input tools such as a mouse or a stylus. These points are the seed points. In order to reduce the complexity of the user interaction process, only one point needs to be set in each independent table area.
[0070] The interactive setting of seed points can also generate seed points in handwritten chess images based on feature point detection algorithms, making the seed point generation stage fully automated.
[0071] Preferably, in this embodiment, each sub-point is assigned a radius of 1 pixel and a code, namely, a seed point n (n=1, 2, 3, ...).
[0072] Create a second stack containing all seed points, push all seed points into the second stack, and traverse each seed point in turn according to the order in which the stack is pushed.
[0073] The grayscale value of the initial position of the seed point is used as the initial grayscale value of the seed point. Then, two probes are assigned to each pixel to be fused in its 8-neighborhood to explore the length in the horizontal and vertical directions respectively. Here, the two probes are assigned empirical thresholds T = [Tx, Ty] based on experience;
[0074] The empirical threshold T is a preset empirical constant, which is generally set to the size of the handwritten chess record paper, that is, the size of a handwritten chess record table.
[0075] Then, the initial gray value and edge threshold are used as constraints to make various sub-points perform regional growth diffusion, and the classic regional growth diffusion is performed in the neighborhood range of the seed point 8. When the difference between the gray value of the pixel to be fused in the neighborhood and the gray value of the seed point is less than the preset threshold, and when the probe of the point (pixel to be fused) detects that the distance Tx and Ty in the horizontal and vertical directions are less than the edge threshold T, it is considered that the point to be fused is still in an independent table area. At this time, the pixel to be fused is given the same code as the current seed point, otherwise the fused pixel is removed.
[0076] S13: Pushing each of the separated independent table areas into the first stack;
[0077] The vertex information of each independent table area obtained by the above segmentation is pushed into the created first stack, and the information of one independent table area is taken out each time for subsequent segmentation.
[0078] The stack has the characteristic of access order, which can ensure that the "independent table area" can save the table content in order according to the order of clicks during user interaction, so that the chess game information of the chess record can be determined, thereby providing effective game data.
[0079] S14: extracting independent table areas from the first stack in sequence and obtaining character information corresponding to the independent table areas;
[0080] Get the character information corresponding to the independent table area, including:
[0081] Extract the outline information of each cell in an independent table area;
[0082] Obtain the centroid coordinates, length and width of the cell according to the cell outline information;
[0083] Sort cells in an independent table area according to the coordinates of the cell's centroid;
[0084] Split the cells in the independent table area according to the centroid coordinates, length and width of the cells;
[0085] The images in each cell are sequentially input into a pre-trained image character string recognition model to obtain character information corresponding to the image in each cell.
[0086] In this embodiment, each unit cell contains a handwritten character record of flag position information generated during a game, and segmentation is performed to extract handwritten character images to facilitate subsequent handwritten character recognition.
[0087] Preferably, extracting the outline information of each cell in the independent table area includes:
[0088] Reverse mapping is performed on the independent table area, and contour information of each cell in the reverse mapped independent table area is extracted.
[0089] After reverse mapping, the cell border is white and the other areas are black, which is convenient for calculation using contour extraction algorithm and can ensure higher segmentation accuracy.
[0090] Sort cells in an independent table area according to the centroid coordinates of the cells, including:
[0091] Sorts cells in an independent table area according to the centroid coordinates of the cells, in the order of rows first and columns later.
[0092] In this embodiment, considering that there may still be a problem of tilt error after correction, a row and column error threshold is further set, and whether adjacent cells are in the same row or column is determined based on the row and column error threshold.
[0093] Finally, the images in each cell are sequentially input into the pre-trained image string recognition model to obtain the character information corresponding to the image in each cell. Since the images in each cell are input sequentially, the obtained character information is also arranged in order. In this embodiment, the cells are quickly and effectively sorted in order, and the order information of the flags in each step of the chess game can be identified.
[0094] Moreover, in this embodiment, only the image in a single cell needs to be recognized for text, which is more convenient and efficient than the prior art that directly recognizes the entire chess record image, and has lower requirements on the recognition model.
[0095] S15: Mark and save the character information corresponding to each independent table area.
[0096] The handwritten chess record entry method in this embodiment includes: obtaining a handwritten chess record image; dividing the handwritten chess record image into multiple independent table areas in an orderly manner based on an interactive region growing algorithm, pressing each independent table area obtained by division into a first stack, extracting the independent table areas from the first stack in turn and obtaining the character information corresponding to the independent table areas, and marking and saving the character information corresponding to each independent table area. Since each independent table area corresponds to a handwritten chess record table, in this embodiment, when the handwritten chess record image to be identified contains multiple handwritten chess record tables, the multiple handwritten chess record tables are orderly divided based on the interactive region growing algorithm and identified separately in turn. Since the handwritten chess record tables are orderly divided, the identified character information can be subsequently marked according to the corresponding handwritten chess record tables and saved. .
[0097] In some embodiments, the method for recording handwritten chess records, after obtaining the handwritten chess record image, the method further includes:
[0098] Grayscale the handwritten chess game image;
[0099] Based on the minimum rectangle and affine matrix algorithm, the correction parameters are obtained and the handwritten chess record image after grayscale processing is corrected to align the row and column spatial positions of the table in the handwritten chess record image.
[0100] In this embodiment, the handwritten chess record image is firstly grayscaled and binarized. On this basis, the minimum rectangular frame of the foreground pixel is obtained, and an angle returned by the function of the minimum rectangle is obtained. Then, this angle is used to obtain a rotated rectangle parameter group (rectangle length, width, centroid and rotation angle), and then the affine transformation parameters (rotation center, rotation angle, scaling ratio) are calculated according to the rectangle parameter group to correct the image. Thus, the row and column spatial positions of the table in the handwritten chess record image are aligned.
[0101] A handwritten chess record input device, referring to Figure 3 ,include:
[0102] Processor 21 and memory 22;
[0103] The processor 21 is connected to the memory 22 via a communication bus;
[0104] The processor 21 is used to call and execute the program stored in the memory;
[0105] The memory 22 is used to store a program, and the program is used to execute at least one of the methods for recording handwritten chess records in any of the above embodiments.
[0106] A device for recording handwritten chess records, comprising:
[0107] Image acquisition module, used to obtain handwritten chess game images;
[0108] An interactive region growing module is used to sequentially divide the handwritten chess record image into multiple independent table regions based on an interactive region growing algorithm; each independent table region corresponds to a handwritten chess record table;
[0109] A stack module, used for pressing each independent table area obtained by segmentation into a first stack;
[0110] A cell segmentation and sequence extraction module, used to extract independent table areas from the first stack in sequence and obtain character information corresponding to the independent table areas;
[0111] A handwritten information recognition and input module is used to mark and save the character information corresponding to each independent table area;
[0112] The image correction module is used to grayscale the handwritten chess record image; based on the minimum rectangle and affine matrix algorithm, the correction parameters are obtained and the handwritten chess record image after grayscale processing is corrected to align the row and column spatial positions of the table in the handwritten chess record image.
[0113] It can be understood that the same or similar parts of the above embodiments can be referenced to each other, and the contents not described in detail in some embodiments can refer to the same or similar contents in other embodiments.
[0114] It should be noted that, in the description of this application, the terms "first", "second", etc. are only used for descriptive purposes and cannot be understood as indicating or implying relative importance. In addition, in the description of this application, unless otherwise specified, the meaning of "plurality" refers to at least two.
[0115] Any process or method description in a flowchart or otherwise described herein may be understood to represent a module, segment or portion of code that includes one or more executable instructions for implementing the steps of a specific logical function or process, and the scope of the preferred embodiments of the present application includes alternative implementations in which functions may not be performed in the order shown or discussed, including performing functions in a substantially simultaneous manner or in the reverse order depending on the functions involved, which should be understood by technicians in the technical field to which the embodiments of the present application belong.
[0116] It should be understood that the various parts of the present application can be implemented by hardware, software, firmware or a combination thereof. In the above-mentioned embodiments, multiple steps or methods can be implemented by software or firmware stored in a memory and executed by a suitable instruction execution system. For example, if implemented by hardware, as in another embodiment, it can be implemented by any one of the following technologies known in the art or their combination: a discrete logic circuit having a logic gate circuit for implementing a logic function for a data signal, a dedicated integrated circuit having a suitable combination of logic gate circuits, a programmable gate array (PGA), a field programmable gate array (FPGA), etc.
[0117] A person skilled in the art may understand that all or part of the steps in the method for implementing the above-mentioned embodiment may be completed by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, which, when executed, includes one or a combination of the steps of the method embodiment.
[0118] In addition, each functional unit in each embodiment of the present application may be integrated into a processing module, or each unit may exist physically separately, or two or more units may be integrated into one module. The above-mentioned integrated module may be implemented in the form of hardware or in the form of a software functional module. If the integrated module is implemented in the form of a software functional module and sold or used as an independent product, it may also be stored in a computer-readable storage medium.
[0119] The storage medium mentioned above can be a read-only memory, a magnetic disk or an optical disk, etc.
[0120] In the description of this specification, the description with reference to the terms "one embodiment", "some embodiments", "example", "specific example", or "some examples" means that the specific features, structures, materials or characteristics described in conjunction with the embodiment or example are included in at least one embodiment or example of the present application. In this specification, the schematic representation of the above terms does not necessarily refer to the same embodiment or example. Moreover, the specific features, structures, materials or characteristics described may be combined in any one or more embodiments or examples in a suitable manner.
[0121] Although the embodiments of the present application have been shown and described above, it can be understood that the above embodiments are exemplary and cannot be understood as limitations on the present application. Ordinary technicians in this field can change, modify, replace and modify the above embodiments within the scope of the present application.
Claims
1. A method for inputting handwritten chess records, characterized in that: include: Get handwritten chess game images; Based on an interactive region growing algorithm, the handwritten chess record image is orderly divided into a plurality of independent table regions; Each of the independent table areas corresponds to a handwritten chess record table; Pushing each of the independent table areas obtained by segmentation into a first stack; extracting the independent table areas from the first stack in sequence and acquiring character information corresponding to the independent table areas; Marking and saving the character information corresponding to each of the independent table areas; The interactive region growing algorithm is used to orderly divide the handwritten chess game image into multiple independent table regions, including: Acquire the seed points entered by the user in the handwritten chess game image, or generate seed points in the handwritten chess game image based on a feature point detection algorithm; Push all seed points into the second stack; Taking the grayscale value of the initial position of the seed point as the initial grayscale value of the seed point; Acquire the size of the handwritten chess record table, and use the size of the handwritten chess record table as an edge threshold; Taking the initial grayscale value and the edge threshold as constraint conditions, traversing the seed points in the queue in sequence according to the compression order of the second stack, so that each seed point performs regional growth diffusion; When all the seed points in the queue are traversed, the coordinates of the vertex positions of the fusion area obtained by performing regional growth diffusion on all the seed points are obtained as the range of the independent table area; Each independent table area in the handwritten chess record image is segmented.
2. The method according to claim 1, characterized in that The obtaining of character information corresponding to the independent table area includes: Extracting outline information of each cell in the independent table area; Obtaining the centroid coordinates, length and width of the cell according to the outline information of the cell; sorting the cells in the independent table area according to the centroid coordinates of the cells; Segment the cells in the independent table area according to the centroid coordinates, length and width of the cells; The images in each cell are sequentially input into a pre-trained image character string recognition model to obtain character information corresponding to the image in each cell.
3. The method according to claim 1, characterized in that The step of causing each of the seed points to perform regional growth diffusion includes: Each of the seed points is allowed to perform regional growth diffusion within an 8-neighborhood range.
4. The method according to claim 3, characterized in that: The step of causing each of the seed points to perform regional growth diffusion also includes: Each pixel to be fused in the neighborhood of the seed point 8 is given two probes, and the probes are used to explore the lengths in the horizontal direction and the vertical direction respectively; The empirical threshold assigned by the probe is the edge threshold.
5. The method according to claim 1, characterized in that After obtaining the handwritten chess record image, the method further includes: grayscale the handwritten chess record image; Based on the minimum rectangle and affine matrix algorithm, correction parameters are obtained and correction processing is performed on the handwritten chess record image after grayscale processing to align the row and column spatial positions of the table in the handwritten chess record image.
6. The method according to claim 2, characterized in that The extracting the outline information of each cell in the independent table area includes: Reverse mapping is performed on the independent table area, and contour information of each cell in the reverse-mapped independent table area is extracted.
7. The method according to claim 2, characterized in that The sorting of cells in the independent table area according to the centroid coordinates of the cells includes: The cells in the independent table area are sorted in the order of rows first and columns later according to the centroid coordinates of the cells.
8. The method according to claim 2, characterized in that: After sorting the cells in the independent table area according to the centroid coordinates of the cells, the method further includes: A row and column error threshold is set, and whether the adjacent cells are in the same row or column is determined based on the row and column error threshold.
9. A handwritten chess record input device, characterized in that: include: Processor and memory; The processor is connected to the memory via a communication bus; Wherein, the processor is used to call and execute the program stored in the memory; The memory is used to store a program, and the program is at least used to execute a method for recording handwritten chess records as described in any one of claims 1-8.
Citation Information
Patent Citations
Handwritten chess manual auxiliary input method and device based on deep learning
CN112948619A
Electronic Chinese chess and automatic display technology
CN1304083A