Welcome to the OpenWeedLocator (OWL) project, an opensource hardware and software weed detector that uses entirely off-the-shelf componentry, very simple green-detection algorithms (with capacity to upgrade to in-crop detection) and 3D printable parts. OWL integrates weed detection on a Raspberry Pi with a relay control board or custom driver board, in a custom designed case so you can attach any 12V solenoid, relay, lightbulb or device for low-cost, simple and open-source site-specific weed control. Projects to date have seen OWL mounted on robots, vehicles and bicycles for spot spraying. For the latest ideas and news, check out the Discussion tab.
08-05-2024 - Check out the latest Compact OWL enclosures!
Front | Back | |
---|---|---|
Official OWL extruded aluminium enclosure | ||
3D printable enclosure |
Find all the 3D printable files on the OWL repository or download them from Printables.
13-04-2024 - OpenWeedLocator now supports Raspberry Pi 5 and picamera2! Improvements include:
- support for both picamera and picamera2
- implementation of a
config/config.ini
approach to setting detection parameters - cleaner, more consistent code
10-04-2024 - v2.1 of the OWL driver board released.
- simplifies assembly
- more robust and improved performance
OWL on a vehicle | OWL on the AgroIntelli Robotti | OWL on the Agerris Digital Farmhand | OWL on a bicycle |
---|---|---|---|
This is the original OWL publication, released in Scientific Reports (open access). A range of green detection algorithms were tested including ExG (excess green 2g - r - b, developed by Woebbecke et al. 1995), a hue, saturation and value (HSV) threshold and a combined ExG + HSV algorithm. If you use the OWL in your research please consider citing this publication.
Investigating image-based fallow weed detection performance on Raphanus sativus and Avena sativa at speeds up to 30 km/h
The performance of the OWL from 5 - 30 km/h with different cameras and on broadleaf and grass 'weeds' was tested and published in Computers and Electronics in Agriculture. The current Raspberry Pi HQ Camera + latest software combination provided a recall of 74.8% at 5 km/h and 50.5 % at 30 km/h. Recall of up to 95.7% at 5 km/h was achieved by the global shutter Arducam AR0234.
- OWL Use Cases
- Community Development
- Hardware Requirements
- Software Installation
- Controller
- 3D Printing
- Updating OWL
- Troubleshooting
- Citing OWL
- Acknowledgements
- References
If you prefer a hardcopy version of these instructions, you can view and download the PDF using one of the links below.
These will be updated as major changes are made. All older versions will be retained within the docs
folder.
Current
The first, and most clear use case for the OWL is for the site-specific application of herbicide in fallow. As part of the development and testing of the unit, the OWL team designed and assembled a 2 m spot spraying boom, using two OWLs to control four 12 V solenoids each. The boom was mounted on the back of a ute/utility vehicle with the spray tank located in the tray and powered by a 12V car battery. Indicator lights for each nozzle were used to highlight more clearly when each solenoid had been activated for demonstration and testing purposes.
Parameter | Details | Notes |
---|---|---|
Mounting gap | 0 cm | Mounted directly to same bar as nozzles, just 32cm higher. |
Forward Speed | 6 - 8 km/h | Image blur/activation time limiting forward speed. Moving the OWL unit forward would be a quick improvement for travel speed and large green weeds. |
Solenoids | Goyen solenoid 3QH/3662 with Teejet body | Many alternatives exist as outlined in #2 |
Spray tips | Teejet TP4003E-SS | 40 degree, flat fan nozzles, stainless steel |
Strainer | TeeJet 50 mesh strainer | Protect spray tip from clogging/damage |
Pump/tank | Northstar 12V 60L ATV Sprayer | 8.3 LPM 12V pump, 60L capacity, tray mounted |
A second system, identical to the first, was developed for the University of Sydney's Digifarm robot, the Agerris Digital Farm Hand. The system is in frequent use for the site-specific control of weeds in trial areas. It is powered by the 24V system on the robot, using a 24 - 12V DC/DC converter.
The OWL can act as a high quality image data collection tool for developing image data training sets in realistic agricultural environments, attached to agricultural equipment. The approach allows whole-image, cropped-to-bounding-box and square images saved on a set frequency to a thumb drive.
Settings are updated in the config.ini
file.
Method | Code | Example |
---|---|---|
Whole image | 'whole' | |
Crop to bounding box | 'bbox' | |
Crop to square around weed centre | 'square' | |
Deactivated (DEFAULT) | None |
As more OWLs are built and fallow weed control systems developed, we would love to share the end results here. Please get in contact and we can upload images of the finished systems on this page.
Check out the OWL Discussion page for any questions, suggestions ideas or feedback. If there's a bug or improvement, please raise an issue.
Please review the contribution page for all the details on how to contribute and follow community guidelines.
The specific hardware requirements and details for each OWL format are provided below. There are two designs developed to ensure improved performance without compromising on the original simplicity of the OWL:
- Education layout (original OWL)
- Compact OWL
- extruded aluminium enclosure
- 3D printed enclosure
Original OWL | Compact OWL - Extruded Aluminium Enclosure | Compact OWL - 3D Printed Enclosure |
---|---|---|
All 3D models and hardware assembly guides are provided in subsequent sections. The quantities of each item below are for one OWL detection unit for each respective design.
Please note links provided in tables below to an example online retailer of each component for convenience only. There are certainly many other retailers that may be better suited and priced to your purposes and we encourage you to find local suppliers. Other types of connector, layout and design are also possible, which may change the parts required.
We now have a range of official OWL hardware available to build or purchase.
The Official OWL Enclosure is an extruded aluminium enclosure with rubber seals and a glued with 2mm thick glass lens. It provides a more production friendly, durable and water/chemical resisant option over 3D printed plastic.
The Official OWL driver board combines the relay control board, power supply and wiring. It will be available for purchase soon, or you can use the files provided to order/make your own.
Original OWL - Hardware List
The original OWL lays out all components in a flat design. It makes the connections and interactions within the system clear. It's a great educational tool to learn the parts required for a weed detection system and has served in the field as a functional weed detection system for a number of years.
Component | Quantity | Link |
---|---|---|
Enclosure | ||
Main Case (single Bulgin connector) | 1 | STL File |
Main Case (cable glands) | 1 | STL File |
Main Cover | 1 | STL File |
Raspberry Pi Mount | 1 | STL File |
Relay Control Board Mount | 1 | STL File |
Voltage Regulator Mount | 1 | STL File |
Camera Mount | 1 | STL File |
Enclosure Plug | 1 | STL File |
Computing | ||
Raspberry Pi 5 4GB (or Pi 4 or 3B+) | 1 | Link |
*Green-on-Green ONLY - Google Coral USB Accelerator | 1 | Link |
64GB SD Card (min. 16 GB) | 1 | Link |
Camera (choose one) | ||
RECOMMENDED: Raspberry Pi Global Shutter Camera | 1 | Link |
CCTV 6mm Wide Angle Lens | 1 (GS or HQ only) | Link |
SUPPORTED: Raspberry Pi 12MP HQ Camera | 1 | Link |
SUPPORTED: Raspberry Pi Camera Module 3 | 1 | Link |
SUPPORTED: Raspberry Pi V2 Camera (NOT RECOMMENDED) | 1 | Link |
1 | Link | |
Power | ||
5V 5A Step Down Voltage Regulator | 1 | Link |
4 Channel, 12V Relay Control Board | 1 | Link |
M205 Panel Mount Fuse Holder | 1 | Link |
Jumper Wire | 1 | Link |
WAGO 2-way Terminal Block | 2 | Link |
Bulgin Connector - Panel Mount | 1 | Link |
Bulgin Connector - Plug | 1 | Link |
Micro USB to USB-C adaptor | 1 | Link |
Micro USB Cable | 1 | Link |
Miscellaneous | ||
12V Chrome LED | 2 | Link |
3 - 16V Piezo Buzzer | 1 | Link |
Brass Standoffs - M2/3/4 | Kit | Link |
M3 Bolts/Nuts | 4 each or Kit | Link |
Wire - 20AWG (red/black/green/blue/yellow/white) | 1 roll each | Link |
Optional | ||
Real-time clock module | 1 | Link |
Compact OWL - Hardware List
The new OWL design is more compact, inside either an extruded aluminium enclosure or 3D printed housing. It offers improved water and dust resistance, plus ease of assembly and longevity. This design is recommended for production use.
The parts list is substantially reduced:
Component | Quantity | Link |
---|---|---|
Enclosure | ||
OFFICIAL OWL ENCLOSURE - aluminium | 1 | TBD |
Extrusion - 3D printed | 1 | STL File |
Front plate | 1 | STL File |
Tray | 1 | STL File |
Back plate - Amphenol, Adafruit RJ45 | 1* | STL File |
Back plate - Amphenol only | 1* | STL File |
Back plate - 16 mm cable gland | 1* | STL File |
Lens mount | 1 | STL File |
Camera mount | 1* | STL File |
Computing | ||
Raspberry Pi 5 4GB (or Pi 4 or 3B+) | 1 | Link |
*Green-on-Green ONLY - Google Coral USB Accelerator | 1 | Link |
64GB SD Card (min. 16 GB) | 1 | Link |
Camera (choose one) | ||
RECOMMENDED: Raspberry Pi Global Shutter Camera | 1 | Link |
CCTV 6mm Wide Angle Lens | 1 (GS or HQ only) | Link |
SUPPORTED: Raspberry Pi 12MP HQ Camera | 1 | Link |
SUPPORTED: Raspberry Pi Camera Module 3 | 1 | Link |
SUPPORTED: Raspberry Pi V2 Camera (NOT RECOMMENDED) | 1 | Link |
1 | Link | |
Power Management * items only needed in place of OWL driver board | 1 | |
OFFICIAL OWL DRIVER BOARD (incl. power mgmt, relay control) | 1 | TBD |
* 5V 5A Step Down Voltage Regulator | 1 | Link |
* 4 Channel, Relay Control Board HAT | 1 | Link |
* Jumper Wire | 1 | Link |
Amphenol Fathomlock Connector - 6 pin connector (FLS6BS10N3W3P03) | 1 | Link |
Amphenol Fathomlock Connector - 6 pin plug (FLS710N3W3S03) | 1 | Link |
Adafruit RJ45 Cable Gland | 1 | Link |
16mm Cable Gland | 1 | Link |
Miscellaneous | ||
3 - 16V Piezo Buzzer (optional) | 1 | Link |
Brass Standoffs - M2/3/4 (required for HAT/driver board) | Kit | Link |
Wire - 20AWG (red/black/green/blue/yellow/white) | 1 roll each | Link |
Separate guides are provided for the Original OWL assembly and the Compact OWL.
- Wire strippers
- Wire cutters
- Pliers
- Soldering iron/solder (only for Original OWL)
Original OWL - Hardware Assembly
⚠️ NOTE⚠️ All components listed above are relatively "plug and play" with minimal soldering or complex electronics required. Follow these instructions carefully and triple check your connections before powering anything on to avoid losing the magic smoke and potentially a few hundred dollars. Never make changes to the wiring on the detection unit while it is connected to 12V and always remain within the safe operating voltages of any component.
A video guide is available for the Original OWL assembly.
Before starting, have a look at the complete wiring diagram below to see how everything fits together. The LEDs, fuse and Bulgin connector are all mounted on the rear of the OWL unit, rather than where they are located in the diagram. If you prefer not to use or can't access a Bulgin connector, there is a separate 3D model design that uses cable glands instead.
Assembling the components for an OWL unit requires the enclosure and mounts as a minimum. These can be 3D printed on your own printer or printed and delivered from one of the many online stores that offer a 3D printing service. Alternatively, you could create your own enclosure using a plastic electrical box and cutting holes in it, if that's easier. We'll be assuming you have printed out the enclosure and associated parts for the rest of the guide, but please share your finished designs however they turn out!
The first few steps don't require the enclosure so you can make a start right away, but while you're working on getting that assembled, make sure you have the pieces printing, they'll be used from Step 4. For a complete device, you'll need: 1 x base, 1 x cover, 1 x RPi mount, 1 x relay mount, 1 x regulator mount, 1 x camera mount and 1 x plug.
There are only a few components that need soldering, including the fuse and voltage regulator:
- Soldering of voltage regulator pins
- Soldering of 12V input wires to voltage regulator pins
- Soldering of 5V output wires to voltage regulator pins (micro USB cable)
- Soldering of red wire to both fuse terminals
Carefully check which pins on the voltage regulator correspond to 12V in, GND in, 5V out and GND out prior to soldering.
To solder the Micro USB cable to the voltage regulator output, you'll need to cut off the USB A end so you are left with approximately 10cm of cable. Using the wire strippers or a sharp box cutter/knife, remove the rubber sheath around the wires. If you have a data + charging cable you should see red, green, white and black wires. The charging only cables will likely only have the red and black wires. Isolate the red (+5V) and black (GND) wires and strip approximately 5mm off the end. Solder the red wire to the positive output on the voltage regulator and black wire to the GND pin. Once you have finished, it should look like the first panel in the figure below.
⚠️ NOTE⚠️ Soldering can burn you and generates potentially hazardous smoke! Use appropriate care, fume extractors and PPE to avoid any injury. If you're new to soldering, read through this guide, which explains in more detail how to perfect your skills and solder safely.
⚠️ NOTE⚠️ When soldering, it's best to cover the exposed terminals with glue lined heat shrink to reduce the risk of electrical short circuits.
Voltage regulator | Voltage regulator pins | Fuse |
---|---|---|
Once the two red wires are soldered to the fuse, the fuse can be mounted on the rear panel of the OWL base. One wire will be connected to the Bulgin plug (next step) and the other to the Wago 2-way block.
For neater wiring you can also solder jumpers between all the normally open (NO) pins on the base of the relay board, but this is optional. If you don't solder these connections, make sure you connect wire using the screw terminals instead. Photos of both are provided below.
Soldered | Screw terminals |
---|---|
The other wires requiring soldering are joins between the buzzer and jumper wires for easy connection to the GPIO pins and from the LEDs to the power in/jumper wires.
Next we'll need to wire the output relay control and input 12V wires to the Bulgin panel mount connector. Fortunately all pins are labelled, so follow the wire number table below. This will need to be repeated for the Bulgin plug as well, which will connect your solenoids or other devices to the relay control board.
The process is:
- Connect all wires to Bulgin connector using the screw terminals
- Mount the connector to the rear panel
- Leave at least 10cm of wire so it can be connected to the relay board and other connections later.
Bulgin terminal number | Wire connection |
---|---|
1 | Blue wire - connects to centre terminal (common) on relay 1 |
2 | Green wire - connects to centre terminal (common) on relay 2 |
3 | Orange wire - connects to centre terminal (common) on relay 3 |
4 | White wire - connects to centre terminal (common) on relay 4 |
5 | Red 12VDC - connects to fuse wire already soldered. Make sure wire is the right length when mounted. |
6 | Black GND - connects to Wago 2-way terminal |
⚠️ NOTE⚠️ Skip this step if you're using cable glands.
Once all the wires have been connected you can now mount the Bulgin connector to the OWL base.
Attach the relay control board to the 3D printed relay control board mount using 2.5 mm standoffs. Attach the voltage regulator to the 3D printed voltage regulator mount with 2 mm standoffs. The mounted voltage regulator can then be mounted to one corner of the relay control board. The relay board and voltage regulator can then be installed in the raised slots in the OWL base.
⚠️ NOTE⚠️ Use 2.5 mm standoffs for mounting the relay control board to its base. Use 2 mm standoffs to mount the voltage regulator to its base.
Connect the relay control board to the Bulgin connector using the table in step 3 as a guide.
⚠️ NOTE⚠️ Some relay control boards such as this on Amazon are ACTIVE on LOW. This means that the signal provided by the Raspberry Pi (a higher voltage) to activate a relay will instead turn the relay off. While this can be changed in the code, please consider purchasing HIGH level trigger ( e.g the board specified in the parts list) or adjustable trigger ( e.g. this board).
Next, connect red and black jumper wires to the VCC and GND header pins on the relay control board. Now choose one Wago block to be a 12V positive block and the second to be the negative or ground. To the positive block, connect the 12 V wire from the fuse (12V input from source), the 12 V input to the voltage regulator, the 12 V solenoid line from the relay board and the VCC line from the relay board to one of the two WAGO terminal blocks, twisting the wires together if necessary. Repeat with the second, negative WAGO terminal block, connecting the input ground line from the Bulgin connector, ground line from the voltage regulator and the GND black wire from the relay board.
Installed relay board | Relay board wiring diagram | Relay board wiring |
---|---|---|
Attach the Raspberry Pi to the 3D printed mount using 2.5 mm standoffs. Install in the raised slots in the OWL base. Connect to micro USB power from the voltage regulator, using a micro USB to USB-C adaptor. Alternatively, the Raspberry Pi can be powered over the GPIO, however, this has not yet been implemented.
Raspberry Pi mount | Raspberry Pi in OWL base |
---|---|
Connect the Raspberry Pi GPIO to the relay control board header pins, using the table below and the wiring diagram above as a guide:
The GPIO pins on the Raspberry Pi are not clearly labelled, so use this guide to help. Be careful when connecting these pins as incorrect wiring can shortcircuit/damage your Pi.
RPi GPIO pin | Relay header pin |
---|---|
13 | IN1 |
14 | COM |
15 | IN2 |
16 | IN3 |
18 | IN4 |
Raspberry Pi GPIO pins | Relay control board header pins |
---|---|
Connect one end of the CSI ribbon cable to the camera. We provide a mounting plate that can be used with both the HQ, Global Shutter or V2 cameras, however, we recommend the use of the HQ camera for improved image clarity. Attach the HQ camera to the 3D printed mount using 2.5 mm standoffs (or 2 mm standoffs if using the V2 camera). Ensuring that the CSI cable port on the camera is directed towards the Raspberry Pi, mount the camera inside the OWL case using four M3 standoffs (50 mm long for HQ camera; 20 mm long for V2 camera). Connect the other end of the CSI cable to the Raspberry Pi CSI camera port.
Before connecting the lens, please be aware the HQ camera comes with fitted a C-CS mount adapter which needs to be removed before fitting the 6mm lens. The image won't focus unless the adapter is removed. More information is available below and in the HQ Camera Datasheet
How to remove the C-CS mount adapter:
HQ camera C-CS mount adapter | Camera and adapter separated | Lens fitted without adapter |
---|---|---|
Mounting the HQ camera to the 3D printed mount:
HQ camera and mount | HQ camera mounted in case |
---|---|
Mounting the V2 camera to the 3D printed mount:
V2 camera and mount | V2 camera mounted in case | Raspberry Pi camera port |
---|---|---|
The HQ lens will need to be focused, details below, once the software is correctly set up.
Mount the buzzer inside the OWL base using double sided mounting tape and connect the 5 V and ground wires to Raspberry Pi GPIO pins 7 and 9, respectively.
For simplicity we have used two 12V LEDs (which are just normal LEDs with a current limiting resistor included) for both the 5V TX/GND connection for Raspberry Pi status indication and also the 12V power connection. While 12 V will work fine on both, the 5 V connection will be dimmer. If you want to use a non-prepackaged, 3 mm LED for the 5V connection, you should solder a current limiting resistor to the LED to prevent damage to either the LED or the Rasperry Pi as described here. Install the 5 V LED inside the OWL base and connect the 5V and ground wire to GPIO pins 8 (TX pin) and 20 (GND pin), respectively. Install the 12 V LED inside the OWL base and connect the 12 V and GND wires to their respective WAGO terminal blocks.
Buzzer location | LEDs in OWL base | GPIO pins |
---|---|---|
Although optional, we recommend that you use a real time clock (RTC) module with the OWL system. This will enable the Raspberry Pi to hold the correct time when disconnected from power and the internet, and will be useful for debugging errors if they arise. The RTC uses a CR1220 button cell battery and sits on top of the Raspberry Pi using GPIO pins 1-6.
PiRTC module | RTC installed on Raspberry Pi |
---|---|
There are four 6.5 mm holes on the OWL base for mounting to a boom. Prior to installing the OWL cover, decide on a mounting solution suitable to your needs. In the photo below, we used 4 x M6 bolts. The cover of the OWL unit is secured with 4 x M3 nuts and bolts. Place M3 nuts into the slots in the OWL base. This can be fiddly and we suggest using tweezers, as shown below. Place the cover onto the base and secure using M3 bolts.
Mounting hardware | Cover nuts | Completed OWL unit |
---|---|---|
Compact OWL - Hardware Assembly
One major benefit of the Compact OWL (with the OWL driver board) is that no soldering is required. The design removes much of the wiring, improving ease of assembly and reliability. If you choose a Raspberry Pi Relay HAT instead of the OWL driver board, you'll just need to add a voltage regulator and solder that in to provide the 5V @ 5A required for the Raspberry Pi 5 or up to 3A required for the older models.
There are two options for the enclosure. The 3D printed enclosure and the official OWL extruded aluminium enclosure. Both share a 3D printed tray and the same components. The 3D printed version allows you to make a start without needing to buy bespoke components if you have access to a 3D printer.
The 3D model files for the printed enclosure can be downloaded here.
The Official OWL Enclosure will be available for purchase through the OWL store soon.
Compact OWL - Extruded Aluminium Enclosure | Compact OWL - 3D Printed Enclosure |
---|---|
⚠️ NOTE⚠️ The 3D printed version requires the additional purchase of:
- 1.6mm and 3mm nitrile rubber o-ring cord
- M2, M3 and M4 threaded inserts + M2, M3 and M4 hex head screws
- K&F Concept 37 mm UV lens filter
The internal tray is the same for both the extruded aluminium or 3D printed enclosures. The 3D printed tray suits the Raspberry Pi HQ Camera and the Global Shutter Camera. A separate mount is available for the Camera Module 3. Details are provided below.
Begin camera installation by removing the adapter ring and fitting the lens. The camera will not focus with this ring.
Global Shutter camera with adapter ring atached | Adapter ring removed |
---|---|
Mount the camera to the front of the tray using M2.5 standoffs. The Global Shutter camera requires slightly longer standoffs to get past the plastic backing cover. Run the ribbon cable over the top of the tray (as pictured)
Internal tray | Mounting the camera | Mounting the camera |
---|---|---|
Once the camera is secured, mount the Raspberry Pi using 4 x M2.5 x 5mm long standoffs. To secure the Pi, use 4 x 15mm standoffs. These will be used to mount the HAT.
Raspberry Pi 4B mounted on tray |
---|
The 37 mm UV lens filter is installed on the faceplate with 8 M2 heat-set threaded inserts and M2 hex head screws. Add the 1.6mm nitrile rubber o-ring cord to the internal channel on the lens mount. Firmly press the 37 mm UV lens filter into the channel on the faceplate.
Tighten down the 8 M2 screws in a cross pattern (similar to how a car tyre is installed), to avoid cracking the 3D printed mount.
Faceplate | Lens mount | Lens fitted with o-ring |
---|---|---|
The 3D printed enclosure also supports the mounting of the Camera Module 3 with an extra 3D printed part. Using M2 threaded inserts in the faceplate, mount the plate with approx. 5mm long M2 standoffs. Route the camera ribbon cable over the top.
Camera mounted on backplate | Faceplate with standoffs and backplate | Assembled |
---|---|---|
The OWL Hat simply fits over the GPIO pins and is mounted using the 4 x 15 mm standoffs installed in the previous step. Secure the HAT with 4 x 2.5mm screws and tighten down.
PWM or GPIO control is selected with four jumper pins (in blue below).
Fitted Official OWL HAT | OWL Hat jumpers | GPIO pin assignment |
---|---|---|
The default option is for GPIO control as pictured. By default the OWL HAT is wired as shown above:
[Relays]
# defines the relay ID (left) that matches to a boardpin (right) on the Pi.
# Only change if you rewire/change the relay connections.
0 = 13
1 = 15
2 = 16
3 = 18
The final jumper pin Pi Power Supply Enable
connects the Raspberry Pi to the 5V provided by the HAT. Only connect this jumper once you want the
Pi to start.
Instead of the Official OWL HAT, a relay control HAT (such as this from PiHut) can be used, with some minor changes to the OWL software. There are many different relay HATs available, so check which is most suitable for your purposes. Be sure to choose one with accessible GPIO pins.
Fit the HAT as recommended by the manufacturer, similar to the below images (source: The PiHut).
HAT | Installed HAT |
---|---|
In its default configuration, this specific relay HAT assigns GPIO boardpins 29, 31, 33, and 35 to relays 4 - 1
respectively. This differs to the default OWL configuration, so the [Relays]
section of the config file would need to
be updated. Using this board as the example:
[Relays]
# defines the relay ID (left) that matches to a boardpin (right) on the Pi.
# Only change if you rewire/change the relay connections.
0 = 35
1 = 33
2 = 31
3 = 29
However, if you use another relay HAT check the assignment/configuration of relays to boardpins. For reference, use this GPIO guide to help.
Without the OWL HAT, 5V power to Pi needs to be supplied separately. We recommend the Pololu 5V 5.5A step down voltage regulator, however, there are many options available.
Solder wires to the input and output of the voltage regulator. Using WAGO connector blocks, connect the input to the 12V from the Amphenol connector. Mount the regulator to the underside of the internal tray using M2 standoffs.
The earlier models of the Raspberry Pi consumer less power (3A @ 5V) than the Raspberry Pi 5 and can be powered over single 5V and GND pins on the GPIO. Use high quality connectors here or consider soldering directly to the GPIO pins on the HAT. A good connection without risk of coming loose, is critical.
You'll need to solder to pins 2 (5V) and 6 (GND) on the relay HAT. More details provided here from The PiHut (image source).
The Raspberry Pi 5 consumes up to 5A @ 5V, so it's suggested to use 2 x 5V and 2 x GND pins on the Raspberry Pi. Some good information on the topic is provided here.
Using the two 5V outputs from the voltage regulator, solder one +5V wire to pin 2 and another to pin 4 on the GPIO on the HAT relay. Similarly, connect two GND wires from the voltage regulator output to pins 30 and 34. Ensure there is a good solder connection, without any short circuits to neighbouring pins.
The images below are from a Raspberry Pi 5, however, the setup is the same for the 4B and 3B+ models just with one 5V/GND wire.
HAT installation - GPIO | HAT installation - soldering the 2 x 5V, 2x GND | HAT Installation - voltage regulator |
---|---|---|
Begin by wiring the Amphenol EcoMate Aquarius receptacle. The connector has 3 x 16 guage connections rated to 13A and 3 x 20 guage rated up to 7.5A (machined) or 5A (stamped). Use the appropriate crimp connections for the 16 and 20 guage connections.
Connections are labeled A - F on the receptacle and should be made in the following order:
- +12V (red) - A
- GND (black) - E
- relay 1 (blue) - B
- relay 2 (green) - C
- relay 3 (orange) - D
- relay 4 (white) - F
Unlike the relay HATs and relay board in the Original OWL, the common ground for the OWL driver board is routed through the board itself, reducing the wiring required. Connect the wires from the back of the connector to each relay, using the above list as a guide. The finished result should appear similar to the images below. Add heat shrink at the end of each wire for neater and more reliable connections.
Connector with wires | Completed HAT | Completed HAT mounted on the Pi |
---|---|---|
OPTIONAL Add a 5V buzzer inside the OWL by mounting it to the corner of the HAT with a screw. Connect the 5 V and ground wires to Raspberry Pi GPIO pins 7 and 9, respectively. The buzzer is useful for identifying when the OWL has started successfully. It isn't essential to operation.
OPTIONAL Add Kapton tape to the camera cable and internal wiring. Kapton tape is a god insulator and resistant to high temperatures, improving the robustness of the device.
Tray with Kapton tape |
---|
⚠️ NOTE⚠️ For software installation, you'll need access to the Raspberry Pi display, and USB ports. We recommend you set up the software prior to completing the build and inserting the tray. Alternatively, flash the SD card with one of the provided owl disk images.
To improve the resistance to dust and water ingression on the 3D printed version, you'll need to add a 3mm nitrile rubber o-ring around the face- and backplates of the enclosure.
Faceplate with o-ring | Backplate with o-ring |
---|---|
Fix the faceplate to the enclosure with the 4 x M4 screws. The 3D printed enclosure will need 4 x M4 threaded inserts set into the plastic on the back and front of the enclosure body. Carefully push the tray into the enclosure on the second row, making sure wires are not caught up on the side.
For the single Amphenol EcoMate Aquarius receptacle, push it through the backplate and tighten down. Fix the backplate to the enclosure.
Front | Back |
---|---|
There is a choice of three different backplates, depending on your hardware requirements. They include:
- 1 x hole for the Amphenol EcoMate Aquarius
- 2 x holes for the Amphenol EcoMate Aquarius and Adafruit waterproof RJ45 (ethernet) connector
- 1 x 16mm hole for a 16mm cable gland.
If you would prefer a different arrangement, just get in touch or raise an issue and we can sort it out for you!
Backplate options (aluminium) | Backplate options (3D printed) |
---|---|
And you're all done! Congratulations on building your OWL.
Connecting Solenoids for Spot Spraying
Once you have completed the setup, you now have the opportunity to wire up your own solenoids for spot spraying, targeted tillage, spot flaming or any other targeted weed control you can dream up. To do this, wire the GND wire of your device (it can be any wire if it's a solenoid) to the ground pin on the Bulgin plug (the same wire used for the GND from the 12V power source) and wire the other to one of the blue, green, orange or white wires on pins 1 - 4. A wiring diagram is provided below. The easiest way to wire them together to the same GND wire is to create a six-way harness, where one end is connected to the plug, one of the five other wires to the source power GND and the remaining four to the solenoids or whatever devices you are driving.
Bulgin plug | Ground wiring harness |
---|---|
A single board computer or SBC is the brains behind the OWL. It can do all the image processing and logic within a single, roughly credit card sized board without moving parts. These SBCs are the backbone of embedded computing or 'edge computing'. While the Raspberry Pi is arguably one of the most widely used and well supported SBCs there are many different options out there. Each has their strengths and weaknesses and may or may not be good fits with the OWL. We've providing a summary of some SBCs below, but this isn't an exhaustive list.
Currently, only Raspberry Pi 5, 4 and 3B+ work with the OWL and have been tested in full. Early tests (alpha) have been made with the LibreComputer LePotato. We will update the 'Works with OWL' column as more boards are tested in the community.
A summary of possible single board computers (SBCs) to use with the OWL
Name | CPU | RAM | MIPI | USB | GPU | Pros | Cons | Dimensions | OWL? | Image |
---|---|---|---|---|---|---|---|---|---|---|
Raspberry Pi 5 | Broadcom BCM2712, quad-core 64-bit ARM Cortex-A76 | 1-8GB | 2 | 2x3.0, 2x2.0 | VideoCore VII | Large community, affordable, PCIe 2.0 lane for externals (including Google Coral and solid state harddrives) | Limited GPU performance, no eMMC storage | 88 x 58 x 19.5mm | ✔️ | Manual install only (disk image coming soon) |
Raspberry Pi 4B | Broadcom BCM2711, quad-core Cortex-A72 | 1-8GB | 2 | 2x3.0, 2x2.0 | VideoCore VI | Large community, affordable | Limited GPU performance, no eMMC storage | 88 x 58 x 19.5mm | ✔️ | OWL v1.0.0 |
Raspberry Pi 3B+ | Broadcom BCM2837B0, quad-core Cortex-A53 | 1GB | 1 | 4x2.0 | VideoCore IV | Large community, affordable | Limited GPU performance, no eMMC storage | 85 x 56 x 17mm | ✔️ | OWL v1.0.0 |
Raspberry Pi CM4 | Broadcom BCM2711 quad-core Cortex-A72 | 1-8GB | 0 | 0 | VideoCore IV | Integration into custom carrier boards, EMMC | Needs carrier board | 55 x 40 x 4.7mm | - | - |
Libre Computer LePotato | Amlogic S905X | 1/2GB | 0 | 4x2.0 | Mali-450 @ 750MHz | Affordable | Limited community support, no onboard Wi-Fi | 85 x 56mm | TBA | |
Libre Computer Renegade | Rockchip RK3328, 4 Core Cortex-A53 | 1-4GB | 0 | 1x3.0, 2x2.0 | Mali-450 @ 500MHz | 4K HDR support | Limited community support, no onboard Wi-Fi | 85 x 56mm | - | - |
Libre Computer Renegade Elite | Rockchip RK3399, 2 Core Cortex-A72 + 4 Core Cortex-A53 | 4GB | 2 | 4x3.0 | 4 Core Mali-T860 | PCIe, highest performance Libre Computer | Higher cost compared to other options | 128 x 64mm | - | - |
Rock Pi 4B | Rockchip RK3399, 2 Core Cortex-A72 + 4 Core Cortex-A53 | 4GB | 1 | 2x2.0 2x3.0 | 4 Core Mali-T860 | PCIe, M.2 slot | Limited community support, no onboard Wi-Fi | 85 x 54mm | - | - |
ODROID-XU4 | Samsung Exynos5422 ARM Cortex-A15 Quad 2Ghz and Cortex-A7 Octa | 2GB | 0 | 2x3.0, 1x2.0 | Mali-T628 MP6 | eMMC module support | Higher cost compared to Raspberry Pi options | 83 x 58 x 20mm | - | - |
NVIDIA Jetson Nano | 4 Core ARM Cortex-A57 | 2/4GB | 2 | 4x3.0 | 128-core Maxwell | Powerful GPU, CSI camera | Higher cost compared to Raspberry Pi options | 100 x 79 x 30.2mm | - | - |
Only the Raspberry Pi 5 is currently capable of operating on larger image sizes. Frame rates of up to 120 FPS were recorded at the default 416 x 320 resolution. We recommend increasing resolution to 640 x 480 for the Raspberry Pi 5.
Want to help fill in this table? Find one of the untested platforms and give the OWL a go!
NVIDIA has released numerous powerful, embedded computers such as the Jetson Orin series (and previously the Jetson Xavier NX). These would likely be good options for the OWL, but are substantially more expensive than the options listed above.
The project will eventually support the use of the two major embedded computing devices, the Raspberry Pi (models 3B+, 4 and 5) and the Jetson Nano/Jetson Xavier NX for possible green-on-green detection with deep learning algorithms. At present, just the details on setting up the Raspberry Pi 3B+/4/5 are provided below. There are two options for installation.
For the first, all you'll need to do is download the disk image file (vX.X.X-owl.img) and flash it to an SD card. The second method is more in depth, but takes you through the entire process from beginning to end. If you're looking to learn about how everything works, take some time to work through this process.
⚠️ NOTE⚠️ 08/05/2024 - OWL transitioned frompicamera
topicamera2
support. The v1.0.0 disk image below (Buster) does not supportpicamera2
and will not work on the Raspberry Pi 5 nor with the recent camera releases. We strongly recommend using the most up to date version of Raspbian with the latest OWL software.
⚠️ NOTE⚠️ 17/03/2023 - running of the OWL changed from usinggreenonbrown.py
toowl.py
. This ensures better cross compatibility with GoG algorithms. It improves the modularity of the system.
⚠️ IMPORTANT⚠️ v1.0.0-owl.img DOES NOT WORK WITH RASPBERRY PI 5.
For this method you'll need access to:
- Desktop/laptop computer
- Micro SD card reader
- Internet with large data capacity and high speed (WARNING: the image file is large, and downloading will take time and use up a substantial quantity of your data allowance if you have are on a limited plan)
Quick method for software installation
Download the entire disk image file (v1.0.0-owl.img) here: OWL disk image (NOT COMPATIBLE WITH RASPBERRY PI 5)
⚠️ NOTE⚠️ The v1.0.0-owl.img file contains the original software and we strongly recommend updating using the process below. It also includes the deprecated naming ofgreenonbrown.py
instead ofowl.py
. If you do not update the software, be aware that you will need to rungreenonbrown.py
instead.
The latest, stable version will be linked above, however, all other older versions or versions with features being tested are available here.
The easiest way to flash (add the vX.X.X-owl.img file to the SD card so it can boot) the SD card is to use Balena Etcher or any other card flashing software. Instructions for Balena Etcher are provided here. Navigate to the website and download the relevant version/operating system. Install Balena Etcher and fire it up.
- Insert the SD card using your SD card reader.
- Select
Flash from file
on the Balena Etcher window and navigate to where you downloaded the vXX-XX-XX-owl.dmg file. This can be a zip file (compressed) too. - Select the target, the SD card you just inserted.
- Click
Flash
If this completes successfully, you're ready to move to the next step. If it fails, use Balena Etcher documentation to diagnose the issue.
Once the SD card is inserted into the slot of the Raspberry Pi, power everything up and wait for the beep. If you hear the beep, you're ready to go and start focusing the camera.
The disk image that you downloaded is likely to be a few versions behind the most recent. We only provide images of the most major updates. So to update the OWL software, just run the follow these steps.
- Have the OWL powered on with screen, keyboard and mouse connected. You should see a desktop with the OWL logo.
- Press CTRL + ALT + T to open a Terminal window or click the black icon with blue line and >_ symbol.
- Once the Terminal window is open, make sure you are working in the
owl
virtual environment by running:
owl@raspberrypi:~ $ workon owl
(owl) owl@raspberrypi:~ $
Notice that (owl) now appears before the line in the Terminal window. This indicates you are in the owl
virtual
environment. This is critical to make sure you install everything in the requirements.txt
file into the right
spot.
- Once you are in the
owl
environment, enter these commands on each new line:
(owl) owl@raspberrypi:~ $ cd ~
(owl) owl@raspberrypi:~ $ mv owl owl-old # this renames the old 'owl' folder to 'owl-old'
(owl) owl@raspberrypi:~ $ git clone https://github.com/geezacoleman/OpenWeedLocator # download the new software
(owl) owl@raspberrypi:~ $ mv OpenWeedLocator owl # rename the download to 'owl'
(owl) owl@raspberrypi:~ $ cd ~/owl
(owl) owl@raspberrypi:~/owl $ pip install -r requirements.txt # installs the necessary software into the (owl) environment
(owl) owl@raspberrypi:~/owl $ chmod a+x owl.py # changes owl.py to be executable
(owl) owl@raspberrypi:~/owl $ chmod a+x owl_boot.sh # changes owl_boot.sh to be executable
Once this is complete your software will be up to date and you can move on to focusing the camera.
The final step in the process is to make sure the camera is correctly focused for the mounting height. With the latest
software, when you run owl.py --focus
a sharpness (i.e. least blurry) estimation is provided on the video feed. The
algorithm determines how sharp an image is, so the higher the value the better. A single script is provided to make
focusing as easy as possible. Simply run:
(owl) owl@raspberrypi:~ $ cd ~/owl
(owl) owl@raspberrypi:~/owl $ bash focus_owl.sh
This will automate all the steps below. If this doesn't work, follow the steps below. If you would like to focus the OWL
again, you can always run ./owl.py --focus
.
Blurry Image | Clear Image |
---|---|
With the older versions of the software, you need to stop all owl.py
or greenonbrown.py
background processes before
you can restart the software with the video feed viewable on the screen. Enter the following into the terminal:
(owl) owl@raspberrypi:~ $ ps -C owl.py # or ps -C greenonbrown.py if you still have the older version.
After pressing ENTER, you should receive the following output:
(owl) owl@raspberrypi:~ $ ps -C owl.py
PID TTY TIME CMD
515 ? 00:00:00 owl.py
The PID is the important part, it's the ID number for the owl.py
program. In this case it is 515
, but it is likely
to be different on your OWL.
IMPORTANT: If the headings PID TTY TIME CMD
appear but a PID/line for owl.py doesn't appear it could mean
two things. Firstly make sure you've typed owl.py
correctly. If it doesn't have the right program to look for, it
won't find it. The other option is that owl.py
isn't running, which may also be the case. If you're certain it's not
running in the background, skip the stop program step below, and move straight to launching owl.py
.
If a PID appears, you'll need to stop it operating. To stop the program, enter the following command:
(owl) owl@raspberrypi:~ $ sudo kill enter_your_PID_number_here
The program should now be stopped
Now you'll need to launch owl.py
manually with the video feed visible. To do this use the Terminal window and type the
following commands:
(owl) owl@raspberrypi:~ $ ~/owl/./owl.py --show-display
This will bring up a video feed you can use to visualise the OWL detector and also use it to focus the camera. Once you're happy with the focus, press Esc to exit.
This is just the cherry on top and non-essential to correct operation of the OWL but to make sure the status LED you connected earlier blinks correctly the GPIO UART needs to be enabled.
Open up a terminal console by pressing Ctrl + T
. Type:
(owl) owl@raspberrypi :-$ sudo nano /boot/config.txt
This will open up the config.txt file. Scroll down to the bottom by holding the down arrow key and add the following line to the very last line of the file:
enable_uart=1
Press ctrl + x
to exit, then type y
to save and then enter
.
You're now ready to run!
If you are using the v1.0.0-owl.img file and don't update the OWL software as above, you will be using the
original greenonbrown.py
Python script. Running it from the command line will require slightly different commands.
Please follow this guide if this is you.
In the greenonbrown.py
file there is a parameter headless
which determines if a video is shown. If set to True
a
video feed is NOT displayed and the system will operate whenever it is powered on. If it is set to False
a video feed
will be displayed. To change this parameter, scroll to the bottom of greenonbrown.py
and find the
line headless=True
. Change as desired.
⚠️ NOTE⚠️ headless
must be set toTrue
for operation without a screen. If a screen is not attached butheadless=False
the Raspberry Pi will not boot correctly and the OWL software will not run.
To run the software from the command line (assuming it is not currently running), follow these steps:
owl@raspberrypi:~ $ workon owl
(owl) owl@raspberrypi:~ $ cd owl
(owl) owl@raspberrypi:~ /owl $ ./greenonbrown.py
⚠️ BUG ALERT⚠️ There is a known bug with this version where the script will not run if you are running it outside of theowl
directory. If you enocunter this error,cd
into theowl
directory and run the code again.
IMPORTANT: Suitable for the Raspberry Pi 5 and Bookworm Raspberry Pi OS.
This setup approach may take a little longer (aproximately 1 hour total) than the quick method, but you'll be much better trained in the ways of OWL and more prepared for any problem solving, upgrades or changes in the future. You'll also download and use the latest software that hasn't been saved in the .img file yet. In the process you'll learn about Python environments, install Python packages and set it all up to run on startup. To get this working you'll need access to:
- Raspberry Pi
- Empty SD Card (SanDisk 32GB SDXC ideally)
- Your own computer with SD card reader
- Power supply (if not using the OWL unit)
- Screen and keyboard
- WiFi/Ethernet cable
Detailed OWL installation procedure
Before powering up the Raspberry Pi, you'll need to install the Raspian operating system (just like Windows/MacOSX for laptops) on the new SD card. This is done using the same process as the quick method used to flash the premade owl.img file, except you'll be doing it with a completely new and untouched version of Raspbian.
From your own computer, download and flash the latest 64-bit version of Raspian from the official Raspberry Pi website to the empty SD card. The official Raspberry Pi Imager is a good piece of software to use.
Leave the hostname as default. To simplify setup, you can specify the wifi network settings. Set the username to 'owl' and choose a password.
Raspberry Pi Imager | Configuring the OWL |
---|---|
Once the Raspian OS has been flashed to the SD Card (may take 5 - 10 minutes), remove the SD card and insert it into the Raspberry Pi. Connect the screen, keyboard and mouse and then power up the Pi.
Alternatively, you can SSH into your OWL from a separate device and install it remotely. A good guide on how to do that is available here.
On the first boot you may be asked to set country, timezone, keyboard, connect to wifi and look for updates among other things. If you haven't already set the username, set it to 'owl' and choose a password. Uninstall the unused browser - this will save space on the Pi. Finally, you will be asked to restart the pi.
After the restart, open up Terminal. You can press CTRL + ALT + T, or click the icon in the top left with the >_
symbol. The instructions that follow are a blend of those available from
PyImageSearch
and QEngineering
⚠️ NOTE⚠️ All commands below are provided for easy copy/paste. When using terminal you should seeowl@raspberrypi:~ $
at the start of each line and(owl) owl@raspberrypi:~ $
when operating within theowl
virtual environment. Pay very close attention to the presence/absence of(owl)
in front of each line, as this can make/break installation.
⚠️ NOTE⚠️ We recommend naming the deviceowl
when asked if you didn't set it during the flashing process.
If you prefer a faster and simpler installation, try the following two-line install. You'll first need to clone the owl repository
before running owl_setup.sh
.
To start, clone the Github repository:
git clone https://github.com/geezacoleman/OpenWeedLocator owl
With the repository cloned into the 'owl' folder, we can now run the bash script owl_setup.sh
. This will take some time
to complete
bash owl/owl_setup.sh
Once completed successfully, your OWL is ready to go.
⚠️ NOTE⚠️ If you use this method, you can finish the installation here. The following steps just go through what is in theowl_setup.sh
script step-by-step. We recommend the step-by-step approach if you want to become more familiar with how the OWL works.
Instead of the two-line installation, the following procedure details all steps required.
The Raspberry Pi comes pre-installed with a range of software. To free up space it can be removed from the OWL.
Depending on your install, these may or may not be present. At the command line (it should look like owl@raspberrypi:~ $
),
run the following:
sudo apt-get purge wolfram-engine
sudo apt-get purge libreoffice*
sudo apt-get clean
sudo apt-get autoremove
A virtual environment contains all the necessary packages in one neat spot. We'll be using virtualenv
and
virtualenvwrapper
on the Pi to create a virtual environment called owl
.
To start with, update the system. The update may take a few minutes depending on your internet connection and how many
packages need updating. It's good practice to do this regularly. Then you'll add the following two lines to the bashrc
file.
⚠️ WARNING⚠️ usingrpi-update
will update to the latest kernel and drivers. This is to fix an issue with image component order. The problem should eventually be merged into normalapt-get update && upgrade
. This notice will be removed then.
Begin by updating the system:
sudo apt-get update && sudo apt-get upgrade
Now, update to the latest firmware version to fix the issue between RGB and BGR channel ordering.
sudo rpi-update
Then add the following lines to the .bashrc
file to prepare for the creation of virtual environments.
echo "# virtualenv and virtualenvwraper" >> ~/.bashrc
echo "export VIRTUALENVWRAPPER_PYTHON=/usr/bin/python" >> ~/.bashrc
Finally, reload the .bashrc
file.
source ~/.bashrc
Once that is complete, you can install virtualenv
and virtualenvwrapper
and add a few more lines to the same bashrc
file.
sudo apt-get install python3-virtualenv
sudo apt-get install python3-virtualenvwrapper
Following the installation of these packages, add the following lines to the .bashrc
file.
echo "export WORKON_HOME=$HOME/.virtualenvs" >> ~/.bashrc
echo "source /usr/share/virtualenvwrapper/virtualenvwrapper.sh" >> ~/.bashrc
As above, reload the file to update the changes.
source ~/.bashrc
With the virtual environment software successfully installed, it's now time to create the owl
environment. Importantly,
we need to inherit the site-packages (i.e. everything currently on the Pi) because they contain picamera2
pre-installed.
To make the owl
environment, run the following:
mkvirtualenv --system-site-packages -p python owl
The command line should now look like (owl) owl@raspberrypi:~ $
. The '(owl)' at the start of the line means you're currently within
that virtual environment. To turn it off you can run deactivate
and to turn it run workon owl
.
IMPORTANT: The next steps must be run within the owl
virtual environment. We're installing packages specific to the OWL.
We now need to install the Python libraries that let the OWL work. The most import is OpenCV, which we'll do first before
downloading the OWL repository and installing the remainder from the requirements.txt
file. Begin by ensuring the owl
environment is active.
⚠️ WARNING⚠️ It is ESSENTIAL that(owl)
is present at the start of each line in terminal for this section. The(owl)
indicates that you are within theowl
virtual environment and that these Python packages will be installed and accessible within this environment. Runworkon owl
to ensure you are in theowl
environment.
workon owl
Now that you are in the owl
virtual environment we can begin installing packages.
pip3 install opencv-contrib-python
This should have successfully installed OpenCV into the owl
virtual environment. You can double check by quickly starting a
Python session at the command line:
python
This will open up an interactive Python session (indicated by >>>) from which you should type:
>>> import cv2
>>> import picamera2
>>> exit()
This should then exit you from the Python session. The command line should look like this:
(owl) owl@raspberrypi:~ $
If both of these complete without error, then you've successfully set up the virtual environment and installed OpenCV.
Now you should have:
- A virtual environment called 'owl'
- A working version of OpenCV installed into that environment
- a Terminal window open with the 'owl' environment activated.
The next step is to download the entire OpenWeedLocator repository into your home directory on the Raspberry Pi. First change into the home directory:
cd ~
then clone the repository 'https://github.com/geezacoleman/OpenWeedLocator' into a new folder called 'owl'
git clone https://github.com/geezacoleman/OpenWeedLocator owl
This will download the repository into a folder called owl
. Double check it is there by typing (owl) owl@raspberrypi:~ $ ls
and reading through the results, alternatively open up the Home folder using a mouse. If that was successful, you can
now move on to Step 4.
Dependencies are Python packages on which the code relies to function correctly. With a range of versions and possible comptibility issues, this is the step where issues might come up. There aren't too many packages, but please make sure each and every module in the requirements.txt file has been installed correctly. These include:
- OpenCV (should already be in 'owl' virtual environment from Step 1)
- numpy
- imutils
- gpiozero
- pandas
- RPi.GPIO
- tqdm
- blessed (for command line visualisation)
- threading, multiprocessing, collections, queue, time, os (though these are included as standard Python modules).
⚠️ IMPORTANT⚠️ Before continuing make sure you are in theowl
virtual environment. Check that(owl)
appears at the start of each command line, e.g.(owl) owl@raspberrypi:~ $
. Runworkon owl
if you are unsure. If you are not in theowl
environment, you will run into errors when startingowl.py
.
To install all the requirements.txt, change into the owl directory:
cd ~/owl
then run:
pip install -r requirements.txt
Now to double-check this has worked, we can open up another Python session and try importing the packages. Begin by typing:
python
Python should start up an interactive session; type each of these in and make sure you don't get any errors.
>>> import cv2
>>> import numpy
>>> import gpiozero
>>> import pandas
Version numbers can be checked with:
>>> print(package_name_here.__version__) ## this is a generic example - add the package where it says package_name_here
>>> print(cv2.__version__)
>>> exit()
If any errors appear, you'll need to go back and check that the modules above have (1) been installed into the owl virtual environment, (2) that Python was started in the owl environment, and/or (3) they all installed correctly. Once that is complete, exit Python and continue with the installation process.
Now that these dependencies have been installed into the owl virtual environment, it's time to make sure the software
runs on startup. The first step is to make both the Python file owl.py
and the boot files owl_boot.sh
and owl_boot_wrapper.sh
executable. Then move both owl_boot.sh
and owl_boot_wrapper.sh
into the /usr/local/bin
directory.
chmod a+x owl.py
chmod a+x owl_boot.sh
chmod a+x owl_boot_wrapper.sh
sudo mv owl_boot.sh /usr/local/bin/owl_boot.sh
sudo mv owl_boot_wrapper.sh /usr/local/bin/owl_boot_wrapper.sh
After they have been made executable, the owl.py
needs to be launched on startup so each time the Raspberry Pi is
powered on, the detection systems starts. The easiest way to do this is by using cron, a scheduler for starting code.
We need to add the owl_boot.sh
file to the schedule so that it launches on boot. The owl_boot.sh
file is
fairly straightforward. It's what's known as a bash script which is just a text file that
contains commands we would normally enter on the command line in Terminal.
This is the owl_boot.sh
file:
#!/bin/bash
# automatically determine the home directory, to avoid issues with username
source $HOME/.bashrc
# activate the 'owl' virtual environment
source $HOME/.virtualenvs/owl/bin/activate
# change directory to the owl folder
cd $HOME/owl
# run owl.py in the background and save the log output
LOG_DATE=$(date -u +"%Y-%m-%dT%H-%M-%SZ")
./owl.py > $HOME_DIR/owl/logs/owl_$LOG_DATE.log 2>&1 &
In the file, the first two commands launch our owl
virtual environment, then we change directory cd
into the owl
folder and run the python program. The owl_boot_wrapper.sh
file figures out which user is running the file, and then
uses that user to run owl_boot.sh
. This makes the system more resilient to changes in Pi username.
To add this to the list of cron jobs, you'll need to edit it as a root user:
sudo crontab -e
Select 1. /bin/nano editor
, which should bring up the crontab file. At the base of the file add this text:
@reboot /usr/local/bin/owl_boot_wrapper.sh > /home/launch.log 2>&1
Once you've added that line, you'll just need to save the file and exit. In the nano editor just press Ctrl + X, then Y and finally press Enter to agree to save and exit.
If you get stuck, this guide or this guide both have a bit more detail on cron and some other methods too.
Now you'll just need to reboot the system. Once it reboots, owl.py
will launch and run in the background.
⚠️ NOTE⚠️ Cameras with automatic focus such as the Raspberry Pi Camera Module 3 will be automatically focused to 1.2m distance. The following guide is useful for the HQ and Global Shutter cameras which require manual focusing.
The final step in the process is to make sure the camera is correctly focused for the mounting height. With the latest
software, when you run owl.py --focus
a sharpness (i.e. least blurry) estimation is provided on the video feed. The
algorithm determines how sharp an image is, so the higher the value the better. A single script is provided to make
focusing as easy as possible. Simply run:
cd ~/owl
bash focus_owl.sh
This will automate all the steps below. If this doesn't work, follow the steps below. If you would like to focus the OWL
again, you can always run ./owl.py --focus
.
Blurry Image | Clear Image |
---|---|
With the older versions of the software, you need to stop all owl.py
or greenonbrown.py
background processes before
you can restart the software with the video feed viewable on the screen. Enter the following into the terminal:
(owl) owl@raspberrypi:~ $ ps -C owl.py # or ps -C greenonbrown.py if you still have the older version.
After pressing ENTER, you should receive the following output:
(owl) owl@raspberrypi:~ $ ps -C owl.py
PID TTY TIME CMD
515 ? 00:00:00 owl.py
The PID is the important part, it's the ID number for the owl.py
program. In this case it is 515
, but it is likely
to be different on your OWL.
⚠️ IMPORTANT⚠️ If the headingsPID TTY TIME CMD
appear but a PID/line for owl.py doesn't appear it could mean two things. Firstly make sure you've typedowl.py
correctly. If it doesn't have the right program to look for, it won't find it. The other option is thatowl.py
isn't running, which may also be the case. If you're certain it's not running in the background, skip the stop program step below, and move straight to launchingowl.py
.
If a PID appears, you'll need to stop it operating. To stop the program, enter the following command:
(owl) owl@raspberrypi:~ $ sudo kill enter_your_PID_number_here
The program should now be stopped
Now you'll need to launch owl.py
manually with the video feed visible. To do this use the Terminal window and type the
following commands:
(owl) owl@raspberrypi:~ $ ~/owl/./owl.py --show-display
This will bring up a video feed you can use to visualise the OWL detector and also use it to focus the camera. Once you're happy with the focus, press Esc to exit.
The moment of truth. Shut the Raspberry Pi down and unplug the power. This is where you'll need to reconnect the camera and all the GPIO pins/power in the OWL unit if they have been disconnected. Once everything is connected again (double check the camera cable is inserted or this won't work), reconnect the power and wait for a beep!
If you hear a beep, grab something green and move it under the camera. If the relays start clicking (the Official OWL HAT uses transistors and will not click - look for the lights) and lights come on, congratulations, you've successfully set the OWL up! If not, check the troubleshooting chart below and see if you can get it fixed. Raise an issue and get in touch if you're not sure how to proceed.
⚠️ NOTE⚠️ The unit does not perform well under office/artificial lighting. The thresholds have been set for outdoor conditions.
Optional Step - installing RTC and setting the time
The optional real time clock module can be set up by following the [detailed instructions](https://learn.adafruit.com/adding-a-real-time-clock-to-raspberry-pi/set-up-and-test-i2c) provided by Adafruit. This is a quick process that should take less than 10 minutes. Note that an internet connection is required to set the time initially, however after this the time will be held on the clock module.
Instructions for changing detection settings
Changing detection settings is now easier by using a specific config file.
You can use command line flags to toggle display, data source and setting focus. Use the config.ini
file in the
config folder to set other parameters as described below.
The default config file is DAY_SENSITIVITY_2.ini
(details provided below). If you change any settings here, make sure
to save the file before restarting owl.py
.
While we recommend tuning detection parameters to your specific environment, we have provided three sensitivity levels to get you started.
Config File Name | Description |
---|---|
DAY_SENSITIVITY_1.ini | The least sensitive parameters, designed to minimise false positive detections to just get the big weeds. Minimum detection size has been increased. |
DAY_SENSITIVITY_2.ini | OWL detection parameters were tuned to this file. |
DAY_SENSITIVITY_3.ini | The most sensitive parameters. Reduce missed detections with lower minimum detection size and wider detection ranges. |
Command line flags are let you specify options on the command line within the Terminal window. It means you don't have
to open up the code and make changes directly. OWL now supports the use of flags for some parameters. To read a
description of all flags available type --help
:
usage: owl.py [-h] [--input] [--show-display] [--focus]
--input path to image directory, single image or video file
--show-display show display windows
--focus focus the camera
Feel free to create your own config files to meet your specific conditions. In owl.py
just update the path to the
config file. Follow the same layout and format as the default.
To open owl.py
, you'll need to open it and not execute the file.
Navigate to the owl directory |
Open the owl.py file |
---|---|
Then scroll down to the very bottom until you find the line below. Update the config_file=
path to your own config file path.
owl = Owl(config_file='config/ENTER_YOUR_CONFIG_FILE_HERE.ini')
These are the various system, data collection and detection settings that can be changed. They are defined further below.
[System]
# select your algorithm
algorithm = exhsv
# operate on a video, image or directory of media
input_file_or_directory =
# choose how many relays are connected to the OWL
relay_num = 4
actuation_duration = 0.15
delay = 0
[Controller]
# choose between 'None', 'ute' or 'advanced'
controller_type = None
# for advanced controller
detection_mode_pin_up = 35
detection_mode_pin_down = 36
recording_pin = 38
sensitivity_pin = 40
low_sensitivity_config = config/DAY_SENSITIVITY_2.ini
high_sensitivity_config = config/DAY_SENSITIVITY_3.ini
# for UteController
switch_purpose = recording
switch_pin = 37
[Visualisation]
image_loop_time = 5
[Camera]
resolution_width = 640
resolution_height = 480
exp_compensation = -2
[GreenOnGreen]
# parameters related to green-on-green detection
model_path = models
confidence = 0.5
class_filter_id = None
[GreenOnBrown]
# parameters related to green-on-brown detection
exg_min = 25
exg_max = 200
hue_min = 39
hue_max = 83
saturation_min = 50
saturation_max = 220
brightness_min = 60
brightness_max = 190
min_detection_area = 10
invert_hue = False
[DataCollection]
# all data collection related parameters
# set sample_images True/False to enable/disable image collection
sample_images = False
# image collection, sample method include: 'bbox' | 'square' | 'whole'
sample_method = whole
sample_frequency = 30
save_directory = /media/owl/SanDisk
# set to True to disable weed detection for data collection only
disable_detection = False
# log fps
log_fps = False
camera_name = cam1
[Relays]
# defines the relay ID (left) that matches to a boardpin (right) on the Pi.
# Only change if you rewire/change the relay connections.
0 = 13
1 = 15
2 = 16
3 = 18
Parameter | Options | Description |
---|---|---|
System | ||
algorithm |
Any of: gog ,exg ,exgr ,exgs ,exhu ,hsv ,exhsv |
Changes the selected algorithm. Most sensitive: 'exg', least sensitive/most precise (least false positives): 'exgr', 'exhu', 'hsv', 'exhsv'. |
actuation_duration |
Any float (decimal) | Changes the length of time for which the relay is activated. |
input_file_or_directory |
path to a image, video, or directory of media | Will iterate over each image at a default 5 FPS, or over a directory of images or videos. |
relay_num |
integer | Change the number of activation 'lanes' and therefore the number of relays activated. Set to 1 for a single relay. |
delay |
Any float | Delay between detection and actuation. Defaults to 0. |
Controller | ||
controller_type |
'None' , 'ute' , 'advanced' |
Specifies the type of controller to use. 'advanced' enables extra features such as detection mode and sensitivity switching, while 'ute' is for simpler use cases. 'None' disables controller. |
detection_mode_pin_up |
Integer | Specifies the GPIO pin for "detection mode up" in advanced controller setups. |
detection_mode_pin_down |
Integer | Specifies the GPIO pin for "detection mode down" in advanced controller setups. |
recording_pin |
Integer | Specifies the GPIO pin to activate/deactivate image recording in advanced controller setups. |
sensitivity_pin |
Integer | Specifies the GPIO pin to switch between low and high sensitivity in advanced controller setups. |
low_sensitivity_config |
Path | Path to the configuration file for low sensitivity settings in advanced controller setups. |
high_sensitivity_config |
Path | Path to the configuration file for high sensitivity settings in advanced controller setups. |
switch_purpose |
'recording' or other purpose | Describes the purpose of the switch in UteController setups (e.g., activating recording or controlling other functions). |
switch_pin |
Integer | GPIO pin used for switching functionality in UteController setups (e.g., recording activation). |
Visualisation | ||
image_loop_time |
Integer | How long (ms) to wait on each image when looping over the same image if a single image file or directory is provided. |
Camera | ||
resolution_width |
Integer | Width of the camera resolution (updated to 640). |
resolution_height |
Integer | Height of the camera resolution (updated to 480). |
exp_compensation |
Integer between -8 and 8 | Change the target exposure setting for the exposure algorithm. Defaults to -2, preferencing darker settings for faster shutter speeds. |
GreenOnGreen | ||
model_path |
Path | A path to the model file |
confidence |
The cutoff confidence value for a detection. Defaults to 0.5 or 50%. | |
class_filter_id |
Integer | Which classes to filter and target. For example, using a out-the-box COCO model, you may want to only detect a specific class. Enter that specific class integer here. |
GreenOnBrown | ||
exg_min |
Any integer between 0 and 255 | Provides the minimum threshold value for the exg algorithm. Usually leave between 10 (very sensitive) and 25 (not sensitive) |
exg_max |
Any integer between 0 and 255 | Provides a maximum threshold for the exg algorithm. Leave above 180. |
hue_min |
Any integer between 0 and 128 | Provides a minimum threshold for the hue channel when using hsv or exhsv algorithms. Typically between 39 and 83. |
hue_max |
Any integer between 0 and 128 | Provides a maximum threshold for the hue (colour hue) channel when using hsv or exhsv algorithms. Typically between 39 and 83. |
saturation_min |
Any integer between 0 and 255 | Provides a minimum threshold for the saturation (colour intensity) channel when using hsv or exhsv algorithms. Typically between 50 and 220. |
saturation_max |
Any integer between 0 and 255 | Provides a maximum threshold for the saturation (colour intensity) channel when using hsv or exhsv algorithms. Typically between 50 and 220. |
brightness_min |
Any integer between 0 and 255 | Provides a minimum threshold for the value (brightness) channel when using hsv or exhsv algorithms. Typically between 60 and 190. |
brightness_max |
Any integer between 0 and 255 | Provides a maximum threshold for the value (brightness) channel when using hsv or exhsv algorithms. Typically between 60 and 190. |
min_detection_area |
Integer | The minimum area for which to detect a weed. |
invert_hue |
Boolean | True/False, inverts the detected hue from everything within the thresholds to everything outside the thresholds. |
DataCollection | ||
sample_images |
Boolean: True or False | Enables or disables image data collection. Defaults to False. Set to True to start collecting images. |
sample_method |
Choose from 'bbox', 'square', 'whole' | If sample_method=None, sampling is deactivated. Do not leave on for long periods or SD card will fill up and stop working. |
sample_frequency |
Any positive integer | Changes how often (after how many frames) image sampling will occur. If sample_frequency=30, images will be sampled every 30 frames. |
save_directory |
Path | Set where you want the images saved. Defaults to /media/owl/SanDisk . When sample_images is True, the software will look for an attached USB drive at this location. It will try 5 times before exiting if none are found. |
disable_detection |
Boolean: True or False | Disable detection when running data collection. This will reduce the workload on the Pi and increase frame rate. Useful if using the OWL for dedicated image data collection. |
log_fps |
Boolean: True or False | Save FPS to a file. |
camera_name |
Any string | Changes the save name if recording videos of the camera. Ignore - only used if recording data. |
Relays | Integer/GPIO Boardpin | Maps a relay number to a boardpin on the GPIO header |
Adding simple controllers to manage four OWLS or fewer
The software and designs for the first generation GPIO-based controllers (between 1 and 4 OWL units) are now available. This approach offers a simpler, hardware-based option for managing devices. However, it is more difficult to scale and add features. Adressing this issue, a CAN FD-based controller is in development.
Ute Controller | 'Advanced' Controller |
---|---|
NOTE: you MUST connect a USB drive when using a controller, otherwise it will not start. The Sandisk Ultrafit Flash Drive will fit within the enclosure.
- Crimping tool for Amphenol crimped connections
- Pliers
- Wire strippers/cutters
- Soldering iron/solder
The parts lists below are provided as a guide only. Please use local suppliers and search around for items that may have equivalent specifications but lower price or faster delivery.
As you increase the number of OWLs connected to the Advanced Controller, be sure to increase the current rating of all relevant components. For systems with four OWLs, consider using a relay box (used in cars) to avoid running high current cables over long distances and switching them inside a cab.
Cable protection and sheaths Trailer cable already has a heavy duty outer covering, however a Nylon Hose Protector sleeve will increase the lifetime of cabling, without adding too much expense.
Suitable for connecting a singular OWL device. TinkerCAD model available here.
Component | Quantity | Link |
---|---|---|
Car cigarette lighter socket (check fuse rating) | 1 | Link (make sure the inbuilt fuse matches your system rating) |
7 strand, 3mm (7.5A rated) trailer cable | As needed | Link |
M12 Cable gland | 2 | Link |
Off-On SPST Toggle Switch | 2 | Link |
Rubber boot for switch | 2 | Link |
Amphenol Fathom Lock - 6 (3 + 3) contact straight plug | 1 | Link |
#16 Contacts (13A rated) | 3 | Link |
#20 Contacts (5A rated) | 3 | Link |
Dialight 12V Green LED Panel Mount | 1 | Link |
Dialight 5V Red LED Panel Mount | 2 | Link |
M3 Heatset inserts + M3 screws (Amazon sell insert kits) | 3 + 3 | Link |
Suitable for connecting up to four OWLs. As the number of OWLs connected increases, each switch should add another pole. For four OWLs, you will need four pole switches and an input power cable (and switch) rating of at least 40A @ 12V (4 OWLs x 10A).
TinkerCAD models (1, 2, and 4 OWLs) available here.
Component | Quantity | Link |
---|---|---|
In-line fuse + holder (10A per OWL connected) | 1 | 30A MAX: Link (make sure the inbuilt fuse matches your system rating) 60A MAX: Link |
7 strand, 3mm (7.5A rated) trailer cable (used for comms) | As needed | Link |
Output power cable (min 10A rating) (used for powering OWL + solenoids) | As needed | Link |
Input power cable (10A per OWL connected) | As needed | 10A: Link 25A: Link 50A: Link |
M16 Cable gland | 1 | Link |
1 OWL controller | ||
Off-On SPST Toggle Switch (16A MAX) | 3 | Link |
On-Off-On SPST Toggle Switch | 1 | Link |
4 OWL controller | ||
POWER SWITCH: Off-On SPST Toggle Switch (50A MAX) NOTE: Consider using a relay bank (e.g. Relay Box) instead of running power through the controller |
1 | Link |
Off-on 4PST toggle switch | 2 | Link |
On-Off-On 4PST toggle switch | 1 | Link |
Other parts | ||
Rubber boot for switch | 4 | Link |
Amphenol Fathom Lock - 8 contact straight plug | 2 (per OWL connected) | Link |
Amphenol Fathom Lock - 8 contact receptacle | 1 (add 1 for OWL back cover) | Link |
#16 Contacts (13A rated) (male) | 16 (per OWL connected) | Link |
#16 Contacts (13A rated) (female) | 8 (add 8 for OWL back cover) | Link |
Dialight 12V Green LED Panel Mount | 1 | Link |
Dialight 5V Red LED Panel Mount | 1 (per OWL connected - status light) | Link |
M3 Heatset inserts + M3 screws (Amazon sell insert kits) | 4 + 4 | Link |
M5 Heatset inserts + M5 screws for Ram Mount | 4 + 4 | Link |
Ram Mount Round Plate with C Ball | 1 | Link |
3D model files are available for both controller types. These could equally be set up quite easily in widely available plastic enclosures available in your local area. It would simply require drilling holes to match switch dimensions. Circular connectors and switches have been selected for this reason.
While the Ute Controller is designed to fit in a cupholder, the rear of the Advanced Controller has heat set embedded nuts to mount a Ram Mount C-size round plate.
File | Image | STL (located in 3D models/Controllers) |
---|---|---|
Ute Controller Base | Link | |
Ute Controller Top | Link | |
Advanced Controller Base | Single: Link Double: Link 4 OWL: Link |
|
Advanced Controller Top | Single: Link Double: Link 4 OWL: Link |
Connections to the switches can be either soldered and covered with heat shrink or connected with automotive-style blade fittings (e.g. these ones)
LEDs should be carefully soldered and covered with heat shrink.
Crimp connections for the Amphenol Fathomlock connectors are most efficiently and reliably done with a crimping tool, but can be crimped with pliers if necessary. Just be very careful to check the quality of the connection by tugging it gently. Improperly crimped connections can cause hard to diagnose problems and/or heat up creating a fire risk.
Use the tables below to make the right connections. In both cases, only 6 of the 7 trailer cable wires are used. Cut the 7th wire and carefully cover it in heatshrink to avoid it rubbing on the other wires. Alternatively find 6 core cable (7 core trailer wire is just much easier to find/cheaper).
Carefully remove the outer protective coating of the trailer cable without damaging the sheaths of the wires inside. If you do damage them (it's very easy to do) just use some heat shrink to cover the cut. Remove about 10cm of the outer sheath.
Use one of the M12 glands for the 12V power in from the cigarette socket (or otherwise) and the other for the trailer cable. Push the 6 internal wires from the trailer cable through the M12 cable gland and make the following connections:
- Connect a black wire to the centre of the REC toggle switch and the shorter pin on the two 5V red LEDs (not the 12V green one). Bundle these wires together with a WAGO block or solder and heatshrink them with the BROWN trailer wire. This will be the GPIO GND.
- Connect the WHITE wire to the recording/detection toggle switch.
- Connect the GREEN wire to the longer pin of the REC red LED.
- Connect the YELLOW wire to the longer pin of the MEM LED (storage status indicator)
Push the cigarette light wires through the other M12 gland. Connect the RED wire to the top, power switch. On the other leg of the switch solder a 10A rated wire (for the OWL) and a smaller gauge wire for the 12V LED pin. Connect the 10A rated wire from the switch to the RED wire from the trailer cable. The 12V black GND wire can be connected directly to the BLACK wire of the trailer cable, adding a black smaller gauge wire for the 12V LED.
On the OWL end of the cable, make the following connections using the 6-pin receptacle. Use the connector pin map for the plug end of the trailer cable. Take care that the connector pins on the receptacle and the plug match.
Purpose | Colour | GPIO Pin | Connector Pin (size) |
---|---|---|---|
Power +12V | Red | N/A - connect to 12V of OWL Driver Board | A (#16) |
Power GND | Black | N/A - connect to GND of OWL Driver Board | B (#16) |
Recording/Detection Toggle Switch | White | BOARD 37 | C (#16) |
Recording status LED (blinks on image save) | Green | BOARD 38 | D (#20) |
Storage status indicator | Yellow | BOARD 40 | E (#20) |
GPIO GND | Brown | BOARD 39 | F (#20) (centre pin) |
Cover the trailer cable in a nylon sheath if needed.
The same principles apply for the advanced controller. Power is carried by the separate power wire instead of through the trailer cable. A single status LED is needed per OWL for indicating errors, detections and available storage capacity.
Multi-pole toggle switches are used to avoid interference between each of the Raspberry Pi in the OWLs.
Use the table below and connect the correct colour wire with the correct switch. Use a single GPIO GND line for each OWL ensuring this is separate to the 12V GND.
Purpose | Colour | GPIO Pin | Connector Pin (size) |
---|---|---|---|
Power +12V | Red (use additional cable) | N/A - connect to 12V of OWL Driver Board | A (#16) |
Power GND | Black (use additional cable) | N/A - connect to GND of OWL Driver Board | B (#16) |
All nozzles on | Blue (trailer cable) | BOARD 36 | C (#16) |
Recording toggle | Green (trailer cable) | BOARD 38 | D (#16) |
Sensitivity toggle | Yellow/Orange (trailer cable) | BOARD 40 | E (#16) |
Status LED | White (trailer cable) | BOARD 37 | F (#16) |
Spot spray enable | Red (trailer cable) | BOARD 35 | G (#16) |
GPIO GND | Brown (trailer cable) | BOARD 39 | H (#16) (centre pin) |
Using a soldering iron on a low setting or specifically designed tools, carefully add the M3 and M5 heatset inserts for the top cover and the Ram Mount round plate respectively Ensure the inserts are correctly aligned, straight and flush with the surface of the controller.
The following parameters are used to change controller settings under the controller section of the config.ini
file.
Choose which controller (or 'None') by using None, ute or advanced.
For the Ute Controller, the toggle switch can be used for either toggling recording or detection. Select this mode here.
For the Advanced Controller, the low and high sensitivity files that are switched between with the sensitivity switch can be adjusted
with paths specified in low_sensitivity_config
and high_sensitivity_config
.
[Controller]
# choose between 'None', 'ute' or 'advanced'
controller_type = None
# for advanced controller
detection_mode_pin_up = 35
detection_mode_pin_down = 36
recording_pin = 38
sensitivity_pin = 40
low_sensitivity_config = config/DAY_SENSITIVITY_2.ini
high_sensitivity_config = config/DAY_SENSITIVITY_3.ini
# for UteController
switch_purpose = recording
switch_pin = 37
NOTE: you MUST connect a USB drive when using a controller, otherwise it will not start.
With the config files set, save them to the OWL, reboot, and you should be ready to go!
How to detect in-crop weeds with the OWL
Green-on-Green capability is (almost) here!
While we previously had implemented in-crop detection models with the Google Coral and Pycoral, the lack of support has made us reconsider that approach. Running detection models like YOLO is in the works to run on the base Raspberry Pi 5 or with additional hardware such as the Raspberry Pi AI Kit with the Hailo 8L.
If you would like to try the Google Coral, you can by following the instructions in the 'models' directory.
Effective models need training data, so if you're interested in using the Green-on-Green functionality, you will need to start collecting and annotating images of relevant weeds for training. Alternatively, head over to Weed-AI to see if any image data may be relevant for your purposes.
⚠️ NOTE⚠️ There do appear to be some issues with the exporting functionality of YOLOv5/v8 to .tflite models for use with the Coral. The issue has been raised on the Ultralytics repository and should hopefully be resolved soon. You can follow the updates here.
YOLOv8 and YOLOv5 currently
provide the most user friendly methods of training, optimisation and exporting as .tflite
files for use with the
Google Coral. There is also a Weed-AI Google Colab
Notebook
which can be used to train models from Weed-AI data directly.
Installing OWL software on a non-Raspberry Pi system
Using OWL software on your laptop/desktop or other non-Raspberry Pi system is a great way to test, develop and learn more about how it works. To start using the software, just follow the steps below. You will need access to virtual environments and your IDE/editor of choice. This method has been successfully tested on PyCharm with Anaconda environments.
> git clone https://github.com/geezacoleman/OpenWeedLocator
> cd OpenWeedLocator
For the next part, make sure you are in the virtual environment you will be working from. If you're unsure about virtual environments, read through this PyImageSearch blog on configuring an Ubuntu environment for deep learning - just skip to the virtual environment step. FreeCodeCamp has a great blog describing them too.
Assuming the virtual environment is working and is activated, run through these next couple of steps:
> pip install -r non_rpi_requirements.txt # this will install all the necessary packages, without including the Raspberry Pi specific ones.
It may take a minute or two for those to complete installing. But once they are done you are free to run the owl.py
software.
> python owl.py --show-display
From there you can change the command line flags (as described above) or play around with the settings to see how it works.
Image processing details and in-field results
So how does OWL actually detect the weeds and trigger the relay control board? It all starts by taking in the colour image from the camera using OpenCV and splitting it into its component channels: Red (R), Green (G) and Blue (B) (RGB) or loading and converting into the hue, saturation and value (HSV) colourspace. Following that, computer vision algorithms such as Excess Green `ExG = 2 * G - R - B` or thresholding type approaches on the HSV colourspace can be used to differentiate green locations from the background.
Once the green locations are identified and a binary (purely black/white) mask generated, a contouring process is run to
outline each detection. If the detection pixel area is greater than the minimum area set in minArea=10
, the central
pixel coordinates of that area are related to an activation zone. That zone is connected to a specific GPIO pin on the
Raspberry Pi, itself connected to a specific channel on the relay (one of IN1-4). When the GPIO pin is driven high (
activated) the relay switches and connects the solenoid for example to 12V and activates the solenoid. It's all
summarised below.
The performance of each algorithm on 7 different day/night fields is outlined below. The boxplot shows the range, interquartile range and median performance for each algorithm. Whilst there were no significant differences (P > 0.05) for the recall (how many weeds were detected of all weeds present) and precision (how many detections were actually weeds), trends indicated the ExHSV algorithm was less sensitive (fewer false detections) and more precise, but did miss more smaller/discoloured weeds compared to ExG.
The image below gives a better indication of the types of weeds that were detected/missed by the ExHSV algorithm. Large, green weeds were consistently found, but small discoloured or grasses with thin leaves that blurred into the background were missed. Faster shutter speed would help improve this performance.
3D printing instructions and files
There are seven total items that need printing for the Original OWL unit. All items with links to the STL files are listed below. There are two options for Original OWL base:
- Single connector (Bulgin) panel mount
- Pros: of this method are easy/quick attach/detach from whatever you have connected, more water resistant.
- Cons: more connections to make, more expensive
- Cable gland
- Pros: fewer connections to make, cheaper, faster to build.
- Cons: more difficult to remove, less water resistant.
We also provide a link to the 3D models on TinkerCAD, an online and free 3D modelling software package, allowing for further customisation to cater for individual user needs.
Ideally supports should be used for the base, and were tested at 0.2mm layer heights with 25% infill on a Prusa MK3S.
Update 02/05/2022
- improved camera mounts
- space for 40mm lens cover
- more compact design
- version tracking
The Compact OWL has fewer parts to print than the Original OWL and is both more durable and water resistant. A complete unit requires printing of only 5 parts.
All 3D model files are availabe on to edit and download on TinkerCAD or Printables. The 3D printing .stl files are provided under the 3D Models and through the links in the table below.
The backplate comes in three options:
- Amphenol EcoMate Aquarius receptacle only
- Amphenol EcoMate Aquarius receptacle + Adafruit RJ45 waterproof ethernet connector
- 16mm cable gland only
Pick one of these backplates when printing.
All .stl files for the 3D printed components of this build are available in the 3D Models directory. Supports are not required but do improve print quality. All parts were printed with a Bambu Labs P1S at 0.16mm layer height at 25% infill.
Updating OWL software
We and others will be continually contributing to and improving OWL as we become aware of issues or opportunities to increase detection performance. Once you have a functioning setup the process to update is simple with a single bash script. First, you'll either need to connect a screen, keyboard and mouse to the OWL unit or do this via SSH.
⚠️ IMPORTANT⚠️ Before continuing make sure you are NOT in theowl
directory: e.g.(owl) owl@raspberrypi:~. You can double check by running
~``
The software can be updated using a one line bash script:
bash ~/owl/owl_update.sh
And that's it! You're good to go with the latest software.
If you have multiple units running, the most efficient method is to update one and then copy the SD card disk image to every other unit. Follow the instructions presented here, to use software already installed on the Pi.
All versions of OWL can be found here. Only major changes will be recorded as separate disk images for use.
Version | File | Raspbian |
---|---|---|
v1.0.0-owl.img | Download | Buster (picamera) |
v2.0.0-owl.img | Download | Bookworm (picamera2) |
Troubleshooting OWL issues
The table below includes a summary of all current error classes and their hierarchy. All errors include detailed logging, color-formatted terminal output, and standardized error handling. When encountering an error, check the terminal output for specific guidance and follow the suggested solutions for your specific error.
If an error appears that isn't caught here, please raise an issue and we'll update this table and the error_manager.py
file.
Error Class | Subclasses / Specific Errors | Common Causes | Solutions |
---|---|---|---|
OWLError |
Base exception for all OWL-related errors | — | — |
CameraNotFoundError |
- Disconnected camera - Damaged ribbon cable - Camera not enabled |
1. Check camera connections 2. Run vcgencmd get_camera 3. Enable camera in raspi-config |
|
OWLProcessError |
— | — | |
- OWLAlreadyRunningError |
- Another OWL instance active - GPIO pins in use |
1. Use kill <PID> to stop process2. Check for zombie processes 3. Reboot if persists |
|
StorageError |
Base class for storage-related errors | — | — |
USBError |
— | — | |
- USBMountError |
• Device not properly mounted • Permission issues |
1. Check physical connection 2. Verify mount points 3. Check device permissions |
|
- USBWriteError |
• Write-protected device • Full storage • Permission issues |
1. Check write protection 2. Verify available space 3. Check file permissions |
|
- NoWritableUSBError |
• No USB storage detected • All devices write-protected |
1. Connect USB device 2. Check write protection 3. Format device if needed |
|
StorageSystemError |
- Incompatible platform for storage operation | 1. Use Linux/Raspberry Pi 2. Specify a valid local directory in config 3. Use --save-directory flag |
|
OWLControllerError |
Base class for controller-related errors | — | — |
- ControllerPinError |
- Pin conflicts - Invalid pin numbers - Hardware issues |
1. Check pin configurations 2. Verify physical connections 3. Check for conflicts |
|
- ControllerConfigError |
- Missing or invalid configuration | 1. Check config file 2. Add missing settings 3. Ensure values are appropriate |
|
OWLConfigError |
Base class for configuration errors | — | — |
- ConfigFileError |
- Missing config file - Invalid file path - Corrupt file |
1. Verify file exists 2. Check file permissions 3. Validate file contents |
|
- ConfigSectionError |
- Missing required sections in config file | 1. Add missing sections to the config file | |
- ConfigKeyError |
- Missing required keys in a section | 1. Add missing keys to the respective config section | |
- ConfigValueError |
- Invalid configuration values | 1. Correct values to fit expected ranges | |
AlgorithmError |
Base class for algorithm-related errors | - Missing dependencies - Invalid model files - Coral device issues |
1. Install required packages 2. Verify model files 3. Check Coral device connection |
OpenCVError |
— | - OpenCV not installed - Wrong virtual environment |
1. Run workon owl 2. Install opencv-python 3. Run owl_setup.sh |
DependencyError |
— | - Missing Python packages - Wrong virtual environment |
1. Activate owl environment 2. Run pip install for package 3. Install from requirements.txt |
Here's a table of some of the common symptoms and possible explanations for errors we've come across. This is by no means exhaustive, but hopefully helps in diagnosing any issues you might have. If you come across any others please contact us so we can improve the software, hardware and guide.
⚠️ NOTE⚠️ If you are using the original disk image without updating, there are a number of issues that will appear. We recommend updating to the latest software by following the procedure detailed in the Updating OWL section above.
Symptom | Explanation | Possible solution |
---|---|---|
Raspberry Pi won't start (no green/red lights) | No power getting to the computer | Check the power source, and all downstream components. Such as Bulgin panel/plug connections fuse connections and fuse, connections to Wago 2-way block, voltage regulator connections, cable into the Raspberry Pi. |
Raspberry Pi starts (green light flashing) but no beep | OWL software has not started | This is likely a configuration/camera connection error with many possible causes. To get more information, boot the Raspberry Pi with a screen connected, open up a Terminal window (Ctrl + T) and type ~/owl/./owl.py . This will run the program. Check any errors that emerge. |
Beep heard, but no relays activating when tested with green | Relays are not receiving (1) 12V power, (2) a signal from the Pi, (3) the Pi is not sending a signal | Check all your connections with a multimeter if necessary for the presence of 12V. Make sure everything is connected as per the wiring diagram. If you're confident there are no connection issues, open up a Terminal window (Ctrl + T) and type ~/owl/./owl.py . This will run the program. Check any errors that emerge. |
Citing OWL
OpenWeedLocator has been published in Scientific Reports. Please consider citing the published article using the details below.
@article{Coleman2022,
author = {Coleman, Guy and Salter, William and Walsh, Michael},
doi = {10.1038/s41598-021-03858-9},
issn = {2045-2322},
journal = {Scientific Reports},
number = {1},
pages = {170},
title = {{OpenWeedLocator (OWL): an open-source, low-cost device for fallow weed detection}},
url = {https://doi.org/10.1038/s41598-021-03858-9},
volume = {12},
year = {2022}
}
Acknowledgements
This project has been developed by Guy Coleman and William Salter at the University of Sydney, Precision Weed Control Lab. It was supported and funded by the Grains Research and Development Corporation (GRDC) and Landcare Australia as part of the University of Sydney's Digifarm project in Narrabri, NSW, Australia. We would like to thank all the farmers that assisted in data collection, validation and feedback on the initial design.
Disclaimer and License
While every effort has been made in the development of this guide to cover critical details, it is not an exhaustive nor perfectly complete set of instructions. It is important that people using this guide take all due care in assembly to avoid damage, loss of components and personal injury, and are supervised by someone experienced if necessary. Assembly and use of OWL is entirely at your own risk and the license expressly states there is no warranty.
MIT License
Copyright (c) 2020 Guy Coleman
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
References
Journal Papers Woebbecke, D. M., Meyer, G. E., Von Bargen, K., Mortensen, D. A., Bargen, K. Von, and Mortensen, D. A. (1995). Color Indices for Weed Identification Under Various Soil, Residue, and Lighting Conditions. Trans. ASAE 38, 259–269. doi:https://doi.org/10.13031/2013.27838.
Blog Posts How to run a Raspberry Pi script at startup
How to Run a Script at Boot on Raspberry Pi (with cron)