Last updated: 29 November 2024

Computer vision for quality control and sorting of vegetables / fruits and plants

More and more companies in the agricultural sector are investing in automation, industrial cameras and smart software (AI) are used for optical quality control and sorting of vegetables, fruits and plants.

Computer vision for quality control and sorting of vegetables / fruits and plants
The industrial cameras are used for visualization of machines, or simply put: the eyes of a robot/computer. Human actions are being replaced by optical inspection and automated processes. With the help of computer vision/machine vision, processes become faster and more reliable, which means that continuous and consistent quality can be guaranteed.
This quality control is mainly done on the basis of 2D area scan camera technology. But 3D cameras, line scan cameras and hyper spectral image processing are also growing technologies within the agricultural sector.

Camera selection

Depending on the vision task, the right camera must be selected. Important choices that need to be made are:

•    Interface type (USB3, GigE or 10GigE)
•    Color or monochrome camera
•    Global Shutter or Rolling shutter camera technology
•    Resolution (number of pixels sensor)

Interface type (USB3, GigE or 10GigE)

Machine vision cameras must be connected to a computer. The camera interface is the connection between the camera and the computer. Engineers often have a preference for a certain interface, but if this is not the case, it is important to know the distance from the camera to the computer. If the distance between the camera and PC is shorter than 4.6 meters, we recommend using a USB3 camera. If the distance is longer, we recommend using GigE cameras. For more information, we advise you to consult the following article: Which machine vision camera to select?

In this example, the distance from the camera to the PC is more than 4.6 meters, so we recommend to use a GigE camera. We always recommend a camera with PoE to our customers. Power over Ethernet (PoE) for GigE is designed to provide both power and data communications over a standard Ethernet cable. This reduces the number of cables and installation time, in applications that do not require a hardware trigger or I/O.

Color or monochrome camera 

Monochrome cameras are often used in machine vision applications. For example, if the number of products has to be counted, presence of an objects is checked or measurements are made, good contrast is needed and a monochrome camera is used. The color information is not relevant and is not used.

In addition, an additional advantage of a monochrome camera (black and white photo/image) is that the sensor is up to 3 times more light sensitive and produces sharp images than a color camera/sensor.

If you want to do something with color information, a color camera is required, also called an RGB (Red, Green, Blue) camera. RGB cameras are often used to inspect vegetables, fruits and plants, because this color information is used for quality control.

For example, checking for different colors of spots/defects on fruits and vegetables, which can be green or brown. This difference in color cannot be seen with a monochrome camera.
A color camera is always used for Deep Learning software, because the color image provides extra information.

In this example we use a color camera, because we want to do optical quality control and the spots/defects may contain different colors.

Global Shutter or Rolling Shutter camera 

If the camera or an object moves while taking images, a Global Shutter camera is the best choice. With Global Shutter cameras, all lines/pixels of the camera are read out simultaneously. If the camera and the object are stationary, a Rolling Shutter camera can be used. If an object moves and Rolling Shutter camera technology is used, the image will be distorted. This is because the sensor is read out line by line. For more information, we advise you to read the following article: Rolling Shutter vs Global Shutter.

In this example, fruits and vegetables are on a conveyor belt for quality control and sorting. The conveyor belt is not stopped during camera acquisition. In this case a Global Shutter camera is required.

Resolution (number of pixels sensor)

The following information is important to calculate the correct resolution for the camera:
  • The smallest detail they want to see/inspect
  • The area they want to inspect (Field Of View)
We usually recommend 3 pixels per smallest detail for a stable vision system. In some cases it is also possible to use 2 pixels per smallest detail, but this depends on how good/powerfull the software is.

In this example we want a camera that can see defects on fruits and vegetables with 1mm accuracy. The fruits and vegetables are on a conveyor belt of 80 centimeters wide. So the horizontal field of view need to be 800mm and vertically they want to be able to see 600mm.

As previously indicated, we want to use 3 pixels per smallest detail for a stable vision system.

System resolution = 1mm/3pixels= 0.33333333 mm/pixel

Horizontal camera resolution = 800 mm (horizontal FOV) / 0.33333333mm (system resolution) = 2400pixels
Vertical camera resolution = 600 mm (vertical FOV) / 0.33333333mm (system resolution) = 1800pixels

A camera with 2400 x 1800 pixels is therefore suitable. Based on this information we can select a camera. The MER2-503-23GC-P (IMX264) is a 5MP (2448 x 2048 pixels) camera, that meets all the above requirements that we formulated in previous steps.

Lens selection for IMX264

A correct lens must be selected for the camera. The lens is not standard included with a camera, so the lens must always be purchased to complete your computer vision system. The machine vision cameras we offer often have a c-mount, so in general c-mount lenses are often used. To calculate the correct lens we need information about the field of view, the working distance (distance from camera/lens to the object) and the sensor size of the selected camera.
The camera and lens are placed above a conveyor belt, in this example we want to place the camera between 700mm and 1000mm from the conveyor belt. With a horizontal fov of 800mm and a working distance of 735mm, the calculated focal length of the lens is 8mm. See below a screenshot of the lens calculator online available on our website. 

Quality control of fruits and vegetables lens calculation

Based on this calculation and the camera specifications, the LCM-5MP-08MM-F1.4-1.5-ND1 lens is suitable.

Machine vision lighting for inspecting fruits, vegetables and plants

Two bar lights are often used to illuminate fruits, vegetables and plants on a conveyor belt. The conveyor belt is often completely closed off from ambient light to prevent external influences and to create diffuse light. The bar lights are placed transversely above the conveyor belt and need to cover the entire width of the belt. The objects are illuminated from two sides. The bar lights need to be placed at a certain angle, so that there is almost no reflection and no shadow.

Computer vision software for quality control and sorting of vegetables, fruits and plants

In addition to the hardware, computer vision software is required to automatically recognize defects. Customers can write software code themselves or use existing vision software licences, such as Zebra Aurora Vision Studio. Aurora Vision is a powerful machine vision software specially designed to easily design a vision program. Thanks to the graphical interface, no programming knowledge is required to create a vision program. The software has a tool box that is suitable for performing many machine vision tasks. By selecting the right tools, you can easily create a workflow within minutes. Difficult machine vision requirements can also be solved using the deep learning add-on, which uses artificial intelligence to solve complex detection and recognition issues.
 Computer vision software to analyse quality control of fruit and vegetables
You can also use Aurora Vision Lite, a free demo program from Aurora vision. You can load images from the hard drive and design your own vision program using all the machine vision tools available in Aurora vision studio.

We can also create a sample program for you in Aurora Vision. Once you have images available, we can create a sample program for you in Aurora Vision. We then ask you to create a specification document with what you want to detect and provide ten images.

Machine vision application

Hopefully the steps above have helped you select the right hardware and software for your quality control and sorting of vegetables, fruits and plants with computer vision application.

If you have any further questions, you can always contact us. We have built up years of experience and knowledge in the machine vision industry. We are happy to give advice and customers can contact us for technical support.