我正在尝试使用 opencv-python 捕获屏幕并连续显示图像。但由于某种原因,图像并没有像往常一样堆叠在一起。请看下面的源代码和截图。我在 ubuntu 18.04。谢谢!!
import time
import cv2
import mss
import numpy as np
with mss.mss() as sct:
# Part of the screen to capture
monitor = {"top": 40, "left": 0, "width": 800, "height": 640}
while True:
last_time = time.time()
# Get raw pixels from the screen, save it to a Numpy array
img = np.array(sct.grab(monitor))
# Display the picture
cv2.imshow('frame', img)
print("fps: {}".format(1 / (time.time() - last_time)))
# Press "q" to quit
if cv2.waitKey(1) & 0xFF == ord("q"):
cv2.destroyAllWindows()
break