DynAIkonTrap: Build your own artificial intelligence camera trap

One of the services that the Cos4Cloud project is developing, led by DynAIkon, is ready to use - A post written by Miklas Riechmann, developer at DynAIkon and Cos4Cloud team member.

The full code and an in-depth setup guide to building your own artificial intelligence camera trap are already available! The service automatically filters out most unwanted pictures (videos or images) from camera traps, keeping only the ones that are animal images. DynAIkon has led the service’s development in the Cos4Cloud project framework.

Credit: Images captured with DynAIkonTrap (top row and bottom left) and the deployed camera trap (bottom right). Backgrounds have been removed for privacy.

Have you ever wanted to record images and videos of animals in your garden? Not sure how to do it? DynAIkon may just have the solution for you! A self-built camera trap, i.e., a camera you can place in a covert location, which will automatically record animal activity. Commercial devices are available through many retailers at prices ranging from around €100 to €800 or more. Our approach is to furnish a Raspberry Pi, a type of single-board computer, with the bespoke capture software. Anyone can do it!

Commercial camera traps have the same fundamental design: a motion sensor triggers a camera to take a picture or video. It sounds like a sensible approach, but it has a few issues. Firstly, the motion sensors measure heat changes, which means many things can incorrectly cause images to be taken, including leaves reflecting sunlight. Additionally, animals that put out a small amount of heat will often be missed, because the camera trap needs a minimum heat threshold to be set. Another problem is the delay from motion being detected to the image being taken, which often results in empty images for fast animals.

At DynAIkon, in the Cos4Cloud project framework, we have tried to address these challenges by starting off with a simple thought: why use a separate component to trigger the camera; why not use the camera as its own trigger? Using this idea, we have developed an architecture that looks at motion in the camera’s field of view and runs an animal detection machine learning model on sequences where enough motion was seen. This approach means the design can be run on inexpensive hardware like a Raspberry Pi computer.

Integrating artificial intelligence in camera traps

All of the above sounds very fancy, but does it help with the problems identified at the start? This system is very different in that the camera is always on and looking for animals. When the system “thinks” it has spotted an animal, it already has the image, so there is no delay from trigger to capture.

Using artificial intelligence in a camera trap allows the system to make intelligent decisions about what it has seen. If there is a lot of motion, that doesn’t mean an animal just passed; it could have just been leaves falling from a tree. The idea is that this system can detect the difference. 

The DynAIkon team have already tested the system in their own gardens with setups that cost around £110 (€120); they have captured videos of foxes, squirrels, and pigeons, among other animals.

A modular system

At DynAIkon, within the Cos4Cloud project, we have designed the system to be very modular. You can think of it as a series of filters applied to a video stream, where a video consists of a series of frames. These filters allow each of the video frames through or filter them out. This pipeline of multiple filters also uses different techniques to smooth out detections in time, including Infinite Impulse Response (IIR) digital filtering. The system also supports the use of USB attached sensors and DynAIkon have even developed a sensor board to compliment this camera trap design. The board can record various environmental sensor values, including air pressure, humidity, temperature, time, location, sun angle and height above the horizon, and more.

Credit: Images captured with DynAIkonTrap. Backgrounds have been removed for privacy.

When the camera captures the individual frames that make up the video it encodes them in the H.264 format — the technique used in MP4 video files. This format contains motion vectors, which describe how pixels move from one frame to the next. The motion detection module takes advantage of this to get an idea of movement in each video frame. If sufficient consistent motion occurred, the frames are then passed to the animal detector. For the artificial intelligence element, we have trained a Tiny YOLO model — a variation of the “You Only Look Once” (YOLO) object detector — to detect animals in video frames, which tells if it is likely that any given frame contains an animal of any species. As animals are unlikely to appear in a single frame, we also label a few previous and subsequent frames as animal frames, which means we don’t need to run the animal detector on every frame where motion was detected.

A service that can continuously evolve

As the system is very modular, the artificial intelligence (AI) model can be updated and replaced as the state of the art improves. This gives DynAIkonTrap design a unique feature of possible improvements over time without buying a new product. Of course, modularity means you can easily drop in your own animal detection models if you’d like.

If you have any questions about the system or problems with the software, send an email to cameratrap@dynaikon.com.

Code and documentation available here.

Written by