-
Notifications
You must be signed in to change notification settings - Fork 19
/
take_a_photo.py
43 lines (31 loc) · 876 Bytes
/
take_a_photo.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
import pyspin
from pyspin import PySpin
# Get system
system = PySpin.System.GetInstance()
# Get camera list
cam_list = system.GetCameras()
# Figure out which is primary and secondary (usually webcam is primary and Flea3 is secondary)
cam = cam_list.GetByIndex(0)
# Initialize camera
cam.Init()
# Set acquisition mode
cam.AcquisitionMode.SetValue(PySpin.AcquisitionMode_SingleFrame)
# Start acquisition
cam.BeginAcquisition()
# Acquire images
image_primary = cam.GetNextImage()
width = image_primary.GetWidth()
height = image_primary.GetHeight()
print "width: " + str(width) + ", height: " + str(height)
# Pixel array (NumPy array)
image_array = image_primary.GetData()
# Save images
image_primary.Save('prime.jpg')
# Stop acquisition
cam.EndAcquisition()
# De-initialize
cam.DeInit()
# Clear references to images and cameras
del image_primary
del cam
del cam_list