-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtake_panorama.py
51 lines (38 loc) · 952 Bytes
/
take_panorama.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
from subprocess import call
import time
import cv2
import serial
import struct
import pyfirmata
board = pyfirmata.Arduino('/dev/ttyACM0')
iter8 = pyfirmata.util.Iterator(board)
iter8.start()
turret = board.get_pin('d:5:s')
camera = PiCamera()
rawCapture = PiRGBArray(camera)
def rotate(angle):
turret.write(angle)
def capture_image(filename):
time.sleep(0.1)
rawCapture.truncate(0)
camera.capture(rawCapture, format="bgr")
image = rawCapture.array
cv2.imwrite(filename, image)
# initialize the camera and grab a reference to the raw camera capture
# allow the camera to warmup
rotate(50)
time.sleep(1)
capture_image("workspace/r45.jpg")
rotate(90)
time.sleep(1)
capture_image("workspace/r90.jpg")
rotate(130)
time.sleep(1)
capture_image("workspace/r135.jpg")
camera.close()
rotate(90)
call(["./build_panorama"])
board.exit()