I would be very grateful for some guidance on the following script. You will see that I have very little experience (3 days!).
Using the pantilthat servo control, I am taking a image (jpg) at various camera positions. This is in a continuous loop that will be run during daylight hours.
I am trying to save the images like so, 1.jpg, 2.jpg, 3.jpg..... 1.jpg, 2.jpg, 3.jpg.... etc etc
The code works, but I just cant figure out the file naming part. Thank you for looking and any improvents gratefully received.
#!/usr/bin/env python
import pantilthat
import time
import picamera
x = 0
while x < 9:
print "Take Photo"
with picamera.PiCamera() as camera:
camera.resolution = (1024, 768)
camera.start_preview()
camera.annotate_text = 'Picture Taken with Raspberry camera'
time.sleep(2)
for filename in camera.record_sequence(
'image%02d.jpg' % i for i in range(1)):
print('Saving to %s' % filename)
camera.stop_preview()
print('Done')
x += 1
if x == 1:
print("1")
pantilthat.pan(30)
pantilthat.tilt(-10)
time.sleep(1)
elif x == 2:
print("2")
pantilthat.pan(20)
pantilthat.tilt(0)
time.sleep(1)
elif x == 3:
pantilthat.pan(10)
pantilthat.tilt(10)
print("3")
time.sleep(1)
elif x == 4:
pantilthat.pan(0)
pantilthat.tilt(-10)
print("4")
time.sleep(1)
elif x == 5:
pantilthat.pan(-10)
pantilthat.tilt(10)
print("5")
time.sleep(1)
elif x == 6:
pantilthat.pan(-20)
pantilthat.tilt(-20)
print("6")
time.sleep(1)
elif x == 7:
pantilthat.pan(-30)
pantilthat.tilt(20)
print("7")
time.sleep(1)
x=0
else:
pass