Skip to content

Image tool that allows you to end that puzzle that you couldn't finish because you lose one piece.

License

Notifications You must be signed in to change notification settings

josepdecid/puzzle-missing-piece

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Puzzle: Missing Piece

Puzzle: Missing Piece, is an image tool that allows you to end that puzzle that you couldn't finish because you lost one piece. And it's obvious that you don't want to manually draw the piece based on a small reference image because it will be horrendous.

To avoid this annoying process, just taking two photos of the incomplete puzzle and the reference image, this tool generates the missing piece, so you can print it to cut it and fill your empty and lonely puzzle hole.

How to get your missing piece

Download or clone this repository in your machine. This program uses Python3.6 (or higher). You can download it from the official Python site.

Dependencies are managed using Pipenv, so simply run the following command to install the required libraries:

$ pipenv install

To obtain the piece, run the main script puzzle.py specifying the following parameters:

  • Reference photo path: Path to the photo of the puzzle reference (i.e., box model reference).
  • Puzzle photo path: Path to the photo of the incomplete puzzle.
  • Puzzle width: Width of the puzzle in cm.
  • Puzzle height: Height of the puzzle in cm.
  • Output path (optional): Directory to store the missing piece image to. If ignored, it is saved in the same directory as the reference photo.

As an example:

$ python src/puzzle.py ./resources/city/reference.jpg ./resources/city/puzzle.jpg 118.4 84.5

How does it work?

Take two pictures of the puzzle. The first picture (reference_photo) is a photo of the puzzle reference, as shown (typically) in the puzzle box. The second picture (puzzle_photo) is a photo of the real puzzle which has one missing piece.

Reference Photo Puzzle Photo

Applying a projective transformation to both images with the puzzle vertices, we get a frontal view of the puzzle of the same size for both reference and puzzle images.

Photo with marked vertices Warped photo

By applying a new channel mask to the puzzle image, we index and extract the remaining pixels that define the piece shape and colors, accessing them from the warped reference photo and storing the obtained piece into a new image file.

Resulting Piece That fits in... Creating...

TODO: Features coming soon

  • Automatic projective transformation for image alignment, without having to specify the coordinates of the vertices.
  • Automatic piece detection without having to draw the overlaying mask.
  • Web client to perform this task without having to download and install the project locally.

But... why?

BrentRamboDrakeMeme

About

Image tool that allows you to end that puzzle that you couldn't finish because you lose one piece.

Topics

Resources

License

Stars

Watchers

Forks

Languages