Chess manual identification method and device, computer equipment, readable storage medium and program product

By performing corner point detection and preset object shape matching on the chessboard image, and combining color detection to accurately identify the position and color of the chess piece, the problem of inaccurate chess score recognition in the prior art is solved, and the accuracy of recognition is improved.

CN118982679APending Publication Date: 2024-11-19CHANGSHA UNIVERSITY
View PDF 7 Cites 0 Cited by

Patent Information

Application Number
CN202410953714.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-16
Publication Date
2024-11-19

AI Technical Summary

Technical Problem

The existing chess score recognition technology has the problem of inaccurate identification, and it is difficult to accurately identify the position and color of the chess piece.

Method used

By acquiring the chessboard images, corner point detection is performed to determine the position of the connecting point, and combining the shape matching and color detection of the preset object, accurately identify the position and color of the chess piece, and then display the chess score.

Benefits of technology

The accuracy of the chess score recognition process is improved, ensuring the accuracy of the position and color recognition of the chess pieces, thereby improving the overall accuracy of chess score recognition.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118982679A_ABST
    Figure CN118982679A_ABST
Patent Text Reader

Abstract

The invention relates to a chess manual recognition method and device, computer equipment, a computer readable storage medium and a computer program product. The method comprises the steps of obtaining a chessboard image; carrying out corner detection on the chessboard image, and determining a connection line intersection point position in the chess manual image; determining the position of a preset object in the chess manual image; determining the position of the preset object as the position of the chess piece under the condition that the preset object is judged to be located at the connecting line intersection point position based on the position of the preset object; determining the color of the chess piece; and displaying a chess manual corresponding to the chessboard image based on the positions and colors of the chess pieces. By adopting the method, the chess manual can be accurately identified.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer vision technology, and in particular to a chess record recognition method, device, computer equipment, computer-readable storage medium and computer program product. Background Art

[0002] With the development of science and technology, chess has become a popular sport. The technology of identifying chess records has emerged. By reviewing the identified chess records, chess players can find problems and accumulate experience, thus improving their chess skills.

[0003] In traditional technology, chess records are generally recognized by obtaining game information through row-column scanning chessboard circuits. That is to say, the two players use row-column scanning chessboard circuits to play the game. During the game, the row-column scanning chessboard circuit scans the chess piece information in each step of the game and transmits it to the computer for processing and display.

[0004] However, the current chess record recognition method still has the problem of insufficient recognition accuracy. Summary of the invention

[0005] Based on this, it is necessary to provide an accurate chessboard recognition method, device, computer equipment, computer-readable storage medium and computer program product to address the above technical problems.

[0006] In a first aspect, the present application provides a chess record recognition method, comprising:

[0007] Get the chessboard image;

[0008] Perform corner detection on the chessboard image to determine the intersection of the lines in the chessboard image;

[0009] Determine the position of a preset object in the chess game image;

[0010] In the case where it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines, the position of the preset object is determined as the position of the chess piece;

[0011] Determine the color of the chess piece;

[0012] Based on the position and color of the chess pieces, the chessboard image is displayed.

[0013] In a second aspect, the present application further provides a chess record recognition device, the device comprising:

[0014] An image acquisition module, used for acquiring a chessboard image;

[0015] The intersection detection module is used to detect corner points of the chessboard image and determine the intersection positions of the lines in the chessboard image;

[0016] A position detection module, used to determine the position of a preset object in a chess record image;

[0017] A chess piece recognition module, for determining the position of the preset object as the position of the chess piece when the preset object is determined to be located at the intersection of the connecting lines based on the position of the preset object;

[0018] Color detection module, used to determine the color of the chess piece;

[0019] The chess record display module is used to display the chess record corresponding to the chessboard image based on the position and color of the chess pieces.

[0020] In a third aspect, the present application further provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0021] Get the chessboard image;

[0022] Perform corner detection on the chessboard image to determine the intersection of the lines in the chessboard image;

[0023] Determine the position of a preset object in the chess game image;

[0024] In the case where it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines, the position of the preset object is determined as the position of the chess piece;

[0025] Determine the color of the chess piece;

[0026] Based on the position and color of the chess pieces, the chessboard image is displayed.

[0027] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0028] Get the chessboard image;

[0029] Perform corner detection on the chessboard image to determine the intersection of the lines in the chessboard image;

[0030] Determine the position of a preset object in the chess game image;

[0031] In the case where it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines, the position of the preset object is determined as the position of the chess piece;

[0032] Determine the color of the chess piece;

[0033] Based on the position and color of the chess pieces, the chessboard image is displayed.

[0034] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0035] Get the chessboard image;

[0036] Perform corner detection on the chessboard image to determine the intersection of the lines in the chessboard image;

[0037] Determine the position of a preset object in the chess game image;

[0038] In the case where it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines, the position of the preset object is determined as the position of the chess piece;

[0039] Determine the color of the chess piece;

[0040] Based on the position and color of the chess pieces, the chessboard image is displayed.

[0041] The above-mentioned chess record recognition method, device, computer equipment, computer-readable storage medium and computer program product perform corner point detection on the chessboard image to determine the position of the intersection of the lines in the chess record image and the position of the preset object in the chess record image. When it is determined based on the position of the preset object that the preset object is located at the position of the intersection of the lines, the preset object is determined to be a valid chess piece, and then the color of the chess piece is determined, thereby achieving accurate recognition of the position and color of the chess piece, thereby further improving the accuracy of the chess record recognition process based on the accurate position and color of the chess piece. BRIEF DESCRIPTION OF THE DRAWINGS

[0042] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0043] FIG1 is a diagram showing an application environment of a chess record recognition method according to an embodiment;

[0044] Figure 2 is a schematic diagram of a process of a chess record recognition method in one embodiment;

[0045] Figure 3 A schematic diagram of a simulated chess game network in a specific application example;

[0046] Figure 4 is a flow chart of a chess record recognition method in another embodiment;

[0047] Figure 5Schematic diagram of the overall scheme of a chess record recognition method in one embodiment;

[0048] Figure 6 It is a test schematic diagram of a chess record recognition process in a specific application example;

[0049] Figure 7 is a structural block diagram of a chess record recognition device in one embodiment;

[0050] Figure 8 FIG. 4 is a diagram showing the internal structure of a computer device in one embodiment. DETAILED DESCRIPTION

[0051] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0052] The chess record recognition method provided in the embodiment of the present application can be applied in the application environment shown in FIG1 . The terminal 102 is provided with an external camera 104 .

[0053] During the chess game, the chess player can start the starting device of the shooting device 104, such as a key device, to control the shooting device 104 to shoot the chessboard image at this time each time he makes a move. The shooting device 104 sends the captured chessboard image to the terminal 102, and the terminal 102 obtains the chessboard image; performs corner point detection on the chessboard image to determine the position of the intersection of the lines in the chess record image; determines the position of the chess piece in the chess record image; determines the color of the chess piece when the chess piece is determined to be located at the intersection of the lines based on the position of the chess piece; displays the chess record corresponding to the chessboard image based on the position and color of the chess piece. Perform corner point detection on the chessboard image to determine the position of the intersection of the lines in the chess record image; determines the position of the chess piece in the chess record image; determines the color of the chess piece when the chess piece is determined to be located at the intersection of the lines based on the position of the chess piece; displays the chess record corresponding to the chessboard image based on the position and color of the chess piece. The chess record displayed on the terminal 102 can be displayed to the chess player.

[0054] The terminal 102 may be, but is not limited to, various personal computers, laptops, smart phones, tablet computers, IoT devices, and portable wearable devices. IoT devices may be smart speakers, smart TVs, smart air conditioners, smart vehicle-mounted devices, projection devices, etc. Portable wearable devices may be smart watches, smart bracelets, head-mounted devices, etc. Head-mounted devices may be virtual reality (VR) devices, augmented reality (AR) devices, smart glasses, etc.

[0055] In an exemplary embodiment, Figure 2 As shown, a chess record recognition method is provided, and the method is applied to the terminal 102 in FIG. 1 as an example for description. Among them:

[0056] S100, obtaining a chessboard image.

[0057] The shape of the chessboard can be square, rectangular, etc. In practical applications, a wooden chessboard is selected as the physical chessboard for playing chess, which not only fits the actual market but also has a flat surface. Different from a leather chessboard, a wooden chessboard will not affect the recognition of chess records in the chessboard image due to wrinkles and reflections.

[0058] Specifically, the terminal has an external shooting device, such as a 1080p high-definition focusable camera, a camera, and other devices for shooting. The shooting device is set at a suitable position on the chessboard. For example, the shooting device is set directly above the chessboard through a bracket so that the camera automatically focuses on the chessboard to avoid missing chess pieces. The real-time picture can be shot to display a clear image, thereby improving the accuracy of obtaining the chessboard image. In the process of playing chess, the chess player can start the shooting device and control the shooting device to shoot the chessboard image at this time for each move. The shooting device sends the captured chessboard image to the terminal, and the terminal obtains the chessboard image. In actual applications, in order to improve the accuracy of chess record recognition, a shadowless lamp can also be added above the chessboard to reduce the impact of uneven lighting.

[0059] In an exemplary embodiment, the photographing device is equipped with an external button, and the method for the terminal to obtain the chessboard image includes: after each chess move, the chess player presses the external button to start the photographing device to capture the chessboard image at that time. In practical applications, the external button can be a USB (Universal Serial Bus) driver-free external button, and the pressing sound of the external button should be as small as possible to avoid affecting the chess player's thinking. The external button can be placed on one side of the chessboard so that both chess players can press it conveniently. In another embodiment, a simulated chessboard is preset in advance, and the method for the terminal to obtain the chessboard image includes: setting the photographing device to real-time photography mode, after the photographing device sends the real-time photographed chessboard image to the terminal, the terminal fits each frame of the chessboard image with the simulated chessboard, and filters out chessboard images that fail to fit. Among the remaining chessboard images, the chessboard image of the previous frame is compared with the chessboard image of the next frame to determine whether the chessboard matrix information of the two chessboard images is consistent. If not, the chessboard image of the next frame is determined to be the chessboard image corresponding to the next move. If consistent, one of the chessboard images is deleted.

[0060] In an exemplary embodiment, the parameter table of the shooting device in this application is shown in Table 1 below, and the parameter table of the external button is shown in Table 2 below:

[0061]

[0062]

[0063] S200, performing corner point detection on the chessboard image to determine the positions of intersections of lines in the chess record image.

[0064] Specifically, in order to realize the recognition of chess records in chessboard images, and because chess pieces are colored objects, the recognition of chess records is divided into the judgment of chess piece color and chess piece position. At this time, a powerful third-party image processing library, such as OpenCV, is needed to process chessboard images. Among them, the OpenCV library is an open source and popular third-party computer vision processing library, written in C / C++, and provides a wealth of image processing functions that can be used to easily acquire images, recognize images, locate images, etc., and provides Python language interfaces and machine learning algorithms, making it more convenient and easy for chess players to perform image processing and recognition.

[0065] To determine the position of chess pieces, first, perform corner detection on the chessboard image to determine the position of the intersection of the lines in the chess image. Taking a 19*19 wooden chessboard as an example, there are 361 intersections of lines on the chessboard. A corner detection algorithm, such as the Shi-Tomasi corner detection algorithm, can be used to perform corner detection on the chessboard image to determine the position of the 361 intersections of lines in the chess image. Among them, the Shi-Tomasi corner detection algorithm is an improvement on the Harris corner detection algorithm. In the Shi-Tomasi corner detection algorithm, the minimum eigenvalue of the response function is used to replace the Harris corner response function R. The Shi-Tomasi corner response function is defined as follows:

[0066] R = min(λ1, λ2)

[0067] Where: λ1——represents the eigenvalue of the autocorrelation gradient covariance matrix M, that is, the grayscale change degree of the pixel;

[0068] λ2——represents the eigenvalue of the autocorrelation gradient covariance matrix M, that is, the degree of grayscale change of the pixel.

[0069] In the Shi-Tomasi corner detection algorithm, the minimum eigenvalue is selected as the basis for judging the corner point, which has a higher recognition rate and is more convenient for parameter adjustment.

[0070] S300, determining the position of a preset object in the chess record image.

[0071] The chess pieces may be in various shapes, for example, they may be regular shapes such as circles and rectangles, or irregular shapes. The preset object is essentially an object that matches the shape of the chess piece.

[0072] Specifically, the shape of the chess piece is acquired in advance, and through an algorithm matching the shape of the chess piece, a preset object matching the shape of the chess piece is identified in the chess record image, and the position of the preset object is determined.

[0073] In an exemplary embodiment, the chess piece is circular. At this time, the circular target on the chessboard can be determined by the Hough gradient circle detection method. Among them, the Hough gradient circle detection method detects the center and radius of the circle. If the detected center and radius are consistent with the set parameters, it is determined to be a circle. In another embodiment, the chessboard image can be segmented according to the chessboard specifications. Taking a 19*19 chessboard as an example, the 19*19 chessboard is divided into 361 sub-images with 361 connecting line intersections as the center, and the pixels in each sub-image are detected. The number of pixels is judged based on a suitable critical point. For example, if the number of black pixels is greater than the critical point, it is black, and if the number of black pixels is less than the critical point, it is white. Finally, based on the color information, it is determined that there is a circular target at this position. In practical applications, although Hough circle detection has high requirements for image denoising and is easily affected by uneven illumination, compared with image segmentation methods, Hough circle detection is fast and adaptable.

[0074] In an exemplary embodiment, the gradient directions of points on the same circle all point to the center of the circle, and the image needs to be edge detected before calculation. After edge detection, the specific steps of the Hough gradient circle detection method include: first calculate the gradient of each pixel point, then traverse the non-zero pixel points in the image after edge detection, draw a straight line along the gradient of the point, and count the points passed by the straight line in the accumulator, where the larger the point in the accumulator, the more likely it is the center of the circle, and retain the points in the accumulator that are greater than a given threshold and greater than all its neighbors, and then arrange these points in descending order according to the accumulated value to ensure that the point most likely to be the center of the circle appears first. After selecting the candidate center point, consider all non-zero pixels for each center, and make a radius estimate for a possible center of the circle:

[0075] ① Calculate the distance from the center of the circle to all non-zero points in the boundary graph and sort them from small to large;

[0076] ② Starting from a small radius r, points whose distances differ within a threshold range are considered to be in the same circle, and the number of non-zero points belonging to the radius r is counted, recorded as n;

[0077] ③Try to enlarge the radius and count the number of points within the radius in the same way;

[0078] ④ The basis for judging which of the two radii is better - the line density of the points (number of points n / radius r). The higher the density, the greater the credibility of the radius;

[0079] ⑤ Repeat the above steps until the radius exceeds the range allowed by the parameters, thus obtaining the optimal radius.

[0080] S400, when it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines, the position of the preset object is determined as the position of the chess piece.

[0081] Specifically, the position of the preset object may not be located at the intersection of the lines, or may be located at the intersection of the lines. In the case where it is determined based on the position of the preset object that the preset object is located at the intersection of the lines, the preset object is considered to be a chess piece, and the position of the preset object is determined as the position of the chess piece. In the case where it is determined based on the position of the preset object that the preset object is not located at the intersection of the lines, the preset object is considered not to be a chess piece.

[0082] In an exemplary embodiment, when the chess piece is circular in shape, determining whether the preset object is located at the intersection of the lines based on the position of the preset object is essentially to determine whether the position of the center of the circle is within the circle of the preset diameter corresponding to the intersection of the lines. If so, there is a chess piece at the intersection of the lines; if not, there is no chess piece at the intersection of the lines.

[0083] In an exemplary embodiment, the chess pieces of the present application are made of resin Go pieces, which are different from the cloud pieces and agate pieces used in standard equipment for large-scale competitions. The resin pieces are not only cheap, reducing the cost for Go enthusiasts, but also effectively reduce the impact of reflection and uneven lighting of the pieces on the recognition algorithm.

[0084] S500, determining the color of the chess piece.

[0085] Specifically, the colors of chess pieces vary, such as black and white, blue and green, etc. Each color of chess piece represents a chess player, so the color of the chess piece needs to be determined to accurately display the chess record corresponding to the chessboard image.

[0086] S600, displaying a chess record corresponding to the chessboard image based on the position and color of the chess pieces.

[0087] Specifically, based on the position and color of the chess pieces, chessboard matrix information is generated, and based on the chessboard matrix information, the chess record corresponding to the current chessboard image is displayed in the simulated chess record network. Figure 3 As shown, the simulated chess record network may include various function buttons, such as step number judgment function, win-loss judgment function, review function, previous step function, next step function, etc.

[0088] In an exemplary embodiment, when the chess player presses the step judgment function button, the terminal's simulated chess record network can display the order of each chess piece placement in the current chess record; when the chess player presses the victory or defeat judgment function button, the terminal's simulated chess record network can display the result of the current chess record, and if there is no victory, it will display "none"; when the chess player presses the previous step function button or the next step function button, the terminal's simulated chess record network can display the previous step or the next step.

[0089] In an exemplary embodiment, the chess record corresponding to the chessboard image is displayed in order to realize the animation of the chessboard. In this application, the display of chess records and the continuous playback of chess records are realized through a third-party library containing drawing functions, such as Pygame in the Python class library. Python is a language with simple syntax and rich and powerful class libraries. Compared with languages ​​such as Java / C++, it is easier to write code and combine rich and powerful third-party class libraries to reduce learning costs; Pygame is a module for developing 2D games. Python programming software includes but is not limited to Pycharm, Python3 plug-in downloaded from VisualStido Code, etc.

[0090] In the above chess record recognition method, by performing corner point detection on the chessboard image, the position of the intersection of the lines in the chess record image is determined, and the position of the preset object in the chess record image is determined. When it is determined based on the position of the preset object that the preset object is located at the position of the intersection of the lines, the preset object is determined to be a valid chess piece, and then the color of the chess piece is determined, so that the position and color of the chess piece can be accurately recognized, thereby further improving the accuracy of the chess record recognition process based on the accurate position and color of the chess piece.

[0091] In an exemplary embodiment, Figure 4 As shown, S100 includes:

[0092] S120, obtaining an initial chessboard image.

[0093] Specifically, since a chessboard is generally a regular shape such as a rectangle, and the initial chessboard image captured by the shooting device is generally an irregular shape such as a tilt, the initial chessboard image needs to be corrected. The correction method includes but is not limited to perspective transformation of the initial chessboard image. After the perspective transformation of the chessboard in the initial chessboard image, not only the shape of the chessboard becomes regular, but also some parts outside the chessboard are removed, so that a chessboard image with only the chessboard is obtained.

[0094] S140, performing edge detection on the initial chessboard image to determine edge vertices in the initial chessboard image.

[0095] Specifically, the edge detection method used in the present application is generally a canny edge detection algorithm. The canny edge detection algorithm is used to perform edge detection on the initial chessboard image to determine the edge vertices in the initial chessboard image.

[0096] S160, performing corner point detection on the initial chessboard image to determine edge corner points in the initial chessboard image.

[0097] Specifically, the corner point detection method used in this application is generally the Shi-Tomasi corner point detection algorithm. By using the Shi-Tomasi corner point detection algorithm, the initial chessboard image is subjected to corner point detection, and the edge corner points in the initial chessboard image can be determined. The edge corner points are essentially the four vertices in the initial chessboard image. More specifically, the Shi-Tomasi corner point detection algorithm is used to perform corner point detection on the initial chessboard image, determine the corner points in the initial chessboard image, and select the maximum coordinate value x on the x-axis and y-axis. max ,y max , and the minimum coordinate value on the x-axis and y-axis (x min ,y min ) respectively correspond to the four edge corner points (x max ,y max )、(x min ,y max ), (y min , x min )、(x max ,y min ).

[0098] S180: If the edge vertices match the edge corner points, a perspective transformation is performed on the initial chessboard image to obtain a chessboard image.

[0099] Specifically, if the edge vertices match the edge corners, it means that the edge vertices or edge corners obtained are correct. At this time, the image can be perspective transformed, that is, the remaining content in the image that is not related to the chessboard can be removed, and the edge corners can also be removed to obtain a chessboard image with only the corners inside the chessboard. For example, a 19*19 chessboard, after removing the edge corners, there are still 361 corners left, that is, 361 line intersection positions. After perspective transformation, for example, after perspective transformation to a square image with a side length of 620 pixels, the image generally leaves a certain blank position. In actual applications, after repeated detection, the blank position is about 22 pixels, with (22, 22) as the origin, and the horizontal and vertical spacing of the grid intersections are both 32 pixels. Therefore, the position of each line intersection in the image, that is, the corner position, can be accurately obtained later.

[0100] In the above embodiment, by performing edge detection and corner point detection on the initial chessboard image respectively, it is possible to determine the edge vertices and edge corner points, and only when the edge vertices and edge corner points match, can the obtained edge vertices and edge corner points be considered accurate, thereby making the process of perspective transformation of the initial chessboard image accurate and improving the accuracy of the obtained chessboard image.

[0101] In an exemplary embodiment, performing edge detection on an initial chessboard image to determine edge vertices in the initial chessboard image includes:

[0102] The initial chessboard image is grayed and filtered to obtain an initial chessboard grayscale image; edge detection is performed on the initial chessboard grayscale image; contour detection is performed on the initial chessboard grayscale image after edge detection to obtain an initial chessboard edge contour; and edge vertices in the initial chessboard image are determined based on the initial chessboard edge contour.

[0103] Specifically, since there are many speckle noises in the initial chessboard image and edge detection is very sensitive to noise, it is necessary to perform denoising on the initial chessboard image. The present application uses grayscale and Gaussian filtering to perform denoising on the initial chessboard image to obtain an initial chessboard grayscale image.

[0104] Then, edge detection is performed on the initial chessboard grayscale image, and contour detection is performed on the initial chessboard grayscale image after edge detection. The chessboard shape is fitted by the contour function to obtain the initial chessboard edge contour with the largest closed area matching the chessboard shape. Based on the initial chessboard edge contour, the edge vertices in the initial chessboard edge contour are determined. For example, in the case where the chessboard is a quadrilateral, the quadrilateral is fitted by the contour function to obtain the quadrilateral contour with the largest closed area. Based on the quadrilateral contour, the four edge vertices in the quadrilateral contour are determined.

[0105] In an exemplary embodiment, after the four edge vertices in the quadrilateral outline are determined, the initial chessboard image may be subjected to perspective transformation to remove the contents outside the outline in the image, such as objects such as the floor.

[0106] In the above embodiment, by graying and filtering the initial chessboard image, the initial chessboard image can be denoised, thereby improving the accuracy of identifying the chessboard image. Furthermore, by performing contour detection on the initial chessboard grayscale image after edge detection, the edge vertices in the initial chessboard image can be accurately determined.

[0107] In an exemplary embodiment, determining the color of a chess piece includes:

[0108] The chessboard image is converted into an HSV mode image, and the HSV values ​​of the pixels corresponding to the chess pieces in the HSV mode image are determined; based on the HSV values ​​of the pixels, the color of the chess pieces is determined.

[0109] Specifically, determining the color of the chess piece is essentially to perform binary thresholding on the pixel values of each channel at the center of the chess piece. If it is greater than or less than a certain value, the specific color can be obtained. Specifically, the chessboard image is converted into an HSV mode image, and the color of the chess piece is determined through the HSV values of each pixel point in the HSV mode image. That is, the color of the chess piece is determined through the hue, saturation, and brightness of each pixel point. The HSV color mode for judging black and white pieces can greatly avoid problems such as reflection and shadow. The color judgment method based on the HSV mode is less affected by noise and is easy to debug and stable.

[0110] In an exemplary embodiment, the three HSV values of the black chess piece are zero, and the three HSV values of the white one are V = 255 and the others are zero. In practical applications, for black pieces, 0 < 115 < V, and for white pieces, 0 < s < 50 and 114 < v < 256.

[0111] In another embodiment, determining the color of the chess piece further includes a judgment based on the grayscale mode image, that is, judging the magnitude of the pixel value at the center of the chess piece after grayscale processing, and then determining the color of the chess piece. For example, if the pixel value is greater than 170, it is a white piece, and if the pixel value is less than 170, it is a black piece. However, in this method, the grayscale image pixel value is greatly affected by noise. In actual operation, there are high requirements for light, shadow, and picture clarity. It takes a lot of time to debug and is unstable. Therefore, this application selects the HSV mode to determine the color of the chess piece.

[0112] In the above embodiments, by converting the chessboard image into an HSV mode image and then judging the color of the chess piece through the HSV values of each pixel point in the image, it is less affected by noise, easy to debug and stable, and improves the accuracy of chess score recognition.

[0113] In an exemplary embodiment, based on the position and color of the chess piece, displaying the chess score corresponding to the chessboard image includes:

[0114] For each connection intersection position, based on the position and color of the chess piece, determine the identifier of the chess piece located at the connection intersection position; based on the identifiers of the chess pieces located at each connection intersection position, display the chess score corresponding to the chessboard image.

[0115] Specifically, initialize several variables to transmit the position information and color of the chess piece. The recognition program of the terminal obtains the chess score matrix information. Taking the chess piece colors included in the chess score matrix information as color 1 and color 2 as an example, the chess score matrix information includes the identifiers of the chess pieces at each connection intersection. Among them, the identifier being 0 means there is no chess piece, the identifier being 1 means the chess piece of color 1, and the identifier being 2 means the chess piece of color 2.

[0116] After the terminal's recognition program obtains the chess matrix information, the terminal's animation display program will traverse each line intersection based on the chess matrix information to determine whether the identifier at the current line intersection is 0. If it is 0, it indicates that there is no chess piece here. If it is 1, it indicates that there is a chess piece of color 1 here. If it is 2, it indicates that there is a chess piece of color 2 here. By traversing the identifiers at all the line intersections, all chess pieces are drawn in the simulated chess network.

[0117] Furthermore, the animated display of chess records requires the Python library Pygame. Through the function of drawing straight lines in Pygame, a preset number of straight lines are drawn within the specific background pixel range of the window to form a simulated chess record network. Sequential marking characters are added next to each straight line in the simulated chess record network to intuitively see the position of the chess pieces. The positions of the four vertices of the simulated chess record network are known according to the pixel length of the drawn straight line and the pixel position of the endpoints, so as to calculate the number of pixels between each grid. Furthermore, based on the position and color of each chess piece, the chess record matrix information is obtained. According to the chess record matrix information, the coordinates of any chess piece are multiplied by the corresponding pixel grid distance, and drawn into the simulated chess record network through the circle drawing function.

[0118] In the above embodiment, by obtaining the identifier at the intersection of each connecting line, the chess record can be accurately displayed on the simulated chess record network.

[0119] In an exemplary embodiment, on the chess record display interface of the terminal, there are several function buttons next to the simulated chess record network, including a replay function button, a step display function button, a game result acquisition function button, a previous step function button, a next step function button, etc. Clicking a button can start the corresponding function. The black area in the figure is the response range of the button, that is, the pixel coordinates obtained by clicking the mouse are compared with the pixel coordinates of the button to determine whether they are within the pixel coordinate range of the button. If so, the button operation is responded to.

[0120] In an exemplary embodiment, the method further comprises:

[0121] In response to the game result acquisition operation for the chess record, the chess pieces in the chess record that do not meet the preset live piece conditions are filtered out; the number of chess pieces of different colors in the chess record is obtained; based on the number of chess pieces of different colors, the game result is generated and pushed.

[0122] Specifically, there are multiple functional operations on the simulated chess record network, including the game result acquisition function. Taking Go as an example, the victory or defeat of Go is compared by who occupies more territory. Based on this, the user clicks on the game result acquisition function next to the chess record in the simulated chess record network, and the terminal responds to the game result acquisition operation for the chess record, obtains the number of chess pieces of different colors in the current chess record, and generates the game result based on the number of chess pieces of different colors, displays the game result, and pushes it to other users' terminals.

[0123] Furthermore, the number of chess pieces of different colors in the current chess record is obtained, which is the number of live pieces. Since not all chess pieces in the chess record are live, before obtaining the number of chess pieces of different colors in the current chess record, it is necessary to filter out chess pieces that do not meet the preset live piece conditions, that is, to clean up dead pieces and residual pieces. In practical applications, dead pieces are surrounded on all four sides, and residual pieces are chess pieces that have not been annihilated but have been seriously damaged in the chess game.

[0124] In an exemplary embodiment, taking the chess record including black and white chess pieces as an example, if black chess pieces move first, since moving first has an advantage, therefore, based on obtaining the number of black and white chess pieces in the current chess record, black chess pieces also need to compensate white chess pieces with a preset number of chess pieces, for example, black chess pieces compensate white chess pieces with 3.75 chess pieces, and then generate the game result based on the number of chess pieces of different colors.

[0125] In an exemplary embodiment, generating a game result based on the number of chess pieces of different colors includes: determining the color corresponding to the chess piece with the largest number based on the number of chess pieces of different colors, and using the chess piece of that color as the winning chess piece.

[0126] In the above embodiment, by filtering out the chess pieces in the chess record that do not meet the preset live piece conditions, the remaining chess pieces are all valid chess pieces, which improves the accuracy of obtaining the number of chess pieces of different colors in the chess record, and further, the game result can be accurately generated to determine which side wins.

[0127] In an exemplary embodiment, the method further comprises:

[0128] In response to a playback operation on a chess record, a historical chess record is obtained; and the historical chess record and the chess record are displayed in sequence according to their respective generation times.

[0129] The historical chess records can be one or more. For example, the historical chess records can be the chess records of the previous step. In some cases, the historical chess records can also be all the chess records before the current chess record. For example, if the current chess record is the chess record of the last step, the historical chess records are all the chess records except the chess record of the last step.

[0130] Specifically, since it is not convenient to look through each chess record one by one from a folder containing multiple chess records when reviewing the game, the present application provides a playback function, and the playback operation actually displays the chess records saved step by step during the game in an animated manner.

[0131] Therefore, the terminal responds to the playback operation of the chess record and obtains one or more historical chess records. Each historical chess record will record its generation time when it is generated. Therefore, one or more historical chess records and chess records can be displayed in sequence according to their respective generation time, so that the chess player can watch the playback record of the chess record. Further, during the playback of all chess records, the chess player can also independently control the playback process by clicking the previous step function button and the next step function button.

[0132] In the above embodiment, by following one or more historical chess records and their respective generation times, each chess record can be automatically replayed without manual operation, thereby improving the automation of chess record display.

[0133] In an exemplary embodiment, the simulated chess record network also provides a replay function, which is equivalent to an initialization function, and returns the simulated chess record network to a state where no moves have been made.

[0134] In an exemplary embodiment, the simulated chess record network also provides a step display function. The step display can help chess players intuitively see each move of themselves and their opponents, improving the efficiency of replaying and the level of the chess players themselves. The step display program locates the chess pieces placed in the current chess record by changing the chess record matrix information of the current chess record and the previous chess record at the position where the chess piece is dropped with each move, and marks it according to the step number to generate the step position information and store it. When it needs to be displayed, click the step button in the animation program to display the order in which each chess piece in the current chess record is dropped.

[0135] In an exemplary embodiment, the simulated chess record network also provides the previous step and next step functions. When the previous step function button is pressed, the simulated chess record network will display the chess record of the previous step. When the next step function button is pressed, the simulated chess record network will display the chess record of the next step. When the number of chess moves is 0, clicking the previous step function button will not respond.

[0136] In an exemplary embodiment, as the number of chess moves increases, more chess pieces are affected by the light, and the possibility of inaccurate recognition of chess pieces due to stickiness of chess pieces is also higher. The present application can also test the accuracy of chess record recognition by controlling the number of chess moves, and the results are shown in Table 3 below:

[0137]

[0138] It can be seen that the chess record recognition method of the present application has a higher recognition accuracy.

[0139] In a specific application example, the present application provides a chess record recognition method that does not interfere with normal game play and can record game records in real time. The chess record recognition method has high accuracy, fast response speed, low cost, and the equipment used is simple to install and inexpensive. It can be applied to record chess records and judge the winning and losing of ordinary Go games; players can also review the game through the chess record to find loopholes in their chess skills.

[0140] The hardware used in the chess record recognition method includes: a computer, a 19×19 chessboard, resin chess pieces, a simulated chess record network, a camera, and a USB button, wherein the USB button is used to start the camera for shooting, and the camera is used to shoot the chessboard. The selected resin chess pieces are round, the size matches the 19×19 chessboard, and the colors of the chess pieces are black and white.

[0141] The overall scheme of the chess record recognition method is as follows: Figure 5 As shown. Every time the chess player makes a move, he presses the USB button, so that the camera captures the initial chessboard image and sends the initial chessboard image to the computer, and the display screen on the computer can display the initial chessboard image. The system main program in the computer controls the image recognition module in the computer to recognize the chess record of the initial chessboard image, and controls the animation display module to display the recognized chess record. Then, through several function buttons in the computer interface, the chess record is subjected to corresponding operations such as replaying, displaying the number of steps, obtaining the game results, previous step, and next step.

[0142] The specific process of the chess record recognition module performing chess record recognition on the initial chessboard image includes:

[0143] The initial chessboard image is grayed and filtered to obtain the initial chessboard grayscale image; the initial chessboard grayscale image is edge detected; the initial chessboard grayscale image after edge detection is contour detected to obtain the initial chessboard edge contour; based on the initial chessboard edge contour, the edge vertices in the initial chessboard image are determined, and the initial chessboard image is perspective transformed to remove the content outside the image contour, such as objects such as the floor. The Shi-Tomasi corner point detection algorithm is used to detect corner points in the initial chessboard image to determine the edge corner points in the initial chessboard image; if the edge vertices match the edge corner points, the initial chessboard image is perspective transformed to obtain the chessboard image after removing the edge vertices.

[0144] The Shi-Tomasi corner detection algorithm is used to detect corners of the chessboard image and determine the positions of 361 intersections of lines in the chess image. The Hough circle detection algorithm is used to determine the position of the circular target in the chess image. When the circular target is located at the intersection of lines based on the position of the circle, the position of the circular target is determined as the position of the chess piece. The chessboard image is converted into an HSV mode image and the HSV values ​​of the pixels corresponding to the chess pieces in the HSV mode image are determined. The color of the chess piece is determined based on the HSV values ​​of the pixels.

[0145] The recognized chess records are displayed through the animation display module, including:

[0146] Based on the position and color of the chess pieces, chess matrix information is obtained, wherein each line intersection position in the chess matrix information has an identifier, an identifier of 0 represents that there is no chess piece here, an identifier of 1 represents that the chess piece is black, and an identifier of 2 represents that the chess piece is white. Based on the identifier of each line intersection position, the chess record corresponding to the chessboard image is displayed in the simulated chess record network.

[0147] Furthermore, after the game is over, the terminal has obtained the chess records corresponding to each step, so the terminal can display the animation according to the chess records corresponding to each step. The terminal also provides game result acquisition function, step display function, review function, previous step function, next step function, etc., so that the chess player can review the game accurately.

[0148] Before performing chess record recognition, the terminal will also test the chess record recognition process, such as Figure 6 As shown, the test process specifically includes: testing whether the external camera sends the chessboard image in real time; testing whether the external button can be pressed; testing whether the computer screen displays the chess game picture; testing whether pressing the function button on the computer performs the corresponding function operation; testing whether the computer can identify and detect the chess pieces after obtaining the chessboard image; testing whether the chess game matrix information can be obtained; testing whether it can be animated and generate chess game animation.

[0149] It should be understood that, although the steps in the flowcharts involved in the above embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps is not strictly limited in order, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above embodiments may include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0150] Based on the same inventive concept, the embodiment of the present application also provides a chess record recognition device for implementing the chess record recognition method involved above. The implementation scheme for solving the problem provided by the device is similar to the implementation scheme recorded in the above method, so the specific limitations in one or more chess record recognition device embodiments provided below can refer to the limitations of the chess record recognition method above, and will not be repeated here.

[0151] In one embodiment, Figure 7 As shown, a chess record recognition device is provided, comprising: an image acquisition module 100, an intersection detection module 200, a position detection module 300, a chess piece recognition module 400, a color detection module 500 and a chess record display module 600, wherein:

[0152] An image acquisition module 100 is used to acquire a chessboard image;

[0153] The intersection detection module 200 is used to detect corner points of the chessboard image and determine the intersection positions of the lines in the chessboard image;

[0154] A position detection module 300 is used to determine the position of a preset object in a chess record image;

[0155] The chess piece recognition module 400 is used to determine the position of the preset object as the position of the chess piece when the preset object is determined to be located at the intersection of the connecting lines based on the position of the preset object;

[0156] A color detection module 500 is used to determine the color of the chess piece;

[0157] The chess record display module 600 is used to display the chess record corresponding to the chessboard image based on the positions and colors of the chess pieces.

[0158] In one embodiment, the image acquisition module 100 is also used to acquire an initial chessboard image; perform edge detection on the initial chessboard image to determine edge vertices in the initial chessboard image; perform corner point detection on the initial chessboard image to determine edge corner points in the initial chessboard image; if the edge vertices match the edge corner points, perform perspective transformation on the initial chessboard image to obtain a chessboard image.

[0159] In one embodiment, the image acquisition module 100 is also used to grayscale and filter the initial chessboard image to obtain an initial chessboard grayscale image; perform edge detection on the initial chessboard grayscale image; perform contour detection on the initial chessboard grayscale image after edge detection to obtain an initial chessboard edge contour; and determine edge vertices in the initial chessboard image based on the initial chessboard edge contour.

[0160] In one embodiment, the color detection module 500 is further used to convert the chessboard image into an HSV mode image, determine the HSV value of the pixel corresponding to the chess piece in the HSV mode image; and determine the color of the chess piece based on the HSV value of the pixel. In one embodiment, the chess record display module 600 is further used to determine the identifier of the chess piece located at the intersection of each connecting line based on the position of the chess piece and the color of the chess piece; and display the chess record corresponding to the chessboard image based on the identifier of the chess piece located at each connecting line intersection.

[0161] In one embodiment, the chess record recognition device further includes a result acquisition module, which is used to respond to a game result acquisition operation for a chess record, filter out chess pieces in the chess record that do not meet preset live piece conditions; obtain the number of chess pieces of different colors in the chess record; and generate and push the game result based on the number of chess pieces of different colors.

[0162] In one embodiment, the chess record recognition device further includes a playback module, which is used to respond to a playback operation on a chess record and obtain multiple historical chess records; and display the historical chess records and chess records in sequence according to their respective generation times.

[0163] Each module in the above chess record recognition device can be implemented in whole or in part by software, hardware or a combination thereof. Each module can be embedded in or independent of a processor in a computer device in the form of hardware, or can be stored in a memory in a computer device in the form of software, so that the processor can call and execute the operations corresponding to each module.

[0164] In an exemplary embodiment, a computer device is provided. The computer device may be a terminal, and its internal structure diagram may be as shown in FIG. Figure 8As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface, a display unit and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface, the display unit and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be realized through WIFI, a mobile cellular network, near field communication (NFC) or other technologies. When the computer program is executed by the processor, a method for recognizing chess records is realized. The display unit of the computer device is used to form a visually visible picture, which can be a display screen, a projection device or a virtual reality imaging device. The display screen can be a liquid crystal display screen or an electronic ink display screen, and the input device of the computer device can be a touch layer covering the display screen, or a button, trackball or touchpad set on the computer device shell, or an external keyboard, touchpad or mouse.

[0165] Those skilled in the art will understand that Figure 8 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0166] In one embodiment, a computer device is further provided, including a memory and a processor, wherein a computer program is stored in the memory, and the processor implements the steps in the above method embodiments when executing the computer program.

[0167] In one embodiment, a computer-readable storage medium is provided, on which a computer program is stored. When the computer program is executed by a processor, the steps in the above-mentioned method embodiments are implemented.

[0168] In one embodiment, a computer program product is provided, including a computer program, which implements the steps in the above method embodiments when executed by a processor.

[0169] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0170] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0171] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A chess record recognition method, characterized in that: The method comprises: Get the chessboard image; Performing corner point detection on the chessboard image to determine the intersection positions of the connecting lines in the chess record image; Determining the position of a preset object in the chess record image; In the case where it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines, the position of the preset object is determined as the position of the chess piece; determining the color of the chess piece; Based on the position of the chess piece and the color of the chess piece, a chess record corresponding to the chessboard image is displayed.

2. The method according to claim 1, characterized in that The step of obtaining a chessboard image comprises: Get the initial chessboard image; Performing edge detection on the initial chessboard image to determine edge vertices in the initial chessboard image; Performing corner point detection on the initial chessboard image to determine edge corner points in the initial chessboard image; If the edge vertices match the edge corner points, a perspective transformation is performed on the initial chessboard image to obtain a chessboard image.

3. The method according to claim 2, characterized in that The performing edge detection on the initial chessboard image to determine edge vertices in the initial chessboard image includes: Grayscale and filter the initial chessboard image to obtain an initial chessboard grayscale image; Performing edge detection on the initial chessboard grayscale image; Performing contour detection on the initial chessboard grayscale image after edge detection to obtain the initial chessboard edge contour; Based on the initial chessboard edge contour, edge vertices in the initial chessboard image are determined.

4. The method according to claim 1, characterized in that: Determining the color of the chess piece includes: Convert the chessboard image into an HSV mode image, and determine the HSV values ​​of the pixels corresponding to the chess pieces in the HSV mode image; The color of the chess piece is determined based on the HSV value of the pixel.

5. The method according to any one of claims 1 to 4, characterized in that: The step of displaying the chess record corresponding to the chessboard image based on the position and color of the chess piece comprises: For each line intersection position, based on the position of the chess piece and the color of the chess piece, determine the identifier of the chess piece located at the line intersection position; Based on the identifiers of the chess pieces located at the intersections of the connecting lines, the chess record corresponding to the chessboard image is displayed.

6. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: In response to the game result acquisition operation for the chess record, filtering chess pieces in the chess record that do not meet the preset live piece condition; Obtain the number of chess pieces of different colors in the chess record; Generate and push the game results based on the number of chess pieces of different colors.

7. The method according to any one of claims 1 to 4, characterized in that: The method further comprises: In response to a playback operation on the chess record, obtaining a historical chess record; The historical chess records and the chess records are displayed in sequence according to their respective generation times.

8. A chess record recognition device, characterized in that: The device comprises: An image acquisition module, used for acquiring a chessboard image; An intersection detection module, used to perform corner detection on the chessboard image and determine the intersection positions of the connecting lines in the chess record image; A position detection module, used to determine the position of a preset object in the chess record image; A chess piece recognition module, configured to determine the position of the preset object as the position of the chess piece when it is determined based on the position of the preset object that the preset object is located at the intersection of the connecting lines; A color detection module, used to determine the color of the chess piece; The chess record display module is used to display the chess record corresponding to the chessboard image based on the position and color of the chess piece.

9. A computer device comprising a memory and a processor, wherein the memory stores a computer program, wherein: When the processor executes the computer program, the steps of the method according to any one of claims 1 to 7 are implemented.

10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 7 are implemented.

Citation Information

Patent Citations

  • Automatic Go notation method based on video recognition technology

    CN107506701A

  • A distortion image correction method and device based on corner detection

    CN109409366A

  • A go chess manual recognition method based on a chess manual RGB image

    CN109559325A

  • A Chinese chess recognition method based on a convolutional neural network model

    CN109726721A

  • Go chess recognition method based on image recognition and program interface

    CN110909727A