Skip to content

Commit da81330

Browse files
committed
Update waitKey() prompts in examples 2 and 3
1 parent d4a137b commit da81330

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

examples/ex02_imread_imwrite.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,10 @@
1717
# depend on the display driver. For example, the default ST7789 display driver
1818
# will crop large images, and show small images in the top-left corner
1919
cv2.imshow(display, img)
20-
key = cv2.waitKey(1000)
20+
21+
# Prompt the user to press a key to continue
22+
print("Press any key to continue")
23+
key = cv2.waitKey(0)
2124

2225
# Let's modify the image! Here we use `cv2.Canny()` to perform edge detection
2326
# on the image, which is a common operation in computer vision

examples/ex03_camera.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@
1313
# `boot.py` script. See the example `boot.py` script for more details
1414
camera.open()
1515

16+
# Prompt the user to press a key to continue
17+
print("Press any key to continue")
18+
1619
# Loop to continuously read frames from the camera and display them
1720
while True:
1821
# Read a frame from the camera, just like any other Python environment! It
@@ -31,8 +34,8 @@
3134
# Check for key presses
3235
key = cv2.waitKey(1)
3336

34-
# If the 'q' key is pressed, exit the loop
35-
if key == ord('q'):
37+
# If any key is pressed, exit the loop
38+
if key != -1:
3639
break
3740

3841
# Release the camera, just like in any other Python environment!

0 commit comments

Comments
 (0)