Calculating distance travelled by uncontrolled animal

Hi there!

I wonder if OpenCV can actually analyze a video and calculate the distance traveled by an animal inside the cage. I have videos of a bat flying around a cage system. I am trying to quantify locomotion. I am super new to this and would love if anybody here can direct me to the right channel!

Thank you!

how accurate do you need it, and how much energy do you want to invest into this ? detecting motion, and building a trajectory from it should only take a few hours / days (assuming, you have to start from scratch)


Hi Berak,

I need it to be of publication standards. But as of now, I am open to exploring how to do this. I have video footages and hoping to analyze this.

Thank you for your reply!

Best regards.

you’d make your own life easier by posting data (source video). be concrete. this isn’t casual street cafe conversation. you should spread your stuff on the table.

first you should start by detecting those bats in a single picture, to some level of satisfaction. that’s the crucial operation.

“publication standards” still means you need to have some idea of what other “noise” there is, and how much accuracy is noticeable, and realistically achievable.

bats are flying scraps of leather with a blob of meat attached somewhere. they’re worse than cats because cats may be liquid but at least they have uniform density and are approximately convex. if you work with bounding boxes around appearances of a bat, those will depend highly on where the wings happen to be in that split second. if you need center of mass, because that doesn’t wiggle around as much, or the torso at least, you’d want to have some neural network for object detection, that has been trained to give you that specific point.

so… worst case, your bat’s “position” will be placed somewhere within a bounding sphere encompassing its spatially very sparse body. you can hope that it’ll be placed somewhere inside its core (everything excluding extremities) most of the time, and closeby otherwise.

oh and all this image processing supposes that your bat is a pedestrian, because plane-to-plane mapping is geometrically simple, no matter how the camera is looking at it.

if the bat enters the third dimension, you need 3D tracking, i.e. multiple cameras.


There is no such thing as generic “publication standard”. There is only the accuracy and reliability a scientist needs to measure whatever she is measuring. For example, it is most often not flying speed, but could be how often a stressed animal changes position in the cage.