forked from f-boustani/sudoku_solver
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
41 lines (27 loc) · 875 Bytes
/
main.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
from Image_Processing import *
from solve_sudoku import *
def main(image):
board,position,final_image = image_processing(image)
start = time.clock()
solved_sudoku = solve(board)
#print solved_sudoku
t = time.clock()-start
print t
if(solved_sudoku):
output=[]
for s in squares:
output.append(solved_sudoku[s])
#print output
for i in range(len(position)):
if(position[i] !=0):
font = cv2.FONT_HERSHEY_SIMPLEX
cv2.putText(final_image,output[i],position[i], font,1.1,(0,255,0),2,cv2.CV_AA)
output = final_image.copy()
cv2.imwrite('output.jpg',output)
cv2.imshow('output',final_image)
cv2.waitKey(0)
return True
else:
print 'not solved!'
return False
main('sudoku.jpg')