Created
          July 29, 2017 04:07 
        
      - 
      
 - 
        
Save linnil1/3e1dbc2abbf1765120f1f0f18d0f7ac1 to your computer and use it in GitHub Desktop.  
    save webcam capture image
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | import cv2 | |
| import numpy as np | |
| import time | |
| cap = cv2.VideoCapture(0) | |
| while not cap.isOpened(): | |
| print("Reset") | |
| time.sleep(0.1) | |
| cap = cv2.VideoCapture(0) | |
| try: | |
| while(True): | |
| ret, frame = cap.read() | |
| randomname = time.strftime("%Y%m%d%H%M%S") + \ | |
| "{:03}".format(round(time.time() * 1000) % 1000) | |
| cv2.imwrite("image/image_" + randomname + '.jpg', frame) | |
| time.sleep(0.33) | |
| finally: | |
| cap.release() | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment