METHOD AND DEVICE FOR GUIDING USERS TO RESTORE RUBIK'S CUBE
20180322356 ยท 2018-11-08
Assignee
Inventors
- Letian Wang (Shanghai, CN)
- Peng DU (Shanghai, CN)
- Qingyun Li (Shanghai, CN)
- Huan Chen (Shanghai, CN)
- Mingying Gu (Shanghai, CN)
Cpc classification
A63F9/0842
HUMAN NECESSITIES
A63F2009/2425
HUMAN NECESSITIES
International classification
A63F9/08
HUMAN NECESSITIES
Abstract
The present disclosure relates to the technical field of computer visual detection processing, and provides a method for guiding users to restore Rubik's cubes. The method comprises step 1, acquiring arrangement information of colored blocks of the Rubik's cube; step 2, displaying restoration process of the Rubik's cube.
Claims
1. A method for guiding users to restore Rubik's cubes, comprising: acquiring arrangement information of colored blocks of a Rubik's cube; and displaying steps for restoring the Rubik's cube according to the arrangement information of the colored blocks of the Rubik's cube, wherein, acquiring arrangement information of colored blocks of a Rubik's cube further comprises: setting a scanning region of interest (ROI) in a software interface; acquiring and adjusting the position of the Rubik's cube such that the Rubik's cube is located at the right position; detecting the position of the Rubik's cube in an image; and extracting colors of the Rubik's cube.
2. The method for guiding users to restore Rubik's cubes according to claim 1, wherein displaying steps for restoring the Rubik's cube according to the arrangement information of the colored blocks of the Rubik's cube further comprises: acquiring a restoring solution of the Rubik's cube; and displaying the restoring steps of the Rubik's cube.
3. The method for guiding users to restore Rubik's cubes according to claim 1, wherein detecting the position of the Rubik's cube in an image comprises: graying the ROI; extracting colored block outlines using an edge detection algorithm; matching shapes; and counting circle centers.
4. The method for guiding users to restore Rubik's cubes according to claim 1, wherein extracting colors of the Rubik's cube comprises: acquiring data from an acquisition device, extracting color information of the Rubik's cube; performing recognition six times in a certain fixed sequence; determining if a total of 54 colored blocks exist, 9 colored blocks in each color; if not, prompting users to perform recognition again with proper lighting; if yes, acquiring the color arrangement information of 54 colored blocks.
5. The method for guiding users to restore Rubik's cubes according to claim 2, wherein acquiring a restoring solution of the Rubik's cube comprises: inputting the color arrangement information of the 54 colored blocks into a Two Phase algorithm; determining if the Two Phase algorithm outputs solutions, and if the number of the solutions is smaller than 8; if not, prompting users to scramble the Rubik's cube and performing recognition again; if yes, operating each of the restored virtual Rubik's cubes by the reverse sequence of the corresponding one of the solutions, wherein the operation result may be the current state of the Rubik's cube of the user or includes a plurality of Rubik's cube states of the Rubik's cube currently in the hands of the user; if the operation result includes a plurality of Rubik's cube states of the Rubik's cube currently in the hands of the user, prompting the user to select a virtual Rubik's cube which is in a state identical with the current state of the Rubik's cube in hands; if the operation result is the current state of the Rubik's cube of the user, making the selected virtual Rubik's cube show the state of the Rubik's cube in hands of the user.
6. The method for guiding users to restore Rubik's cubes according to claim 3, wherein graying the ROI comprises: defining the image acquired by the acquisition device as the pixel value of a current coordinate position represented by R, G and B; graying the ROI in a color image, wherein graying refers to converting the ROI in the color image into a gray image by using one of the following equations;
Gray(x,y)=0.2989?R.sub.xy+0.5870?G.sub.xy+0.1140?B.sub.xy: wherein, Gray (x,y) represents the gray image.
7. The method for guiding users to restore Rubik's cubes according to claim 3, wherein extracting colored block outlines using an edge detection algorithm comprises: quantitatively expressing the change degree of the gray value by using the gradient change between adjacent pixels, wherein the gradient is a two-dimensional equivalent expression of a first-order two-dimensional derivative, and the calculation process comprises: calculating the difference between adjacent pixels by using the following equations:
Gx=f[i,j+1]?f[i,j]
Gy=f[i,j]?f[i+1,j] wherein, Gx represents the difference of adjacent pixels in the direction x; Gy represents the difference of the adjacent pixels in direction y; f [i, j+1] represents the pixel value in array j+1 of row i in the image; f [i, j] represents the pixel value in array j of row i in the image; f [i+1, j] represents the pixel value of the array j in the row i+1 in the image; calculating the gradient between adjacent pixels by using the following equation:
8. The method for guiding users to restore Rubik's cubes according to claim 7, wherein edge detection algorithm used in the edge detection method is selected from Sobel operator, Roberts operator, Prewitt operator, and Canny operator.
9. The method for guiding users to restore Rubik's cubes according to claim 3, wherein matching shapes comprises: for the extracted colored block outlines, screening binary outlines by using a shape matching method as described in the text concerning shapes, and calculating distances between outlines of shapes and an oval shape of the colored blocks of the Rubik's cube, wherein the distance value is calculated by using the following formula:
10. The method for guiding users to restore Rubik's cubes according to claim 3, wherein counting circle centers comprises: determining if the Rubik's cube is correctly placed by calculating the number of the oval outlines; in the ROI, if 18 oval outlines are detected, determining that the Rubik's cube is correctly placed in a game scanning area; or, promoting the user to adjust the position of the Rubik's cube for re-testing.
11. The method for guiding users to restore Rubik's cubes according to claim 4, wherein acquiring data from an acquisition device further comprises: aligning acquisition devices such as cameras and scanning or photographing the six surfaces of the Rubik's cube to acquire all information of the Rubik's cube.
12. The method for guiding users to restore Rubik's cubes according to claim 4, wherein acquiring data from an acquisition device further comprises: scanning or photographing two surfaces of the Rubik's cube at the same time; rotating the Rubik's cube and acquiring the image information of two of the remaining surface of the Rubik's cube; and deducing the image information of the remaining surface by the image information of the four surfaces.
13. The method for guiding users to restore Rubik's cubes according to claim 4, wherein acquiring data from an acquisition device further comprises: scanning or photographing three surfaces of the Rubik's cube at the same time; and rotating the Rubik's cube and acquiring the image information of the three remaining surface of the Rubik's cube.
14. A device for guiding users to restore Rubik's cube: an acquisition equipment that acquires the arrangement information of color blocks of a Rubik's cube; a restore equipment that connects with the acquisition equipment and acquires a restoring solution and displays steps for restoring the Rubik's cube according to the arrangement information of the colored blocks of the Rubik's cube.
15. The device of claim 13, wherein the restore equipment is: PAD, smart phone or computer.
16. The device of claim 13, further comprising: a stand and a bottom plate, the bottom plate is positioned on the bottom of the stand, the restore equipment is supported by the stand, the acquisition equipment is fixed on the top of the restore equipment; the bottom plate provides a game area and background for the cube, enabling the restoration simple, fast and accurate.
Description
BRIEF DESCRIPTION OF THE DRAWINGS
[0018] The disclosure is illustrated by way of example, and not by way of limitation in the figures of the accompanying drawings in which like reference numerals are used to refer to similar elements.
[0019]
[0020]
[0021]
[0022]
[0023]
[0024]
[0025]
DETAILED DESCRIPTION OF THE DISCLOSURE
[0026] For better understanding of the implementation methods, inventive features, objectives and effects of the technical solution of the present disclosure, the technical solutions in embodiments of the present disclosure are described clearly and completely in conjunction with the attached drawings in the embodiments of the present disclosure. Obviously, the described embodiments are only a part of embodiments of the present disclosure, not all embodiments of the present disclosure. Based on the embodiments in the present disclosure, a person skilled in this art can obtain other embodiments without creative labor, which all shall fall within the protective scope of the present disclosure.
[0027] The present disclosure provides a method for guiding users to restore Rubik's cubes, comprising the following steps:
[0028] Step 1: acquiring the arrangement information of colored blocks of a Rubik's cube;
[0029] Step 2: displaying the steps for restoring the Rubik's cube according to the arrangement information of the colored blocks of the Rubik's cube.
[0030] Step 1 of acquiring the arrangement information of the colored blocks of a Rubik's cube comprises the following steps 11, 12, and 13:
[0031] In step 11, a scanning region of interest (ROI) is set in a software interface. As shown in
[0032] In step 12, the position of the Rubik's cube is acquired and adjusted, such that the Rubik's cube is located at the right position.
[0033] As shown in
[0034] In step 13, the position of the Rubik's cube in an image is detected.
[0035] The flowchart of the position detection of the Rubik's cube can be seen in
[0036] In step 131, the ROI can be grayed.
[0037] In step 132, colored block outlines using an edge detection algorithm can be extracted.
[0038] In step 133, shapes can be matched.
[0039] In step 134, circle centers can be counted.
[0040] Step 131 is described in detail below.
[0041] First, the image is defined as the pixel value of a current coordinate position represented by R, G and B. For example, the acquired image of the Rubik's cube is a color picture, and the three primary colors (i.e., red, green, and blue) can be used to represent the color value of a pixel in the image, namely, wherein R, G and B represent the numbers of the red, green and blue channels at a certain coordinate position.
[0042] Second, the ROI of the color image is grayed. The following formula can be used to convert the ROI in the color image into a gray image:
Gray(x,y)=0.2989?R.sub.xy+0.5870?G.sub.xy+0.1140?B.sub.xy:
[0043] wherein, Gray(x,y) represents the gray image.
[0044] The Step 132 is described in detail below.
[0045] Edges of the image are usually portions with dramatic changes in gray value. The change degree of the gray value is usually quantitatively expressed by using the gradient change between adjacent pixels. The gradient is a two-dimensional equivalent expression of a first-order two-dimensional derivative, and the specific calculation process is as follows.
[0046] First, the difference between adjacent pixels can be calculated by using the following specific equations:
Gx=f[i,j+1]?f[i,j]
Gy=f[i,j]?f[i+1,j]
[0047] wherein, Gx represents the difference of adjacent pixels in the direction x; Gy represents the difference of the adjacent pixels in direction y; f [i, j+1] represents the pixel value in column j+1 of row i in the image; f [i, j] represents the pixel value in column j of row i in the image; f [i+1, j] represents the pixel value of the column j in the row i+1 in the image.
[0048] Second, the gradient between adjacent pixels can be calculated by using the equation:
[0049] wherein, G(x,y) represents the gradient value at point (x,y) in the image;
represents the deviation of the pixel value in the direction x;
represents the deviation of the pixel value in the direction y.
[0050] Third, the gradient amplitudes of edge points can be calculated, wherein the set of the gradient amplitudes of all edge points is the edge outline extracted.
[0051] For a Rubik's cube target to be detected, after conversion into the gray image, the six colors (e.g., red, yellow, blue, cyan, green and purple) blocks are relatively greatly different from the ground color of the white Rubik's cube, so the outlines of the six colored blocks are deemed as the edges of the current image. The colored block outlines are extracted by using an edge detection method. The edge detection algorithm includes, but is not limited to: Sobel operator, Roberts operator, Prewitt operator, and Canny operator. The obtained binary outlines of the edges of the colored blocks can be seen in
[0052] The Step 133 is described in detail. Shape matching is as follows.
[0053] For the colored block outlines obtained in Step 132, the binary outlines are screened by using a shape matching method as described in the text concerning shapes, and the distances between the outlines of shapes and an oval shape (the colored blocks of the Rubik's cube are oval) are calculated. The distance value is calculated by using the following formula:
[0054] wherein, Cs represents the distance value between the outline of a standard oval shape and the shape of a colored block of the Rubik's cube; g(k) and h(k) respectively represent an outline point set of the standard oval shape and a shape to be detected; M represents a threshold distance value; k represents the k.sup.th element point in the outline point set; K represents the number of the elements in the outline point set; when Cs is smaller than M, it is determined that the outline shape of the current colored block is oval; and when Cs is greater than or equal to M, it is determined that the outline shape of the current colored block is not oval.
[0055] Step 134 of counting the circle centers is described in detail below. Whether or not the Rubik's cube is correctly placed is determined by calculating the number of the oval outlines.
[0056] In the ROI, if 18 ovals are detected, it is deemed that the Rubik's cube is correctly placed in the scanning ROI of the game. Or, the user will be prompted to adjust the position of the Rubik's cube for re-testing.
[0057] Acquiring the arrangement information of the colored blocks of the Rubik's cube by scanning two surfaces at the same time is illustrated above. Those skilled in the art should understand that the image information of all surfaces of the Rubik's cube can be acquired by means of scanning or photographing the six surfaces of the Rubik's cube one by one using the acquisition device such as the camera; and, three surfaces can be scanned or photographed at the same time.
[0058] The Rubik's cube is rotated to acquire the image information of the remaining surface to obtain the arrangement information of the colored blocks on the six surfaces of the Rubik's cube.
[0059] According to the present disclosure, the image information of the remaining surface can also be deduced by scanning the image information of five surfaces.
[0060] According to the present disclosure, the image information of the remaining surfaces can also be deduced by scanning the image information of four surfaces.
[0061] The present disclosure has no limit in this aspect. The method of the present disclosure or similar methods used should fall within the protective scope of the present disclosure.
[0062] In step 14, colors of the Rubik's cube is extracted.
[0063] In the present disclosure, the colors can be identified by using an HSV (Hue, Saturation, Value) technology. The image acquired by the camera is defined as Ixy. Ixy=f(x,y), wherein (x,y) represents the position coordinate of a pixel in the image; f(x,y) represents the pixel value of the image at the point x,y. An original image is converted into an HSV color image. The number of the H-color channels of each one of the colors in the HSV color space is relatively stable, and the numerical interval between different colors is relatively large, so a pixel average set is compared with a threshold value interval of the six colors on the H channel to determine the color of each one of the colored blocks in the scanning ROI.
[0064]
[0065] Step 141, acquiring data from an acquisition device;
[0066] Step 142, extracting color information of the Rubik's cube;
[0067] Step 143, performing recognition six times according to a certain fixed sequence (for example, R\F\D\L\B\U), wherein R(right), L(left), B(backward), F(forward), D(down) and U(up) respectively correspond to a total of six surfaces, namely the right, left, rear, front, top and bottom surfaces, of the Rubik's cube;
[0068] Step 144, determining if a total of 54 colored blocks exist, 9 colored blocks in each color;
[0069] if not, executing Step 145 to prompt users to perform recognition again with proper lighting;
[0070] if yes, executing Step 146 to acquire the color arrangement information of 54 colored blocks.
[0071] Step 2 is described in detail below. The method for displaying the method for restoring the Rubik's cube according to the arrangement information of the colored blocks of the Rubik's cube comprises the following steps.
[0072] Step 21 of acquiring the restoration solutions of the Rubik's cube, as shown in
[0073] Step 211, inputting the color arrangement information of the 54 colored blocks into the Two Phase algorithm. The Two Phrase may output thousands of solutions, and it is very troublesome for a user to find out one solution from the thousands of solutions, so the present disclosure adopts the standard of no more than eight solutions.
[0074] Step 212, determining if the Two Phase algorithm outputs solutions, and if the number of the solutions is smaller than 8;
[0075] if not, executing Step 213 to prompt users to scramble the Rubik's cube and performing recognition again;
[0076] if yes, executing Step 214 to operate each of the restored virtual Rubik's cubes by the reverse sequence of the corresponding one of the solutions, wherein the operation result may be the current state of the Rubik's cube of the user or includes a plurality of Rubik's cube states of the Rubik's cube currently in the hands of the user;
[0077] if the operation result includes a plurality of Rubik's cube states of the Rubik's cube currently in the hands of the user, executing Step 215 to prompt the user to select a virtual Rubik's cube which is in a state identical with the current state of the Rubik's cube in hands;
[0078] if the operation result is the current state of the Rubik's cube of the user, executing Step 216, wherein the selected virtual Rubik's cube shows the state of the Rubik's cube in hands of the user.
[0079] In step 22, the restoring steps of the Rubik's cube can be displayed.
[0080] Selected virtual Rubik's cube is restored in the forward sequence, and the restoration process is displayed to the user. Then, the user can operate the Rubik's cube in hands according to the restoration process. Finally, the restoration of the Rubik' cube is completed.
[0081]
[0082] Restore equipment 4 can include, for example: PAD, smart phone or computer etc.
[0083] In an embodiment of the disclosure, acquisition equipment 2 can be a reflector positioned on the top of restore equipment 4. Restore equipment 4 may be positioned and/or supported by a stand 1, and a bottom plate 3 is positioned on the bottom of stand 1 providing a game area and background for the cube, enabling the restoration simple, fast and accurate. The material of bottom plate 3 may be silica gel, which is soft, conducive to the health of children and may reduce the occurrence of scratches and other injuries.
[0084] Acquisition equipment 2 may be part of restore equipment 4 in another exemplary device for guiding users to restore Rubik's cube. For example, restore equipment 4 is a mobile phone and acquisition equipment 2 is the camera of it.
[0085] From the above detailed description it is seen that the present disclosure displays the virtual Rubik's cube which completely corresponds to the rear Rubik's cube in the aspects of arrangement and color information by scanning and recognition the real Rubik's cube, and outputs the method for restoring the Rubik's cube. It is fast and convenient to input the colors and arrangement information of the Rubik's cube into application programs by means of scanning the Rubik's cube. The restoration methods output for the Rubik's cubes are simple and practical. The output restoration methods are highly targeted at the current state of Rubik's cubes in hands of the users. The restoration fast, helpful for the game.
[0086] The basic principle, main characteristics and advantages of the present disclosure are described above. Those skilled in this field shall understand that the present disclosure is not limited by the above embodiments; the embodiments and the description only explain the principle of the present disclosure; based on the concept and scope of the present disclosure, various changes and improvements can be made, which shall all fall within the scope of the present disclosure claimed for protection. The scope of the present disclosure claimed for protection is defined by the Claims and the equivalent substances.