Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- import matplotlib.pyplot as plt
- import cv2
- import os
- cap = cv2.VideoCapture(0)
- opened = cap.isOpened
- fps = cap.get(cv2.CAP_PROP_FPS)
- width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH))
- height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT))
- print(fps,width,height)
- #偵綠 寬*高 = 720*1280
- i= 0
- n = 0
- while(opened):
- i=i+1
- (flag , frame) = cap.read()
- gray = cv2.cvtColor(frame , cv2.COLOR_BGR2GRAY)
- frame = cv2.resize(gray,(28,28))
- cv2.imshow('frame',gray)
- if cv2.waitKey(1) & 0xFF == ord('q'):
- break
- #plt.imshow(frame)
- #plt.show()
- if flag == True:
- if(i%1==0 and i>=200):
- print(n)
- n+=1
- if n==500:
- print('over')
- break
- fileName = 'images'+str(n)+'.jpg'
- cv2.imwrite('gesture_picture/option4/'+fileName,frame)
Add Comment
Please, Sign In to add comment