A chess piece target positioning and identification method based on optimization parameters and China-chess-net
By optimizing the parameters of the China-chess-net network and combining it with improved Canny edge detection and Hough circle detection algorithms, the problems of large data requirements and overfitting in Chinese chess piece detection algorithms are solved, achieving high-precision, real-time piece localization and recognition, which is suitable for Chinese chess human-computer game systems.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- NANJING NORMAL UNIVERSITY
- Filing Date
- 2022-12-27
- Publication Date
- 2026-04-21
AI Technical Summary
There is a lack of effective algorithms for detecting Chinese chess pieces in existing technologies. Traditional convolutional neural network models require a large amount of training data and are prone to overfitting, resulting in poor detection performance, especially in complex lighting environments.
An improved Canny edge detection and Hough circle detection algorithm with optimized parameters is adopted using the China-chess-net network. The localization and recognition of chess pieces are achieved through training with a small amount of data. An improved algorithm combining convolutional neural network and backpropagation neural network is used to fuse chess piece position and category information.
It achieves high-precision, real-time chess piece positioning and recognition in complex lighting environments, with chess piece positioning accuracy and recognition accuracy approaching 100%. The model has strong generalization ability and good real-time performance, making it suitable for Chinese chess human-computer game systems.
Smart Images

Figure CN115984852B_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of target recognition and involves technologies such as artificial intelligence, deep learning and computer vision. Specifically, it relates to a method for chess piece target localization and recognition based on optimized parameters and China-chess-net. Background Technology
[0002] With the continuous development of artificial intelligence, deep learning, and machine vision in recent years, the AI Go program AlphaGo emerged. AlphaGo's consecutive victories over top-ranked Go players have significantly overturned people's perceptions of artificial intelligence. Subsequently, a large number of people have flocked to the development and application of AI algorithms, leading to the desire to develop a Chinese chess human-machine chess system that would allow humans to play chess against machines. Currently, chess piece detection is a crucial part of the development of a Chinese chess human-machine chess system. However, there are very few algorithms specifically designed for chess piece detection. Using convolutional neural networks to detect chess pieces requires a large dataset to train the model, and the trained model has poor generalization ability and is prone to overfitting. Chess piece detection algorithms are a major challenge in the development of human-machine chess systems. Summary of the Invention
[0003] Purpose of the invention: To address the current scarcity of detection algorithms specifically for Chinese chess pieces, and the fact that traditional convolutional neural network models require large amounts of training data and are extremely prone to overfitting (i.e., performing well on training samples but poorly on validation samples), this invention proposes a chess piece target localization and recognition method based on optimized parameters and China-chess-net. This method enables accurate localization and recognition of multiple small targets like Chinese chess pieces, and allows for real-time detection with minimal impact from complex lighting conditions.
[0004] Technical Solution: To achieve the above objectives, this invention provides a method for chess piece target localization and identification based on optimized parameters and China-chess-net, comprising the following steps:
[0005] S1: Collect and save multiple images of complete chessboards, crop out the chess pieces from each image, use the labelme tool to label the category of each chess piece, and divide the dataset into training set, validation set and test set in an 8:1:1 ratio.
[0006] S2: Build the China-chess-net network, select the optimizer adam and the loss function CTCLoss, and train the China-chess-net network using the dataset to obtain the trained China-chess-net network model. This model is used for chess recognition.
[0007] S3: An improved Canny edge detection algorithm with optimized parameters using a convolutional neural network and an improved Hough circle detection and localization algorithm with optimized parameters using a BP neural network are used to locate chess pieces in a chessboard image and save the chess piece images and position information.
[0008] S4: The improved Canny edge detection algorithm with optimized parameters of convolutional neural network and the improved Hough circle detection and localization algorithm with optimized parameters of BP neural network are fused with the China-chess-net recognition algorithm to obtain the position and category information of each chess piece, and to calculate the accuracy of chess piece localization and recognition and the real-time performance of model detection.
[0009] Furthermore, the method for building the China-chess-net network in step S2 includes the following steps:
[0010] A1: Randomly select a chess piece image with a size of 60×60×3 from the chess test set obtained in step S1 and input it into the Color-Net network of the China-chess-net network to obtain the color information of the chess piece image;
[0011] A2: Convert the chess piece image selected in step A1 to grayscale and downsample the grayscale image to obtain a grayscale image that matches the size of the image input to the Rec-Net network.
[0012] A3: If the color information output by the Color-Net network in step A1 is red, then the grayscale image obtained in step A2 is used as the input of the Rec-Net network; if the color information output by the Color-Net network in step A1 is black, then the grayscale image obtained in step A2 is flipped 180 degrees and used as the input of the Rec-Net network.
[0013] A4: Input the feature map obtained in step A3 into the Rec-Net network to obtain the recognition result of the chess piece image.
[0014] Furthermore, the construction of the Color-Net network structure in step A1 includes the following steps:
[0015] B1: The input image size is 60×60×3. First, the image is input into the first convolutional layer. This first convolutional layer has 32 kernels, a kernel size of 3×3, padding of 1, stride of 1, and uses COSRULU activation. The output feature map size is 60×60×32. Then, it passes through the first Dropout layer, randomly deactivating 25% of neurons. Finally, it passes through the first max-pooling layer, with a kernel size of 2×2 and stride of 2. The output feature map size is 30×30×32. The formula for calculating the input and output sizes of the convolutional layer is:
[0016]
[0017] in, This indicates the size of the output image after passing through the convolutional layer. This indicates the size of the image input to the convolutional layer. This indicates the size of the convolutional kernel in the convolutional layer. Indicates the number of pixels filled in the image. This indicates the stride of the convolution kernel during feature extraction;
[0018] The formula for calculating the input and output sizes of a pooling layer is:
[0019]
[0020] in, This indicates the size of the image output after passing through the pooling layer. This indicates the size of the image input to the pooling layer. This indicates the size of the pooling layer convolution kernel. This represents the stride of the convolution kernel during max pooling;
[0021] The formula for calculating the COSRuLU activation function is:
[0022]
[0023] This represents the output of the activation function. This represents the input to the activation function; in this invention, c is set to 5.
[0024] B2: The feature map output from step B1 is input into the second convolutional layer. The second convolutional layer has 64 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRULU activation function. The output feature map size is 30×30×64. Then, it passes through the second Dropout layer, randomly deactivating 25% of the neurons. Finally, it passes through the second max pooling layer. The second max pooling layer has a kernel size of 2×2, a stride of 2, and the output feature map size is 30×30×64.
[0025] B3: The final output feature map from step B2 is input into the third convolutional layer. The third convolutional layer has 128 kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function COSRuLU. The output feature map size is 15×15×128. Then, it goes through the third Dropout layer, randomly deactivating 25% of the neurons. Finally, it goes through the third max pooling layer. The second max pooling layer has a kernel size of 2×2, stride of 2, and output feature map size is 7×7×128.
[0026] B4: The final output feature map in step B3 is flattened, and the size of the output feature map is 1×1×1024;
[0027] B5: The feature map output from step B4 is input into the first fully connected layer. The activation function is COSRuLU, and the size of the output feature map is 1×1×1024.
[0028] B6: The feature map output from step B5 is input into the second fully connected layer. The activation function is LGmax, and the output feature map is 1×1×2. Finally, the probabilities of the chess pieces being red and black are obtained, and the color corresponding to the highest probability is taken as the predicted color of the chess piece. The formula for the LGmax activation function is:
[0029]
[0030] S represents the output value of the activation function LGmax. This represents the input value for the activation function LGmax.
[0031] Furthermore, the grayscale conversion, downsampling, and image transformation processes in steps A2 and A3 are as follows:
[0032] C1: Convert the chess piece image with a size of 60×60×3 randomly selected in step A1 into a grayscale image of 60×60×1 through grayscale processing;
[0033] C2: The grayscale image obtained in step C1 is passed through a convolutional layer with 1 kernel, a kernel size of 2×2, a stride of 2, and a padding of 2. The output 32×32×1 feature map is used as the input of Rec-Net.
[0034] C3: If the color information of the chess piece is predicted to be red in step B6, the feature map output in step C2 is directly fed into the Rec-Net network; if the color information of the chess piece is predicted to be black in step B6, the feature map output in step C2 is rotated 180 degrees and fed into the Rec-Net network.
[0035] Furthermore, the Rec-Net network structure construction in step A4 includes the following steps:
[0036] D1: The feature map of size 32×32×1, which is the final output of C3, is input into the first convolutional layer. The first convolutional layer has 64 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 32×32×64. Then it goes through the first max pooling layer. The kernel size of the first max pooling layer is 2×2, stride of 2, and the output feature map size is 16×16×64.
[0037] D2: The feature map output from D1 is input into the second convolutional layer. The second convolutional layer has 128 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map is 16×16×128. Then it goes through the second max pooling layer. The kernel size of the second max pooling layer is 2×2, stride of 2, and the output feature map size is 8×8×128.
[0038] D3: Input the feature map output by D2 into the third convolutional layer. The third convolutional layer has 256 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, activation function of COSRuLU, and an output feature map size of 8×8×256.
[0039] D4: The feature map output from D3 is input into the fourth convolutional layer. The fourth convolutional layer has 256 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map size is 8×8×256. Then it goes through the third max pooling layer. The third max pooling layer has a kernel size of 2×2, a stride of 2, and an output feature map size of 4×4×256.
[0040] D5: The feature map output from D4 is input into the fifth convolutional layer. The fifth convolutional layer has 512 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 4×4×512. Then, a regularization layer is applied to improve the model's generalization ability and prevent overfitting.
[0041] D6: The feature map output from D5 is input into the sixth convolutional layer. The sixth convolutional layer has 512 kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 4×4×512. Then, a regularization layer is applied to improve the model's generalization ability and prevent overfitting. Finally, a fourth max pooling layer is applied. The fourth max pooling layer has a kernel size of 2×2, a stride of 2, and the output feature map is 2×2×512.
[0042] D7: Input the feature map output from D6 into the 7th convolutional layer. The 7th convolutional layer has 512 convolutional kernels, a kernel size of 2×2, padding of 0, stride of 1, activation function of COSRuLU, and output feature map size of 1×1×512.
[0043] D8: Transform the feature map output by D7 into a sequence vector;
[0044] D9: Input the sequence vector formed in D8 into two bidirectional LSTM layers with 256 units each, and finally obtain the output result.
[0045] Furthermore, the positioning of the chess pieces in the chessboard image in step S3 specifically includes the following steps:
[0046] E1: A real-time captured RGB three-channel chess image with dimensions of 972×1296×3 is processed by an improved Canny edge detection algorithm with optimized parameters through a convolutional neural network to obtain a binarized single-channel feature map;
[0047] E2: The binarized single-channel feature map finally obtained in step E1 is processed by the improved Hough circle detection and localization algorithm with optimized parameters of BP neural network, which can obtain the center coordinates and radius of each piece on the chessboard image.
[0048] Furthermore, the calculation process of the improved Canny edge detection algorithm for optimizing convolutional neural network parameters in step E1 is as follows:
[0049] F1: Input the complete chessboard image with dimensions of 972×1296×3 captured in step E1 into the first convolution. The first convolutional layer has 3 convolutional kernels, a kernel size of 14×18, padding of 0, stride of 2, and the output feature map size is 480×640×3. Then, it goes through the first max pooling layer, which has a convolutional kernel size of 2×2, a stride of 2, and the output feature map size is 240×320×3.
[0050] F2: Input the feature map output from step F1 into the second convolutional layer. The second convolutional layer has 32 convolutional kernels, a kernel size of 4×4, padding of 0, stride of 4, and activation function of COSRuLU. The output feature map size is 60×80×32. After image resizing, the output feature map size is 60×60×32.
[0051] F3: The feature map output from step F2 is input into the third convolutional layer. The third convolutional layer has 64 convolutional kernels, a kernel size of 2×2, padding of 0, stride of 2, and activation function of COSRuLU. The output feature map size is 30×30×64. Then, it goes through the second max pooling layer. The second max pooling layer has a convolutional kernel size of 2×2, a stride of 2, and an output feature map size of 15×15×64.
[0052] F4: The feature map output from step F3 is input into the fourth convolutional layer. The fourth convolutional layer has 128 convolutional kernels, a kernel size of 5×5, padding of 0, stride of 2, and activation function of COSRuLU. The output feature map size is 6×6×128. Then, it goes through the third max pooling layer. The third max pooling layer has a convolutional kernel of 2×2, a stride of 2, and the output feature map size is 3×3×128.
[0053] F5: Input the final feature map output from step F4 into the fifth convolutional layer. The fifth convolutional layer has 256 convolutional kernels, a kernel size of 1×1, padding of 0, stride of 2, and activation function COSRuLU. The output feature map size is 2×2×256. Then, it goes through the fourth max pooling layer. The fourth max pooling layer has a convolutional kernel size of 2×2, a stride of 1, and the output feature map size is 1×1×256.
[0054] F6: Input the feature map output from step F5 into the first fully connected layer. The activation function is COSRuLU. Use Dropu to deactivate 20% of the neurons. The size of the output feature map is 1×1×512.
[0055] F7: Input the feature map output from step F6 into the second fully connected layer. The activation function is COSRuLU and the output feature map size is 1×1×2. Based on the output feature map size of 1×1×2, obtain the threshold parameters maxVal and minVal for the Canny edge detection prediction of this chessboard.
[0056] F8: The predicted threshold parameters maxVal and minVal are fed into the improved Canny edge detection algorithm. The complete chessboard image with a size of 972×1296×3 captured in step E1 is processed by the improved Canny edge detection algorithm with optimized parameters through a convolutional neural network. Finally, a binarized feature map with a size of 972×1296×1 is obtained.
[0057] Furthermore, the calculation process of the improved Canny edge detection algorithm in step F8 is as follows:
[0058] G1: Convert the complete chessboard image with dimensions of 972×1296×3 captured in step E1 to grayscale to obtain a grayscale image of 972×1296×1.
[0059] G2: Apply an exponential filter to the grayscale image obtained in step G1. The size of the exponential filter is 5×5. [The remaining text appears to be incomplete and requires further context.] , Substituting the values into the exponential function yields the exponential filter, which is then used to obtain the processed grayscale image. The two-dimensional exponential function is as follows:
[0060]
[0061] in , These are the x and y coordinates in the exponential filter. Let b be the output value of the two-dimensional function; in this invention, b is 3.
[0062] G3: Calculate the pixel gradients of the grayscale image obtained in step G2 using a 5×5 pole operator, thus obtaining the gradient intensity matrix. The pole operators in the x-axis and y-axis directions are as follows:
[0063]
[0064] The formula for calculating the gradient intensity matrix is:
[0065]
[0066] Where I represents the grayscale image matrix, This represents the gradient intensity matrix along the x-axis. This represents the gradient intensity matrix along the y-axis. This represents the gradient intensity matrix, where d represents the kernel size, and d=5;
[0067] G4: Perform non-maximum suppression on the gradient intensity matrix obtained in step G3. That is, compare the gradient intensity of the current pixel with the gradient intensity of the adjacent pixels along the positive and negative gradient directions. If the gradient intensity of the current pixel is a maximum value, then retain the pixel as an edge point. If the gradient intensity of the current pixel is not a maximum value, then suppress the current pixel and do not treat it as an edge point.
[0068] G5: Use the threshold parameters maxVal and minVal predicted in step F7 to judge the maximum values selected in step G4. If the maximum value is greater than maxVal, the pixel is an edge; if the maximum value is less than minVal, the pixel is not an edge; the maximum values between the high and low thresholds need to be judged in the next step.
[0069] G6: Determine the maximum value between the high and low thresholds in step G5. If the pixel corresponding to the maximum value is connected to an edge point, it is considered an edge point. If the pixel corresponding to the maximum value is not connected to an edge point, it is considered a non-edge point. Finally, the edge image can be generated.
[0070] Furthermore, the calculation process of the improved Hough circle detection and localization algorithm for optimizing the BP neural network parameters in step E2 is as follows:
[0071] H1: Input the parameters maxVal and minVal predicted in step F7 into the input layer of the BP neural network. The activation function of the input layer is Logistic-plus. After passing through the first Dropout layer, 30% of the neurons are randomly deactivated. The formula for the activation function Logistic-plus is:
[0072]
[0073] L represents the output of the Logistic-plus activation function. This represents the input to the Logistic-plus activation function;
[0074] H2: The output of the input layer is fed into a hidden layer of 10 neurons. The activation function of the hidden layer is Logistic-plus. After passing through the second Dropout layer, 15% of the neurons are randomly deactivated.
[0075] H3: The output of the hidden layer is fed into the output layer of 5 neurons. The activation function of the output layer is Logistic-plus. The output results are the 5 parameters required by the Hough circle detection algorithm, namely minDist, param1, param2, minRadius, and maxRadius. minDist represents the minimum distance between the coordinates of the center of the detected circles, param1 represents the threshold parameter maxVal in G5, param2 represents the center threshold parameter. The smaller the threshold, the more circles are detected. minRadius represents the minimum detection radius, and maxRadius represents the maximum detection radius.
[0076] H4: The 5 parameters predicted in step H3 are fed into the improved Hough circle detection and localization algorithm. The binarized feature map finally obtained in step F8 is optimized by the improved Hough circle detection and localization algorithm through the BP neural network. The position information of each chess piece can be obtained, namely the predicted center coordinates (x, y) and the predicted radius r of the chess piece.
[0077] Furthermore, the calculation process of the improved Hough circle detection and localization algorithm in step H4 is as follows:
[0078] I1: Establish a three-dimensional space for the Hough parameters, and calculate the predicted center coordinates (x, y) and radius r of the chess piece using the formula:
[0079]
[0080] In the formula, 'st' represents the constraint condition. Five randomly selected edge points that satisfy the constraints in the final binarized feature map obtained in F8. Let (x, y) represent the kth edge point randomly selected from the final binarized feature map obtained in F8 that satisfies the constraints, (x, y) represent the coordinates of the predicted center of the chess piece, r represents the predicted radius of the chess piece, and V represents the number of votes for this center.
[0081] I2: The five parameters predicted in step H3 are fed into the improved Hough circle detection and localization algorithm. Non-maximum suppression is applied to the circles selected in I1. When the number of votes is greater than param2, it can be identified as a circle. Then, by limiting the parameters minDist, minRadius and maxRadius, circles that meet the parameter conditions are obtained, and the predicted center coordinates (x, y) and the predicted radius r of the chess piece are obtained.
[0082] Furthermore, in step S4, the accuracy of the fusion detection and calculation of the positioning and recognition algorithms for chess piece positioning is as follows:
[0083] J1: The chessboard image is fed into the improved Canny edge detection algorithm and the improved Hough circle detection and localization algorithm with optimized parameters to obtain the position information of each piece and save the image of the corresponding position;
[0084] J2: Input the image saved in step J1 into the trained China-chess-net model to obtain the category information of each chess piece, and finally obtain the position and category information of each chess piece;
[0085] J3: Calculate the positioning accuracy of each piece (piece positioning accuracy consists of the piece's center positioning accuracy and piece radius accuracy) and the piece recognition accuracy, ultimately obtaining the detection accuracy of the entire chessboard image. Verification shows that the detection accuracy of the entire chessboard image is close to 100%, and the model has excellent real-time performance, enabling real-time detection with a processing speed of approximately 60 frames per second (FPS). The piece positioning accuracy, center positioning accuracy, piece radius accuracy, piece recognition accuracy, and the detection accuracy of the entire chessboard image are expressed using the following formulas:
[0086]
[0087] in, Indicates the accuracy of the center positioning of the chess piece. Represents the center coordinates of a chess piece. This indicates the accuracy of the chess piece's radius positioning. Indicates the accuracy of the chess piece's positioning. This represents the accuracy of piece recognition, where n represents the number of correctly recognized pieces. This represents the detection accuracy of the entire chessboard image, where q represents the q-th piece on the chessboard. This represents the positioning accuracy of the q-th piece. This represents the accuracy of recognizing the q-th piece.
[0088] Beneficial effects: Compared with the prior art, the present invention has the following advantages:
[0089] 1. This invention proposes a China-chess-net network, which is mainly composed of a Color-Net network and a Rec-Net network. The Color-Net network is mainly used for color classification of chess pieces, and the Rec-Net network is mainly used for classifying the categories of chess pieces. This model can be trained with very little training data and very few training rounds. Moreover, the model has strong generalization ability, high recognition accuracy and speed, with accuracy approaching 100% and strong real-time performance.
[0090] 2. This invention proposes an improved Canny edge detection algorithm with optimized parameters of a convolutional neural network. The chess pieces are used as input images and fed into a trained convolutional neural network. The output is two prediction parameters required for Canny edge detection. These two parameters are then fed into the improved Canny edge detection algorithm to obtain a binarized chessboard feature map. This method avoids the time wasted on manual parameter tuning and improves efficiency through predictive parameter tuning.
[0091] 3. This invention proposes an improved Hough circle detection and localization algorithm with optimized parameters using a BP neural network. The predicted parameters of Canny edge detection are input into the BP neural network, and the output is the five predicted parameters required by the improved Hough circle detection and localization algorithm. By inputting these five predicted parameters into the improved Hough circle detection and localization algorithm, the center coordinates of each piece can be obtained. This method can avoid the time wasted on manual parameter tuning based on experience and improve efficiency through predictive parameter tuning.
[0092] 4. This invention provides a chess detection method that can be used in scenarios of human-computer chess games, and can still accurately detect chess games under various complex lighting conditions. Attached Figure Description
[0093] Figure 1 This is the overall flowchart of the present invention;
[0094] Figure 2 This is the overall network structure diagram of the China-chess-net model of this invention;
[0095] Figure 3 This is a network structure diagram of the Rec-Net model of this invention;
[0096] Figure 4 This is a network structure diagram of the Color-Net model of this invention;
[0097] Figure 5 This is a structural diagram of the improved Canny edge detection algorithm for optimizing convolutional neural network parameters according to the present invention;
[0098] Figure 6 This is a detection result image of the improved Canny edge detection algorithm with optimized parameters of convolutional neural networks;
[0099] Figure 7 This is a structural diagram of the improved Hough circle detection and localization algorithm for optimizing the parameters of the BP neural network model of this invention;
[0100] Figure 8 This is a detection result image of the improved Hough circle detection and localization algorithm with optimized parameters of BP neural network;
[0101] Figure 9This is a real-time detection result image after fusing the China-chess-net algorithm and the detection and localization algorithm;
[0102] Figure 10 This is a real-time detection result image under low-light conditions, obtained by fusing the China-chess-net algorithm and the detection and localization algorithm. Detailed Implementation
[0103] The present invention will be further illustrated below with reference to the accompanying drawings and specific embodiments. It should be understood that these embodiments are for illustrative purposes only and are not intended to limit the scope of the invention. After reading this invention, any modifications of the invention in various equivalent forms by those skilled in the art will fall within the scope defined by the appended claims.
[0104] This invention provides a method for chess piece target localization and identification based on optimized parameters and China-chess-net, such as... Figure 1 As shown, it includes the following steps:
[0105] S1: Collect and save multiple images of complete chessboards, crop out the chess pieces from each image, use the labelme tool to label the category of each chess piece, and divide the dataset into training set, validation set and test set in an 8:1:1 ratio.
[0106] S2: Construct the China-chess-net network, select the optimizer adam [Diederik P. Kingma, Jimmy Ba. Adam: A Method for Stochastic Optimization[J]. CoRR,2014] and the loss function CTCLoss [Alex Graves, Santiago Fern'andez. Connectionist Temporal Classification: Labelling Unsegmented Sequence Data with Recurrent Neural Networks[J].ICML,2006], and train the China-chess-net network using the dataset to obtain the trained China-chess-net network model. This model is used for chess recognition.
[0107] S3: An improved Canny edge detection algorithm with optimized parameters using a convolutional neural network and an improved Hough circle detection and localization algorithm with optimized parameters using a BP neural network are used to locate chess pieces in a chessboard image and save the chess piece images and position information.
[0108] S4: The improved Canny edge detection algorithm with optimized parameters of convolutional neural network and the improved Hough circle detection and localization algorithm with optimized parameters of BP neural network are fused with the China-chess-net recognition algorithm to obtain the position and category information of each chess piece, and to calculate the accuracy of chess piece localization and recognition and the real-time performance of model detection.
[0109] like Figure 2 The diagram shows the China-chess-net network structure in step S2 of the method of the present invention. The specific process is as follows:
[0110] A1: Randomly select a chess piece image with a size of 60×60×3 from the chess test set obtained in S1 and input it into the Color-Net network of the China-chess-net network to obtain the color information of the chess piece image;
[0111] A2: Convert the chess piece image selected in A1 to grayscale and downsample the grayscale image to obtain a grayscale image that matches the size of the image input to the Rec-Net network.
[0112] A3: If the color information output by the Color-Net network in A1 is red, then the grayscale image obtained in A2 is used as the input of the Rec-Net network; if the color information output by the Color-Net network in A1 is black, then the grayscale image obtained in A2 is flipped 180 degrees and used as the input of the Rec-Net network.
[0113] A4: Input the feature map obtained in A3 into the Rec-Net network to obtain the recognition result of the chess piece image.
[0114] like Figure 3 The diagram shows the Color-Net network structure in step S2 of the method of the present invention. The specific construction process is as follows:
[0115] B1: The input image size is 60×60×3. The image is first input into the first convolutional layer. The first convolutional layer has 32 kernels, each 3×3 in size, with padd set to 1 and strdie set to 1.
[0116] The liveness function is COSRuLU, and the output feature map size is 60×60×32. After passing through the first Dropout layer (randomly deactivating 25% of neurons), it finally passes through the first max-pooling layer. The kernel size of the first max-pooling layer is 2×2, the stride is 2, and the output feature map size is 30×30×32. The formula for calculating the input and output sizes of the convolutional layer is:
[0117]
[0118] This indicates the size of the output image after passing through the convolutional layer. This indicates the size of the image input to the convolutional layer. This indicates the size of the convolutional kernel in the convolutional layer. Indicates the number of pixels filled in the image. This indicates the stride of the convolution kernel during feature extraction.
[0119] The formula for calculating the input and output sizes of a pooling layer is:
[0120]
[0121] This indicates the size of the image output after passing through the pooling layer. This indicates the size of the image input to the pooling layer. This indicates the size of the pooling layer convolution kernel. This represents the stride of the convolution kernel during max pooling.
[0122] The formula for calculating the COSRuLU activation function is:
[0123]
[0124] This represents the output of the activation function. This represents the input to the activation function; in this invention, c is set to 5.
[0125] B2: The feature map output from B1 is input into the second convolutional layer. The second convolutional layer has 64 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRULU activation function. The output feature map size is 30×30×64. Then, it goes through the second Dropout layer, randomly deactivating 25% of the neurons. Finally, it goes through the second max pooling layer. The second max pooling layer has a kernel size of 2×2, stride of 2, and the output feature map size is 30×30×64.
[0126] B3: The feature map output from B2 is input into the third convolutional layer. The third convolutional layer has 128 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRULU activation function. The output feature map size is 15×15×128. Then, it goes through the third Dropout layer, randomly deactivating 25% of the neurons. Finally, it goes through the third max pooling layer. The second max pooling layer has a kernel size of 2×2, stride of 2, and the output feature map size is 7×7×128.
[0127] B4: The final output feature map in B3 is flattened, and the size of the output feature map is 1×1×1024;
[0128] B5: The feature map output from B4 is input into the first fully connected layer, the activation function is COSRuLU, and the size of the output feature map is 1×1×1024.
[0129] B6: The feature map output from B5 is input to the second fully connected layer, with LGmax as the activation function. The output feature map is 1×1×2. Finally, the probabilities of the chess pieces being red and black are obtained, and the color corresponding to the highest probability is taken as the predicted color of the chess piece. The formula for the LGmax activation function is:
[0130]
[0131] S represents the output value of the activation function LGmax. This represents the input value for the activation function LGmax.
[0132] like Figure 4 The diagram shows the Rec-Net network structure in S2 of the method of this invention. The specific construction and operation process is as follows:
[0133] D1: The feature map of size 32×32×1, which is the final output of C3, is input into the first convolutional layer. The first convolutional layer has 64 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 32×32×64. Then it goes through the first max pooling layer. The kernel size of the first max pooling layer is 2×2, stride of 2, and the output feature map size is 16×16×64.
[0134] D2: The feature map output from D1 is input into the second convolutional layer. The second convolutional layer has 128 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map is 16×16×128. Then it goes through the second max pooling layer. The kernel size of the second max pooling layer is 2×2, stride of 2, and the output feature map size is 8×8×128.
[0135] D3: Input the feature map output by D2 into the third convolutional layer. The third convolutional layer has 256 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, activation function of COSRuLU, and an output feature map size of 8×8×256.
[0136] D4: The feature map output from D3 is input into the fourth convolutional layer. The fourth convolutional layer has 256 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map size is 8×8×256. Then it goes through the third max pooling layer. The third max pooling layer has a kernel size of 2×2, a stride of 2, and an output feature map size of 4×4×256.
[0137] D5: The feature map output from D4 is input into the fifth convolutional layer. The fifth convolutional layer has 512 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 4×4×512. Then, a regularization layer is applied to improve the model's generalization ability and prevent overfitting.
[0138] D6: The feature map output from D5 is input into the sixth convolutional layer. The sixth convolutional layer has 512 kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 4×4×512. Then, a regularization layer is applied to improve the model's generalization ability and prevent overfitting. Finally, a fourth max pooling layer is applied. The fourth max pooling layer has a kernel size of 2×2, a stride of 2, and the output feature map is 2×2×512.
[0139] D7: Input the feature map output from D6 into the 7th convolutional layer. The 7th convolutional layer has 512 convolutional kernels, a kernel size of 2×2, padding of 0, stride of 1, activation function of COSRuLU, and output feature map size of 1×1×512.
[0140] D8: Transform the feature map output by D7 into a sequence vector;
[0141] D9: Input the sequence vector formed in D8 into a two-layer bidirectional LSTM with 256 units each [Xingjian Shi, Zhourong Chen. Convolutional LSTM Network: A Machine Learning Approach for Precipitation Nowcasting.[J]. Computer Vision and Pattern Recognition,2015] to obtain the final output.
[0142] like Figure 5The improved Canny edge detection algorithm for optimizing convolutional neural network parameters in S3 of the method of this invention is shown below. The specific process is as follows:
[0143] F1: The complete chessboard image with dimensions of 972×1296×3 captured in E1 is input into the first convolution. The first convolutional layer has 3 kernels, a kernel size of 14×18, padding of 0, and stride of 2. The output feature map size is 480×640×3. Then, it goes through the first max pooling layer. The first max pooling layer has a kernel size of 2×2, a stride of 2, and the output feature map size is 240×320×3.
[0144] F2: The feature map output from F1 is input into the second convolutional layer. The second convolutional layer has 32 convolutional kernels, a kernel size of 4×4, padding of 0, stride of 4, and activation function of COSRuLU. The output feature map size is 60×80×32. After image resizing, the output feature map size is 60×60×32.
[0145] F3: The feature map output from F2 is fed into the third convolutional layer. The third convolutional layer has 64 kernels, a kernel size of 2×2, padding of 0, stride of 2, and activation function COSRuLU. The output feature map size is 30×30×64. Then it goes through the second max pooling layer. The second max pooling layer has a kernel size of 2×2, stride of 2, and the output feature map size is 15×15×64.
[0146] F4: The feature map output from F3 is input into the fourth convolutional layer. The fourth convolutional layer has 128 kernels, a kernel size of 5×5, padding of 0, stride of 2, and activation function of COSRuLU. The output feature map size is 6×6×128. Then it goes through the third max pooling layer. The third max pooling layer has a kernel size of 2×2, a stride of 2, and an output feature map size of 3×3×128.
[0147] F5: The feature map output from F4 is input into the fifth convolutional layer. The fifth convolutional layer has 256 kernels, a kernel size of 1×1, padding of 0, stride of 2, and activation function COSRuLU. The output feature map size is 2×2×256. Then it goes through the fourth max pooling layer. The fourth max pooling layer has a kernel size of 2×2, stride of 1, and the output feature map size is 1×1×256.
[0148] F6: Input the feature map of the final output in F5 into the first fully connected layer. The activation function is COSRuLU. Use Dropu to deactivate 20% of the neurons. The size of the output feature map is 1×1×512.
[0149] F7: Input the feature map of the final output in F6 into the second fully connected layer. The activation function is COSRuLU and the output feature map size is 1×1×2. Based on the output feature map size of 1×1×2, obtain the threshold parameters maxVal and minVal for the Canny edge detection prediction of this chessboard.
[0150] F8: The predicted threshold parameters maxVal and minVal are fed into the improved Canny edge detection algorithm. The complete chessboard image with a size of 972×1296×3 captured in E1 is processed by the improved Canny edge detection algorithm with optimized parameters through a convolutional neural network. Finally, a binarized feature map with a size of 972×1296×1 is obtained.
[0151] The calculation process of the improved Canny edge detection algorithm in F8 is as follows:
[0152] G1: The complete chessboard image with dimensions of 972×1296×3 captured in E1 is converted to grayscale to obtain a grayscale image of 972×1296×1;
[0153] G2: The grayscale image obtained in G1 is subjected to an exponential filter. The size of the exponential filter is 5×5. The x and y coordinates in the filter are... , Substituting the values into the exponential function yields the exponential filter, which is then used to obtain the processed grayscale image. The two-dimensional exponential function is as follows:
[0154]
[0155] in , These are the x and y coordinates in the exponential filter. b is the output value of the two-dimensional function, and in this embodiment, b is 3.
[0156] G3: The pixel gradient of the final grayscale image obtained in G2 is calculated using a 5×5 pole operator, which yields the gradient intensity matrix. The pole operators in the x-axis and y-axis directions are as follows:
[0157]
[0158] The formula for calculating the gradient intensity matrix is:
[0159]
[0160] Where I represents the grayscale image matrix. This represents the gradient intensity matrix along the x-axis. This represents the gradient intensity matrix along the y-axis. Let represent the gradient intensity matrix, and d represent the convolution kernel size, where d=5.
[0161] G4: Perform non-maximum suppression on the gradient intensity matrix obtained in step G3. That is, compare the gradient intensity of the current pixel with the gradient intensity of the adjacent pixels along the positive and negative gradient directions. If the gradient intensity of the current pixel is a maximum value, then retain the pixel as an edge point. If the gradient intensity of the current pixel is not a maximum value, then suppress the current pixel and do not treat it as an edge point.
[0162] G5: Use the threshold parameters maxVal and minVal predicted in step F7 to judge the maximum values selected in step G4. If the maximum value is greater than maxVal, the pixel is an edge; if the maximum value is less than minVal, the pixel is not an edge; the maximum values between the high and low thresholds need to be judged in the next step.
[0163] G6: Determine the maximum value between the high and low thresholds in step G5. If the pixel corresponding to the maximum value is connected to an edge point, it is considered an edge point. If the pixel corresponding to the maximum value is not connected to an edge point, it is considered a non-edge point. Finally, the edge image can be generated.
[0164] like Figure 6 The figure shows the detection results of the improved Canny edge detection algorithm with optimized parameters of the convolutional neural network in S3 of the method of the present invention. It can be seen from the figure that the parameters optimized by the convolutional neural network have good adaptability and the edge detection results of the algorithm are good.
[0165] like Figure 7 The improved Hough circle detection and localization algorithm for optimizing the parameters of the BP neural network model in S3 of the present invention is shown below. The specific process is as follows:
[0166] H1: The parameters maxVal and minVal, ultimately predicted by F7, are input into the input layer of the BP neural network. The activation function of the input layer is Logistic-plus, and 30% of neurons are randomly deactivated after passing through the first Dropout layer. The formula for the activation function Logistic-plus is:
[0167]
[0168] L represents the output of the Logistic-plus activation function. This represents the input to the Logistic-plus activation function.
[0169] H2: The output of the input layer is fed into a hidden layer of 10 neurons. The activation function of the hidden layer is Logistic-plus. After passing through the second Dropout layer, 15% of the neurons are randomly deactivated.
[0170] H3: The output of the hidden layer is fed into the output layer of 5 neurons. The activation function of the output layer is Logistic-plus. The output results are the 5 parameters required by the Hough circle detection algorithm, namely minDist, param1, param2, minRadius, and maxRadius. minDist represents the minimum distance between the coordinates of the center of the detected circles, param1 represents the threshold parameter maxVal in G5, param2 represents the center threshold parameter. The smaller the threshold, the more circles are detected. minRadius represents the minimum detection radius, and maxRadius represents the maximum detection radius.
[0171] H4: The 5 parameters predicted in H3 are fed into the improved Hough circle detection and localization algorithm. The binarized feature map finally obtained in F8 is optimized by the improved Hough circle detection and localization algorithm through the BP neural network. This will give us the position information of each chess piece, namely the predicted center coordinates (x, y) and the predicted radius r of the chess piece.
[0172] I1: Establish a three-dimensional space for the Hough parameters, and calculate the predicted center coordinates (x, y) and radius r of the chess piece using the formula:
[0173]
[0174] In the formula, 'st' represents the constraint condition. Five randomly selected edge points that satisfy the constraints in the final binarized feature map obtained in F8. Let represent the kth edge point randomly selected from the final binarized feature map obtained in F8 that satisfies the constraints, (x, y) represent the coordinates of the predicted center of the chess piece, r represents the predicted radius of the chess piece, and V represents the number of votes for this center.
[0175] I2: The five parameters predicted in H3 are fed into the improved Hough circle detection and localization algorithm. Non-maximum suppression is applied to the circles selected in I1. When the number of votes is greater than param2, it can be identified as a circle. Then, by limiting the parameters minDist, minRadius and maxRadius, circles that meet the parameter conditions are obtained, and the predicted center coordinates (x, y) and the predicted radius r of the chess piece are obtained.
[0176] like Figure 8 The image shows the detection results of the improved Hough circle detection and localization algorithm with optimized BP neural network model parameters in step S3 of the present invention. As can be seen from the image, the improved Hough circle detection and localization algorithm with optimized BP neural network model parameters can accurately locate the position of each chess piece in the image. Figure 8 The right side of the image shows the center coordinates of each located piece.
[0177] like Figure 9 The image shows the real-time detection result after fusing the China-chess-net algorithm and the detection and localization algorithm in S4 of the method of the present invention. The specific process is as follows:
[0178] J1: The chessboard image is fed into the improved Canny edge detection algorithm and the improved Hough circle detection and localization algorithm with optimized parameters to obtain the position information of each piece and save the image of the corresponding position;
[0179] J2: The image saved in J1 is fed into the trained China-chess-net model to obtain the category information of each chess piece, and finally the position and category information of each chess piece are obtained;
[0180] J3: Calculate the positioning accuracy of each piece (piece positioning accuracy consists of the piece's center positioning accuracy and the piece's radius accuracy) and the accuracy of piece recognition, ultimately obtaining the detection accuracy of the entire chessboard image. Figure 9 The results show that the detection accuracy of the entire chessboard image is close to 100%. Figure 9 The right side of the image shows the center coordinates and category of each located piece. The model exhibits excellent real-time performance, achieving real-time detection with an FPS of 61.23. The accuracy of piece location, center location, piece radius, piece recognition accuracy, and overall chessboard detection accuracy are expressed using the following formulas:
[0181]
[0182] in, Indicates the accuracy of the center positioning of the chess piece. Represents the center coordinates of a chess piece. This indicates the accuracy of the chess piece's radius positioning. Indicates the accuracy of the chess piece's positioning. This represents the accuracy of piece recognition, where n represents the number of correctly recognized pieces. This represents the detection accuracy of the entire chessboard image, where q represents the q-th piece on the chessboard. This represents the positioning accuracy of the q-th piece. This represents the accuracy of recognizing the q-th piece.
[0183] like Figure 10 The image shows the real-time detection results under low-light conditions after fusing the China-chess-net algorithm and the detection and localization algorithm in S4 of the method of this invention. Figure 10 The results show that the detection accuracy of the entire chessboard image is close to 100% under low lighting conditions. Furthermore, the model exhibits excellent real-time performance, achieving real-time detection with an FPS of 62.41.
[0184] Figure 10 The right side of the image shows the center coordinates and piece category of each located piece.
Claims
1. A method for chess piece target localization and identification based on optimized parameters and China-chess-net, characterized in that, Includes the following steps: S1: Collect and save multiple images of complete chessboards, crop out the chess pieces from each image, use the labelme tool to label the category of each chess piece, and divide the dataset into training set, validation set and test set. S2: Build the China-chess-net network, select the optimizer adam and the loss function CTCLoss, and train the China-chess-net network using the dataset to obtain the trained China-chess-net network model; S3: An improved Canny edge detection algorithm with optimized parameters using a convolutional neural network and an improved Hough circle detection and localization algorithm with optimized parameters using a BP neural network are used to locate chess pieces in a chessboard image and save the chess piece images and position information. S4: The improved Canny edge detection algorithm with optimized parameters of convolutional neural network and the improved Hough circle detection and localization algorithm with optimized parameters of BP neural network are fused with the China-chess-net recognition algorithm to obtain the position and category information of each chess piece, and to calculate the accuracy of chess piece localization and recognition and the real-time performance of model detection. The positioning of the chess pieces in the chessboard image in step S3 specifically includes the following steps: E1: A real-time captured RGB three-channel chess image with dimensions of 972×1296×3 is processed by an improved Canny edge detection algorithm with optimized parameters through a convolutional neural network to obtain a binarized single-channel feature map; E2: The binarized single-channel feature map finally obtained in step E1 is processed by the improved Hough circle detection and localization algorithm with optimized parameters of BP neural network, which can obtain the center coordinates and radius of each chess piece on the chessboard image; The calculation process of the improved Canny edge detection algorithm for optimizing convolutional neural network parameters in step E1 is as follows: F1: Input the complete chessboard image with dimensions of 972×1296×3 captured in step E1 into the first convolution. The first convolutional layer has 3 convolutional kernels, a kernel size of 14×18, padding of 0, stride of 2, and the output feature map size is 480×640×3. Then, it goes through the first max pooling layer, which has a convolutional kernel size of 2×2, a stride of 2, and the output feature map size is 240×320×3. F2: Input the feature map output from step F1 into the second convolutional layer. The second convolutional layer has 32 convolutional kernels, a kernel size of 4×4, padding of 0, stride of 4, and activation function of COSRuLU. The output feature map size is 60×80×32. After image resizing, the output feature map size is 60×60×32. F3: The feature map output from step F2 is input into the third convolutional layer. The third convolutional layer has 64 convolutional kernels, a kernel size of 2×2, padding of 0, stride of 2, and activation function of COSRuLU. The output feature map size is 30×30×64. Then, it goes through the second max pooling layer. The second max pooling layer has a convolutional kernel size of 2×2, a stride of 2, and an output feature map size of 15×15×64. F4: The feature map output from step F3 is input into the fourth convolutional layer. The fourth convolutional layer has 128 convolutional kernels, a kernel size of 5×5, padding of 0, stride of 2, and activation function of COSRuLU. The output feature map size is 6×6×128. Then, it goes through the third max pooling layer. The third max pooling layer has a convolutional kernel of 2×2, a stride of 2, and the output feature map size is 3×3×128. F5: Input the final feature map output from step F4 into the fifth convolutional layer. The fifth convolutional layer has 256 convolutional kernels, a kernel size of 1×1, padding of 0, stride of 2, and activation function COSRuLU. The output feature map size is 2×2×256. Then, it goes through the fourth max pooling layer. The fourth max pooling layer has a convolutional kernel size of 2×2, a stride of 1, and the output feature map size is 1×1×256. F6: Input the feature map output from step F5 into the first fully connected layer. The activation function is COSRuLU. Use Dropu to deactivate 20% of the neurons. The size of the output feature map is 1×1×512. F7: Input the feature map output from step F6 into the second fully connected layer. The activation function is COSRuLU and the output feature map size is 1×1×2. Based on the output feature map size of 1×1×2, obtain the threshold parameters maxVal and minVal for the Canny edge detection prediction of this chessboard. F8: The predicted threshold parameters maxVal and minVal are fed into the improved Canny edge detection algorithm. The complete chessboard image with a size of 972×1296×3 captured in step E1 is processed by the improved Canny edge detection algorithm with optimized parameters through a convolutional neural network. Finally, a binarized feature map with a size of 972×1296×1 is obtained. The calculation process of the improved Canny edge detection algorithm in step F8 is as follows: G1: Convert the complete chessboard image with dimensions of 972×1296×3 captured in step E1 to grayscale to obtain a grayscale image of 972×1296×1. G2: Apply an exponential filter to the grayscale image obtained in step G1. The size of the exponential filter is 5×5. [The remaining text appears to be incomplete and requires further context.] , Substituting the values into the exponential function yields the exponential filter, which is then used to obtain the processed grayscale image. The two-dimensional exponential function is as follows: ; in, and These represent the x and y coordinates in the exponential filter. The output value of the two-dimensional function; G3: Calculate the pixel gradients of the grayscale image obtained in step G2 using a 5×5 pole operator, thus obtaining the gradient intensity matrix. The pole operators in the x-axis and y-axis directions are as follows: ; The formula for calculating the gradient intensity matrix is: ; Where I represents the grayscale image matrix, This represents the gradient intensity matrix along the x-axis. This represents the gradient intensity matrix along the y-axis. The gradient strength matrix is represented by d, and the kernel size is represented by d. G4: Perform non-maximum suppression on the gradient intensity matrix obtained in step G3. That is, compare the gradient intensity of the current pixel with the gradient intensity of the adjacent pixels along the positive and negative gradient directions. If the gradient intensity of the current pixel is a maximum value, then retain the pixel as an edge point. If the gradient intensity of the current pixel is not a maximum value, then suppress the current pixel and do not treat it as an edge point. G5: Use the threshold parameters maxVal and minVal predicted in step F7 to judge the maximum values selected in step G4. If the maximum value is greater than maxVal, the pixel is an edge; if the maximum value is less than minVal, the pixel is not an edge; the maximum values between the high and low thresholds need to be judged in the next step. G6: Determine the maximum value between the high and low thresholds in step G5. If the pixel corresponding to the maximum value is connected to an edge point, the pixel is considered an edge point. If the pixel corresponding to the maximum value is not connected to an edge point, the pixel is considered a non-edge point. Finally, the edge image is generated. The calculation process of the improved Hough circle detection and localization algorithm with optimized BP neural network parameters in step E2 is as follows: H1: Input the parameters maxVal and minVal predicted in step F7 into the input layer of the BP neural network. The activation function of the input layer is Logistic-plus. After passing through the first Dropout layer, 30% of the neurons are randomly deactivated. The formula for the activation function Logistic-plus is: ; L represents the output of the Logistic-plus activation function. This represents the input to the Logistic-plus activation function; H2: The output of the input layer is fed into a hidden layer of 10 neurons. The activation function of the hidden layer is Logistic-plus. After passing through the second Dropout layer, 15% of the neurons are randomly deactivated. H3: The output of the hidden layer is fed into the output layer of 5 neurons. The activation function of the output layer is Logistic-plus. The output results are the 5 parameters required by the Hough circle detection algorithm, namely minDist, param1, param2, minRadius, and maxRadius. minDist represents the minimum distance between the coordinates of the center of the detected circles, param1 represents the threshold parameter maxVal in G5, param2 represents the center threshold parameter. The smaller the threshold, the more circles are detected. minRadius represents the minimum detection radius, and maxRadius represents the maximum detection radius. H4: The 5 parameters predicted in step H3 are fed into the improved Hough circle detection and localization algorithm. The binarized feature map finally obtained in step F8 is optimized by the improved Hough circle detection and localization algorithm through the BP neural network. The position information of each chess piece can be obtained, namely the predicted center coordinates (x, y) and the predicted radius r of the chess piece. The calculation process of the improved Hough circle detection and localization algorithm in step H4 is as follows: I1: Establish a three-dimensional space for the Hough parameters, and calculate the predicted center coordinates (x, y) and radius r of the chess piece using the formula: ; In the formula, 'st' represents the constraint condition. Five randomly selected edge points that satisfy the constraints in the final binarized feature map obtained in F8. Let (x, y) represent the kth edge point randomly selected from the final binarized feature map obtained in F8 that satisfies the constraints, (x, y) represent the coordinates of the predicted center of the chess piece, r represents the predicted radius of the chess piece, and V represents the number of votes for this center. I2: The five parameters predicted in step H3 are fed into the improved Hough circle detection and localization algorithm. Non-maximum suppression is applied to the circles selected in I1. When the number of votes is greater than param2, it can be identified as a circle. Then, by limiting the parameters minDist, minRadius and maxRadius, circles that meet the parameter conditions are obtained, and the predicted center coordinates (x, y) and the predicted radius r of the chess piece are obtained.
2. The method for chess piece target localization and identification based on optimized parameters and China-chess-net as described in claim 1, characterized in that, The method for building the China-chess-net network in step S2 includes the following steps: A1: Randomly select a chess piece image with a size of 60×60×3 from the chess test set obtained in step S1 and input it into the Color-Net network of the China-chess-net network to obtain the color information of the chess piece image; A2: Convert the chess piece image selected in step A1 to grayscale and downsample the grayscale image to obtain a grayscale image that matches the size of the image input to the Rec-Net network. A3: If the color information output by the Color-Net network in step A1 is red, then the grayscale image obtained in step A2 is used as the input of the Rec-Net network; if the color information output by the Color-Net network in step A1 is black, then the grayscale image obtained in step A2 is flipped 180 degrees and used as the input of the Rec-Net network. A4: Input the feature map obtained in step A3 into the Rec-Net network to obtain the recognition result of the chess piece image.
3. The method for chess piece target localization and identification based on optimized parameters and China-chess-net according to claim 2, characterized in that, The construction of the Color-Net network structure in step A1 includes the following steps: B1: The input image size is 60×60×3. First, the image is input into the first convolutional layer. This first convolutional layer has 32 kernels, a kernel size of 3×3, padding of 1, stride of 1, and uses COSRULU activation. The output feature map size is 60×60×32. Then, it passes through the first Dropout layer, randomly deactivating 25% of neurons. Finally, it passes through the first max-pooling layer, with a kernel size of 2×2 and stride of 2. The output feature map size is 30×30×32. The formula for calculating the input and output sizes of the convolutional layer is: ; in, This indicates the size of the output image after passing through the convolutional layer. This indicates the size of the image input to the convolutional layer. This indicates the size of the convolutional kernel in the convolutional layer. Indicates the number of pixels filled in the image. This indicates the stride of the convolution kernel during feature extraction; The formula for calculating the input and output sizes of a pooling layer is: ; in, This indicates the size of the image output after passing through the pooling layer. This indicates the size of the image input to the pooling layer. This indicates the size of the pooling layer convolution kernel. This represents the stride of the convolution kernel during max pooling; The formula for calculating the COSRuLU activation function is: ; F(x a ) represents the output of the activation function, x a This represents the input to the activation function; B2: The feature map output from step B1 is input into the second convolutional layer. The second convolutional layer has 64 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRULU activation function. The output feature map size is 30×30×64. Then, it passes through the second Dropout layer, randomly deactivating 25% of the neurons. Finally, it passes through the second max pooling layer. The second max pooling layer has a kernel size of 2×2, a stride of 2, and the output feature map size is 30×30×64. B3: The final output feature map from step B2 is input into the third convolutional layer. The third convolutional layer has 128 kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function COSRuLU. The output feature map size is 15×15×128. Then, it goes through the third Dropout layer, randomly deactivating 25% of the neurons. Finally, it goes through the third max pooling layer. The second max pooling layer has a kernel size of 2×2, stride of 2, and output feature map size is 7×7×128. B4: The final output feature map in step B3 is flattened, and the size of the output feature map is 1×1×1024; B5: The feature map output from step B4 is input into the first fully connected layer. The activation function is COSRuLU, and the size of the output feature map is 1×1×1024. B6: The feature map output from step B5 is input into the second fully connected layer. The activation function is LGmax, and the output feature map is 1×1×2. Finally, the probabilities of the chess pieces being red and black are obtained, and the color corresponding to the highest probability is taken as the predicted color of the chess piece. The formula for the LGmax activation function is: ; S represents the output value of the activation function LGmax. This represents the input value for the activation function LGmax.
4. The method for chess piece target localization and identification based on optimized parameters and China-chess-net according to claim 3, characterized in that, The grayscale conversion, downsampling, and image transformation processes in steps A2 and A3 are as follows: C1: Convert the chess piece image with a size of 60×60×3 randomly selected in step A1 into a grayscale image of 60×60×1 through grayscale processing; C2: The grayscale image obtained in step C1 is passed through a convolutional layer with 1 kernel, a kernel size of 2×2, a stride of 2, and a padding of 2. The output 32×32×1 feature map is used as the input of Rec-Net. C3: If the color information of the chess piece is predicted to be red in step B6, the feature map output in step C2 is directly fed into the Rec-Net network; if the color information of the chess piece is predicted to be black in step B6, the feature map output in step C2 is rotated 180 degrees and fed into the Rec-Net network.
5. The method for chess piece target localization and identification based on optimized parameters and China-chess-net according to claim 4, characterized in that, The Rec-Net network architecture construction in step A4 includes the following steps: D1: The feature map of size 32×32×1, which is the final output of C3, is input into the first convolutional layer. The first convolutional layer has 64 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 32×32×64. Then it goes through the first max pooling layer. The kernel size of the first max pooling layer is 2×2, stride of 2, and the output feature map size is 16×16×64. D2: The feature map output from D1 is input into the second convolutional layer. The second convolutional layer has 128 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map is 16×16×128. Then it goes through the second max pooling layer. The kernel size of the second max pooling layer is 2×2, stride of 2, and the output feature map size is 8×8×128. D3: Input the feature map output by D2 into the third convolutional layer. The third convolutional layer has 256 convolutional kernels, a kernel size of 3×3, padding of 1, stride of 1, activation function of COSRuLU, and an output feature map size of 8×8×256. D4: The feature map output from D3 is input into the fourth convolutional layer. The fourth convolutional layer has 256 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map size is 8×8×256. Then it goes through the third max pooling layer. The third max pooling layer has a kernel size of 2×2, a stride of 2, and an output feature map size of 4×4×256. D5: The feature map output from D4 is input into the fifth convolutional layer. The fifth convolutional layer has 512 kernels, a kernel size of 3×3, padding of 1, stride of 1, and COSRuLU activation function. The output feature map is 4×4×512. Then, a regularization layer is applied to improve the model's generalization ability and prevent overfitting. D6: The feature map output from D5 is input into the sixth convolutional layer. The sixth convolutional layer has 512 kernels, a kernel size of 3×3, padding of 1, stride of 1, and activation function of COSRuLU. The output feature map is 4×4×512. Then, a regularization layer is applied to improve the model's generalization ability and prevent overfitting. Finally, a fourth max pooling layer is applied. The fourth max pooling layer has a kernel size of 2×2, a stride of 2, and the output feature map is 2×2×512. D7: Input the feature map output from D6 into the 7th convolutional layer. The 7th convolutional layer has 512 convolutional kernels, a kernel size of 2×2, padding of 0, stride of 1, activation function of COSRuLU, and output feature map size of 1×1×512. D8: Transform the feature map output by D7 into a sequence vector; D9: Input the sequence vector formed in D8 into two bidirectional LSTM layers with 256 units each, and finally obtain the output result.
6. The method for chess piece target localization and identification based on optimized parameters and China-chess-net according to claim 1, characterized in that, In step S4, the accuracy of the fusion detection and calculation of the positioning and recognition algorithms for chess pieces is as follows: J1: The chessboard image is fed into the improved Canny edge detection algorithm and the improved Hough circle detection and localization algorithm with optimized parameters to obtain the position information of each piece and save the image of the corresponding position; J2: Input the image saved in step J1 into the trained China-chess-net model to obtain the category information of each chess piece, and finally obtain the position and category information of each chess piece; J3: Calculate the positioning accuracy and recognition accuracy of each piece to obtain the detection accuracy of the entire chessboard image. Verification shows that the detection accuracy of the entire chessboard image is close to 100%, and the model has excellent real-time performance, enabling real-time detection with a processing rate of approximately 60 frames per second. The positioning accuracy of the pieces, the center positioning accuracy, the radius accuracy of the pieces, the recognition accuracy of the pieces, and the detection accuracy of the entire chessboard image are expressed using the following formulas: ; in, Indicates the accuracy of the center positioning of the chess piece. Represents the center coordinates of a chess piece. This indicates the accuracy of the chess piece's radius positioning. Indicates the accuracy of the chess piece's positioning. This represents the accuracy of piece recognition, where n represents the number of correctly recognized pieces. This represents the detection accuracy of the entire chessboard image, where q represents the q-th piece on the chessboard. This represents the positioning accuracy of the q-th piece. This represents the accuracy of recognizing the q-th piece.
Citation Information
Patent Citations
Transfer robot target identification method based on multi-mask convolutional neural network
CN111368637A
KR1016358040000B1