PuzzleSolver
← Project Index PuzzleSolver

PuzzleSolver

An image-based jigsaw puzzle solver that segments individual pieces from a photo, analyzes their shapes and visual content, computes optimal placement, and walks you through assembly with an interactive guided UI.

Archived Started: 2025 Updated: Apr 2026

Overview

Dump all your jigsaw pieces on a white sheet, photograph them, and PuzzleSolver works out where each one goes. It isolates every piece from the photo, reads the shape of each side, matches tabs to blanks, and assembles the answer -; then presents it as a step-by-step guide rather than a single "here's the picture" cheat. It's a helper for solving the puzzle, not a way to skip it.

How It Works

It's an OpenCV-and-SciPy pipeline in Python with a Flask web UI on the front. The stages run roughly like this:

  • Segmentation -; isolate each piece from the white background, with auto-crop, perspective correction, shadow removal, and watershed separation for pieces that touch.
  • Feature extraction -; find each piece's four corners and four sides, classify every side as tab, blank, or flat, and capture its contour profile and edge-color strip.
  • Matching -; compare side displacement profiles (a tab is a positive bump, a blank a negative dent); flip one, overlay on the other, and the residual scores the fit, using a directed Hausdorff distance. Optional SIFT reference matching can localize pieces against a box-art image.
  • Solver -; "edge-first assembly," treated as a constraint satisfaction problem with soft constraints: build the border from the flat-sided pieces, then fill the interior row by row via greedy best-first search with limited backtracking. It can size the grid from the box's piece count and leave gaps for missing pieces.

The Flask UI is the payoff -; a piece gallery, a solution grid, click-to-highlight placement and neighbors, and a confidence-ordered list of assembly steps with a progress tracker.