↑
logo

Show HN: Solve hard jigsaw puzzles scanning with phone

Posted by javierluraschi |2 hours ago |2 comments

javierluraschi 2 hours ago

I got a super hard jigsaw puzzle and got frustrated by it. I tried some of the apps and services out there but nothing worked, mostly cause this puzzle was close to single color so the only way to match the pieces was by shape.

This project started with an existing PHP solver (https://github.com/byWulf/jigsawlutioner) but after trying it many things were broken, the phone outlines not accurate enough, I found out direct geometric side matching worked better, so I rewrote it from scratch (with AI obviously) in plain Node with no deps and used the old results just as a reference.

Scanning took the most time. Problem was that live segmentation overheated the phone, so I changed it so it only finds the card live and does the outline after the photo.

Shadows were bad as well, part—early edges included dark crescents and came out 7-9% too big. So switched to printing a PDF to scan the cards and then also change snapping the edge at full res.

Ended up printing a few card colors because some pieces vanish against certain backgrounds, but then found out most reliable to scan the pieces from the back for consistency.

Assembly is strongest-first with some local backtracking when groups almost close but conflict.

There’s a 54-piece demo that solves cleanly; it also does okay on a 1000-piece set.

Still rough on pieces that are close in color to the card, and the gap can be sensitive to how you scan.

The “match these three pieces” thing was added later for when you just want the missing corner of a 2x2 ranked. Which was useful cause even this algorithm was not able to match everything.

The last few pieces of the puzzle I matched them by hand (so this project won’t match all the pieces) but that was the remaining 10% of the puzzle and was quite fun and enjoyable.

Repo: https://github.com/javierluraschi/puzzle

javierluraschi 2 hours ago