117
footage_socket = context.socket(zmq.PAIR)
footage_socket.bind('tcp://*:5555')
while True:
'''
Received video frame data
'''
frame = footage_socket.recv_string()
'''
Decode and save it to the cache
'''
img = base64.b64decode(frame)
'''
Interpret a buffer as a 1-dimensional array
'''
npimg = np.frombuffer(img, dtype=np.uint8)
'''
Decode a one-dimensional array into an image
'''
source = cv2.imdecode(npimg, 1)
'''
Display image
'''
cv2.imshow("Stream", source)
'''
Generally, waitKey () should be used after imshow () to leave time for image drawing, otherwise the window will
appear unresponsive and the image cannot be displayed
'''
cv2.waitKey(1)
● After source = cv2.imdecode (npimg, 1), you can use OpenCV to process the source, as shown below is the
routine for binarizing the real-time video image from the Raspberry Pi using the host computer:
'''
First import the required libraries
'''
import cv2
import zmq
import base64
Need help?
Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?