Elephant AI

a system to prevent human-elephant conflict by detecting elephants using machine vision, and warning humans and/or repelling elephants

Similar projects worth following
The conflict that arises between humans and elephants in countries such as India, Sri Lanka, and Kenya claims many hundreds of human and elephant lives per year. These negative interactions arise when humans meet elephants on their trails, when elephants raid fields for food, and when elephants try to cross railways. Machine vision and automated deterrence can mitigate such conflict.


This is an evolution of my 'Automated Elephant-detection system' that was a semi-finalist in the Hackaday Prize 2016. The current project differs substantially in that it makes use of more advanced machine vision techniques, eliminates the usage of RF communications (using 4G/3G/EDGE/GPRS), village base stations, and includes elephant-deterrence devices to completely eliminate interaction between humans and elephants whenever possible.

So, let's get to the primary goals of Elephant AI:

  • Eliminate contact between humans and elephants
  • Protect elephants from injury and death
  • Protect humans from injury and death

How will the Elephant AI accomplish these goals?

  • Detect elephants as they move along their regular paths. These paths have been used by elephants for many years (perhaps centuries) and often cut through areas now used by humans. Humans will be warned that elephants are moving on the paths so they can stay away or move with caution.
  • Detect elephants as they leave forested areas to raid human crop fields. At this point, elephant deterrence devices will attempt to automatically scare elephants. This will be using sounds of animals they dislike (e.g. bees and tigers, and human voices in the case of Maasai people in Kenya/Tanzania), and perhaps by firing chili balls into the paths of the elephants from compressed air guns.
  • Detect elephants before they stray onto railway lines. This can be done via a combination of machine vision techniques and more low-tech IR (or laser) break-beam sensors. Train drivers can be alerted to slow-down and stop before hitting the elephants who are crossing.

Just how bad is it for humans and elephants to interact? This video, shot several months ago, in India, gives some idea. It is really bad indeed. It causes great stress to elephants, and puts both the elephants and humans at risk of injury or death.

That's why Elephant AI wants to take human-elephant interaction out of the equation entirely!


We need a daylight camera (IR-filtered) and a night camera (NoIR filtered + IR illumination array) since elephants need to be detected 24hrs per day! In my original project I completely forgot about this, then decided to multiplex cameras to one Raspberry Pi. It was actually cheaper and easier to use two raspberry pi's; each with its own camera. Night-time and daytime classification of elephant images both need their own trained object detector anyway, so I don't think it's such a bad solution (for now).


This is the main part of the project. In my original automated elephant detection project I'd envisaged just comparing histograms!! Or failing that I'd try feature-matching with FLANN. Both of these proved to be completely rubbish in regard of detecting elephants! I tried Haar cascades too, but these had lots of false positives and literally took several weeks to train!

I'm currently working with an object detector using Histogram of Oriented Gradients (HOG) and Linear Support Vector Machines (SVM). That's working out well so far. But I'm also looking to try out using TensorFlow. That is using a pre-trained model (e.g. Inception) but with a retrained final layer.

After the object detector gives us a true or false for detection of elephant, the detection device will:

  1. upload the image to a web server (via 4G/3G/GPRS modem)
  2. notify cell phones on list of detection (via SMS)
  3. activate deterrence devices

Step one is actually a great thing for education as these images could be shared with schools!

  • 2 × Raspberry Pi 3 Model B [detection device]
  • 1 × Raspberry Pi Camera Module v2 (8MP) Standard [detection device] daytime usage [£29]
  • 1 × Raspberry Pi Camera Module v2 (8MP) NoIR [detection device] nightime usage (IR filtered) [£29]

  • First results with object detector using Histogram of Oriented Gradients (HOG) and Linear Support Vector Machines (SVM)

    Neil K. Sheridan2 hours ago 0 comments

    So I trained this one using 500 negative images from the Caltech 101 dataset . That is, specifically from the sceneclass13 section. And with 64 positive elephant images from the same dataset.

    Now the sceneclass13 section contains images mostly not containing animals! Not the best choice as we will see!

    In this first test image you can see lots of overlapping bounding boxes on the left! This was prior to applying non-maxima suppression. The same test image on the right, after applying non-maxima suppression, has just one bounding box on the elephant:

    It was pretty good at detecting elephants in random photos I downloaded!

    Unfortunately it also detected rhinos!

    Hey, well rhinos are similar looking to elephants [a bit]! But then it also detected cows too! :-(

    On the bright side, it didn't think cars were elephants!

    So in this first attempt, I made the mistake of using negative images that didn't contain objects similar to elephants i.e. animals! N.B. There was no hard negative mining done, although I doubt it would make much difference considering the negative images mostly contained no animals!

    The next attempt I made was using the Caltech 256 dataset!

    I'll add the python code and dependencies here later..

  • Thread on WILDLABS about the project

    Neil K. Sheridan3 days ago 0 comments

    I got some interesting ideas here, especially as regards security!

View all 2 project logs

Enjoy this project?



Does this project spark your interest?

Become a member to follow this project and never miss any updates