-
-
Notifications
You must be signed in to change notification settings - Fork 55.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Check return value in python tutorial #13877
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Error checks make sense.
if cv.waitKey(1) & 0xFF == ord('q'): | ||
# Display the resulting frame | ||
cv.imshow('frame',gray) | ||
if cv.waitKey(1) & 0xFF == ord('q') or not ret: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
& 0xFF
Not needed anymore with waitKey()
.
# Our operations on the frame come here | ||
gray = cv.cvtColor(frame, cv.COLOR_BGR2GRAY) | ||
# if frame is read correctly ret is True | ||
if ret: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is about this?
if not ret:
print("Can't receive frame (stream end?). Exiting...")
break
At least we don't need to complicate condition below.
@@ -25,17 +25,21 @@ import numpy as np | |||
import cv2 as cv | |||
|
|||
cap = cv.VideoCapture(0) | |||
|
|||
if not cap.isOpened: | |||
print("Cannot open VideoCapture") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Cannot open camera" ?
73884d7
to
7bad23d
Compare
3e4cc6e
to
4ebb617
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me! Thank you 👍
good practise in tutorial?