简体   繁体   中英

Python: cv2.imshow without waitKey()

I am trying to find a way to show an image without the dependency of waitKey(). I want the image to be shown and continue on with next operations (like a plot using matplotlib). How can this be achieved?

If you're wanting to show the window and have the program continue execution without relying on cv2.waitKey() , then cv2.startWindowThread() is what you're looking for.

Example:

import cv2

img = cv2.imread("C:\\Test\\so1.png")
cv2.imshow("Test", img)
cv2.startWindowThread()

for x in range(0, 10000000):
    print(x)

This will display the image and continue execution without using waitKey

I tried multiple methods, but what worked was using matplotlib

import matplotlib.pyplot as plt
#obtain I as a numpy array
plt.imshow(cv2.cvtColor(I, cv2.COLOR_BGR2RGB))

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM