


Challenge
At Puttalam salterns, operators inspect harvested salt for discolouration, mineral inclusions, sand and organic debris by eye. Changing light, fatigue and translucent crystal surfaces make grading inconsistent. The system needed to locate individual crystals and contaminants, work within a 200 ms frame budget, and produce quality records operators could review.
Approach
I used roughly 650 field images from Puttalam, annotated in Label Studio and CVAT and expanded to 1,952 with augmentation. YOLOv8 provides the location and class of each object so HSV analysis can measure whiteness within its bounding box. ONNX inference feeds a NestJS service, with gRPC and WebSocket delivery to a Next.js dashboard and asynchronous session and batch storage in MongoDB. The dashboard combines detection overlays, region-of-interest controls and historical quality analysis.
Quality grading
Detection-based purity is the share of salt detections classified as pure, with foreign objects reported separately. Whiteness measures brightness and colour neutrality in each detected region. A composite score weights that whiteness by class: 1.0 for pure salt, 0.3 for impure salt and 0.0 for foreign material, then averages scores across detections. These measures describe visual quality; chemical composition and food safety require separate testing.
Results
The research reports 99.41% precision, 99.14% recall, 99.37% mAP@0.5 and 79.95% mAP@0.5:0.95 on 293 held-out images. Impure-salt recall was 99.67%, with two missed instances out of 609. The reported synchronous pipeline took approximately 45 ms, with a CPU stream rate of 5 FPS. On 50 expert-rated frames, the composite score had a Spearman rank correlation above 0.92 with human quality rankings.
Next steps
The prototype was evaluated on images from Puttalam. Broader deployment needs datasets and calibration from other salterns, where crystal shapes and contaminants may differ. Further work includes tracking crystals across frames, reducing background false positives, testing edge inference and connecting monitoring to physical sorting.
