Thomas Green

Machine vision

Detecting and counting apples in orchard imagery

Yield estimation from orchard imagery, split into three problems. Find the apples, count them, and separate the ones that are touching.

Context
Machine Vision, MSc Robotics, Bristol
Role
Model training and evaluation, five-person team
Approach
Faster R-CNN and YOLO, compared
Code
apple-machine-vision
Report
Group report (PDF)
Top row: an orchard image with green detection boxes around apples, the same image with coloured instance masks, and crops of detected apples including blurred, occluded and yellow fruit. Bottom row: four source images of red and yellow varieties in varying light.
Detections, instance masks and crops from one orchard scene. The bottom row shows source images with two cultivars, different light and fallen fruit on the ground, which should not be counted.

Orchard imagery

Fruit hangs in clusters, and the boundary between two touching apples is a soft edge. Foliage hides most of the crop most of the time. The same variety looks very different depending on where the sun is. Windfall on the ground looks the same as fruit on the tree and must not be counted.

Small detection errors add up in the yield figure. A model with a good per-image metric can still be well out on the total.

Four panels: the original orchard image, its blurred LAB A channel where red fruit shows as bright blobs, its blurred B channel, and a colour-enhanced version of the original.
The image in LAB colour space. The A channel separates red fruit from foliage more cleanly than any RGB combination. We used it for preprocessing and as a classical baseline for the learned models.

What we built

This was a five-person team. I did the model training and evaluation.

  • Training and prediction pipelines for Faster R-CNN and YOLO on the same dataset, with the same data handling for both.
  • A LAB colour-space preprocessing stage, used as an input enhancement and as a non-learned baseline.
  • Separate evaluation for detection, counting and segmentation, since they fail in different ways and a single mAP number hides that.
  • A conversion step from polygon annotations to instance masks. This was most of the work.

Results

The results matched the literature. The single-stage detector was faster. The two-stage detector was better on small and partially occluded fruit. For yield estimation those fruit cause most of the counting error, so we valued accuracy over throughput.

← All projects