# Design of a Four-Axis Robot Arm System Based on Machine Vision
## 3 Vision-Guided Design of the Four-Axis Robotic Arm System
### Robotic Arm Control System Design  
#### 3.1.1 Upper Computer Implementation  
Due to the need to use the deep learning algorithm Yolov7, the Jetson Nano is chosen as the host controller for this paper after comprehensively considering the computing power and code running effect. The upper controller is externally connected to the camera and the robotic arm, and the software algorithm is embedded internally to implement the image recognition function and the robotic arm control function. Furthermore, because of the depth data of the target in the image being used, the depth camera RealSense D435i from Intel is chosen, which integrates two IR stereo cameras, one IR projector, and one color camera.  
To control the work of the lower computer, the upper computer software based on the QT software development platform is compiled using the Python language. PYQT is the implementation of the QT library in Python, which is a convenient interface for Python  
Figure 9: The physical picture of the robotic arm.  
programming and thus enables graphical interface programming. The basic interactive interface was designed in conjunction with the actual requirements of the robotic arm control system by taking into account factors such as efficient collaboration between software subsystems, reasonable interface layout, user-friendly interaction, and user habits, as shown in Figure 10.  
The main interface contains the following functional areas: serial information area, identification interface display area, and motor control area. The following are the roles of these three sections:  
1. Serial port connection display area: The design goal of this area is to facilitate the user to use the serial communication method to connect to the lower Arduino controller through the upper computer software. This area can be set up with a series of parameters such as baud rate, serial number, etc. There are functions such as serial port detection, serial port setting and sending motion information, and receiving answer signals from the lower computer.
2. Recognition interface display area: The recognition interface display area is mainly used to show the recognition situation of the camera, and also to allow the user to directly see the position information of the target in the camera.
3. Sliding bar control motor area: To facilitate the user to operate the robotic arm directly, this area is set up so that the user can control the movement distance of the motor by clicking on the various data in the sliding bar or directly by entering the numbers after the sliding bar.  
Next, the YOLOV7 target detection algorithm and the depth detection algorithm are embedded in the software. For the YOLOV7 target detection algorithm, a configuration file is first loaded in the constructor along with randomly generated colors for each category, and the model is initialized. To improve processing efficiency, the image method is first preprocessed, i.e., the array is converted from a discontinuous array in memory to a continuous array in memory, making it run faster. After the pre-processing, the detect method calls the processed array and performs image normalization followed by model inference and NMS non-maximum suppression of the inferred results. Finally, a rectangular box with labels is drawn when a target object is present in the image  
Figure 10: Upper computer interface diagram.  
For the depth detection algorithm, the different images of the open camera and the return values are mainly defined. The depth image of the camera is first configured in the constructor, after which the various internal parameters of the camera can be obtained via the library functions of Realsense. Once the parameters have been obtained, the camera parameters, depth parameters, color map, depth map, etc., are returned.