Skip to content

Commit

Permalink
Drop the frame if we could not get the data.
Browse files Browse the repository at this point in the history
  • Loading branch information
Dilawar Singh committed Dec 15, 2015
1 parent 6cce3f9 commit 836062f
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 4 deletions.
7 changes: 6 additions & 1 deletion blinky_gui.py
Expand Up @@ -98,7 +98,12 @@ def animate(i):
t = float(i) / fps_
ret, img = cap_.read()
(x0, y0), (x1, y1) = box_
frame = img[y0:y1,x0:x1]
try:
frame = img[y0:y1,x0:x1]
except Exception as e:
print('[WARN] Frame %s dropped' % i)
return lines_.values(), time_text_

gray = cv2.cvtColor(frame, cv2.COLOR_RGB2GRAY)

if save_video_:
Expand Down
7 changes: 4 additions & 3 deletions webcam.py
Expand Up @@ -119,11 +119,12 @@ def onmouse(event, x, y, flags, params):
def get_bounding_box(frame):
global current_frame_, bbox_
current_frame_ = frame.copy()
cv2.namedWindow('Bound_eye')
cv2.setMouseCallback('Bound_eye', onmouse)
title = "Bound eye and press 'q' to quit."
cv2.namedWindow(title)
cv2.setMouseCallback(title, onmouse)
clone = frame.copy()
while True:
cv2.imshow("Bound_eye", current_frame_)
cv2.imshow(title, current_frame_)
key = cv2.waitKey(1) & 0xFF
if key == ord("c"):
current_frame_ = clone.copy()
Expand Down

0 comments on commit 836062f

Please sign in to comment.