xbusi missing piece - computer...
TRANSCRIPT
![Page 1: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/1.jpg)
PuzzleSolver
Joe Zeimen
Monday, April 29, 13
![Page 2: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/2.jpg)
Goal
Monday, April 29, 13
![Page 3: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/3.jpg)
General Outline
• Scan Pieces• Find pieces• Extract edges• Compare edges• Assemble Puzzle• Generate output image
Monday, April 29, 13
![Page 4: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/4.jpg)
Thresholding
Monday, April 29, 13
![Page 5: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/5.jpg)
Find Contours
• use cv::findContours() on the binary image.• Filter out contours smaller than an expected puzzle piece size.• Provides shape informaFon• Provides a mask to produce the final output image.
5
Monday, April 29, 13
![Page 6: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/6.jpg)
Find the corners
• cv::goodFeaturesToTrack()• cv::cornerSubPix()
6
Monday, April 29, 13
![Page 7: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/7.jpg)
7
Edges and classifica7on
Monday, April 29, 13
![Page 8: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/8.jpg)
Comparing Edges
8
First and LastUsed Matches from Angry
Birds Puzzle
Best: 0.453672 Last Used: 0.865829
Monday, April 29, 13
![Page 9: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/9.jpg)
Assembly Algorithm
–Goal: Join pieces together to result in lowest cost.–4nn! combinaFons where n is the number of pieces
9
n combina(ons
24 1.74641E+38
48 9.83532E+89
104 4.23677E+228
Monday, April 29, 13
![Page 10: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/10.jpg)
Assembly Algorithm
• Compare every pair of edges, store in a sorted list.• While the puzzle is not finished:–Pop the next best match off the list–Merge the 2 pieces using the 2 edges from the list
• Merge(piece 1, edge 1, piece2, edge 2)– If piece 1 and piece 2 are in same set return– If merging piece 1 and piece 2 result in overlap return–merge piece 1 and piece 2
10
Monday, April 29, 13
![Page 11: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/11.jpg)
Best Matches List
11
Cost Piece 1 Edge 1 Piece 2 Edge 20.453672 12 2 13 1
0.539882 14 1 23 0
0.557301 4 0 9 1
0.589648 11 0 23 2
0.598454 0 0 20 2
0.61856 3 3 20 1
0.625861 5 3 9 0
0.630817 11 2 22 3
... ... ... ... ...
Monday, April 29, 13
![Page 12: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/12.jpg)
Combine Pieces:
12
Monday, April 29, 13
![Page 13: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/13.jpg)
Combine Pieces:
12
Monday, April 29, 13
![Page 14: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/14.jpg)
Combine Pieces:
12
Monday, April 29, 13
![Page 15: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/15.jpg)
Combine Pieces:
12
Monday, April 29, 13
![Page 16: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/16.jpg)
Side numbering conven7on
13
0
1
2
3
Monday, April 29, 13
![Page 17: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/17.jpg)
How the computer does it:
14
4 5
9 -‐1
0 1
3 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
Monday, April 29, 13
![Page 18: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/18.jpg)
How the computer does it:
14
4 5
9 -‐1
0 1
3 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
1
Rotate the matrix set with 5 in it
Monday, April 29, 13
![Page 19: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/19.jpg)
How the computer does it:
15
5 -‐1
4 9
0 1
3 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
Monday, April 29, 13
![Page 20: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/20.jpg)
How the computer does it:
15
5 -‐1
4 9
0 1
3 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
1
Update the rotaFon matrix
Monday, April 29, 13
![Page 21: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/21.jpg)
How the computer does it:
16
5 -‐1
4 9
2 0
1 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
Monday, April 29, 13
![Page 22: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/22.jpg)
How the computer does it:
16
5 -‐1
4 9
2 0
1 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
2
Rotate 6
Monday, April 29, 13
![Page 23: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/23.jpg)
How the computer does it:
17
5 -‐1
4 9
2 0
1 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
Monday, April 29, 13
![Page 24: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/24.jpg)
How the computer does it:
17
5 -‐1
4 9
2 0
1 0
6
0
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
2
Update 6’s rotaFon matrix
Monday, April 29, 13
![Page 25: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/25.jpg)
How the computer does it:
18
5 -‐1
4 9
2 0
1 0
6
2
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
Monday, April 29, 13
![Page 26: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/26.jpg)
How the computer does it:
19
5 -‐1
4 9
2 0
1 0
6
2
LocaFons
RotaFons
Want to merge piece 5, edge 0 with piece 6 edge 2
5 6
4 9
2 2
1 0
+ =
Monday, April 29, 13
![Page 27: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/27.jpg)
Saving the Image
• Given the locaFons an rotaFons of the soluFon, the pieces can be put into place using affine transforms.• Can figure out all corner locaFons except lower right. • Use the 3 corners to calculate the transformaFon matrix.• Scan horizontally then verFcally using the corners computed previously to place the next piece.
20
Monday, April 29, 13
![Page 28: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/28.jpg)
Other Solved Puzzles
21
Monday, April 29, 13
![Page 29: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/29.jpg)
Other Solved Puzzles
2248 Pieces
Monday, April 29, 13
![Page 30: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/30.jpg)
Other Solved Puzzles
23
Monday, April 29, 13
![Page 31: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/31.jpg)
Other Solved Puzzles
24Back of Toy Story puzzle, numbered based on soluFon by hand.
Monday, April 29, 13
![Page 32: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/32.jpg)
25104 piece puzzle (back)Monday, April 29, 13
![Page 33: Xbusi Missing Piece - Computer Sciencecs-courses.mines.edu/csci507/projects/2013/PuzzleSolver_Presentat… · ComparingEdges 8 Firstand+Last Used+Matches+from+Angry+ Birds+Puzzle](https://reader034.vdocument.in/reader034/viewer/2022042804/5f553aa59ce05774b7050200/html5/thumbnails/33.jpg)
26
Ques(ons?
Code and images at:github.com/jzeimen/PuzzleSolver
Monday, April 29, 13