Identify and count vegetables

Is it possible to use the OpenMV cam to identify and count the number of vegetables in my hydroponic garden? Maybe even determine if a tomato is ripe or not? I’m new to this (machine vision, not micro-controllers and programming), so if it is possible, and you can point me in a direction to get started, it is greatly appreciated.

Hi, you need to specify exactly how you plan to do he counting. If it’s via color we can do that as long as there’s contrast between the foregorund object and the background object.

I’m thinking by color, for tomatoes cucumbers and peppers. I am assuming that it can differentiate the objects, based on shape, and I would have to provide it with images of each group (tomatoes, peppers, and cucumbers), and then in those groups, divided groups by ripeness( so for tomatoes I would have two more separate groups of green tomatoes (unripe) and red tomatoes (ripe)). I just need an idea on how to get started coding that.

Okay, start with the color tracking examples built into OpenMV IDE under File->Examples. You should also loo into the sensor control examples which let you control the sensor exposure and whatnot. These help greatly. Anyway, to do color tracking well you can do do this…

Assuming you 100% control the lighting of your garden (if it’s indoors). Then you can do everything via color tracking. First, you just need to determine the color of the soil. You can use the Threshold Editor in OpenMV IDE to do this (see tools → machine vision). Once you have the color of the soil you can find_blobs() with the invert flag set to True to find all colors that aren’t the color of the soil. This will give you blobs that represent each plant. You can then pass options to find_blobs() to merge blobs and whatnot. Anyway, after doing this you can then proceed to look at the color within each blob using get_stats(). This will then return the color distribution for each blob. Note that you want to use a loop over the objects returned by find_blobs() and call get_stats() with the roi argument on each blob returned by find_blobs().

Anyway, for color tracking getting the lighting stable will be your enemy. Focus on that carefully.

I’ve been doing a little research, and I am finding that the pi-Cam is more suited for this task, because of its higher resolution, and an existing library that I can use, based around object recognition. However, I do have a hexapod project that I can see the OpenMv Cam being very applicable in. Thanks for the help.

Cool. Good luck.