-
Notifications
You must be signed in to change notification settings - Fork 2
/
frame_capture.py
49 lines (40 loc) · 1.07 KB
/
frame_capture.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
import ADNS3080
import matplotlib.pyplot as plt
import numpy as np
import time
import array
import socket
#Set to local IP
TCP_IP = '192.168.1.27'
TCP_PORT = 8000
BUFFER_SIZE = 60 # Normally 1024, but we want fast response
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.bind((TCP_IP, TCP_PORT))
s.listen(1)
conn, addr = s.accept()
print 'Connection address:', addr
startTime = time.time()
this = ADNS3080.ADNS3080()
this.wait()
this.initializeSensor()
initTime = time.time()
while 1:
try:
#print this.getSQUAL()
rawdata = this.frameCapture()
#capTime = time.time()
print "Got data..."
conn.send(array.array('B', rawdata).tostring())
except:
conn.close()
raise
#reshapedData = np.reshape(rawdata, (30,30))[::-1,::-1]
#reshTime = time.time()
#plt.imshow(reshapedData, interpolation="none")
#plotTime = time.time()
#print "Initialization time:", initTime-startTime
#print "Capture time:", capTime-initTime
#print "Reshape time:", reshTime - capTime
#print "Display time:", plotTime - reshTime
#plt.show()
conn.close()