# Deep Learning-Based Method for Accurate Real-Time Seed Detection in Glass Bottle Manufacturing
## 3 Materials and Methods
### Vision Subsystem  
The vision module includes the set of elements that capture images of the bottles. These elements are: (1) high resolution monochrome linear camera; (2) optics for the linear camera with high depth of field; (3) high-intensity white backlight illumination. This vision module is in charge of carrying out the functions related to capturing the images. It manages the communication with the camera, sending it the appropriate configuration parameters and controlling the acquisition of the images. It is also in charge of interpreting the messages coming from the camera (which can provide error information) and of sending the captured images to the processing module. The HW of the capture entity is a high-speed monochrome linear camera with a telecentric lens, where the acquisition of each line is synchronized with a rising edge of the encoder pulse of the manufacturing line where the system is located. The camera will understand that an image is constituted when an established number of lines is grabbed. In this situation, an image is created with 3600 lines. The encoder must be capable of providing around 28,000 lines/s in order to be able to achieve the resolution of 0.03 mm/pulse (resolution = 0.03 mm/pixel) necessary for detection of seeds with a minimum size of 0.1 \(\times\) 0.1 mm\({}^{2}\). The seed detection system in bottles consists mainly of the vision system. The mechanical and electrical HW modules do nothing but provide support and allow the capture and processing of images to be possible. The mechanical system consists of the set of supports that hold the camera and the lighting, which is placed behind the bottle to illuminate it by contrast. The HW elements chosen for the constitution of the optical system are the following:  
* Teledyne Dalsa Monochrome Line Camera (Teledyne Dalsa, Waterloo, ON, Canada) 2048 pixels and 52 kHz, Gigabit Ethernet
* Telecentric optics TC4K120
* Backlight lighting MB-BLL206-W-24 The calculations and reasoning that led to this choice are detailed below. Operating requirements are that the system must work at a line speed of 50 m/min, detect bubbles of 0.1 \(\times\) 0.1 mm\({}^{2}\) in a strip approximately 60 mm high in practically the entire surface of the bottle for diameters between 52 and 120 mm. The required minimum detectable size determines the resolution of the camera, the capture speed and the resolution of the necessary encoder. Considering three pixels as a minimum default both in the x and y axis, it implies having a resolution in x and y of 0.03 mm/pixel. If the field of view is 60 mm, this resolution is achieved on the x-axis with a 2048-pixel camera. In the direction of movement, which would constitute the y-axis of the image, it is also necessary to have the same resolution of 0.03 mm/pixel, which is equal to 0.03 mm/pulse. At a speed of 50 m/min (0.833 m/s), to have 0.03 mm/pulse, it means providing 27,777 pulses/s to capture at 27,777 lines/s. The camera must capture a minimum of 28 kHz, and the line encoder that will synchronize the capture must provide around 28,000 pulses/s. Taking into account all these calculations, the chosen camera is a linear monochrome camera with 2048 pixels and 52 kHz with Gigabit Ethernet communication protocol. On the other hand, the fact that the bottle is curved suggests the use of an optic that allows for a good depth of field in order to ensure that the largest surface of the bottle is well focused and, in this way, to be able to conveniently detect seeds in the entire diameter of the circular bottle. The TC4K120 telecentric lens was chosen for this linear camera, which provides a depth of field of 29.2 mm. The maximum working distance of this optic is 174 mm, and it has a length of 337.3 mm, which must be considered for the correct design of the mechanical support and the selection of the location of the system. The operating range was established and verified for distances in the range 130-160 mm between the end of the lens and the bottle surface.