python reads the camera data and saves the instance

  • 2020-11-30 08:28:35
  • OfStack

As shown below:


import cv2

cap = cv2.VideoCapture(0)

k = 0 
while k != 27: # esc 
ret, img = cap.read(0) 
cv2.imshow( ' 233', img) 
k = cv2.waitKey(20) & 0xff

print(  ' begin to record images ... ' )

for ii in range(1000): 
ret, img = cap.read(0) 
cv2.imshow( ' 233', img) 
cv2.imwrite( ' imaged%04d.jpg'%(ii), img) 
cv2.waitKey(20)

Related articles: