01The problem
Research groups studying how insecticides and pesticides affect insects need to measure behavioral changes — the route travelled, time in flight versus at rest, speed — from experiment videos. Doing it by hand is slow and subjective, and the existing alternatives are proprietary tools with a cost per analysis and no room for researchers to add the metrics their own project needs.
The project started as my undergraduate thesis in Information Systems at UNESP (Bauru, 2024), "Ferramenta para análise comportamental de insetos" (A tool for insect behavioral analysis), advised by Prof. Dr. Marcelo de Paiva Guimarães, with the goal of an open, extensible tool that runs on any computer, with no GPU and no internet connection.
02The solution
The insect sits in a transparent, white-backed box filmed by two cameras at 90° (top and side). The software, written in Python with OpenCV and NumPy, corrects the perspective of every frame from four points the researcher marks, builds a background mask from the brightest pixels of frames sampled across the video, subtracts that mask from each frame, removes noise with a threshold and takes the centre of the largest contour as the insect position.
The top camera gives width and depth; the side camera gives height. Combined, they produce a frame-by-frame 3D route, shown in an interactive Matplotlib chart and saved as JSON. Metadata modules run on top of the route — time at each edge and in flight, speed — and researchers can add their own by dropping a Python file into a folder, with no changes to the core. Analysis profiles store the videos, box dimensions and perspective points, and a PDF report summarises the results.
03Outcome
In the thesis tests, the tool recovered the route of a fly filmed by two phones in an improvised aquarium — with reflections, shadows and tape in the background — losing it in only a few isolated frames, and registered the turns, course corrections and pauses of a cockroach in footage provided by a researcher in the field. The tests also exposed limits, such as losing the subject when it stays still along one axis.
The software was adopted by 3 pharmacology labs at UNICAMP.