-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdrv.py
More file actions
91 lines (67 loc) · 1.22 KB
/
drv.py
File metadata and controls
91 lines (67 loc) · 1.22 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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
import subprocess
import time
import socket
from XMLDoc import XMLDoc
from webcamclient import Webcam
#
# Initialization
#
port = 9123
try:
subprocess.Popen(["python", "webcamserver.py", "%d" % port],
shell=False, stdin=None, stdout=None, stderr=None, close_fds=True)
except:
print "unable to spawn"
exit(1)
time.sleep(1)
s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
s.connect(('4.2.2.1', 123))
ip = s.getsockname()[0]
wc = Webcam(ip, port)
#
# connect to a specific camera
#
rc, xml = wc.connect("/dev/video0")
if not rc:
exit(1)
print "Connect: ", xml
#
# change attributes
#
rc, xml = wc.fnpicture(directory="/tmp")
if not rc:
exit(1)
print "FNPicture: ", xml
#
# take a picture
#
rc, xml = wc.picture()
if not rc:
exit(1)
print "Picture: ", xml
xd = XMLDoc(xml).getRoot()
print "Filename: (%s)" % str(xd.filename)
#
# change timelapse parameters at take a burst
#
wc.fntimelapse(prefix="tl1")
rc, xml = wc.timelapse(5, count=10)
if not rc:
exit(1)
print "Timelapse1: ", xml
print "sleeping for 60"
time.sleep(60)
#
# do it again
#
wc.fntimelapse(prefix="tl2")
rc, xml = wc.timelapse(5, duration=30)
if not rc:
exit(1)
print "Timelapse2: ", xml
print "sleeping for 60"
time.sleep(60)
#
# exit
#
wc.exit()