Created
June 5, 2020 03:46
-
-
Save timothymugayi/76943d0ab97e11c299b0e19e22839071 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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