Counting the number of red peppers, green peppers and flowers on a chilli plant

This is the picture of a chilli plant I recently bought. I want to set-up a raspberry pi with a camera to take photos of this plant everyday and record down the number of red peppers, green peppers and flowers. Additionally, I want my program to be able to draw boxes around the objects it draws.

Here is where I need advice. Could you guys recommend some approaches that I could use. I have thought of either

  1. Finding groups of red pixels together (to indicate a red pepper) and groups of purple/white pixels together (to indicate a flower). This method obviously has its limitations when it comes to the green peppers

or

  1. Machine learning

Most machine learning programs are made to identify that an image has peppers rather than count the number of peppers (correct me if I am wrong) so I need some guidance on how I would take the machine learning approach.

Additionally, just one point of view would not able to spot all the peppers and adding multiple points of views would result in double counting. Any solutions to this problem will also be greatly appreciated.

Thank you guys so much for your help!

Hi,
With the machine learning you can count objects on your image or video stream. You’ll have to get a neural network framework such as Darknet (AlexeyAB - Darknet on github). You also have to have a detection system like YOLO.
Each object detected will be in a array in your code, so you’ll just have to loop on the table to get each element detected and draw a rectangle or whatever you need. You even got the confidence of the detection, the label etc.

Thomas.

Well, I have to say that this is not an easy task at all. Definitely not a weekend project.

The objects you want to detect are often hidden by the leaves, the green peppers are very similar to the leaves and the background has the same color as the flowers. The lighting can change, so the colors are inconsistent…

The disadvantage of the machine learning algorithms is that they need a large training set. To train a Yolo detector, you would need thousands of photos of plants in these conditions (not 1000 photos of a single plant), manually mark the positions of the objects you’re interested in and train the network (on a good video card).

Sounds like the machine learning approach will be too much for me then at the moment. I guess I will just compromise and use pixel counting :slight_smile: