In this video, I show how computer vision and artificial intelligence help companies improve production and save money. This is done by automating processes that normally have to be done by people. I will speak in particular of Agriculture plant analysis with the drone and Artificial Intelligence.

It doesn’t take a lot of imagination or skill in predicting the future to understand how artificial intelligence has entered all industries. In particular, 2021 is the year of agriculture, in this article “10 Ways AI Has The Potential To Improve Agriculture In 2021” forbs there are some possible applications. I will show you an example.

Intel with “Intel-Powered AI Helps Optimize Crop Yields” also makes us understand that the future is now. You can produce more with fewer resources.

Crop and count broccoli with the drone

In this project we will analyze a video footage over broccoli plantation with the aim of counting the broccoli to have an estimation of homogeneity in crop plants.

cultivated field of broccoli

To make An estimate of homogeneity in cultivated plants, one would have to manually count thousands of plants with huge waste of time and the risk of error. Without considering the problem of photographing or checking plant by plant in order to verify the growth, if it is damaged or other parameters.

Everything can be done by writing software that leverages computer vision and AI in real-time. Just fly the drone over the cultivated field.

How to structure the software

1 Object Detection
To detect broccolis crop

2 Object Tracking
To associate a univocal ID to each crop

3 Object Counting
To count the crops

4 Take crops snapshots
To save the picture of every single crop

1 Object detection

First, we need to recover a lot of images. We need to have all these images so that we can train any deep learning model to identify and cut out things that it has never seen before. There are many models of artificial intelligence and object detection, for this example I will use YOLO because in this case, it is the easiest to use in a not particularly complex operation. In this article, I’ll explain how to make it work YOLO object detection using Opencv with Python

Train the model

To make the artificial intelligence model recognize new objects, in our case YOLO, it is necessary to teach it what a broccoli is. I wrote a python code to automatically extract the images from the video and save them in a folder.

To have a great result it is always necessary to have photos with different types of lighting, different positions, backgrounds and contexts. This must be done so that the drone can recognize plants even when it is cloudy or when there is a lot of light.

Now you need to use image labeling software to identify the location of each broccoli plant on the images we downloaded earlier from the video. This software generates a .txt file associated with each image in which it indicates the exact position of all the plants present in the image.

image labeling

Use trained model

All this information must be passed to the training algorithm to make sure that the drone, thanks to artificial intelligence, recognizes the plants. In the photo here is the result.

YOLO with drone

2 Object Tracking

Object tracking consists of associating a unique ID for each individual broccoli plant. For example, if we take as a reference a number visible on the screen, we can see that it always remains the same even when the drone is moving. This is because the code maintains a track history where the object was over time and this is essential even if you only work with object detection.

I recommend this article Object Tracking with Opencv and Python to get a deeper idea on the subject.

Object tracking sort

3 Object Counting

When we can uniquely identify each plant, counting becomes an easy step. We have to define an ROI and every time a plant is inside it is counted.

crop counting

As you can see from the image, the Region Of Interest is the area delimited by the yellow line.

4 Take crops snapshots

By identifying every single image, we also get its position. With simple calls of the OpenCV functions, we can automatically save each plant as the drone passes. I also made a video on how to cut images with OpenCV, I recommend looking at this article “How crop images with OpenCV and Python” and the step may seem clearer to you.

We can also decide to see in the detail the images of the plants that pass the yellow line. All this is feasible in real time and with the passage of the drone.


What I have shown you is just a small example of the many applications on Agriculture plant analysis with the drone and Artificial Intelligence, the possibilities are endless.

Where can I find the complete tutorial of the project?

The whole project with the explanation and the codes used are available to the users of the course “Build COMPUTER VISION PROJECTS, even though you only have basic programming knowledge”.