Guest User

Untitled

a guest
Jan 20th, 2019
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. import numpy as np
  2. import matplotlib.pyplot as plt
  3. import cv2
  4. import os
  5. cap = cv2.VideoCapture(0)
  6. opened = cap.isOpened
  7. fps = cap.get(cv2.CAP_PROP_FPS)
  8. width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
  9. height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
  10. print(fps,width,height)
  11. #偵綠 寬*高 = 720*1280
  12. i= 0
  13. n = 0
  14. while(opened):
  15. i=i+1
  16. (flag , frame) = cap.read()
  17. gray = cv2.cvtColor(frame , cv2.COLOR_BGR2GRAY)
  18. frame = cv2.resize(gray,(28,28))
  19. cv2.imshow('frame',gray)
  20. if cv2.waitKey(1) & 0xFF == ord('q'):
  21. break
  22. #plt.imshow(frame)
  23. #plt.show()
  24. if flag == True:
  25. if(i%1==0 and i>=200):
  26. print(n)
  27. n+=1
  28. if n==500:
  29. print('over')
  30. break
  31. fileName = 'images'+str(n)+'.jpg'
  32. cv2.imwrite('gesture_picture/option4/'+fileName,frame)
Add Comment
Please, Sign In to add comment