# Quality and Defect Inspection of Green Coffee Beans Using a Computer Vision System
## 5 Conclusions  
Neither technique provides a good option to select the best quality of coffee beans, meaning that a more modern approach is required. In manual selection, non-uniform selection can easily result from long working hours, a lack of training and workers' attitudes. Furthermore, this manual procedure takes considerable time and can be inefficient when many beans are to be evaluated. Mechanical sorting machines are used to grade the beans based on their size; however, these machines are not able to evaluate physical appearance and they could potentially damage the beans due to their invasive sorting procedure. The vision system shown is a good approach for academic research. The objective of this article is to test the classification algorithm that is useful for many different industrial implementations in industries related to coffee. This machine vision can be used to test the quality of the coffee beans used to make a cup of coffee at a coffee shop determining the price. It can also be useful to assess the quality of a whole lot by inspecting some coffee beans selected from the lot. The system can also be implemented in a production process when packing coffee beans for sale; controlling the quality of the production becomes easier, faster and more efficient when using the machine vision systems than when doing it manually of mechanically. For improving the quality of the production an ejector to set apart the bad quality coffee beans from the production can be implemented as well as a user interface to complement the machine vision system and make it reliable for use in industry production. A machine \begin{table}
\begin{tabular}{c c c} \hline \hline \(k\)-Value & Average Accuracy of Quality Evaluation & Average Accuracy of Defect Type Evaluation \\ \hline
3 & 90\% & 92\% \\
5 & 92\% & 93\% \\
10 & 94.99\% & 95.66\% \\
20 & 93\% & 92\% \\ \hline \hline \end{tabular}
\end{table} 
Table 4: Percentage of accuracy for different \(k\)-values in the algorithm. \begin{table}
\begin{tabular}{c c} \hline \hline \(\text{{Test}}\) & Standard Deviation \\ \hline Quality inspection & 1.87\% \\ Defect type inspection & 2.03\% \\ \hline \hline \end{tabular}
\end{table} 
Table 5: Standard deviation of the accuracy. vision system was developed for quality and defect type evaluations of coffee beans. The coffee samples tested are labeled with a percentage quality and a defect type such as sour, very long berry, black, small or broken. Few machine vision systems have been presented to select green coffee beans and consider several physical characteristics for quality identification. Other papers only consider the color to grade the grain quality, ignoring important defects such as small, very long berry or broken beans that are considered in the present manuscript. Furthermore, this paper presents higher accuracy in the classification of the defect types. Image processing techniques and the \(k\)-nearest neighbor algorithm were employed to extract the features and carry out a classification with an Arduino Mega2560 board as a controller for external devices. The machine vision developed in this paper showed a high average accuracy of 94.79% for quality evaluation and 95.78% for defect type evaluation; however, a high accuracy of 98.05% was achieved for very long berry beans classification due to the existence of more than one feature value particular of these coffee beans' defect, eccentricity and roundness. The general accuracy of the system over 90% is high regarding the literature, and it is supported by the standard deviation computed, which resulted in low values of 1.87% for the quality inspection and 2.03% for the defect type inspection. This guarantees a low false rejection of the system. The best \(k\)-value algorithm was 10 neighbors. Finally, the application of artificial vision has shown to help reduce the cost of production and time required as it improves quality control.