-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdatacollection.py
More file actions
72 lines (51 loc) · 1.66 KB
/
Copy pathdatacollection.py
File metadata and controls
72 lines (51 loc) · 1.66 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# ENME489Y: Remote Sensing
# import the necessary packages
from picamera.array import PiRGBArray
from picamera import PiCamera
import numpy as np
import time
import cv2
import imutils
# initialize the camera and grab a reference to the raw camera capture
camera = PiCamera()
camera.resolution = (1280,720)
camera.framerate = 25
rawCapture = PiRGBArray(camera, size=(1280,720))
# allow the camera to setup
time.sleep(1)
# Enter the initial IMU angle from user
d = raw_input("Please IMU angle: ")
print "Confirming the IMU angle you entered is: "
print d
# grab an image from the camera
for frame in camera.capture_continuous(rawCapture, format="bgr", use_video_port=False):
image = frame.array
image = cv2.flip(image,-1) # this may need to be changed based on your setup
# plot crosshairs for alignment
cv2.line(image, (640,0), (640,720), (0,150,150), 1)
cv2.line(image, (600,360), (1280,360), (0,150,150), 1)
# display IMU angle, for reference
font = cv2.FONT_HERSHEY_COMPLEX_SMALL
red = (0, 0, 255)
cv2.putText(image, d, (800, 200), font, 10, red, 10)
# display the image on screen and wait for a keypress
cv2.imshow("Image", image)
key = cv2.waitKey(1) & 0xFF
rawCapture.truncate(0)
# proceed as specified by the user
# press q to break out of video stream
if key == ord("q"):
break
# press m to save .jpg image with imu angle as filename
if key == ord("m"):
d = int(d)
filename = "%d.jpg" %d
cv2.imwrite(filename, image)
# pause everything for 2 seconds
time.sleep(2)
# Enter IMU angle from user
d = raw_input("Please IMU angle: ")
print "Confirming the IMU angle you entered is: "
print d
# pause everything for 2 seconds
time.sleep(2)