How to detect a particular object using just opencv

Hi, I am new to OpenCV and want to do object detection without using deep learning techniques. So I have an image of lemons on a lemon tree (both are green in colour) and I couldn’t figure out a way to detect them. Can you tell me which function and parameters should I work with? Please see this image for reference.

There is no OpenCV function or definitive solution for this. Fruit detection in trees is still a domain with a lot of research going on. Believe me, I work in this domain for over a decade.

There are several articles published in this field, so best is to read some recently published work. Methods range from color and texture analysis to deep learning methods.

Anyway, my first suggestion is to try to take better pictures. If some objects are difficult to see, they’ll be even more difficult to detect automatically.
One way to enhance the photo is to use controlled lighting. This will eliminate the effects of the sun and the shadows, and ensure that all the images have the same kind of lighting.

Use a strong flash and a short exposure time (<1ms) to achieve this effect.

The following image shows this effect in an apple orchard, comparing a normal photo with a photo taken using a very strong flash (GN62). At this distance the flash is much more powerful than the sun, so it seems as it was taken during the night - but it’s not the case.
![control_light|(upload://lW5u1kNIQHkDmCPF7KJEVgvqGCD.jpeg)
The apples are almost invisible in the first photo (as in your case), and in the second case they just pop out.

1 Like

Thanks a lot. I will try the things that u mentioned.