

import numpy as np
from picamera import PiCamera
from time import sleep
import cv2

def capture(path):
	try:
		choice = input('Number of photos: ')
		print('Initializing camera')
		camera = PiCamera()
		camera.resolution = (640, 480)
		print('[ OK ] Camera')
		sleep(2)
	except:
		print('[ Error ] Can not initialize PiCamera')
	for i in range(1, choice):
		camera.capture(path+str(i)+'.jpg')
		photo = cv2.imread(path+str(i)+'.jpg',1)
		cv2.imshow('Photo',photo)
		print('Captured '+str(i)+'\nPath ('+path+str(i)+'.jpg)')
		cv2.waitKey(100)
		sleep(1)
	cv2.destroyAllWindows()
	print('Done!')
capture('train/')

