Created
March 13, 2016 00:12
-
-
Save gigafide/9fb59719d21c7552257b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import the SimpleCV library | |
from SimpleCV import * | |
#initialize the camera | |
cam = Camera() | |
#set the maximum display size | |
display = Display((800,600)) | |
#create a loop to constantly get a new image from the camera | |
while True: | |
#check the display for user interaction | |
display.checkEvents() | |
#grab the image from the camera | |
img = cam.getImage() | |
#show the image in a new window | |
img.show() | |
#if a left mouse click is detected, save the image | |
if display.mouseLeft: | |
#initiate the counter variable | |
i = 0 | |
#check to see if the filename already exists | |
while os.path.exists('image%s.png' % i): | |
#if it does, add one to the counter | |
i += 1 | |
#save the image to a file within the project folder | |
img.save('image%s.png' % i) | |
#print a confirmation response | |
print('Image Saved') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment