import threading
import cv2
global timer
import sys
import time
def shot_img():
global num
success, frame = cameraCapture.read()
path = "D:/Images/"
cv2.imwrite( path +str(num) + '.png', frame)
print(num)
num += 1
if num==5:
cameraCapture.release()
cv2.destroyAllWindows()
sys.exit()
timer = threading.Timer(1, shot_img)
timer.start()
if __name__ == '__main__':
num=0
cameraCapture = cv2.VideoCapture(0)
timer = threading.Timer(1,shot_img)
timer.start()
python-opencv 利用摄像头保存截图到本地
最新推荐文章于 2024-07-09 17:57:14 发布