Skip to content
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

Merged
merged 1 commit into from Feb 22, 2019

Conversation

LaurentBerger
Copy link
Contributor

@LaurentBerger LaurentBerger commented Feb 20, 2019

good practise in tutorial?

Copy link
Member

@alalek alalek left a 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:
Copy link
Member

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:
Copy link
Member

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")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"Cannot open camera" ?

Copy link
Member

@alalek alalek left a 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 👍

@opencv-pushbot opencv-pushbot merged commit 4ebb617 into opencv:3.4 Feb 22, 2019
@alalek alalek mentioned this pull request Feb 26, 2019
@LaurentBerger LaurentBerger deleted the pythonvideo branch March 24, 2019 20:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
category: documentation Documentation fix or update
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants