Chessboard image correction method and device, electronic equipment and storage medium

By detecting the initial image of the chessboard, grouping chess pieces, calculating relative coordinates and reconstructing the image, the problem of strict requirements for shooting position and angle of chessboard detection technology is solved, and the accuracy of chess piece positioning and the accuracy of chessboard detection are improved.

CN119067894AActive Publication Date: 2024-12-03AIQIDAO (BEIJING) CULTURE COMMUNICATION CO LTD
View PDF 15 Cites 0 Cited by

Patent Information

Application Number
CN202411192800.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-08-28
Publication Date
2024-12-03
Estimated Expiration
2044-08-28

AI Technical Summary

Technical Problem

The existing chess board detection technology strictly requires the shooting position and angle of the chess board, and the high degree of freedom is likely to lead to inaccurate positioning of the chess piece, especially when the chess board image is severely tilted.

Method used

By detecting the initial image of the chessboard, obtaining the absolute coordinates of the chess piece, grouping them into chess strings, calculating the relative coordinates of the chess piece, and reconstructing the image based on the relative coordinates and categories to generate correction images to improve the accuracy of the chess piece positioning.

Benefits of technology

Effectively reduce the inaccurate positioning of chess pieces caused by image distortion, improve the accuracy of chess pieces positioning, ensure that the relative position error between chess pieces is within a chessboard grid, and improve the accuracy of chessboard detection.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119067894A_ABST
    Figure CN119067894A_ABST
Patent Text Reader

Abstract

The invention provides a chessboard image correction method and device, electronic equipment and a storage medium. The method comprises the steps of detecting an initial image of a chessboard, obtaining a chess piece category and an absolute coordinate of each chess piece in the chessboard, grouping each chess piece according to the absolute coordinate of each chess piece in the chessboard, obtaining a plurality of chess strings of the chessboard, and obtaining a plurality of chess pieces based on two absolute coordinates of any two adjacent chess pieces in each chess string. Obtaining the relative coordinates of each chess piece in the chessboard, and carrying out image reconstruction based on the relative coordinates of each chess piece in the chessboard and the type of the chess piece to obtain a corrected image of the chessboard. Therefore, the position relation between the chess pieces can be accurately corrected, and the problem that the chess pieces are not accurately positioned due to image distortion is avoided.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of image processing technology, and in particular to a chessboard image correction method, device, electronic equipment and storage medium. Background Art

[0002] In the field of computer vision, object detection is one of the important research topics. Among them, chessboard detection has broad application prospects in game AI, graphic recognition, and human-computer interaction. With the development of deep learning technology, more and more researchers have applied deep learning to chessboard detection and achieved remarkable results.

[0003] In the chessboard detection method based on deep learning, the accuracy of the chessboard detection results will directly affect the victory or defeat of the board, and the shooting quality of the chessboard image is an important factor affecting whether the chessboard detection results are accurate. This leads to the current chessboard detection technology having many strict restrictions on the chessboard shooting environment (such as light, etc.) and the chessboard shooting angle.

[0004] Specifically, in shooting scenes with a high degree of freedom, the positioning of chess pieces on the chessboard may be inaccurate due to shooting angles and other factors. This problem is particularly prominent when the captured chessboard image is severely tilted. Summary of the invention

[0005] In view of this, the embodiments of the present disclosure provide a chessboard image correction method, device, electronic device, and storage medium to at least partially solve the above-mentioned problems.

[0006] According to a first aspect of an embodiment of the present disclosure, a chessboard image correction method is provided, comprising: detecting an initial image of a chessboard to obtain a chess piece category and absolute coordinates of each chess piece in the chessboard; grouping each chess piece according to the absolute coordinates of each chess piece in the chessboard to obtain a plurality of chess strings of the chessboard, wherein each chess piece belonging to the same chess string is located in the same row of the chessboard; obtaining relative coordinates of each chess piece in the chessboard based on two absolute coordinates of any two adjacent chess pieces in each chess string; and performing image reconstruction based on the relative coordinates and chess piece category of each chess piece in the chessboard to obtain a corrected image of the chessboard.

[0007] According to a second aspect of an embodiment of the present disclosure, a chessboard image correction device is provided, comprising: a detection module, which detects an initial image of a chessboard and obtains a chess piece category and an absolute coordinate of each chess piece in the chessboard; a grouping module, which groups each chess piece in the chessboard according to the absolute coordinate of each chess piece in the chessboard to obtain a plurality of chess strings in the chessboard, wherein each chess piece belonging to the same chess string is located in the same row in the chessboard; a conversion module, which obtains a relative coordinate of each chess piece in the chessboard based on two absolute coordinates of any two adjacent chess pieces in each chess string; and a reconstruction module, which performs image reconstruction based on the relative coordinates and chess piece category of each chess piece in the chessboard to obtain a corrected image of the chessboard.

[0008] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, comprising: a processor; and a memory storing a program, wherein the program comprises instructions, which, when executed by the processor, cause the processor to execute the checkerboard image correction method described in the first aspect above.

[0009] According to a fourth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium storing computer instructions is provided, wherein the computer instructions are used to enable the computer to execute the chessboard image correction method as described in the first aspect.

[0010] In summary, the chessboard image correction scheme provided by various aspects of the present disclosure can improve the problem of inaccurate chess piece positioning caused by image distortion by converting the absolute coordinates of chess pieces into relative coordinates to accurately correct the positional relationship between the chess pieces. BRIEF DESCRIPTION OF THE DRAWINGS

[0011] Further details, features and advantages of the present disclosure are disclosed in the following description of exemplary embodiments in conjunction with the accompanying drawings, in which:

[0012] Figure 1 The present invention is a flowchart of a chessboard image correction method according to an exemplary embodiment of the present invention.

[0013] Figure 2 A schematic diagram of a chessboard according to an exemplary embodiment of the present disclosure.

[0014] Figure 3 The present invention is a flowchart of a chessboard image correction method according to another exemplary embodiment of the present invention.

[0015] Figure 4 It is a structural block diagram of a chessboard image correction device according to an exemplary embodiment of the present disclosure.

[0016] Figure 5 It is a schematic diagram of the architecture of an electronic device according to an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION

[0017] Embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as being limited to the embodiments described herein, which are instead provided for a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are only for exemplary purposes and are not intended to limit the scope of protection of the present disclosure.

[0018] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.

[0019] The term "including" and its variations used in this document are open inclusions, that is, "including but not limited to". The term "based on" means "based at least in part on". The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one other embodiment"; the term "some embodiments" means "at least some embodiments". Relevant definitions of other terms will be given in the description below. It should be noted that the concepts of "first", "second", etc. mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.

[0020] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, it should be understood as "one or more". The names of the messages or information exchanged between the multiple devices in the embodiments of the present disclosure are only for illustrative purposes and are not used to limit the scope of these messages or information.

[0021] The current chessboard detection technology has many restrictions on the shooting position and shooting angle of the chessboard. In shooting scenes with a high degree of freedom, it is easy for the captured image to be distorted, resulting in poor recognition accuracy of the chess piece position on the chessboard.

[0022] In view of this, each embodiment of the present disclosure provides a checkerboard image correction solution. The specific implementation of each embodiment of the present disclosure will be described in detail below in conjunction with the accompanying drawings.

[0023] Figure 1 The following is a processing flow chart of a chessboard image correction method according to an exemplary embodiment of the present disclosure. As shown in the figure, this embodiment mainly includes the following steps:

[0024] Step 102: Detect the initial image of the chessboard to obtain the chess piece category and absolute coordinates of each chess piece on the chessboard.

[0025] In some embodiments, the initial image of the chessboard may be preprocessed, including but not limited to: resizing, cropping, noise reduction, normalization, etc., to ensure that the image data can achieve the best effect in subsequent processing.

[0026] In some embodiments, each target object in the initial image can be classified and detected to obtain each chess piece in the chessboard and the chess piece category of each chess piece, and the two diagonal points of the chessboard and the two diagonal points of each chess piece are detected respectively to obtain the absolute coordinates of each vertex of the chessboard and the absolute coordinates of each chess piece.

[0027] In this embodiment, the absolute coordinates of each chess piece are used to identify the center point position of each chess piece.

[0028] In some embodiments, an image detection model (e.g., a deep learning model) may be used to detect an initial image of a chessboard to obtain the chess piece category and absolute coordinates of each chess piece on the chessboard.

[0029] In this embodiment, the absolute coordinates of each chess piece consist of a horizontal absolute coordinate and a vertical absolute coordinate.

[0030] In this embodiment, the chessboard may include a Go chessboard, and the chess piece categories may include a white chess piece category and a black chess piece category.

[0031] Specifically, the image detection model can be used to perform target detection on the initial image of the chessboard based on given category labels (white chess label and black chess label), obtain the confidence value of each detected object in the chessboard, and determine each detected object with a confidence value greater than a confidence threshold (for example, 0.8) as a target object, wherein the obtained target objects are the black and white chess pieces in the chessboard.

[0032] Preferably, the image detection model can be used to detect the coordinates of the lower left corner and the upper right corner of the chess piece, that is, the minimum Xmin, Ymin coordinates and the maximum Xmax, Ymax coordinates. The horizontal and vertical sizes of the chess piece can be calculated according to the coordinates of the two diagonal points, respectively, as w=Xmax-Xmin, h=Ymax-Ymin, thereby calculating the center point position of the chess piece, that is, the absolute coordinates of the chess piece.

[0033] In this embodiment, the image detection model also outputs the absolute coordinates of the four corners of the chessboard. The detection method of the absolute coordinates of the corners of the chessboard can refer to the description of the detection method of the corner points of the chess pieces.

[0034] Step 104: group each chess piece on the chessboard according to its absolute coordinates to obtain multiple chess strings on the chessboard.

[0035] In this embodiment, each chess piece belonging to the same chess string is located in the same row on the chessboard. For example, in a Go board, each chess piece belonging to the same chess string is located in the same row (horizontal row) or the same column (vertical row) on the Go board.

[0036] For example, in Figure 2 In the example shown, white chess piece 1, white chess piece 2, and white chess piece 3 belong to the same chess piece string; white chess piece 1, black chess piece 1, white chess piece 7, white chess piece 10, and black chess piece 9 belong to the same chess piece string.

[0037] In some embodiments, the plurality of chess strings of the chess board include at least one horizontal chess string and at least one vertical chess string.

[0038] For example, in Figure 2 In the example shown, the chessboard includes 5 horizontal chess strings and 7 vertical chess strings. Among them, white chess 1, white chess 2, and white chess 3 belong to the same vertical chess string; white chess 1, black chess 1, white chess 7, white chess 10, and black chess 9 belong to the same horizontal chess string, and so on.

[0039] In some embodiments, each chess string includes at least one chess piece. Figure 2 In the example shown, the horizontal chess string 5 includes only white chess pieces 5 .

[0040] In this embodiment, each chess piece is grouped into a horizontal chess string and a vertical chess string of the chessboard.

[0041] For example, in Figure 2 In the example shown, white chess piece 1 belongs to horizontal chess piece string 1 and vertical chess piece string 1, and white chess piece 2 belongs to horizontal chess piece string 2 and vertical chess piece string 1.

[0042] Step 106: Based on the two absolute coordinates of any two adjacent chess pieces in each chess string, the relative coordinates of each chess piece on the chessboard are obtained.

[0043] In some embodiments, any chess string can be determined as the current chess string, and according to the arrangement order of the chess pieces in the current chess string, one chess piece in the current chess string is determined as the current chess piece, and the chess piece before the current chess piece is determined as the previous chess piece.

[0044] For example, in Figure 2 In the example shown, a horizontal chess string consisting of white chess piece 1, black chess piece 1, white chess piece 7, white chess piece 10, and black chess piece 9 (hereinafter referred to as horizontal chess string 1) can be used as the current chess string, and the chess pieces can be arranged in order based on the absolute coordinates of each chess piece to obtain the chess string sequence of horizontal chess string 1: white chess piece 1, black chess piece 1, white chess piece 7, white chess piece 10, and black chess piece 9. In the case where black chess piece 1 is used as the current chess piece, white chess piece 1 is the previous chess piece of black chess piece 1, and in the case where white chess piece 7 is used as the current chess piece, the previous chess piece should be black chess piece 1.

[0045] In this embodiment, the relative coordinates of the previous chess piece can be determined, and the distance between the current chess piece and the previous chess piece can be obtained based on the absolute coordinates of the current chess piece and the absolute coordinates of the previous chess piece. The relative coordinates of the current chess piece can be obtained based on the chess square size of the chessboard, the distance between the current chess piece and the previous chess piece, and the relative coordinates of the previous chess piece.

[0046] Specifically, the interval distance between the current chess piece and the previous chess piece is obtained according to the absolute coordinates of the current chess piece and the absolute coordinates of the previous chess piece. The additional coordinate value of the current chess piece can be obtained by dividing the interval distance by the chessboard square size. The relative coordinates of the previous chess piece and the additional coordinate value of the current chess piece are added together to obtain the relative coordinates of the current chess piece.

[0047] In this embodiment, the relative coordinates of each chess piece are composed of a horizontal relative coordinate and a vertical relative coordinate. Therefore, the horizontal relative coordinates of each chess piece on the chessboard can be identified based on the two horizontal absolute coordinates of any two adjacent chess pieces in each horizontal chess string, and the vertical relative coordinates of each chess piece on the chessboard can be identified based on the two vertical absolute coordinates of any two adjacent chess pieces in each vertical chess string.

[0048] For example, when the current chess string is horizontal chess string 1 and the current chess piece is black chess piece 1, the horizontal interval distance between black chess piece 1 and white chess piece 1 can be obtained based on the horizontal absolute coordinates of each of black chess piece 1 and white chess piece 1, and then the horizontal interval distance is divided by the chess square size of the chessboard, and the horizontal additional coordinate value of black chess piece 1 can be obtained as "1". The horizontal relative coordinate "1" of white chess piece 1 and the horizontal additional coordinate value "1" of black chess piece 1 can be added together to obtain the horizontal relative coordinate of black chess piece 1 as "2".

[0049] For example, when the current chess string is horizontal chess string 1 and the current chess piece is white chess piece 7, the horizontal spacing distance between black chess piece 1 and white chess piece 7 can be obtained based on their respective horizontal absolute coordinates, and then the horizontal spacing distance is divided by the chess square size of the chessboard, and the horizontal additional coordinate value of white chess piece 7 can be obtained as "2". The horizontal relative coordinate value "2" of black chess piece 1 and the horizontal additional coordinate value "2" of white chess piece 7 can be added to obtain the horizontal relative coordinate value of white chess piece 7 as "4".

[0050] In this embodiment, the horizontal relative coordinates and the vertical relative coordinates of the same chess piece on the chessboard can be combined to obtain the relative coordinates of each chess piece on the chessboard. For example, the relative coordinates of white chess piece 1 are (1,1), the relative coordinates of black chess piece 1 are (1,2), the relative coordinates of white chess piece 2 are (2,1), and so on.

[0051] In some embodiments, when the current chess piece is the first chess piece in the current chess string, the interval distance between the current chess piece and the given reference position of the chessboard is obtained based on the absolute coordinates of the current chess piece and the absolute coordinates of the given reference position of the chessboard, and the relative coordinates of the current chess piece are obtained based on the chess square size of the chessboard and the interval distance between the current chess piece and the given reference position.

[0052] refer to Figure 2 , when the current chess string is horizontal chess string 1 and the current chess piece is white chess piece 1, the horizontal spacing distance between white chess piece 1 and the given reference position can be calculated, and the horizontal spacing distance is divided by the chess grid size of the chessboard to obtain the horizontal additional coordinate value of white chess piece 1 as "1". According to the sum of the horizontal relative coordinate "0" of the given reference position and the horizontal additional coordinate value "1" of white chess piece 1, the horizontal relative coordinate of white chess piece 1 is obtained as "1".

[0053] Step 108: Reconstruct an image based on the relative coordinates and the category of each chess piece on the chessboard to obtain a corrected image of the chessboard.

[0054] In some embodiments, based on a given reference position in a standard chess grid of a chessboard and the relative coordinates or absolute coordinates of each chess piece, a chess piece among all chess pieces that is closest to the given reference position can be determined as a reference chess piece, and each chess piece except the reference chess piece can be determined as a non-reference chess piece.

[0055] In this example, a vertex position in a standard chess grid of the chessboard can be determined as a given reference position in the standard chess grid of the chessboard. Figure 2 In the example shown, the lower left corner vertex of the chessboard can be determined as a given reference position, and the white chess piece 1 closest to the lower left corner vertex can be determined as a reference chess piece, and the white chess pieces 2 to 10 and the black chess pieces 1 to 10 can be determined as non-reference chess pieces.

[0056] In some embodiments, the positioning position of the reference chess piece in the standard chess grid can be determined based on a given reference position of the chessboard and the relative coordinates of the reference chess piece; the positioning position of each non-reference chess piece in the standard chess grid of the chessboard can be determined based on the positioning position of the reference chess piece and the relative coordinates of each non-reference chess piece; and based on the positioning positions of the reference chess piece and each non-reference chess piece in the standard chess grid and the chess piece categories of the reference chess piece and each non-reference chess piece, the standard chess grid is rendered to obtain a corrected image of the chessboard.

[0057] Exemplarily, the positioning position of white chess piece 1 in the standard chess square can be first determined based on the coordinate position of the lower left corner vertex of the chessboard and the relative coordinates (1,1) of white chess piece 1. Based on the positioning position of white chess piece 1 and the relative coordinates of each non-reference chess piece (i.e., white chess pieces 2 to white chess pieces 10, black chess pieces 1 to black chess pieces 10), the positioning position of each non-reference chess piece in the standard chess square of the chessboard can be deduced in reverse. The standard chess squares of the chessboard are thus rendered to obtain a corrected image of the chessboard.

[0058] In summary, the chessboard image correction device of this embodiment groups chess pieces by detecting the absolute coordinates of each chess piece to obtain multiple chess strings in the chessboard, and then recursively calculates the relative coordinates of each chess piece according to the position arrangement order of each chess piece in the chess string, thereby effectively reducing the problem of inaccurate chess piece positioning caused by image distortion.

[0059] Specifically, the traditional solution usually uses a single reference point to locate each chess piece on the chessboard. When there is distortion such as distortion in the image, the farther the chess piece is from the reference point, the greater the positioning offset will be. This embodiment uses a recursive calculation solution to calculate the positioning positions of adjacent chess pieces in sequence, so that the relative position error between the corrected chess pieces does not exceed one chessboard grid, and the position relationship between the chess pieces can be accurately corrected to effectively improve the accuracy of chess piece positioning.

[0060] Figure 3 FIG. 1 is a processing flow chart of a chessboard image correction method according to another exemplary embodiment of the present disclosure. As shown in the figure, this embodiment shows a specific implementation scheme of the above step 104.

[0061] It should be noted that the chess piece grouping scheme of this embodiment is only executed for one direction in the chessboard, and each processing step of this embodiment can be executed twice to respectively determine each horizontal chess string and each vertical chess string in the chessboard.

[0062] In order to avoid blurring the technical key points of this solution and to facilitate readers to understand the technical solution of this embodiment more clearly, the following description is only based on the example of generating each horizontal chess string in the chessboard. The following solution is also applicable to generating each vertical chess string in the chessboard. As shown in the figure, this embodiment mainly includes the following steps:

[0063] Step 302: Determine each chess piece to be grouped that has not formed a chess string from among the chess pieces on the chessboard.

[0064] For example, in Figure 2 In the example shown, when the horizontal chess string 1 in the chessboard is determined, white chess pieces 2 to 6, white chess pieces 8, white chess pieces 9, black chess pieces 2 to 8, and black chess pieces 10 can be determined as chess pieces to be grouped. When the horizontal chess string 1 and horizontal chess string 2 in the chessboard are determined, white chess pieces 3 to 6, white chess pieces 8, black chess pieces 3 to 6, and black chess pieces 8 can be determined as chess pieces to be grouped.

[0065] Step 304: Based on a given reference position of the chessboard, a reference chess piece is determined from each chess piece to be grouped, and each chess piece to be grouped that has not been determined as a reference chess piece is determined as a candidate chess piece for the reference chess piece.

[0066] In this embodiment, based on a given reference position of the chessboard and the absolute coordinate position of each chess piece, a chess piece to be grouped that is closest to the given reference position can be determined as a reference chess piece.

[0067] In this embodiment, the given reference position of the chessboard is determined based on the absolute coordinates of a vertex of the chessboard. Figure 2 In the example shown, the lower left corner position of the chessboard can be determined as the given reference position.

[0068] Among them, when any horizontal chess string is not determined, white chess piece 1 (chess piece to be grouped) is the reference chess piece closest to the given reference position, and white chess pieces 2 to white chess pieces 10, and black chess pieces 1 to black chess pieces 10 are all candidate chess pieces for white chess piece 1; when horizontal chess piece string 1 is determined, white chess piece 2 (chess piece to be grouped) is the reference chess piece closest to the given reference position, and white chess pieces 3 to white chess pieces 6, white chess pieces 8, white chess pieces 9, black chess pieces 2 to black chess pieces 8, and black chess pieces 10 are candidate chess pieces for white chess piece 2.

[0069] Step 306: Determine each target chess piece of the reference chess piece from each candidate chess piece according to the coordinate difference between the absolute coordinate of each candidate chess piece and the absolute coordinate of the reference chess piece, and form a chess string on the chessboard based on the reference chess piece and each target chess piece.

[0070] In this embodiment, when generating each horizontal chess string in the chessboard, the absolute longitudinal coordinate of each candidate chess piece and the absolute longitudinal coordinate of the reference chess piece can be calculated by difference, so as to obtain the longitudinal offset value of each candidate chess piece compared with the reference chess piece, and each candidate chess piece whose longitudinal offset value is less than a given longitudinal offset threshold is determined as the target chess piece of the reference chess piece, and a horizontal chess string of the chessboard is formed based on the reference chess piece and each target chess piece.

[0071] In this embodiment, the given longitudinal offset threshold is determined based on the size of each chess piece.

[0072] Exemplarily, when the reference chess piece is white chess piece 1, the absolute longitudinal coordinates of each candidate chess piece can be traversed, and each candidate chess piece whose longitudinal deviation value does not exceed the chess piece radius (i.e. black chess piece 1, white chess piece 7, white chess piece 10, black chess piece 9) is determined as the target chess piece of white chess piece 1, and based on white chess piece 1, i.e. black chess piece 1, white chess piece 7, white chess piece 10, black chess piece 9, the horizontal chess string 1 of the chessboard is formed.

[0073] In other embodiments, when each vertical chess string in the chessboard is generated by this embodiment, the absolute horizontal coordinate of each candidate chess piece and the absolute horizontal coordinate of the reference chess piece may be calculated to obtain the horizontal offset value of each candidate chess piece compared to the reference chess piece, and each candidate chess piece whose horizontal offset value is less than a given horizontal offset threshold is determined as the target chess piece of the reference chess piece, so as to form a vertical chess string of the chessboard based on the reference chess piece and each target chess piece. The given horizontal offset threshold may also be determined based on the chess piece size of each chess piece.

[0074] In some embodiments, when there is no target chess piece of the reference chess piece among the candidate chess pieces, a chess string of the chessboard is directly formed based on the reference chess piece. Figure 2 The horizontal chess string 5 is shown.

[0075] Step 308, determine whether there are chess pieces to be grouped on the chessboard, if yes, return to step 302, otherwise go to step 310.

[0076] Specifically, when it is determined that there are no chess pieces to be grouped on the chessboard, it means that the grouping operation of all chess pieces on the chessboard has been completed.

[0077] Step 310: Get each chess string on the chessboard.

[0078] In summary, this embodiment is based on the absolute coordinates of each chess piece, and recursively traverses each chess piece to group the chess pieces into multiple chess strings for subsequent conversion of the relative coordinates of the chess pieces, thereby realizing automatic correction of the relative positions between the chess pieces and improving the positioning accuracy of the chess pieces.

[0079] Figure 4 The structure block diagram of the chessboard image correction device of the exemplary embodiment of the present disclosure is shown. As shown in the figure, the chessboard image correction device 400 of this embodiment includes:

[0080] A detection module 402 detects an initial image of a chessboard and obtains a chess piece category and an absolute coordinate of each chess piece on the chessboard;

[0081] A grouping module 404, groups each chess piece on the chessboard according to the absolute coordinates of each chess piece, to obtain a plurality of chess strings on the chessboard, wherein each chess piece belonging to the same chess string is located in the same row on the chessboard;

[0082] A conversion module 406 obtains the relative coordinates of each chess piece on the chessboard based on the two absolute coordinates of any two adjacent chess pieces in each chess string;

[0083] The reconstruction module 408 performs image reconstruction based on the relative coordinates and the type of each chess piece in the chessboard to obtain a corrected image of the chessboard.

[0084] In some embodiments, the detection module 402 is further used to: classify and detect each target object in the initial image to obtain each chess piece in the chessboard and the chess piece category of each chess piece; respectively detect the two diagonal points of the chessboard and the two diagonal points of each chess piece to obtain the absolute coordinates of each vertex of the chessboard and the absolute coordinates of each chess piece; wherein the absolute coordinates of each chess piece are used to identify the center point position of each chess piece.

[0085] In some embodiments, the grouping module 404 is further used to: determine each chess piece to be grouped that is not formed into a chess string from the chess pieces on the chess board; determine a reference chess piece from the chess pieces to be grouped based on a given reference position of the chess board, and determine each chess piece to be grouped that is not determined as the reference chess piece as a candidate chess piece for the reference chess piece; determine each target chess piece of the reference chess piece from the candidate chess pieces according to the coordinate difference between the absolute coordinates of each candidate chess piece and the absolute coordinates of the reference chess piece, and form a chess string of the chess board based on the reference chess piece and each target chess piece; return to execute the step of determining each chess piece to be grouped that is not formed into a chess string from the chess pieces on the chess board until there are no chess pieces to be grouped on the chess board.

[0086] In some embodiments, the grouping module 404 is further used to: based on a given reference position of the chessboard and the absolute coordinate position of each chess piece, determine a chess piece to be grouped that is closest to the given reference position as a reference chess piece; wherein the given reference position is determined based on the absolute coordinate of a vertex of the chessboard.

[0087] In some embodiments, each chess string includes at least one chess piece.

[0088] In some embodiments, the grouping module 404 is further configured to: when there is no target chess piece of the reference chess piece among the candidate chess pieces, directly form a chess string on the chessboard based on the reference chess piece.

[0089] In some embodiments, the plurality of chess strings include at least one horizontal chess string and at least one vertical chess string, and the absolute coordinates of each chess piece consist of a horizontal absolute coordinate and a vertical absolute coordinate.

[0090] In some embodiments, the grouping module 404 is further used to: calculate the difference between the absolute longitudinal coordinate of each candidate chess piece and the absolute longitudinal coordinate of the reference chess piece to obtain the longitudinal offset value of each candidate chess piece compared to the reference chess piece; determine each candidate chess piece whose longitudinal offset value is less than a given longitudinal offset threshold as the target chess piece of the reference chess piece; and form a horizontal chess string of the chessboard based on the reference chess piece and each target chess piece.

[0091] In some embodiments, the grouping module 404 is further used to: calculate the difference between the absolute horizontal coordinate of each candidate chess piece and the absolute horizontal coordinate of the reference chess piece to obtain the horizontal offset value of each candidate chess piece compared to the reference chess piece; determine each candidate chess piece whose horizontal offset value is less than a given horizontal offset threshold as the target chess piece of the reference chess piece; and form a vertical chess string of the chessboard based on the reference chess piece and each target chess piece.

[0092] In some embodiments, the given longitudinal offset threshold or the given lateral offset threshold is determined based on the size of each chess piece.

[0093] In some embodiments, the conversion module 406 is further used to: determine any chess string as the current chess string; determine a chess piece in the current chess string as the current chess piece in turn according to the arrangement order of the chess pieces in the current chess string, determine the chess piece before the current chess piece as the predecessor chess piece, and determine the relative coordinates of the predecessor chess piece; obtain the interval distance between the current chess piece and the predecessor chess piece according to the absolute coordinates of the current chess piece and the absolute coordinates of the predecessor chess piece; obtain the relative coordinates of the current chess piece based on the chess grid size of the chessboard, the interval distance between the current chess piece and the predecessor chess piece, and the relative coordinates of the predecessor chess piece.

[0094] In some embodiments, the conversion module 406 is also used to: when the current chess piece is the first chess piece in the current chess string, obtain the interval distance between the current chess piece and the given reference position of the chessboard according to the absolute coordinates of the current chess piece and the absolute coordinates of the given reference position of the chessboard; obtain the relative coordinates of the current chess piece based on the chess grid size of the chessboard and the interval distance between the current chess piece and the given reference position.

[0095] In some embodiments, the multiple chess strings include at least one horizontal chess string and at least one vertical chess string, each chess piece is grouped into a horizontal chess string and a vertical chess string of the chessboard, respectively, the absolute coordinates of each chess piece consist of a horizontal absolute coordinate and a vertical absolute coordinate, and the relative coordinates of each chess piece consist of a horizontal relative coordinate and a vertical relative coordinate.

[0096] In some embodiments, the conversion module 406 is further used to: identify the horizontal relative coordinates of each chess piece in the chessboard based on the two horizontal absolute coordinates of any two adjacent chess pieces in each horizontal chess string, and identify the vertical relative coordinates of each chess piece in the chessboard based on the two vertical absolute coordinates of any two adjacent chess pieces in each vertical chess string; merge the horizontal relative coordinates and the vertical relative coordinates of the same chess piece in the chessboard to obtain the relative coordinates of each chess piece in the chessboard.

[0097] In some embodiments, the reconstruction module 408 is further used to: determine, according to a given reference position in the standard chess grid of the chessboard and the relative coordinates or absolute coordinates of each chess piece, a chess piece among the chess pieces that is closest to the given reference position as a reference chess piece, and determine each chess piece other than the reference chess piece as a non-reference chess piece; determine the positioning position of the reference chess piece in the standard chess grid based on the given reference position of the chessboard and the relative coordinates of the reference chess piece; determine the positioning position of each non-reference chess piece in the standard chess grid of the chessboard based on the positioning position of the reference chess piece and the relative coordinates of each non-reference chess piece; render the standard chess grid based on the positioning positions of the reference chess piece and each non-reference chess piece in the standard chess grid and the chess piece categories of the reference chess piece and each non-reference chess piece to obtain a corrected image of the chessboard.

[0098] The embodiments of the present disclosure also provide a non-transitory computer-readable storage medium storing computer instructions, wherein the computer instructions are used to enable the computer to execute the chessboard image correction method described in each exemplary embodiment of the present disclosure.

[0099] The exemplary embodiments of the present disclosure also provide an electronic device, comprising: at least one processor; and a memory connected to the at least one processor in communication. The memory stores a computer program that can be executed by the at least one processor, and when the computer program is executed by the at least one processor, the electronic device performs the chessboard image correction method according to each exemplary embodiment of the present disclosure.

[0100] Please refer to Figure 5 , a block diagram of an electronic device 500 that can serve as a server or client of the present disclosure will now be described, which is an example of a hardware device that can be applied to various aspects of the present disclosure. The electronic device is intended to represent various forms of digital electronic computer devices, such as laptop computers, desktop computers, workbenches, personal digital assistants, servers, blade servers, mainframe computers, and other suitable computers. The electronic device can also represent various forms of mobile devices, such as personal digital processing, cellular phones, smart phones, wearable devices, and other similar computing devices. The components shown herein, their connections and relationships, and their functions are merely examples and are not intended to limit the implementation of the present disclosure described and / or required herein.

[0101] like Figure 5As shown, the electronic device 500 includes a computing unit 501, which can perform various appropriate actions and processes according to a computer program stored in a read-only memory (ROM) 502 or a computer program loaded from a storage unit 508 into a random access memory (RAM) 503. In the RAM 503, various programs and data required for the operation of the device 500 can also be stored. The computing unit 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.

[0102] A plurality of components in the electronic device 500 are connected to the I / O interface 505, including: an input unit 506, an output unit 507, a storage unit 508, and a communication unit 509. The input unit 506 may be any type of device capable of inputting information to the electronic device 500, and the input unit 506 may receive input digital or character information, and generate key signal inputs related to user settings and / or function control of the electronic device. The output unit 507 may be any type of device capable of presenting information, and may include, but is not limited to, a display, a speaker, a video / audio output terminal, a vibrator, and / or a printer. The storage unit 508 may include, but is not limited to, a disk, an optical disk. The communication unit 509 allows the electronic device 500 to exchange information / data with other devices through a computer network such as the Internet and / or various telecommunication networks, and may include, but is not limited to, a modem, a network card, an infrared communication device, a wireless communication transceiver, and / or a chipset, such as a Bluetooth™ device, a WiFi device, a WiMax device, a cellular communication device, and / or the like.

[0103] The computing unit 501 may be a variety of general and / or special processing components with processing and computing capabilities. Some examples of the computing unit 501 include, but are not limited to, a central processing unit (CPU), a graphics processing unit (GPU), various dedicated artificial intelligence (AI) computing chips, various computing units running machine learning model algorithms, digital signal processors (DSPs), and any appropriate processors, controllers, microcontrollers, etc. The computing unit 501 performs the various methods and processes described above. For example, in some embodiments, the chessboard image correction method described above may be implemented as a computer software program, which is tangibly included in a machine-readable medium, such as a storage unit 508. In some embodiments, part or all of the computer program may be loaded and / or installed on the electronic device 500 via the ROM 502 and / or the communication unit 509. In some embodiments, the computing unit 501 may be configured to perform the above-described chessboard image correction method by any other appropriate means (e.g., by means of firmware).

[0104] The program code for implementing the method of the present disclosure may be written in any combination of one or more programming languages. These program codes may be provided to a processor or controller of a general-purpose computer, a special-purpose computer, or other programmable data processing device, so that the program code, when executed by the processor or controller, implements the functions / operations specified in the flow chart and / or block diagram. The program code may be executed entirely on the machine, partially on the machine, partially on the machine and partially on a remote machine as a stand-alone software package, or entirely on a remote machine or server.

[0105] In the context of the present disclosure, a machine-readable medium may be a tangible medium that may contain or store a program for use by or in conjunction with an instruction execution system, device, or equipment. A machine-readable medium may be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium may include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium may include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.

[0106] As used in this disclosure, the terms "machine-readable medium" and "computer-readable medium" refer to any computer program product, apparatus, and / or device (e.g., disk, optical disk, memory, programmable logic device (PLD)) for providing machine instructions and / or data to a programmable processor, including a machine-readable medium that receives machine instructions as a machine-readable signal. The term "machine-readable signal" refers to any signal for providing machine instructions and / or data to a programmable processor.

[0107] To provide interaction with a user, the systems and techniques described herein can be implemented on a computer having: a display device (e.g., a CRT (cathode ray tube) or LCD (liquid crystal display) monitor) for displaying information to the user; and a keyboard and pointing device (e.g., a mouse or trackball) through which the user can provide input to the computer. Other types of devices can also be used to provide interaction with the user; for example, the feedback provided to the user can be any form of sensory feedback (e.g., visual feedback, auditory feedback, or tactile feedback); and input from the user can be received in any form (including acoustic input, voice input, or tactile input).

[0108] The systems and techniques described herein may be implemented in a computing system that includes backend components (e.g., as a data server), or a computing system that includes middleware components (e.g., an application server), or a computing system that includes frontend components (e.g., a user computer with a graphical user interface or a web browser through which a user can interact with implementations of the systems and techniques described herein), or a computing system that includes any combination of such backend components, middleware components, or frontend components. The components of the system may be interconnected by any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include: a local area network (LAN), a wide area network (WAN), and the Internet.

[0109] A computer system may include a client and a server. The client and the server are generally remote from each other and usually interact through a communication network. The client and the server relationship is generated by computer programs running on respective computers and having a client-server relationship with each other.

[0110] It should be pointed out that, according to the needs of implementation, the various components / steps described in the embodiments of the present disclosure can be split into more components / steps, or two or more components / steps or partial operations of components / steps can be combined into new components / steps to achieve the purpose of the embodiments of the present disclosure.

[0111] The above implementation methods are only used to illustrate the embodiments of the present disclosure, and are not limitations of the embodiments of the present disclosure. Ordinary technicians in the relevant technical field may make various changes and modifications without departing from the spirit and scope of the embodiments of the present disclosure. Therefore, all equivalent technical solutions also belong to the scope of the embodiments of the present disclosure. The scope of patent protection of the embodiments of the present disclosure should be defined by the claims.

Claims

1. A chessboard image correction method, comprising: Detecting an initial image of a chessboard to obtain a chess piece category and an absolute coordinate of each chess piece on the chessboard; Grouping each chess piece on the chessboard according to its absolute coordinates to obtain a plurality of chess strings on the chessboard, wherein each chess piece belonging to the same chess string is located in the same row on the chessboard; Based on the two absolute coordinates of any two adjacent chess pieces in each chess string, the relative coordinates of each chess piece on the chessboard are obtained; Image reconstruction is performed based on the relative coordinates and chess piece category of each chess piece on the chessboard to obtain a corrected image of the chessboard.

2. The method according to claim 1, wherein: The detecting the initial image of the chessboard to obtain the chess piece category and absolute coordinates of each chess piece on the chessboard includes: Classify and detect each target object in the initial image to obtain each chess piece and the chess piece category of each chess piece in the chessboard; Respectively detect the two diagonal points of the chessboard and the two diagonal points of each chess piece to obtain the absolute coordinates of each vertex of the chessboard and the absolute coordinates of each chess piece; The absolute coordinates of each chess piece are used to identify the center point position of each chess piece.

3. The method according to claim 1, wherein: The step of grouping each chess piece according to the absolute coordinates of each chess piece on the chessboard to obtain a plurality of chess strings on the chessboard comprises: Determine each chess piece to be grouped that has not formed a chess string from the chess pieces on the chessboard; Based on a given reference position of the chessboard, a reference chess piece is determined from the chess pieces to be grouped, and each chess piece to be grouped that has not been determined as the reference chess piece is determined as a candidate chess piece for the reference chess piece; Determine each target chess piece of the reference chess piece from each candidate chess piece according to the coordinate difference between the absolute coordinate of each candidate chess piece and the absolute coordinate of the reference chess piece, and form a chess string of the chessboard based on the reference chess piece and each target chess piece; Return to the step of determining each chess piece to be grouped that has not formed a chess string from the chess pieces on the chess board until there are no more chess pieces to be grouped on the chess board.

4. The method according to claim 3, wherein: The step of determining a reference chess piece from the chess pieces to be grouped based on a given reference position of the chessboard comprises: Based on the given reference position of the chessboard and the absolute coordinate position of each chess piece, a chess piece to be grouped that is closest to the given reference position is determined as a reference chess piece; The given reference position is determined based on the absolute coordinates of a vertex of the chessboard.

5. The method according to claim 3, wherein: Each chess string includes at least one chess piece; The method further comprises: In the case that the target chess piece of the reference chess piece does not exist among the candidate chess pieces, a chess string of the chessboard is directly composed based on the reference chess piece.

6. The method according to any one of claims 3 to 5, wherein: The multiple chess strings include at least one horizontal chess string and at least one vertical chess string, and the absolute coordinates of each chess piece consist of a horizontal absolute coordinate and a vertical absolute coordinate; Wherein, any horizontal chess string of the chessboard is formed by the following method: Calculate the difference between the absolute longitudinal coordinate of each candidate chess piece and the absolute longitudinal coordinate of the reference chess piece to obtain a longitudinal offset value of each candidate chess piece compared to the reference chess piece; Determine each candidate chess piece whose longitudinal offset value is less than a given longitudinal offset threshold as a target chess piece of the reference chess piece; Based on the reference chess piece and each target chess piece, a horizontal chess string of the chess board is formed; Wherein, any vertical chess string of the chessboard is formed by the following method: Calculate the difference between the absolute horizontal coordinate of each candidate chess piece and the absolute horizontal coordinate of the reference chess piece to obtain a horizontal offset value of each candidate chess piece compared to the reference chess piece; Determine each candidate chess piece whose lateral offset value is less than a given lateral offset threshold as a target chess piece of the reference chess piece; Based on the reference chess piece and each target chess piece, a vertical chess string of the chess board is formed; The given longitudinal offset threshold or the given lateral offset threshold is determined based on the chess piece size of each chess piece.

7. The method according to claim 1, wherein: The step of identifying the relative coordinates of each chess piece on the chessboard based on the two absolute coordinates of any two adjacent chess pieces in each chess string includes: Determine any chess string as the current chess string; According to the arrangement order of the chess pieces in the current chess string, one of the chess pieces in the current chess string is determined as the current chess piece, the chess piece before the current chess piece is determined as the previous chess piece, and the relative coordinates of the previous chess piece are determined; Obtaining the interval distance between the current chess piece and the preceding chess piece according to the absolute coordinates of the current chess piece and the absolute coordinates of the preceding chess piece; The relative coordinates of the current chess piece are obtained based on the chess grid size of the chessboard, the interval between the current chess piece and the previous chess piece, and the relative coordinates of the previous chess piece.

8. The method according to claim 7, wherein: In the case where the current chess piece is the first chess piece in the current chess string, the method includes: Obtaining the interval distance between the current chess piece and the given reference position according to the absolute coordinates of the current chess piece and the absolute coordinates of the given reference position of the chessboard; Based on the chess grid size of the chessboard and the interval distance between the current chess piece and the given reference position, the relative coordinates of the current chess piece are obtained.

9. The method according to claim 1, 7 or 8, wherein: The multiple chess strings include at least one horizontal chess string and at least one vertical chess string, each chess piece is grouped into a horizontal chess string and a vertical chess string of the chessboard, respectively, the absolute coordinate of each chess piece consists of a horizontal absolute coordinate and a vertical absolute coordinate, and the relative coordinate of each chess piece consists of a horizontal relative coordinate and a vertical relative coordinate; The step of obtaining the relative coordinates of each chess piece on the chessboard based on the two absolute coordinates of any two adjacent chess pieces in each chess string includes: Based on the two horizontal absolute coordinates of any two adjacent chess pieces in each horizontal chess string, identify the horizontal relative coordinate of each chess piece on the chess board; based on the two vertical absolute coordinates of any two adjacent chess pieces in each vertical chess string, identify the vertical relative coordinate of each chess piece on the chess board; The horizontal relative coordinate and the vertical relative coordinate of the same chess piece on the chessboard are combined to obtain the relative coordinate of each chess piece on the chessboard.

10. The method according to claim 1, wherein: The image reconstruction based on the relative coordinates and the chess piece category of each chess piece on the chessboard to obtain a corrected image of the chessboard includes: According to a given reference position in a standard chess grid of the chessboard and the relative coordinates or absolute coordinates of each chess piece, a chess piece among all chess pieces that is closest to the given reference position is determined as a reference chess piece, and each chess piece other than the reference chess piece is determined as a non-reference chess piece; Determine the positioning position of the reference chess piece in the standard chess square based on the given reference position of the chessboard and the relative coordinates of the reference chess piece; Based on the positioning position of the reference chess piece and the relative coordinates of each non-reference chess piece, determining the positioning position of each non-reference chess piece in the standard chess square of the chessboard; Based on the positioning positions of the reference chess piece and each non-reference chess piece in the standard chess grid and the chess piece categories of the reference chess piece and each non-reference chess piece, the standard chess grid is rendered to obtain a corrected image of the chessboard.

11. The method according to claim 1 or 10, wherein: The chessboard includes a Go chessboard; The chess piece categories include a white chess piece category and a black chess piece category.

12. A chessboard image correction device, comprising: A detection module detects an initial image of a chessboard and obtains a chess piece category and an absolute coordinate of each chess piece on the chessboard; A grouping module, grouping each chess piece on the chessboard according to the absolute coordinates of each chess piece, to obtain a plurality of chess strings on the chessboard, wherein each chess piece belonging to the same chess string is located in the same row on the chessboard; A conversion module, based on the two absolute coordinates of any two adjacent chess pieces in each chess string, obtains the relative coordinates of each chess piece in the chessboard; The reconstruction module performs image reconstruction based on the relative coordinates and chess piece category of each chess piece in the chessboard to obtain a corrected image of the chessboard.

13. An electronic device comprising: processor; as well as Memory for storing programs, The program includes instructions, which, when executed by the processor, cause the processor to perform the chessboard image correction method according to any one of claims 1 to 11.

14. A non-transitory computer-readable storage medium storing computer instructions, characterized in that: The computer instructions are used to enable the computer to execute the chessboard image correction method according to any one of claims 1 to 11.

Citation Information

Patent Citations

  • Electronic chessboard device and automatic chess moving method

    CN102008816A

  • Coordinate matching method and device for stereo chessboard

    CN106823361A

  • Chessboard recognition method and recognition system

    CN107480678A

  • Object display method, device, storage medium and electronic device

    CN107967447A

  • Method for determining position of chess piece in three-dimensional space and calculating height

    CN108550169A