import cv2

videoCaptureObject = cv2.VideoCapture(0)
while(True):
	ret,frame = videoCaptureObject.read()
	cv2.imshow('Capturing Video',frame)
	if(cv2.waitKey(1) & 0xFF == ord('y')):
		cv2.imwrite('pic.png', frame)
		cv2.destroyAllWindows()
		break
    elif(cv2.waitKey(1) & 0xFF == ord('q')):
        videoCaptureObject.release()
		cv2.destroyAllWindows()

cap.release()
