# Intelligent Control System to Irrigate Orchids Based on Visual Recognition and 3D Positioning
## 2 System Design and Methodology
### System Process Control  
The system process control is divided into four parts: the motor control, the command control, the triggering process and the automatic watering process.  
The three-axis sliding table is driven by three stepper motors with the synchronous wheel timing belts and screws. Firstly, for the motor control, the computer uses Python and Arduino to execute the operation instructions of the stepping motor through the Arduino control board. Secondly, the command control for the stepping motor to accomplish the specified task is implemented by mutual communications between Arduino and the computer via the package _pySerial_ of Python. The function _not.write()_ is used to pass a set of strings combining letters and numbers (e.g., j0), which stand for the code of the task type and the relevant parameters, respectively. Afterwards, the functions, _Serial.read()_ and _Serial.Parseint()_, are used in the Arduino to receive the commands to control the motor.  
Figure 12: Elaboration on correction process of targeted watering point (stem-root junction).  
Thirdly, the triggering of the watering process is started to launch the automatic watering process, as addressed in Figure 14. If the seedlings enter the camera screen and the YOLOv3 boxes the junctions between stems and leaves to several blocks, the specific one of which is selected in the picture to trigger the watering process.  
Figure 14: Flow chart of triggering for the watering process.  
Figure 13: Correction process of watering point.  
The area that triggers the process is represented as the function _rectangle()_ with a green line in the real-time image of the left image. The triggering area is located above the center of the left lens, with a length of 240 pixels and a width of 120 pixels. When the central point of the prediction box enters into the triggering area, the watering process will be triggered.  
Whether the prediction frame firstly enters the triggering area is determined by the fact that the number of prediction frames is greater than zero and the central points of all prediction frames are in the triggering area. At this time, the trigger signal is set to 1. If the number of frames is greater than zero, but the central point of the prediction frame does not enter the triggering area, the trigger signal is set to 0. When the number of prediction frames equals zero, the trigger signal is also set to 0. When the current trigger signal is greater than the previous one, the automatic watering process will be triggered. This approach ensures that the prediction frame staying in the triggering area will not cause repeated watering problems.  
Finally, the watering process is completed by the customized functions, which at first, defines the moving boundary of each axis motor, and confirms whether each group of target coordinates exceeds the moving boundary. If any group of target coordinates exceeds the moving boundary, it will be removed. When the sprinkler reaches the plane position of the targeted watering point, the Z-axis motor is lowered to the specified height. Then, the valve is opened with a duration of time to satisfy the preset watering volume for completing the pouring step. Once the irrigation is accomplished, the Z-axis motor is raised to the specified height, e.g., 2 to 5 cm, based on the dimensions of the seedlings. The overall flowchart is detailed in Figure 15.  
Figure 15: Flow chart of automatic watering process.