summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2014-12-20 20:25:25 +0100
committerFlorian Jung <flo@windfisch.org>2014-12-20 20:25:25 +0100
commitbebe709f46a53e1752dc220070613df25c285e4f (patch)
tree7869a8c7743623fd0ab5a88b57b7c8adbfb68b12
parent0fbdbb674022239356a0da7aae7ea91d91662c9a (diff)
image server
-rw-r--r--server.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/server.py b/server.py
index 6fc2814..4e5cd65 100644
--- a/server.py
+++ b/server.py
@@ -26,14 +26,19 @@ while True:
connection, client_address = sock.accept()
try:
print >>sys.stderr, 'connection from', client_address
+ cap = cv2.VideoCapture("/home/flo/outvid2.avi")
# Receive the data in small chunks and retransmit it
while True:
data = connection.recv(16)
print >>sys.stderr, 'received "%s"' % data
if data:
- print >>sys.stderr, 'sending data back to the client'
- connection.sendall(data)
+ if data=="get\n":
+ status, frame = cap.read()
+ print >>sys.stderr, 'sending image to the client'
+ connection.sendall(frame.tostring())
+ cv2.imshow("img",frame)
+ cv2.waitKey(20)
else:
print >>sys.stderr, 'no more data from', client_address
break
@@ -42,7 +47,6 @@ while True:
# Clean up the connection
connection.close()
-cap = cv2.VideoCapture("/home/flo/outvid2.avi")
while True:
status, frame = cap.read()
cv2.imshow("img",frame)