AUTHOR: Cynthia
Initial Goal: Operate picamera through Python and allow it to continually take photos (within a loop)
Realized Outcome: Yes
Note: includes I2C code and the python function
from smbus import SMBus
from picamera import PiCamera
from time import sleep
#import sys #not needed due to numb condition in li #34 (set when !(0,1,2))
addr = 0x8 #bus address
bus = SMBus(1) #indicates /dev/ic2-1 when I2C is enabled ls /dev/*i2c*
numb = 1
loopN = 0
camera = PiCamera()
camera.rotation = 90 # comment out if your camera is in correct orientation
# dynamic function
def snapPose(loopN):
camera.start_preview(alpha=200)
sleep(3) # max min on sleep for lighting adjustment
camera.capture('testimage%s.jpg' % loopN) #saves in working directory
camera.stop_preview()
print ('Enter 1 for ON / 0 for OFF')
while numb == 1:
ledstate = input('>>>> ')
if ledstate == '1':
bus.write_byte(addr,0x1) #switch ON, may need to add some delay before pose
snapPose(loopN)
print(numb, 'numb: with', loopN)
loopN +=1
elif ledstate == '0':
bus.write_byte(addr,0x0) #switch OFF
else:
numb = 0 #escapes out of loop for any malformed input (it also exits the program)
https://picamera.readthedocs.io/en/release-1.13/recipes2.html
https://projects.raspberrypi.org/en/projects/getting-started-with-picamera