在opencv imshow()函数中,不会打开新窗口并在jupyter笔记本中显示图像


import cv2
cap = cv2.VideoCapture(0)
status , photo = cap.read()
cv2.imwrite('Surendar.png',photo)
cap.release()  
cv2.imshow('image', photo) 
cv2.waitKey(5000) 
cv2.destroyAllWindows()

我在jupyter笔记本上解释了这个代码。它只是符合,但不显示图片的新窗口

尝试将cv2.waitKey(5000)更改为cv2.waitKey(0),这样窗口将一直保持直到用户关闭为止。看起来窗口等待了5000毫秒才破坏窗口。

编辑

不要用cv2来显示你的图像,试着用matplot代替

import cv2
from matplotlib import pyplot as plt
cap = cv2.VideoCapture(0)
status , photo = cap.read()
cv2.imwrite('Surendar.png',photo)
cap.release()  
plt.imshow(photo)
plt.show()

最新更新