Skip to content

Commit

Permalink
reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
LaurentBerger committed Feb 21, 2019
1 parent fef51f4 commit 73884d7
Showing 1 changed file with 12 additions and 12 deletions.
24 changes: 12 additions & 12 deletions doc/py_tutorials/py_gui/py_video_display/py_video_display.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -25,27 +25,27 @@ import numpy as np
import cv2 as cv

cap = cv.VideoCapture(0)
if not cap.isOpened:
print("Cannot open VideoCapture")
if not cap.isOpened():
print("Cannot open camera")
exit()
while(True):
while True:
# Capture frame-by-frame
ret, frame = cap.read()

# if frame is read correctly ret is True
if ret:
# Our operations on the frame come here
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)

# Display the resulting frame
cv.imshow('frame',gray)
if cv.waitKey(1) & 0xFF == ord('q') or not ret:
if not ret:
print("Can't receive frame (stream end?). Exiting ...")
break
# Our operations on the frame come here
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY)
# Display the resulting frame
cv.imshow('frame', gray)
if cv.waitKey(1) == ord('q'):
break

# When everything done, release the capture
cap.release()
cv.destroyAllWindows()
@endcode
cv.destroyAllWindows()@endcode
`cap.read()` returns a bool (`True`/`False`). If frame is read correctly, it will be `True`. So you can
check end of the video by checking this return value.

Expand Down

0 comments on commit 73884d7

Please sign in to comment.