Home > Mobile >  cv2 wait input depending on previous input
cv2 wait input depending on previous input

Time:10-12

I am trying to 'do more some stuff' after 's' is pressed. 'do more some stuff' will be triggered with pressing any/specific key after recieving the 's' input. Because 'do more some stuff' is dependent on 'do stuff' .I tried these so far.

while True:
  kk = cv2.waitKey(1)
  if kk == ord('s'):
    # Do stuff
    input("Press any key to continue")
    # Do more stuff

And

while True:
  kk = cv2.waitKey(1)
  if kk == ord('s'):
    # Do stuff
    print("Press c to continue")
    if kk == ord('c'):
      # Do more stuff

CodePudding user response:

Instead of using input, you could use cv2.waitKey once more.

import cv2

img = cv2.imread("D://Code//01.Python//yolov5//runs//detect//exp8//3.jpg")
cv2.imshow("name", img)
kk = cv2.waitKey(0)
if kk == ord('s'):
    print("Do stuff")
    tmp = cv2.waitKey(0)
    print("Do More Stuff")

enter image description here

  • Related