-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtestStatic.py
103 lines (71 loc) · 1.79 KB
/
testStatic.py
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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import sys
import math
import numpy as np
import cv2
import mazeSearch
from imaging import *
###########################
## Image Processing Library
###########################
import argparse
#Parse cmd-line args and find/load image
ap = argparse.ArgumentParser()
ap.add_argument("-i", "--image", help = "path to the image")
args = vars(ap.parse_args())
image = cv2.imread(args["image"])
#image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
#ret,image = cv2.threshold(image,127,255,cv2.THRESH_BINARY)
#
#kernel = np.ones((1,1), np.uint8)
#image = cv2.erode(image, kernel, iterations=1)
#
#findStartEnd(image) #TESTING
#
#cv2.imshow("image",image)
#
#size = np.size(image)
#skel = np.zeros(image.shape,np.uint8)
#
#element = cv2.getStructuringElement(cv2.MORPH_CROSS,(3,3))
#done = False
#
#while(not done):
# eroded = cv2.erode(image,element)
# temp = cv2.dilate(eroded,element)
# temp = cv2.subtract(image,temp)
# skel = cv2.bitwise_or(skel,temp)
# image = eroded.copy()
#
# zeros = size - cv2.countNonZero(image)
# if zeros==size:
# done = True
#
#findStartEnd(skel) #TESTING
#
#cv2.imshow("skel",skel)
#cv2.waitKey(0)
#
#exit()
##FAKE SLIDER VALS
contourThreshVal = 60
minBoundBoxVal = 5000
erosionVal = 40
#Do 10 times and get average
#total = 0
for i in range(1):
thing = getMazeOutlineImage(image.copy(), contourThreshVal, minBoundBoxVal)
if len(thing) < 3:
print "oops, bye"
exit()
thresh,img,box = thing
dst2,h = getImageFromBox(thresh, box)
#mazeImg,solvedImage,timez = getSolvedMaze(image.copy(), h, dst2, erosionVal)
mazeImg,solvedImage = getSolvedMaze(image.copy(), h, dst2, erosionVal)
#total += timez
#print total / 10.0
cv2.imshow("original", img)
#cv2.waitKey(0)
cv2.imshow("solution", solvedImage)
#cv2.waitKey(0)
cv2.imshow("solution2", mazeImg)
cv2.waitKey(0)