-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathsample_python_program.py
More file actions
29 lines (24 loc) · 877 Bytes
/
sample_python_program.py
File metadata and controls
29 lines (24 loc) · 877 Bytes
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
from boost_camera import CameraManager
import os
MAX_CONNECTION_RETRIES = 5
camera_manager = CameraManager()
num_retries = 0
# For Macs in particular, this daemon needs to be killed to free the camera for
# us
print "Killing interfering camera processes..."
os.popen("killall PTPCamera")
print "Trying to connect to the camera..."
while num_retries < MAX_CONNECTION_RETRIES:
success = camera_manager.initialize()
if success:
print "Successfully connected to the camera"
break
num_retries += 1
for frame_number in xrange(10):
# this byte array can easily be integrating into OpenCV or the Python
# Imaging Library
numpy_array_jpeg_bytes = camera_manager.grab_frame()
print numpy_array_jpeg_bytes
# lastly, take a picture that saves directly to the camera
print "Taking a picture"
print camera_manager.take_picture_and_transfer()