Point autotracker
Automatically tracks points across frames in experiment videos.
I wrote this autotracker in 2016, years before DeepLabCut existed, to track the antennae of my moths. The method I used is quite nice. Using a minimal set of templates, the code learns how the antenna looks during different stages of wingbeats and under different light levels. Based on this template repository, it tries to find the antenna using a distance-minimization method.
I put in some interesting optimization here. There is, of course, a distance minimization: the template that fits the image most accurately (with the lowest distance) is preferred. But because there are multiple cameras, there can be cases where one video has a good fit and others have bad fits (which happens quite often, unfortunately). To circumvent this, I optimize not just the template fit in each video, but also how accurately the 3D point is estimated. This ensures that only points with low 3D error residuals are chosen. In addition, points tracked in one frame should be near the points tracked in the previous frame (i.e., the antennae movement has a reasonable velocity limit). I optimize all these factors together to track the antennae.
And the code worked quite well. I was able to digitize all my videos within a week or so. This is not much, considering I had 28,000 frames per video, 2 videos per trial, 4 trials per moth, and approximately 15 moths ![]()
Of course, DeepLabCut and recent machine-learning-based tracking software will do much better because they can store templates more compactly and identify features more accurately than my methods (though they take a lot more computational power). So, this code might be a relic from the past, but it is nice to see that I was on the right track ![]()
If you want to check the code, you can find it here. If you do use it for something, do shoot me a message. I would be very curious to know why ![]()