Apple Counting using Convolutional Neural Networks

Nicolai Häni, Pravakar Roy, Volkan IslerIROS 2018 · DOI

Abstract: Estimating accurate and reliable fruit and vegetable counts from images in real-world settings, such as orchards, is a challenging problem that has received significant recent attention. Estimating fruit counts before harvest provides useful information for logistics planning. While considerable progress has been made toward fruit detection, estimating the actual counts remains challenging. In practice, fruits are often clustered together. Therefore, methods that only detect fruits fail to offer general solutions to estimate accurate fruit counts. Furthermore, in horticultural studies, rather than a single yield estimate, finer information such as the distribution of the number of apples per cluster is desirable. In this work, we formulate fruit counting from images as a multi-class classification problem and solve it by training a Convolutional Neural Network. We first evaluate the per-image accuracy of our method and compare it with a state of the art method based on Gaussian Mixture Models over four test datasets. Even though the parameters of the Gaussian Mixture Model based method are specifically tuned for each dataset, our network outperforms it in three out of four datasets with a maximum of 94% accuracy. Next, we use the method to estimate the yield for two datasets for which we have ground truth. Our method achieved 96-97% accuracies.

Introduction

Accurately predicting crop yield is a primary goal of precision agriculture. For orchard managers, knowing exactly how many apples are on the trees before the harvest begins is critical for logistics, labor planning, and market forecasting. However, nature presents significant challenges to automated counting. In the paper "Apple Counting using Convolutional Neural Networks," researchers Nicolai Häni, Pravakar Roy, and Volkan Isler from the University of Minnesota present a robust way to tackle this problem by moving away from traditional object detection and toward a cluster-based classification approach.

The Challenge of Orchard Counting

Standard computer vision tasks usually rely on "detection": drawing a box around an object. In an orchard, this often fails because apples rarely grow in isolation. They grow in dense clusters, overlap one another, and are frequently hidden behind branches or leaves. Existing methods struggle with:

  1. Occlusion: One apple partially blocking another.
  2. Clustering: Multiple fruits appearing as a single red or green "blob."
  3. Variability: Apples come in different colors (red, green, yellow) and sizes, and lighting conditions in an orchard change constantly.

While previous state-of-the-art methods used Gaussian Mixture Models (GMMs) to count pixels, these required heavy manual tuning for every new dataset. This research seeks a more generalized, automated solution.

Methodology

The authors propose a two-stage pipeline that transitions from image-level counting to full orchard yield estimation.

The proposed pipeline for orchard yield estimation, from single image detection to multi-row merging.

1. Cluster Detection

First, the system identifies "regions of interest" where apples are likely to be. They use a color-based segmentation method (using the LAB colorspace and superpixels) to generate bounding boxes around potential fruit clusters.

2. Counting via Classification

This is the core innovation. Instead of trying to segment individual apples within those boxes, the system feeds the image patches into a Convolutional Neural Network (CNN). The network is trained to classify the patch into one of seven categories: 0, 1, 2, 3, 4, 5, or 6+ apples. The researchers used a modified AlexNet architecture, leveraging transfer learning from ImageNet.

3. Yield Estimation

To count an entire row of trees, the system uses 3D reconstruction to track apples across frames. This prevents "double counting" the same apple seen from different angles as the camera moves down the row.

Datasets and Validation

The study utilized data collected from the University of Minnesota Horticultural Research Center, including 13,000 manually annotated image patches. Testing was conducted across four distinct datasets representing different challenges, such as red apples on the ground, yellow apples in bright sunlight, and green apples in deep shadow.

Key Results

The CNN approach demonstrated significant improvements over traditional methods:

  • Superior Accuracy: The CNN outperformed the GMM baseline in three out of four test sets. In the green apple dataset, the CNN achieved 94.3% accuracy, beating the GMM by nearly 15%.
  • Real-World Yield: When tested against actual harvested counts, the system achieved 96.97% and 96.72% accuracy on the two validation rows.
  • Robustness: The system maintained high performance even when leaves turned brown (mimicking apple colors) or when illumination shifted from cloudy to sunny.
The system identifies clusters and classifies the number of apples within each bounding box.

Discussion and Future Work

The "aha moment" of this research is that a CNN is better at recognizing the visual pattern of a cluster than a detection algorithm is at finding distinct circles. The network learns to account for the "nooks and crannies" created by overlapping fruit. Unlike GMM methods that need to be tweaked for different apple varieties, the CNN learned features that generalized across different colors and lighting conditions.

Despite the success, some hurdles remain. The model currently caps at "6 or more" apples per patch, which could lead to undercounting in extremely dense orchards. Additionally, the model occasionally struggles to distinguish between apples on the tree and those rotting on the ground. Future work may involve generating synthetic training data to help the network learn even more complex cluster shapes, potentially extending the method to other clustered crops like strawberries or grapes.

Summary updated

BibTeX
@inproceedings{hani2018apple,
  author = {Nicolai Häni and Pravakar Roy and Volkan Isler},
  title = {{Apple Counting using Convolutional Neural Networks}},
  booktitle = {IEEE/RSJ International Conference on Intelligent Robots and Systems},
  year = {2018},
  doi = {10.1109/iros.2018.8594304},
}
Figure