Skip to content

Instantly share code, notes, and snippets.

@timothymugayi
Created June 5, 2020 03:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save timothymugayi/76943d0ab97e11c299b0e19e22839071 to your computer and use it in GitHub Desktop.
Save timothymugayi/76943d0ab97e11c299b0e19e22839071 to your computer and use it in GitHub Desktop.
import cv2
import zmq
import numpy as np
port = "5555"
context = zmq.Context()
footage_socket = context.socket(zmq.SUB)
footage_socket.connect("tcp://localhost:%s" % port)
footage_socket.setsockopt_string(zmq.SUBSCRIBE, np.unicode(''))
while True:
try:
frame = footage_socket.recv()
npimg = np.frombuffer(frame, dtype=np.uint8)
source = cv2.imdecode(npimg, 1)
cv2.imshow("Stream", source)
cv2.waitKey(1)
except KeyboardInterrupt:
cv2.destroyAllWindows()
break
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment