Created
October 4, 2017 23:09
-
-
Save garybradski/57a9f76087c698211f2f73b6ed00d77f to your computer and use it in GitHub Desktop.
Using python matplotlib and opencv cv2 imshow in the same loop using the keyboard to trigger pause or run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import cv2 | |
from matplotlib import pyplot as plt | |
. . . | |
#DO PYTHON MATPLOTLIB IMAGE DISPLAY | |
plt.imshow(image_seg) | |
plt.draw() | |
plt.show() # , plt.draw(), plt.show() | |
plt.pause(0.01) | |
#DO OPENCV IMSHOW IMAGE DISPLAY | |
cv2.imshow("video", frame) | |
#key handling | |
k = cv2.waitKey(wait_key) & 0xff | |
if chr(k) == 'r': #start running | |
wait_key = 30 | |
elif chr(k) == 'p': #pause between frames | |
wait_key = 0 | |
elif k == 27: #end processing | |
break | |
else: | |
k = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Now you can use either and step though them in an OpenCv manner or just "r" for run, "p" for pause, "esc" for quit