import os from time import sleep from SimpleCV import ImageSet from utils import PreparedCamera # Settings cam_size = {'width': 640, 'height': 480} gif_interval = 0.5 # Seconds between frames gif_length = 10 # Length in seconds file_name = os.path.join('pictures', 'ani.gif') cam = PreparedCamera(0, cam_size, debug=True) print("Recording images") img_set = ImageSet() for frame in range(0, int(gif_length * gif_interval)): img = cam.getImage() img_set.append(img) sleep(1.0/gif_interval) img_set.save(destination=file_name, dt=gif_interval)
from SimpleCV import Camera, ImageSet import time cam = Camera() camImages = ImageSet() # Set to a maximum of 10 images saved # Feel free to increase, but bewared running out of space maxImages = 10 for counter in range(maxImages): # Capture a new image and add to set img = cam.getImage() camImages.append(img) # Show the image and wait before capturing another img.show() time.sleep(6) camImages.save(verbose=True)
def main( args ): # # Set these flags so they can be checked for validity later. # res = None fac = None # # Check for any args that can safely be defaulted. # if args.dest: outdir = args.dest # # Append a trailing slash if it's not there. # if outdir[-1] != '/': outdir = outdir + '/' else: outdir = 'scaled_thumbs/' # # Check for scale or resolution. The default action is to scale # by 1/2. # if args.res: (width, height) = args.res.split('x') # # Just set this to something other than None, so the script can # tell whether or not to use the resolution later. # res = args.res elif args.fac: # # Limit the scale factor so super-large images are made even bigger. # fac = float(args.fac) if fac >= 2.0: fac = 2.0 if fac <= 0.0: fac = 0.1 else: fac = .5 # # Make sure the new files have a home. # if not isdir(outdir): mkdir(outdir) # # Load the files from the command line # images = ImageSet() _info_('Adding images to image set... this may take a moment.') for item in args.files: # # Make sure I don't try to convert something that's not an image. # try: image = Image(item) except IOError, err: _err_("Invalid/unuseable file: " + item) exit(2) images.append(image)