# Deep Learning-Based Method for Accurate Real-Time Seed Detection in Glass Bottle Manufacturing
## 3 Materials and Methods
### Proposed SW Solution: The Image Algorithm
#### 3.3.4 Proposed SW Solution: Final Integrated System  
Once the model was properly trained and best weights are chosen according to the results over the validation subset, it is necessary to integrate the model into the complete SW solution. The development of the integrated SW was executed on a Pentium IV computer running the 64-bit Windows 7 operating system. The PC needs at least one network card to communicate with the linear monochrome camera with Gigabit Ethernet communication protocol. The software tools for the development of the application are:  
* National Instruments LabWindows CVI (version 2012)
* Sapera library SDK (version 8.41) for camera control and image capture
* Halcon library (version 18.11)  
The model is part of the final integrated system that inspects the bottle in the manufacturing line in real time, 24 h per day and 7 days per week. As explained above, the processing pipeline has several stages. All suspected bubble candidates detected by the first stage of the process are evaluated by the deep learning-based model for the final decision. The inclusion of this stage with the classification model hardly penalizes the pipeline processing time by a few milliseconds, so the system fulfils the real-time requirement and allows 100% inspection of the bottles at a production rate of up to 250 bottles per minute. Every image processing action takes around 150-200 ms; this range is due to the number of located possible candidates. The higher the number, the higher the number of elements to be classified by the model, thus the processing time is elapsed. Figure 11 below shows an image of a bottle correctly grabbed by the camera, with detected seeds framed within the inspected area. Figure 10: Example of the outcome of the processing pipeline: (**a**) input image; (**b**) output image with the detected seeds (black squared) and blisters (white squared). When seeds are ultimately confirmed by the classification model, their dimensions are calculated. Likewise, the number of seeds per kilogram will be calculated for bubbles of all sizes; and the number of blisters per ton will be estimated for any seed of more than 1 mm in its largest dimension, calculated based on the known thickness for each. Glass density is considered constant and equal to 2.52 kg/m\({}^{2}\). Those calculated relevant values are displayed in the user interface. The information is stored in a different text file for each reference produced. The user is responsible for providing the reference data of the model of the bottles that are being analyzed. The correct indication of the model of the bottle that is being manufactured affects the final calculation. Every model has a different reference thickness value, and this implies the same number of detected seeds may rely on a different number of seeds per kilo and blisters per ton. These are the final expected indicators to manage the process. The information related to every model that has to be provided to the system is:  
* Reference code: alphanumeric string that identifies the model being manufactured;
* Average glass thickness in mm;
* Color: it can be white or flint, green, dark-green or moss;
* Bottle diameter in mm. Additionally, in the event that the window presents engravings in the lower or upper part of the inspection zone, an exclusion zone can be created that will indicate that said area should not be processed. If no value is entered (0.00 mm), the system will inspect the 60 mm field of view in the bottle height direction. The operation of the whole developed application is as follows. As soon as the interface is launched, the program checks that the camera is properly connected. The acquisition parameters of the camera are loaded, the camera is automatically initialized, and it is verified that it is working correctly. If this is the case, the visual indicator of \"System Information\" located at the bottom of the interface, named as \"Ready,\" turns green. If the camera was not connected or presented any problem, the visual indicator \"Ready\" would turn red.