Code for controlling mbed hardware (LED's, motors), as well as code for the Raspberry Pi to run a Support Vector Machine that identifies objects using the Pi camera

Dependencies:   mbed Motordriver mbed-rtos PololuLedStrip

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers collectImages.py Source File

collectImages.py

00001 import sys
00002 import time
00003 import picamera
00004 
00005 
00006 
00007 myargs = sys.argv[1:]
00008 
00009 camera = picamera.PiCamera()
00010 camera.resolution = (352, 240)
00011 camera.color_effects = (128, 128)  # turn camera to black and white
00012 camera.start_preview()
00013 time.sleep(2)
00014 
00015 
00016 if len(myargs) <= 1:
00017     sys.exit("Incorrect arguments")
00018 
00019 num_images_per_type = int(myargs[0])  # number of images to take of each type of object
00020 
00021 print("Taking ", num_images_per_type, "images each of ", myargs[1:])
00022 
00023 for image_type in myargs[1:]:
00024     for i in range(num_images_per_type):
00025         filename = image_type + "_" + str(i) + ".bmp"
00026         camera.capture("images/"+filename, format='bmp', resize=(352, 240))
00027         print(filename)
00028         time.sleep(1)