-
Image comparison methods
09/20/2016 at 19:06 • 0 commentsAfter testing I found histogram comparison, FLANN-based matching, and brute-force matching to be not up to the task of animal detection. Histogram comparison was heavily confounded by lighting conditions! As I guess I should have expected.! I should also note that the SIFT and SURF algorithms for feature matching are no longer available in OpenCV (they are now in opencv_contrib https://github.com/opencv/opencv_contrib) so I'm not keen on using these. Especially as they are patented, and thus I'm not sure if I consider them open-source.
Anyway, I'm currently training a Haar feature-based cascade classifier (see openCV docs here) which I've had decent results on so far with detecting leaves! Actually, if you have OpenCV you can try one of these yourself to detect cat faces, since OpenCV has pre-trained Haar cascades (see git here)!! It's not great for cat faces, but it is reasonable..
I've added a list of useful resources for common problems when attempting to use Haar feature-based cascade classifiers here. Relative path is really common problem! Also training can take just for ever - and by for ever, I do mean weeks! I'm using an Amazon EC2 instance for my training.
Problems and solutions: http://stackoverflow.com/questions/38628504/opencv-exception-after-1-day-calculation
problems and solutions: http://answers.opencv.org/question/10872/cascade-training-error-opencv-244-train-dataset-for-temp-stage-can-not-filled-branch-training-terminated-cascade-classifier-cant-be-trained-check-the/
problems and solutions: http://answers.opencv.org/question/16868/error-in-train-casacde/?answer=53164#post-id-53164
problems and solutions: http://stackoverflow.com/questions/11412655/error-train-dataset-for-temp-stage-can-not-be-filled-while-using-traincascade
-
Development timeline for elephant-detection system project
04/24/2016 at 18:55 • 0 commentsHere's my updated development timeline for the automated elephant-detection project
-
Alternative configuration to RF for communications
04/22/2016 at 19:05 • 0 commentsAlthough 3G/4G coverage is not prevalent in majority of villages afflicted by human-elephant conflict, GPRS (General Packet Radio Service) coverage is available in many of the villages. Thus, it may be possible to replace the RF communication configuration - involving elephant detection devices communicating via the field transmission stations to the village base station - with GPRS modems fitted to each elephant detection device.
In this alternative communications scenario, the elephant detection devices would transmit SMS messages, using their GPRS modems containing the following data:
- Is elephant detected (yes/no)
- Which elephant detection device is this (e.g. number 14)
These SMS messages could be sent to the village base station, where they would be processed, and the data regarding location of elephants output to the LED signboard, sent to villager's mobile phones, and uploaded to internet.
A suitable GSM/GPRS/EDGE modem is made by SparqEE [see here], along with a Raspberry Pi shield (total cost £70). Although slightly more expensive than the RF transmitters already chosen, this would eliminate the need for field transmission stations, thus reducing overall costs. In addition, the SIM900A MODEM WITH TTL is significantly lower-cost (Rs 875 / £9 gbp in India) and can be easily connected to the Raspberry Pi.
One of the main aims of the automated elephant-detection system is to be as flexible as possible regarding communication and hardware configurations, making it easier for afflicted villagers to adapt it their needs/budgets. In fact, at the final stage of the project, I plan to test multiple components, depending on what is easier for villagers to obtain locally. Thus, this alternative communications configuration will be tested subsequently to the planned RF configuration.
-
The simple method for computer-vision! Histograms!
04/22/2016 at 15:26 • 0 commentsUsing histograms for image comparison
Using Python and OpenCV we can compare the histograms of two images to see how similar they are. In this case, an image of an elephant from the database, and the image of the suspected elephant. This is is simplest method for image comparison, but also the least accurate. However, elephants are large and they are a distinct colour, so it might just be viable for the project!
Overview of method using OpenCV and Python
- Import the cv2 package
- Make dictionary to store the image histograms
- Make dictionary to store images
- Use cv2.calcHist to calculate BGR histograms from reference
- elephant images and new pi camera elephant images
- Use cv2.compareHist(H1, H2, method) to compare the histograms of
- new pi camera elephant images and reference elephant images
- Make dictionary to store results of histogram comparisons
The methods available are:
- CV_COMP_CORREL: Correlation between histograms
- CV_COMP_CHISQR: Chi-Squared distance to the histograms
- CV_COMP_INTERSECT: Intersection between two histograms
- CV_COMP_BHATTACHARYYA: Bhattacharyya distance, measuring the “overlap” between the two histograms.
-
More advanced concepts in computer vision
04/22/2016 at 14:50 • 0 commentsMore advanced work on computer vision for animal identification, presented in the paper 'Automated identification of animal species in camera trap images' could perhaps be adapted for elephant detection.
In the method outlined in this paper, we have a flow of:
1. Animal images cropped out of background (overcoming cluttered background problems)
2. Sparse coding spatial pyramid matching (ScSPM) extracts dense SIFT (Scale-invariant feature transform) descriptor and cell-structed local binary patterns (cLBP) as the local features
3. Generation of global feature via weighted sparse coding and max pooling using multi-scale pyramid kernal
4. Classify images using a linear support vector machine algorithm
-
Components for the elephant detection device
04/22/2016 at 10:56 • 0 commentsHere are all of the computational hardware components for the elephant-detection device: Raspberry Pi 3 Model B, Raspberry Pi 5MP Camera Module -> CSI interface on Pi, XBee 2mW Wire Antenna, SparkFun XBee Explorer Dongle (XBee -> USB).
Cost of computational hardware components:
- Xbee 2mW Module with Whip Antenna (Series ZB) £26
- XBee Explorer Dongle £28
- Raspberry Pi 3 £28
- Raspberry Pi 5MP Camera Module £19
Total: £101
Power supply components:
- 6W 2V Solar Panel
- USB / DC / Solar Lithium Ion/Polymer charger
- Lithium Ion Polymer Battery - 3.7v 2500mAh
- PowerBoost 500 Basic - 5V USB Boost @ 500mA from 1.8V+
Also required is a PIR sensor (£2)
-
Computer Vision for elephant-detection
04/21/2016 at 20:36 • 0 commentsThis is the most challenging part of the project. After discounting MathLab and GNU Octave, I've decided to use OpenCV in Python to compare images of suspected elephants with images of known elephants. Specifically I'm working on using feature matching ( Brute-Force matcher and FLANN Matcher); although this is rather slow. Perhaps just plain histogram comparison will be good enough. This is really fast, and elephants do have a distinct color!
Here's an outline of using FlannBasedMatcher and FLANN ( Fast Approximate Nearest Neighbor Search Library ) in OpenCV:
- Detect the keypoints using SURF Detector
- Calculate descriptors (feature vectors)
- Matching descriptor vectors using FLANN matcher
- Quick calculation of max and min distances between keypoints
- Report only "good" matches (i.e. whose distance is less than 2*min_dist, or a small arbitary value ( 0.02 ) in the event that min_dist is very small)
-
Prototyping of Communication
03/26/2016 at 20:32 • 0 commentsInitially we will use 2x 'XBee 2mW Wire Antenna - Series 2' connected to the elephant detection device and the base station (a laptop) using USB via the 'SparkFun XBee Explorer Dongle'
-
Communication Problems
03/20/2016 at 21:12 • 0 commentsUnfortunately, due to lack of 3G - or even 2G - coverage in rural villages it seems unlikely that the elephant detection devices can communicate using GSM. Instead the elephant detection devices will need to be fitted with RF wireless networking modules (e.g. XBee 1mW Wire Antenna - Series 1 (802.15.4) 1mW) to communicate (range 100m) with a longer-range transmission station (e.g. XTend 900 1W RPSMA Modem- 40 Mile Range 902 - 928MHz) which in turn will communicate with its twin in village centre. Here something like the XBee ConnectPort X2 Xbee-IP Gateway can connect to the internet using 3G/DSL/Modem.
-
Resources
03/19/2016 at 22:20 • 0 commentsResources
My storify on mitigating human-elephant conflict and the techniques which could be used to do so.. https://storify.com/4nks/human-elephant-conflict
An Improved Real Time Image Detection System for Elephant Intrusion along the Forest Border Areas http://www.hindawi.com/journals/tswj/2014/393958/
Visual Informatics Tools for Wildlife Monitoring with Citizen Scientists
Human-Elephant Conflict: Case Study from Balasore and Rairangpur division of Mayurbhanj Elephant Reserve, Odisha, India
http://www.isca.in/IJENS/Archive/v2/i4/2.ISCA-IRJEvS-2013-033.pdf
The use of audio playback to deter crop-raiding Asian elephants