
python-opencv 利用摄像头保存截图到本地
import threadingimport cv2global timerimport sysimport timedef shot_img():global numsuccess, frame = cameraCapture.read()path = "D:/Images/"cv2.imwrite( path +str(num) + '.png', frame)print(num)num +=
·
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()
更多推荐
所有评论(0)