This page never keeps a list of your turns, only a count. When you press Solve, the solver is handed six photos of the cube and nothing else. OpenCV reads the 54 sticker colors from the pixels, and a solving algorithm plans the moves from what OpenCV saw.
What the computer saw
The photos below are everything the solver received. Each is taken with a slight tilt, uneven light and a little camera noise, so the vision steps have real work to do. The dots show the color OpenCV read for each sticker.
Laid out as if the cube were unfolded. Click any photo to see inside it below.
- 1Move history: none kept
The solver never sees how the cube was mixed.
- 2Six photos taken
One of each face, the only input the solver gets.
- 3OpenCV reads 54 stickers
Finds the stickers, flattens each face and measures every color.
- 4Check that it’s a real cube
Every corner and edge must match a real piece.
- 5Plan the moves
Search for a short solution.
- 6Solve it
Play the plan on the cube above.
Inside one photo
How OpenCV turns one photo into nine colors. Pick a face to follow it through every step.
The photo
About 57,000 colored dots, with shadows, glare and noise mixed in.
imread
Stickers only
Keeps dots that are either colorful or bright. The black plastic and the table drop away.
cvtColor + inRange
Nine stickers found
Traces each sticker’s outline and keeps the nine biggest. Slivers of the side faces are ignored.
findContours + convexHull
Face flattened
The tilted face is stretched back into a perfect square so the 3×3 grid lines up.
getPerspectiveTransform + warpPerspective
Colors decided
Left half of each square: the average color measured. Right half: the color it was matched to, using the six centers as references.
mean
How it works
Seeing
A computer doesn’t see stickers, it sees a grid of numbers. OpenCV finds the bright, colorful patches, works out the outline of the face, and flattens it so the nine stickers land in predictable spots.
Colors are judged relative to each other, not against a fixed list. The center sticker of each face never moves, so the computer uses the six centers as its color reference, which keeps the reading steady in uneven light.
Checking
One misread sticker makes a cube that can’t exist, and no algorithm can solve it. So before planning, the computer checks that there are nine of each color and that every corner and edge matches a real piece.
It also checks the hidden rules a real cube obeys. For example, you can never have a single corner twisted in place; corner twists always add up across the cube.
Planning
The plan comes from Herbert Kociemba’s two-phase algorithm. Phase one gets the cube into a special family of positions that can be finished using only a few kinds of turns. Phase two finishes it using only those turns.
Splitting the problem makes an enormous search manageable, so it finds a solution of around 20 moves in well under a second.
Possible arrangements of a standard cube. Trying them one by one is out of the question; the computer has to reason its way there.
Known as “God’s number.” In 2010, researchers proved every arrangement can be solved in 20 face turns or fewer.
The solver works only from what it sees, the same way it will work with a real cube held up to a webcam.