ADEEPT AWR Wheeled Robot Manual page 123

4wd smart robot kit compatible with raspberry pi 4 3 model b+ b, opencv target tracking
Table of Contents

Advertisement

114
'''
IP = '192.168.3.11'
'''
Then initialize the camera, you can change these parameters according to your needs
'''
camera = picamera.PiCamera()
camera.resolution = (640, 480)
camera.framerate = 20
rawCapture = PiRGBArray(camera, size=(640, 480))
'''
Here we instantiate the zmq object used to send the frame, using the tcp communication protocol, where 5555 is the
port number
The port number can be customized, as long as the port number of the sending end and the receiving end are the same
'''
context = zmq.Context()
footage_socket = context.socket(zmq.PAIR)
footage_socket.connect('tcp://%s:5555'%IP)
print(IP)
'''
Next, loop to collect images from the camera, because we are using a Raspberry Pi camera, so use_video_port is True
'''
for
frame
in
camera.capture_continuous(rawCapture, format="bgr", use_video_port=True):
'''
Since imencode () function needs to pass in numpy array or scalar to encode the image
Here we convert the collected frame to numpy array
'''
frame_image = frame.array
'''
We encode the frame into stream data and save it in the memory buffer
'''
encoded, buffer = cv2.imencode('.jpg', frame_image)
jpg_as_text = base64.b64encode(buffer)
'''
Here we send the stream data in the buffer through base64 encoding to the video receiving end
'''
footage_socket.send(jpg_as_text)

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the AWR Adeept Wheeled Robot and is the answer not in the manual?

This manual is also suitable for:

Picar-b

Table of Contents

Save PDF