Click here to Skip to main content
15,946,316 members
Articles / Artificial Intelligence / Deep Learning

Real-time AI Pest Elimination on Edge Devices: Getting Started

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
3 Mar 2021CPOL4 min read 10.3K   586   4   5
In this article, we compared two DNN types we can use to detect pests: detectors and classifiers.
Here, we state the problem of pest elimination in terms of using AI and DNN. We then suggest two possible solutions: 1 – using pretrained SSD models to detect cats, sheep and others; 2 – using MD and train our own DNN to detect ‘nonstandard’ pests such as moose. Finally, we provide a short outline of the series and state the tools for developing: Python, OpenCV, Caffe.

Introduction

Unruly wildlife can be a pain for businesses and homeowners alike. Animals like deer, moose, and even cats can cause damage to gardens, crops, and property.

In this article series, we’ll demonstrate how to detect pests (such as a moose) in real time (or near-real time) on a Raspberry Pi and then take action to get rid of the pest. Since we don’t want to cause any harm, we’ll focus on scaring the pest away by playing a loud noise.

This series will guide you through several steps. First, we’ll show you how to apply a pre-trained deep neural network (DNN) detector to find pests on video. We’ll then describe the possible solutions for detecting unusual pests that cannot be detected with most of the existing DNN detectors. Next, we’ll focus on the implementation of the selected approach. We’ll explain how to gather a dataset for DNN training and provide data augmentation methods for extending the dataset. We’ll train a DNN for detecting a rare pest, then we’ll develop the computer code for a simple motion detector and explain how to use it together with the trained DNN. Finally, we’ll adapt the code for Raspberry Pi and show you how to play a scary sound to chase the detected pests away.

The project code will be written in Python 3.7 to run on a PC and then on a Raspberry Pi device. The OpenCV library will provide us with computer vision algorithms, and the Caffe DL framework will be used for DNN training. These software pieces are easy to download and install on your PC.

You are welcome to download the source code of the project. We are assuming that you are familiar with Python and have a basic understanding of how neural networks work.

Selectors vs. Detectors

Our first task is to detect a pest in the video stream from a camera using an edge device like Raspberry Pi. We’ll use AI to solve this problem. The most powerful modern AI approach to image recognition and video processing is to use deep neural networks (DNNs). Various types of DNNs have been successfully applied to the most difficult problems in computer vision, including the detection of various objects: humans, animals, and so on.

To achieve our goal, we can use two main DNN types. The first network type is a simple classifier. This is a DNN trained to define what class an object in an image belongs to.

Image 1

Image classification was the major success for convolutional neural networks (CNNs). This led to the deep learning (DL) revolution in image processing. One of the advantages of classifiers is their high precision. Modern DNN classifiers can achieve 90% — or higher — classification accuracy for image datasets with hundreds or even thousands of classes.

However, applying classifiers to our task poses some challenges. One problem is that an image submitted to a classifier should only contain one identifiable object. Another issue is that an object — such as a human or an animal — must usually occupy most of the image’s area for a classifier to handle it correctly. Since a pest probably won’t occupy most of a camera frame, we need to find a way to detect objects that only take up part of an image.

We can circumvent the limitations of classifiers by using an alternative DNN type: a detector. Detector networks can determine if an image contains an object of a certain class, and can also identify the location of the object within the image.

Image 2

Detector DNNs can be used on images containing multiple objects of different classes because they locate the separate objects first, and then classify each located object. The only drawback of Detector DNNs is that they’re less accurate than classifiers.

Overall, a detector network will be a more viable option in our case, so a detector it is!

What About Real-Time?

Detector DNNs can definitely help us solve the first part of our problem — detect a pest in an image. If we can do that, we’ll also be able to detect pests in a video stream. The only question is whether we can do it in real time on an edge device, such as a Raspberry Pi. These devices aren’t very powerful, so we should be very careful when selecting a neural network. We need one that can run in real-time on our edge device. See this article for a deep-dive into choosing object detector neural networks suitable for edge devices.

Next Step

In the next article, we’ll use a pre-trained DNN to detect pests on video.

History

  • 15th December, 2020: Initial version
This article is part of the series 'Real-time AI Pest Elimination on Edge Devices View All

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Team Leader VIPAKS
Russian Federation Russian Federation
EDUCATION:

Master’s degree in Mechanics.

PhD degree in Mathematics and Physics.



PROFESSIONAL EXPERIENCE:

15 years’ experience in developing scientific programs
(C#, C++, Delphi, Java, Fortran).



SCIENTIFIC INTERESTS:

Mathematical modeling, symbolic computer algebra, numerical methods, 3D geometry modeling, artificial intelligence, differential equations, boundary value problems.

Comments and Discussions

 
Questionexcellent article on AI vs. pests Pin
Member 109411924-Mar-21 9:28
Member 109411924-Mar-21 9:28 
AnswerRe: excellent article on AI vs. pests Pin
Ryan Peden4-Mar-21 9:49
professionalRyan Peden4-Mar-21 9:49 
GeneralRe: excellent article on AI vs. pests Pin
Member 109411924-Mar-21 10:34
Member 109411924-Mar-21 10:34 
GeneralRe: excellent article on AI vs. pests Pin
Ryan Peden4-Mar-21 11:26
professionalRyan Peden4-Mar-21 11:26 
GeneralRe: excellent article on AI vs. pests Pin
Member 109411924-Mar-21 19:41
Member 109411924-Mar-21 19:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.