-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsingleImageTest.py
More file actions
74 lines (50 loc) · 1.48 KB
/
singleImageTest.py
File metadata and controls
74 lines (50 loc) · 1.48 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import numpy as np
import cv2
import sys
from Tangrams import *
from TangramsGraph import *
def main():
if len(sys.argv) > 2:
filename1 = sys.argv[1]
filename2 = sys.argv[2]
else:
print("Invalid input")
sys.exit()
g = makeGraphFromImage(filename1)
f = makeGraphFromImage(filename2)
graphTest(f, g)
cv2.waitKey(0)
# When everything is done, shutdown.
cv2.destroyAllWindows()
###########################################
###########################################
###########################################
###########################################
###########################################
###########################################
def makeGraphFromImage(filename):
img = cv2.imread(filename, 1)
#Create Empty lists for pieces and connections.
pieces = []
connections = []
#Find pieces and connections.
valid = findValid(img)
pieces = indentifyPieces(valid, img)
connections = findConnections(pieces)
#Create blank image to draw on.
blank = np.zeros(img.shape)
#Draw pieces and connections.
drawPieces(blank, pieces)
drawConnections(img, connections)
# Display the resulting images.
cv2.imshow('blank '+filename, blank)
cv2.imshow('frame '+filename, img)
g = makeGraph(pieces, connections)
return g
def graphTest(f, g):
if f == g:
print("They match.")
else:
print("They don't match.")
if __name__ == "__main__":
main()