我想使用python在openCV中播放视频并随时关闭该窗口,但是它不起作用。
import numpy as np
import cv2
fileName='test.mp4' # change the file name if needed
cap = cv2.VideoCapture(fileName) # load the video
while(cap.isOpened()):
# play the video by reading frame by frame
ret, frame = cap.read()
if ret==True:
# optional: do some image processing here
cv2.imshow('frame',frame) # show the video
if cv2.waitKey(1) & 0xFF == ord('q'):
break
else:
break
cv2.waitKey(1)
cv2.destroyAllWindows()
cv2.waitKey(1)
窗口打开并开始播放视频,但是我无法关闭窗口。
答案 0 :(得分:1)
您可以使用Counter({('network discover', '192.168.0.15'): 3,
('network discover', '192.168.0.12'): 1,
('ETERNALBLUE tool', '192.168.0.15'): 1,
('ETERNALBLUE tool', '192.168.0.12'): 1})
检测窗口是否关闭。我对索引不确定,但这对我有用:
pad_width = 8 - length_of_your_array
pad_array = np.zeros(pad_width)
desired_array = np.concatenate((pad_array, your_array))