Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 19 additions & 6 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,31 @@ def init_opts():
def main():
"""
"""
start = time.time()

font = cv2.FONT_HERSHEY_SIMPLEX
options, args = init_opts()
track = finger_track()
cap = cv2.VideoCapture(0)
newCanvas = canvas(cap.get(3), cap.get(4))
disappr = options.disappr
track.pathlength = options.length

game_time = 5
current_time = 1
start = time.time()
while True:
if time.time() - start > 1:
print(time.time() - start)
if time.time() - start > 1 and options.game:
current_time += 1
start = time.time()

if current_time == game_time+1:
while True:
cv2.putText(newCanvas.new_canvas, 'Yay!!!', (int(newCanvas.width/2-100), int(newCanvas.height/2)), font, 3, (255, 0, 0), 2)
cv2.putText(newCanvas.new_canvas, 'Your final score is:', (int(newCanvas.width/2-300), int(newCanvas.height/2+50)), font, 2, (0, 0, 255), 2)
cv2.putText(newCanvas.new_canvas, str(newCanvas.points)+'!!!', (int(newCanvas.width/2-75), int(newCanvas.height/2+50)+75), font, 3, (0, 255, 0), 2)
newCanvas.show_canvas()
if cv2.waitKey(1) & 0xFF == ord('q'):
break
break
ret, frame = cap.read()
frame = cv2.flip(frame, 1)

Expand All @@ -54,7 +66,7 @@ def main():

# newCanvas.rectangle()
if options.game:
print(newCanvas.points, newCanvas.run)
# print(newCanvas.points, newCanvas.run)
if newCanvas.points == 0:
if newCanvas.run == False:
newCanvas.make_rect()
Expand All @@ -65,6 +77,7 @@ def main():
newCanvas.clear()
newCanvas.show_rect()
newCanvas.show_rect()
cv2.putText(newCanvas.new_canvas, 'Time left: '+str(game_time-current_time), (0, 15), font, .5, (255, 255, 255), 1)
newCanvas.show_canvas()


Expand All @@ -78,7 +91,7 @@ def main():
disappr = False
else:
disappr = True
print(disappr)
# print(disappr)
if cv2.waitKey(1) & 0xFF == ord('c'):
newCanvas.clear()

Expand Down