python-opencv 利用摄像头保存截图到本地

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()

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
THE END
分享
二维码

)">
< <上一篇
下一篇>>