Chess and card front and back face recognition method, device and equipment and computer readable storage medium

By converting chess and card game images to grayscale images and performing binarization, and extracting and statistically analyzing background pixel features, the problem of low accuracy in recognizing the front and back sides of non-magnetic chess and card games is solved, achieving a high-accuracy recognition effect.

CN121963161APending Publication Date: 2026-05-01HANGZHOU MINGCHUANG NETWORK TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
HANGZHOU MINGCHUANG NETWORK TECHNOLOGY CO LTD
Filing Date
2024-10-31
Publication Date
2026-05-01

AI Technical Summary

Technical Problem

Existing color sensor recognition methods for non-magnetic chess pieces cannot accurately identify the front and back of the chess pieces, especially when the colors are similar, the accuracy is even lower.

Method used

By acquiring the front and back images of the game board and converting them into grayscale images, performing binarization processing, extracting image pixel features, counting the number of background pixel features, and determining the front and back of the game board based on the area of ​​the background pixel features.

Benefits of technology

It improves the accuracy of recognizing the front and back of chess and card games, and is applicable to both magnetic and non-magnetic chess and card games, enhancing image processing efficiency and feature reliability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121963161A_ABST
    Figure CN121963161A_ABST
Patent Text Reader

Abstract

The invention provides a chess and card front and back face recognition method, device and equipment and a computer readable storage medium, and belongs to the technical field of card arranging machines. The method includes: acquiring front and back images of chess and cards, and converting the images into gray images; carrying out binarization on the grayscale image to obtain a binarized image; extracting image pixel features in the binarized image, traversing all pixel features of the image, and counting the number of background pixel features; calculating an image feature area based on the background pixel feature number, and determining front and back sides of the chess and card based on the image feature area. The problem that in the prior art, chess and card front and back face recognition accuracy is low is solved. According to the method, the RGB image of the chess and card is converted into the gray level image, so that the image processing efficiency is improved; the image is divided into the chess and card front pattern area and the background area, interference of background factors is eliminated, the reliability of features of chess and card patterns is enhanced, the image feature area is calculated based on the background pixel feature number, and the chess and card front and back face determination based on the image feature area is simple in calculation and high in accuracy.
Need to check novelty before this filing date? Find Prior Art

Description

A method, apparatus, device, and computer-readable storage medium for recognizing the front and back of a chessboard. Technical Field

[0001] This application relates to a method, apparatus, device, and computer-readable storage medium for recognizing the front and back sides of card games, belonging to the field of card sorting machine technology. Background Technology

[0002] As living standards improve, people's demand for leisure and entertainment continues to increase. More and more people are choosing automatic card sorting machines as their preferred form of entertainment, replacing manual card sorting. Card sorting machines need to identify the front and back of the cards to sort them. Currently, the mahjong machines people use all have magnetic mahjong tiles. For magnetic mahjong tiles, card sorting machines use magnets inserted into the tiles to identify the front and back of the cards in a consistent way. This method cannot identify the front and back of non-magnetic mahjong tiles.

[0003] Existing non-magnetic mahjong tiles utilize color sensors as sensors for front and back identification. When using color sensors, the front and back of the tiles need to be calibrated, and then identification is performed based on the calibration results. However, the colors of the tiles are not uniform, and the color positions of each mahjong tile are different. This inconsistency in color positions leads to low accuracy in using color sensors to identify the front and back of mahjong tiles. Furthermore, there are cases where the front and back colors are similar, which further worsens the accuracy.

[0004] Therefore, the technology of using color sensors to identify the front and back of chess and cards cannot meet the current needs, and there is an urgent need for a method with high accuracy in identifying the front and back of chess and cards. Summary of the Invention

[0005] A brief overview of the invention is given below to provide a basic understanding of certain aspects of it. It should be understood that this overview is not an exhaustive summary of the invention. It is not intended to identify key or essential parts of the invention, nor is it intended to limit the scope of the invention. Its purpose is merely to present certain concepts in a simplified form as a prelude to the more detailed description that follows.

[0006] In view of this, in order to solve the technical problem of low accuracy in recognizing the front and back of chess and cards in the prior art, the present invention provides a method, apparatus, device and computer-readable storage medium for recognizing the front and back of chess and cards.

[0007] Option 1: A method for recognizing the front and back of a chess or card game, comprising the following steps:

[0008] Obtain the front and back images of the chess pieces and convert them to grayscale images;

[0009] Binarize the grayscale image to obtain a binary image;

[0010] Extract image pixel features from the binarized image, traverse all pixel features of the image, and count the number of background pixel features;

[0011] The image feature area is calculated based on the number of background pixel features, and the front and back of the chess piece are determined based on the image feature area.

[0012] Preferably, the method for obtaining the front and back images of the chess pieces and converting them into grayscale images includes the following steps:

[0013] Images of the front and back of the chess pieces were captured using a device with a camera function;

[0014] Preprocess the acquired images;

[0015] The obtained color images of the front and back of the chess and card games are converted into grayscale images.

[0016] Preferably, preprocessing the acquired images includes:

[0017] Use filters to remove noise from an image and adjust its brightness and contrast.

[0018] Sharpen the image;

[0019] Color space conversion of an image, transforming the image from one color space to another;

[0020] Smooth the image.

[0021] Preferably, the method for converting the acquired color images of the front and back of the chess pieces into grayscale images is as follows: extract the values ​​of the R, G, and B channels of the color image, denoted as a, b, and c respectively. Combining this with the relationship between color and grayscale images determined by psychological formulas, the grayscale value of the image is calculated using the following formula:

[0022] L=0.299×a+0.587×b+0.114×c

[0023] Where L is the image grayscale value.

[0024] Preferably, the method for binarizing a grayscale image to obtain a binarized image is as follows: set a pixel value threshold to divide the pixel values ​​in the image into two categories. Pixels with pixel values ​​higher than the pixel value threshold are regarded as the foreground, i.e., the pattern of the chess and card game, and pixels with pixel values ​​lower than the pixel value threshold are regarded as the background, i.e., the bottom surface of the chess and card game pattern.

[0025] Preferably, the pixel threshold is determined based on the pattern of the chess or card game or using an adaptive thresholding algorithm.

[0026] Preferably, the adaptive threshold algorithm includes the following steps:

[0027] Set the initial threshold to T0 and take the median value of the image gray levels;

[0028] Based on the current threshold, the image is divided into foreground and background, and the intra-class means μ1, μ2 and intra-class variances σ12, σ22 are calculated.

[0029] Calculate the new threshold T = (μ1 + μ2) / 2;

[0030] Repeat steps 202 and 203 until the threshold no longer changes or the preset maximum number of iterations is reached;

[0031] The final threshold T is output, and the image is binarized based on the threshold T to obtain the segmented image.

[0032] Preferably, the method for extracting image pixel features from a binarized image, traversing all pixel features of the image, and counting the number of background pixel features includes the following steps:

[0033] Count the pixel values ​​of all images, determine the distribution range of pixel values, denote the minimum value as Lmin, the maximum value as Lmax, and the pixel distribution range is (Lmin, Lmax);

[0034] Let L be the grayscale threshold. Using L as the initial critical point, divide the pixel distribution range into two regions: the first region (Lmin, L) and the second region (L, Lmax). Count the number of pixels n1 and n2 within the first and second regions, and calculate the weights ω1 and ω2 of the number of pixels in the first and second regions in the entire image. Calculate the average pixel values ​​L1 and L2 of the two intervals, and calculate the pixel variance σ of the first and second regions.

[0035] σ=ω1×ω2×(L1-L2) 2

[0036] The grayscale threshold L ranges from [Lmin, Lmax], and the pixel increment step is 1 pixel.

[0037] Traverse all grayscale thresholds L to obtain the pixel variance of the first and second regions in turn. Record the maximum value σmax in the variance. The grayscale threshold L corresponding to the variance is the critical pixel value between the image background and the linear crack region. Record the grayscale threshold corresponding to the critical pixel value between the background and the background region as the final grayscale threshold.

[0038] Using the final grayscale value threshold as the final dividing point, the image is divided into a binary image composed of pixel values ​​0 and 1. Pixels with grayscale values ​​less than the final grayscale value threshold are all changed to 0; pixels with grayscale values ​​greater than or equal to the final grayscale value threshold are changed to 1, thus obtaining a new binary image.

[0039] Preferably, the method for calculating the image feature area based on the number of background pixel features and determining the front and back of the game board based on the image feature area is as follows: count the number of background pixels, calculate the area of ​​the image feature based on the number of background pixels and the actual area represented by each pixel; and determine the front and back of the game board based on the image feature area.

[0040] Option 2: A card game front and back recognition device, characterized in that it includes: a card game front and back image acquisition module, an image processing module, an image pixel feature statistics module, and a card game front and back output module;

[0041] The chess and card game front and back image acquisition module, image processing module, image pixel feature statistics module, and chess and card game front and back output module are connected in sequence;

[0042] The chess and card game front and back image acquisition module is used to acquire front and back images of chess and cards;

[0043] The image processing module is used to convert the front and back images of the chess and card games into grayscale images, and to binarize the grayscale images to obtain a binarized image;

[0044] The image pixel feature statistics module is used to extract and statistically analyze the image pixel features in the binarized image;

[0045] The chess and card game front and back output module is used to calculate the image feature area, determine the front and back of the chess and card game based on the image feature area, and output the recognition result.

[0046] Option 3: An electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor, when executing the program stored in the memory, implements the steps of the method described in Option 1.

[0047] Option 4: A computer-readable storage medium storing a computer program, wherein the computer program, when executed by a processor, implements the steps of the method described in Option 1.

[0048] Option 5: A card sorting machine, characterized in that the card sorting machine includes a card pushing device as described in Option 2.

[0049] Preferably, the card sorting machine is a mahjong machine, a domino machine, or a tile sorting machine.

[0050] The beneficial effects of this invention are as follows: This invention converts the RGB image of a chess piece into a grayscale image, improving image processing efficiency; it divides the image into the front pattern area and the background area of ​​the chess piece, eliminating the interference of background factors and enhancing the reliability of the chess piece pattern features; it calculates the image feature area based on the number of background pixel features, and the calculation of the front and back of the chess piece based on the image feature area is simple and accurate; this invention has a wide range of applications, applicable to both magnetic and non-magnetic chess pieces. Attached Figure Description

[0051] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:

[0052] Figure 1 is a flowchart of a method for recognizing the front and back of a chess piece;

[0053] Figure 2 is a flowchart of the method for obtaining the front and back images of chess and card games and converting them into grayscale images;

[0054] Figure 3 is a flowchart of the preprocessing process for the acquired images;

[0055] Figure 4 is a schematic diagram of a device for recognizing the front and back sides of a chess and card game.

[0056] Figure 5 is a schematic diagram of the structure of an electronic device. Detailed Implementation

[0057] To make the technical solutions and advantages of the embodiments of this application clearer, the exemplary embodiments of this application will be described in further detail below with reference to the accompanying drawings. Obviously, the described embodiments are only a part of the embodiments of this application, and not an exhaustive list of all embodiments. It should be noted that, unless otherwise specified, the embodiments and features in the embodiments of this application can be combined with each other.

[0058] Example 1: Referring to Figures 1-3, this embodiment describes a method for recognizing the front and back of a game board, comprising the following steps:

[0059] Step 1: Obtain the front and back images of the chess and card games, and convert them to grayscale images;

[0060] Step 101: Use a device with a camera function to capture images of the front and back of the chess and card game.

[0061] When shooting, ensure that the light is evenly distributed to avoid the impact of shadows and highlights on image quality; multiple light sources can be used to illuminate from different directions to enhance image quality.

[0062] Step 102: Preprocess the acquired image; Before converting the image to grayscale, perform a preprocessing step to improve image quality and make subsequent feature extraction more accurate.

[0063] Preprocessing the acquired images includes: using filters to remove noise from the images;

[0064] Filters include mean filters, Gaussian filters, median filters, etc. For example, the cv2.blur() function from the OpenCV library can be used for mean filtering.

[0065] Adjust the brightness and contrast of the image;

[0066] Histogram equalization or adaptive histogram equalization can be used to enhance the brightness and contrast of an image. For example, histogram equalization can be performed using the cv2.equalizeHist() function from the OpenCV library.

[0067] Sharpening an image enhances its edges and improves its clarity. Sharpening methods include the Laplacian operator and the Sobel operator. For example, the Laplacian operator can be applied using the `cv2.filter2D()` function from the OpenCV library.

[0068] Color space conversion of an image involves transforming it from one color space to another to better represent its features. For example, converting an RGB image to a grayscale image or an HSV image.

[0069] Smooth the image to reduce noise and make it smoother. Methods such as Gaussian blur and median filtering can be used.

[0070] The preprocessing of the acquired images can be performed using any one or more of the methods described above, and the order of these methods is not limited.

[0071] Step 103: Convert the obtained color images of the front and back of the chess and card games into grayscale images.

[0072] The method for converting a color image to a grayscale image is as follows: Extract the values ​​of the R, G, and B channels of the color image, and label them a, b, and c respectively. Combining this with the relationship between color and grayscale images determined by psychological formulas, the grayscale value L of the image is calculated using the following formula:

[0073] L=0.299×a+0.587×b+0.114×c

[0074] Converting a color image to a grayscale image, transforming the color value of each pixel into a single brightness value, can be achieved by reducing color information. This can be done using weighted averaging, average averaging, maximum averaging, minimum averaging, or by using the cvtColor function in the OpenCV library.

[0075] Step 2: Binarize the grayscale image to obtain a binarized image;

[0076] A pixel value threshold is set to divide the pixel values ​​in the image into two categories: pixels with values ​​above the threshold are considered foreground (i.e., the pattern of the game board), and pixels with values ​​below the threshold are considered background (i.e., the bottom surface of the game board pattern). The pixel threshold is determined based on the pattern of the game board or using an adaptive thresholding algorithm.

[0077] Pixel value thresholding can also use an adaptive thresholding algorithm, which automatically calculates the pixel threshold based on the statistical characteristics of the image; this includes the following steps:

[0078] Step 201: Set the initial threshold to T0 and take the median value of the image gray levels;

[0079] Step 202: Based on the current threshold, divide the image into foreground and background parts, and calculate the intra-class mean μ1, μ2 and intra-class variance σ12, σ22;

[0080] Within-class mean: Calculate the sum of pixel values ​​for each class. For each class, iterate through all pixels belonging to that class and sum their pixel values. For each class, calculate the total number of pixels belonging to that class. Divide the sum of pixel values ​​for each class by the corresponding number of pixels to obtain the within-class mean for that class.

[0081] Within-class variance: Calculate the sum of squared pixel values ​​for each class. For each class, iterate through all pixels belonging to that class, calculate the square of their pixel values, and sum these squared values. Similar to the calculation of the within-class mean, calculate the total number of pixels belonging to each class; calculate the within-class variance for each class.

[0082] Step 203: Calculate the new threshold T = (μ1 + μ2) / 2;

[0083] Step 204: Repeat steps 202 and 203 until the threshold no longer changes or the preset maximum number of iterations is reached;

[0084] Step 205: Output the final threshold T, and perform binarization on the image based on the threshold T to obtain the segmented image.

[0085] Step 3: Extract the image pixel features from the binarized image, traverse all pixel features of the image, and count the number of background pixel features;

[0086] Step 301: Count all image pixel values ​​and determine the distribution range of pixel values. The minimum value is denoted as Lmin and the maximum value is denoted as Lmax. The pixel distribution range is (Lmin, Lmax).

[0087] Step 302: Set a grayscale threshold L. Using the grayscale threshold L as the initial critical point, divide the pixel distribution range into two regions: the first region (Lmin, L) and the second region (L, Lmax). Count the number of pixels n1 and n2 within the first and second regions, and calculate the weights ω1 and ω2 of the number of pixels in the first and second regions in the entire image. Calculate the average pixel values ​​L1 and L2 of the two intervals, and calculate the pixel variance σ of the first and second regions.

[0088] σ=ω1×ω2×(L1-L2) 2

[0089] The grayscale threshold L ranges from [Lmin, Lmax], and the pixel increment step is 1 pixel.

[0090] Step 303: Traverse all gray value thresholds L, obtain the pixel variance of the first region and the second region in turn, record the maximum value σmax in the variance, and the gray value threshold L corresponding to the variance is the critical pixel value between the image background and the linear crack region. Record the gray value threshold corresponding to the critical pixel value between the background and the background region as the final gray value threshold.

[0091] Step 304: Using the final grayscale value threshold as the final dividing point, divide the image into a binary image composed of pixel values ​​0 and 1. Pixels with grayscale values ​​less than the final grayscale value threshold are all changed to 0; pixels with grayscale values ​​greater than or equal to the final grayscale value threshold are changed to 1, thus obtaining a new binary image.

[0092] Step 4: Calculate the image feature area based on the number of background pixel features, and determine the front and back of the chess piece based on the image feature area.

[0093] Count the number of background pixels, calculate the area of ​​the image feature based on the number of background pixels and the actual area represented by each pixel, and determine the front and back of the chess piece based on the area of ​​the image feature.

[0094] For example, if each pixel represents an actual area of ​​0.1 square millimeters, then the area of ​​the image feature is the number of background pixels multiplied by 0.1.

[0095] Example 2: Referring to Figure 4, this embodiment describes a card game front and back recognition device, comprising: a card game front and back image acquisition module, an image processing module, an image pixel feature statistics module, and a card game front and back output module;

[0096] The chess and card game front and back image acquisition module, image processing module, image pixel feature statistics module, and chess and card game front and back output module are connected in sequence;

[0097] The chess and card game front and back image acquisition module is used to acquire front and back images of chess and cards;

[0098] The image processing module is used to convert the front and back images of the chess and card games into grayscale images, and to binarize the grayscale images to obtain a binarized image;

[0099] The image pixel feature statistics module is used to extract and statistically analyze the image pixel features in the binarized image;

[0100] The chess and card game front and back output module is used to calculate the image feature area, determine the front and back of the chess and card game based on the image feature area, and output the recognition result.

[0101] Example 3: A card sorting machine, which includes a card and board game front and back recognition device as described in Example 1 or Example 2.

[0102] The card sorting machine is a mahjong machine, a domino machine, or a tile sorting machine.

[0103] Example 4: An electronic device includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other through the communication bus; the memory is used to store computer programs; and the processor, when executing the program stored in the memory, implements the steps of the method described in Example 1.

[0104] A computer-readable storage medium storing a computer program that, when executed by a processor, implements the steps of the method described in Embodiment 1.

[0105] Based on the same technical concept, this embodiment of the invention also provides an electronic device, as shown in FIG5, including a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402 and the memory 403 communicate with each other through the communication bus 404.

[0106] Memory 403 is used to store computer programs;

[0107] The processor 401 is used to implement the steps of the card-pushing method when executing the program stored in the memory 403.

[0108] The communication bus mentioned in the above electronic devices can be a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. This communication bus can be divided into address bus, data bus, control bus, etc. For ease of illustration, only one thick line is used to represent it in the diagram, but this does not mean that there is only one bus or one type of bus.

[0109] The communication interface is used for communication between the aforementioned electronic devices and other devices.

[0110] The memory may include random access memory (RAM) or non-volatile memory (NVM), such as at least one disk storage device. Optionally, the memory may also be at least one storage device located remotely from the aforementioned processor.

[0111] The processors mentioned above can be general-purpose processors, including central processing units (CPUs), network processors (NPs), etc.; they can also be digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, or discrete hardware components.

[0112] The computer program product for the card-pushing method provided in this embodiment of the invention includes a computer-readable storage medium storing program code. The instructions included in the program code can be used to execute the methods described in the preceding method embodiments. For specific implementation details, please refer to the method embodiments, which will not be repeated here.

[0113] The card-pushing device provided in this embodiment of the invention can be specific hardware on a device or software or firmware installed on the device. The implementation principle and technical effects of the device provided in this embodiment of the invention are the same as those in the foregoing method embodiments. For the sake of brevity, any parts not mentioned in the device embodiments can be referred to the corresponding content in the foregoing method embodiments. Those skilled in the art will clearly understand that, for the sake of convenience and brevity, the specific working processes of the systems, devices, and units described above can all be referred to the corresponding processes in the above method embodiments, and will not be repeated here.

[0114] In the embodiments provided by this invention, it should be understood that the disclosed apparatus and method can be implemented in other ways. The apparatus embodiments described above are merely illustrative. For example, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. Furthermore, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Additionally, the displayed or discussed mutual couplings, direct couplings, or communication connections may be through some communication interfaces; indirect couplings or communication connections between devices or units may be electrical, mechanical, or other forms.

[0115] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.

[0116] In addition, the functional units in the embodiments provided by the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.

[0117] If the aforementioned functions are implemented as software functional units and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, essentially, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device, such as a personal computer, server, or network device, to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.

[0118] It should be noted that similar labels and letters in the following figures indicate similar items. Therefore, once an item is defined in one figure, it does not need to be further defined and explained in subsequent figures. In addition, the terms "first", "second", "third", etc. are used only to distinguish descriptions and should not be construed as indicating or implying relative importance.

[0119] Finally, it should be noted that the above-described embodiments are merely specific implementations of the present invention, used to illustrate the technical solutions of the present invention, and not to limit it. The scope of protection of the present invention is not limited thereto. Although the present invention has been described in detail with reference to the foregoing embodiments, those skilled in the art should understand that any person skilled in the art can still modify or easily conceive of changes to the technical solutions described in the foregoing embodiments within the technical scope disclosed in the present invention, or make equivalent substitutions for some of the technical features; and these modifications, changes, or substitutions do not cause the essence of the corresponding technical solutions to deviate from the spirit and scope of the technical solutions of the embodiments of the present invention. All should be covered within the scope of protection of the present invention. Therefore, the scope of protection of the present invention should be determined by the scope of the claims.

Claims

1. A method for recognizing the front and back of a chess or card game, characterized in that, Includes the following steps: Obtain the front and back images of the chess pieces and convert them to grayscale images; Binarize the grayscale image to obtain a binarized image; extract the image pixel features from the binarized image, traverse all pixel features of the image, and count the number of background pixel features; The image feature area is calculated based on the number of background pixel features, and the front and back of the chess piece are determined based on the image feature area.

2. The method for recognizing the front and back of a chessboard according to claim 1, characterized in that, The method for acquiring the front and back images of a game board and converting them into grayscale images includes the following steps: capturing images of the front and back of the game board using a device with a camera function; preprocessing the captured images; and converting the acquired color images of the front and back of the game board into grayscale images.

3. The method for recognizing the front and back of a chessboard according to claim 2, characterized in that, Preprocessing of the acquired images includes: removing noise from the image using filters; adjusting the brightness and contrast of the image; sharpening the image; converting the image to a color space from one color space to another; and smoothing the image.

4. The method for recognizing the front and back of a chessboard according to claim 1, characterized in that, The method to convert the obtained color images of the front and back of the chess and card game into grayscale images is as follows: extract the values ​​of the R, G, and B channels of the color image, and denote them as a, b, and c respectively. Combined with the relationship between color images and grayscale images determined by psychological formulas, the grayscale value of the image is calculated using the following formula: L=0.299×a+0.587×b+0.114×c where L is the grayscale value of the image.

5. The method for recognizing the front and back of a chessboard according to claim 1, characterized in that, The method to binarize a grayscale image and obtain a binarized image is as follows: set a pixel value threshold to divide the pixel values ​​in the image into two categories. Pixels with pixel values ​​higher than the threshold are regarded as the foreground, i.e., the pattern of the chess and card game, and pixels with pixel values ​​lower than the threshold are regarded as the background, i.e., the bottom surface of the chess and card game pattern.

6. The method for recognizing the front and back of a chessboard according to claim 5, characterized in that, The pixel threshold is determined based on the pattern of the chess or card game or using an adaptive thresholding algorithm.

7. The method for recognizing the front and back of a chessboard according to claim 6, characterized in that, The adaptive thresholding algorithm includes the following steps: setting an initial threshold of T0, and taking the median value of the image's gray levels; dividing the image into foreground and background parts based on the current threshold, and calculating the within-class mean. μ1 , μ2 and within-class variance σ1 2 σ2 2 ; Calculate the new threshold T = (μ1 + μ2) / 2; Repeat steps 202 and 203 until the threshold no longer changes or the preset maximum number of iterations is reached; Output the final threshold T, and perform binarization processing on the image based on the threshold T to obtain the segmented image.

8. The method for recognizing the front and back of a chessboard according to claim 1, characterized in that, The method for extracting image pixel features from a binarized image, traversing all pixel features, and counting the number of background pixel features includes the following steps: counting all image pixel values, determining the distribution range of pixel values, and denoting the minimum value as Lmi. n The maximum value is denoted as Lma. x The pixel distribution range is (Lmi) n Lma x Let L be the grayscale threshold. Using L as the initial critical point, divide the pixel distribution range into two regions: the first region (Lmin, L) and the second region (L, Lmax). Count the number of pixels n1 and n2 within the first and second regions, and calculate the weights ω1 and ω2 of the number of pixels in the first and second regions in the entire image. Calculate the average pixel values ​​L1 and L2 of the two intervals, and calculate the pixel variance σ of the first and second regions: σ = ω1 × 2 × (L1 - L2). Where the grayscale threshold L ranges from [Lmin, Lmax], and the pixel increment step is 1 pixel. The process involves iterating through all grayscale thresholds L to obtain the pixel variances of the first and second regions, recording the maximum value σmax in the variance, and defining the grayscale threshold L corresponding to the variance as the critical pixel value between the image background and the linear crack region. The grayscale threshold corresponding to the critical pixel value between the background and the background region is recorded as the final grayscale threshold. Using the final grayscale threshold as the final dividing point, the image is divided into a binary image composed of pixel values ​​0 and 1. Pixels with grayscale values ​​less than the final grayscale threshold are all changed to 0, while pixels with grayscale values ​​greater than or equal to the final grayscale threshold are changed to 1, thus obtaining a new binary image.

9. The method for recognizing the front and back of a chessboard according to claim 1, characterized in that, The method for calculating the image feature area based on the number of background pixels and determining the front and back of a game board based on the image feature area is as follows: count the number of background pixels, calculate the area of ​​the image feature based on the number of background pixels and the actual area represented by each pixel, and determine the front and back of the game board based on the image feature area.

10. A device for recognizing the front and back of a game board, characterized in that, include: The system comprises a card and board game front and back image acquisition module, an image processing module, an image pixel feature statistics module, and a card and board game front and back output module; these modules are connected sequentially. The card and board game front and back image acquisition module is used to acquire images of the front and back of the card and board game; the image processing module is used to convert the card and board game front and back images into grayscale images, and then binarize the grayscale images to obtain binarized images; the image pixel feature statistics module is used to extract and statistically analyze the image pixel features in the binarized images. The chess and card game front and back output module is used to calculate the image feature area, determine the front and back of the chess and card game based on the image feature area, and output the recognition result.

11. An electronic device, characterized in that, The system includes a processor, a communication interface, a memory, and a communication bus, wherein the processor, the communication interface, and the memory communicate with each other via the communication bus; the memory is used to store computer programs; and the processor, when executing the program stored in the memory, implements the steps of the method described in any one of claims 1-10.

12. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program that, when executed by a processor, implements the steps of the method described in any one of claims 1-10.

13. A card sorting machine, characterized in that, The card sorting machine includes a card pushing device as described in claim 10.

14. A card sorting machine according to claim 13, characterized in that, The card sorting machine is a mahjong machine, a domino machine, or a tile sorting machine.