Precise planting
Guy Coleman has extensive experience as an agricultural scientist, and began using Raspberry Pi five years ago as a means of exploring how computer vision might be used in such settings. Weed recognition and precision control using deep learning is the focus of his PhD at the University of Sydney. Before this, Guy was more comfortable doing precision weed-control fieldwork on large-scale paddocks in Australia than developing projects using Python such as the OpenWeedLocator.
He works alongside Dr William Salter, whose background is in plant physiology and open-source technology for plant phenotyping, and who had already built several light sensors and an instrument for the high-throughput measurement of photosynthesis.
“Managing weeds in crops so they don’t reduce yields is a big challenge in agriculture, and current methods rely on herbicide applications to whole fields,” explains Guy. “Being able to assess where weeds are with cameras means the herbicide is only applied to individual weeds, meaning big savings to the farmer and reduced chemical inputs to the environment.”
However, weeds vary hugely in colour, size, and shape and the team needed to find a way of recognising them in all sorts of environmental conditions. Since the weed detector also had to work at a reasonable speed, any algorithm used would have to operate with high frame rates, Guy explains. They chose to base OWL around an 8GB Raspberry Pi 4 because of its combination of low cost, high power and small form factor. “Being easily connected to a whole variety of inputs and outputs has been absolutely essential to this project,” Guy comments.
A green detection algorithm running on Raspberry Pi identifies any green weeds that appear in the video feed and then activates a GPIO pin that connects to a relay board. A solenoid can then be switched on to deliver herbicide to the detected weeds.
Smarter applications
Guy and William wrote the code for OWL in Numpy and OpenCV. Keeping OWL open source means it can be easily updated with improved weed detection capabilities. Their biggest challenge was developing an algorithm that performed at an acceptable level in a range of conditions but testing convinced them to settle on a combination of the Excess Green + HSV thresholding systems.
OWL is very much a community project, with the full hardware details posted on GitHub (magpi.cc/owlgit) including a 3D-printable enclosure. This has already led to versions of OWL being assembled and used on four different continents, with some tweaking of the enclosure design for easier printing and assembly. The most critical pieces are the Raspberry Pi 4 with 8GB, Raspberry Pi HQ Camera, a relay control board and 12V to 5V 5A DC to DC converter, says Guy. Aside from printing parts, building OWL takes a couple of hours and running costs are minimal – only 12V of input power required for it to run.
Guy and William plan to add in-crop weed detection and GPS and say quite a few farmers have spoken to them about different uses they see for OWL to improve the efficiency of food and fibre production globally. The ability to find anything green means OWL can also be used to only apply fungicide or insecticide to the crop or to defoliate green cotton plants. “OWL is a living project. Now that it has ‘flown the nest’, so to speak, we’re excited to see where the community takes it.”