Tutorial

Table Of Contents
116
'''
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)
When running the program, we first run RPiCam.py in the Raspberry Pi and PC.py in the PC to see the
real-time picture of the Raspberry Pi in the PC.
26 Use OpenCV to Process Video Frames on The
PC
Due to the limited computing power of the Raspberry Pi, our OpenCV in the Raspberry Pi can only
guarantee a relatively high frame rate when implementing simple functions such as color recognition and visual
line inspection. If we need more complex machine vision functions , We need to send the video frames that
need to be analyzed to the device equipped with advanced GPU to process, and finally send the processed
results to the robot where the Raspberry Pi is located to perform the corresponding operation, and the machine
vision of the Raspberry Pi robot The ability is stronger, thus achieving more advanced functions.
We can refer to the content of 26 to send video frames to the host computer, or refer to the content of 15
to let the Raspberry Pi put the video stream on a page, and the host computer obtains the video stream from
the page to analyze the video frame.
The content of this chapter is based on 26. First, we open PC.py as follows:
'''
First import the required libraries
'''
import cv2
import zmq
import base64
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()