Advertisement
Benkex

RCCloudTest1

Sep 10th, 2019
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. # -*- coding: utf-8 -*-
  2. import socket
  3. import base64
  4. import cv2
  5. import zmq
  6.  
  7. context = zmq.Context()
  8. footage_socket = context.socket(zmq.PUB)
  9. footage_socket.connect('tcp://localhost:5555')
  10. camera = cv2.VideoCapture(0)
  11.  
  12. sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
  13.  
  14. while True:
  15.     grabbed, frame = camera.read()  # grab the current frame
  16.     frame = cv2.resize(frame, (480, 360))  # resize the frame
  17.     encoded, buffer = cv2.imencode('.jpg', frame)
  18.     jpg_as_text = base64.b64encode(buffer)
  19.     footage_socket.send(jpg_as_text)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement