Created
June 5, 2020 03:45
-
-
Save timothymugayi/8605f18f3b83bf240b1d681d641cec80 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 | |
context = zmq.Context() | |
footage_socket = context.socket(zmq.PUB) | |
footage_socket.bind("tcp://*:5555") | |
camera = cv2.VideoCapture(0) # init the camera | |
while True: | |
try: | |
grabbed, frame = camera.read() # grab the current frame | |
frame = cv2.resize(frame, (640, 480)) # resize the frame | |
encoded, buffer = cv2.imencode('.jpg', frame) | |
footage_socket.send(buffer) | |
except KeyboardInterrupt: | |
camera.release() | |
cv2.destroyAllWindows() | |
break |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment