Dual-Sided Green Coffee Bean Defect Inspection Using a Mechatronic System with AI-Powered Computer Vision
Quality control in green coffee bean production is critical for food safety and economic sustainability. A persistent gap in existing automated inspection systems is their inability to capture both sides of each bean, which leads to systematic under-detection of surface defects. This work presents three contributions: (i) a novel mechatronic apparatus that mechanically guarantees dual-sided imaging of every bean, (ii) a public 12-class dataset of green coffee bean defects, and (iii) an embedded, real-time inspection pipeline validated on low-cost hardware. The apparatus sequentially presents each bean, from a standard 350 g sample, to two 16-megapixel cameras under controlled LED illumination. A dataset of 9600 images spanning 12 classes (11 defects and 1 normal) was generated from expert-classified samples and enriched through data augmentation. Four convolutional neural network (CNN) architectures, VGG-16, VGG-19, ResNet-50 and YOLOv8, were trained and benchmarked using precision, recall, F1-score and mean average precision. YOLOv8 achieved the best overall performance, with a precision of 97.4%, a recall of 99.6%, an F1-score of 0.930 and a mean average precision of 96.5%, outperforming VGG-16 (accuracy 86.07%), VGG-19 (accuracy 67.03%) and ResNet-50 (accuracy 87.76%). Dual-sided acquisition raised mean per-class detection accuracy from 0.727 to 0.908, a relative gain of 25.7% over an equivalent single-sided configuration. Deployed in real-time “track” mode on a Raspberry Pi 4, the system simultaneously classifies defects and counts beans by category, processing a 350 g sample in approximately 38 min. Combining mechanical innovation with lightweight deep learning enables practical, scalable, and cost-effective quality control for laboratories specialized in coffee analysis.
Authors
- Otniel Portillo-Rodríguez (ORCID: https://orcid.org/0000-0002-2198-477X)
- Oscar Sandoval-González (ORCID: https://orcid.org/0000-0002-0309-5231)
- Gerardo Águila Rodríguez (ORCID: https://orcid.org/0000-0003-2345-7591)
- Ofelia Landeta-Escamilla (ORCID: https://orcid.org/0000-0003-1966-0116)
- Blanca Estela González Sánchez (ORCID: https://orcid.org/0000-0002-0775-0432)
- Dora Manrique-Santos (ORCID: https://orcid.org/0000-0001-5811-5503)
- Diego Cruz-Jarquin (ORCID: https://orcid.org/0009-0003-4090-4100)
Institutions
- Universidad Autónoma del Estado de México (MX)
- Instituto Tecnologico de Orizaba (MX)
Publication Details
- Journal
- Agriculture
- Published
- 2026-08-21
- DOI
- https://doi.org/10.3390/agriculture16161796
- Primary Topic
- Industrial Vision Systems and Defect Detection
- Type
- article
- Field-Weighted Citation Impact
- 0.00
Funders
- Tecnológico Nacional de México