# A Vision Detection Scheme Based on Deep Learning in a Waste Plastics Sorting System
## 3 Materials and Methods
### Workflow of Plastic Dynamic Detection  
#### 3.4.1 Information Acquisition Logic Based on Virtual Two-Line Detection  
The location, class, and ID (identity) of the plastic can be obtained using the optimized YOLOX and DeepSORT. However, simply obtaining this information is not sufficient for plastic sorting. It is crucial to accurately and methodically acquire information about each plastic and send it to the robotic arm.  
We set up two virtual detection lines called the object entry line and the object exit line. They constitute the plastic detection area. The system no longer acquires and records information about the plastics outside the detection area. To filter out missed detections and false detections that take too long, the plastic is determined as the sorting object only if it meets the criteria of being continuously tracked and passing through the object entry line and the object exit line in sequence. In this paper, the state of the plastic is judged based on the relative position between the center point of the bounding box and the two virtual lines. As shown in Figure 10, the red dot represents the center point and the red lines represent the detection lines. We set the sets A, B, and C. A records the IDs of all plastics that pass through the object entry line. B records the IDs of all plastics that pass through the object  
Figure 8: The case of equal \(IoU\).  
Figure 9: The schematic diagram of \(DIoU\).  
exit line. C records the IDs that exist in both A and B, which are the sorting objects after preliminary filtering.  
As shown in Figure 11, in this paper, the class output by YOLOX and the ID assigned by DeepSORT are added to the bounding box. Plastics with the same ID in each frame are considered as the same object. The relative motion trace of the plastics is obtained by connecting the center points of adjacent frames. The algorithm only records the trace of the plastic in the detection area.  
When the plastic is determined as the sorting object, its angle, height, and velocity are calculated. To obtain more accurate information, the distance between the two virtual detection lines is set as small as possible, and the object exit line is set directly below the camera as far as possible. In this paper, a queue is maintained to record and send information about the plastics to be sorted. The queue adopts the first in, first out principle, and the information is added sequentially to the end of the queue in the form of a list. The plastic information is represented as:  
\[P=[(m,n),cls,\theta,h,v,t_{1}], \tag{13}\]  
where \((m,n)\) is the center point of the plastic. \(cls\), \(\theta\), \(h\), \(v\) denote the class, angle, height, and velocity of the plastic, respectively. \(t_{1}\) is the timestamp when the plastic first crosses the object exit line.  
Due to the heavy workload of plastic sorting, it is necessary to minimize the single sorting distance, so a virtual grasping baseline is set to limit the movement of the robotic arm. When the center point of the plastic reaches the grasping baseline, the robotic arm picks it and places it in the specified position. The workflow of plastic sorting is shown in Figure 12.  
Figure 11: Plastic tracking.  
Figure 10: The schematic diagram of two-line detection method.