118
import numpy as np
'''
Here we instantiate the zmq object used to receive the frame
Note that the port number needs to be consistent with the sender's
'''
context = zmq.Context()
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)
'''
Convert image to grayscale
'''
source = cv2.cvtColor(source, cv2.COLOR_BGR2GRAY)
'''
Binary image
'''
retval, source = cv2.threshold(source, 0, 255, cv2.THRESH_OTSU)
'''
Remove small noise in the image
Need help?
Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?