Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to refresh the image content in a window?

cv2.namedWindow("image",0)

img=cv2.imread("autojump.png")
while 1:
    img=cv2.imread("autojump.png")
    cv2.imshow("image",img)
    k=cv2.waitKey(0) & 0XFF
    if k== 27 :
        break
cv2.destroyAllWindows()

The image file autojump.png's content will change along with time(rewrited by with open("autojump.png","w" as f : f.write(some_other_bytes_stream) of another part of program.), so I reload it during the while loop, but it seems that the window never refresh.Just always the same image. What's wrong?

How to refresh the image content in a window?

cv2.namedWindow("image",0)

img=cv2.imread("autojump.png")
while 1:
    img=cv2.imread("autojump.png")
    cv2.imshow("image",img)
    k=cv2.waitKey(0) & 0XFF
    if k== 27 :
        break
cv2.destroyAllWindows()

The image file autojump.png's content will change along with time(rewrited by with open("autojump.png","w" as f : f.write(some_other_bytes_stream)f.write(some_other_image_bytes_stream) of another part of program.), ), so I reload it during the while loop, but it seems that the window never refresh.Just always the same image. What's wrong?