Real Time Pill Counting on Low Power Device: A YOLOv5 Pipeline with Confidence Thresholding and NMS - A, Galih Prakoso Rizky; Widyastuti, Rifka (Jurnal Teknik Informatika C.I.T Medicom, 2025)
Manual pill counting is still commonly performed in healthcare facilities and pharmacies, but this method is vulnerable to human error and requires significant processing time. This study develops an automatic pill counting pipeline using the YOLOv5 deep learning model, optimized for low-power devices such as Raspberry Pi, Orange Pi, and Jetson Nano. Unlike earlier techniques that depend on conventional retrieval or machine-learning approaches, this pipeline integrates real-time object detection with customized confidence thresholding and Non-Maximum Suppression (NMS), enabling high accuracy and fast performance on edge hardware with limited resources. The development process includes collecting and annotating a dataset of pill images with variations in shape, color, and orientation, followed by training YOLOv5 using optimized parameters. A simple webcam is used as the input device, and system performance is evaluated under different lighting and background conditions. Experimental results show that the model achieves 98% precision, 88% recall, 95% mAP@0.5, and 67% mAP@0.5:0.95, with an average inference speed of around 15 milliseconds per image. Tests on ten pill-counting scenarios under optimal lighting demonstrate strong performance, with only minor discrepancies in dense cases involving 50 and 127 pills, producing accuracies of 98% and 99.21%. These results indicate that the optimized YOLOv5 pipeline provides fast and accurate real-time pill counting on low-power devices. Future work will enhance robustness to lighting variations, validate using external datasets, and incorporate color and shape feature analysis to improve performance in challenging scenarios.