You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
553 B
22 lines
553 B
5 years ago
|
import cv2
|
||
|
import zmq
|
||
|
import base64
|
||
|
import numpy as np
|
||
|
|
||
|
context = zmq.Context()
|
||
|
footage_socket = context.socket(zmq.SUB)
|
||
|
footage_socket.bind('tcp://*:5555')
|
||
|
footage_socket.setsockopt_string(zmq.SUBSCRIBE, np.unicode(''))
|
||
|
|
||
|
while True:
|
||
|
try:
|
||
|
frame = footage_socket.recv_string()
|
||
|
img = base64.b64decode(frame)
|
||
|
npimg = np.fromstring(img, dtype=np.uint8)
|
||
|
source = cv2.imdecode(npimg, 1)
|
||
|
cv2.imshow("Stream", source)
|
||
|
cv2.waitKey(1)
|
||
|
|
||
|
except KeyboardInterrupt:
|
||
|
cv2.destroyAllWindows()
|
||
|
break
|