# LED tracking with a particle filter

Some LED bike light tracking using a particle filter:

I’ve been invited to do a lecture for Markku Nousiainen’s experimental course on computational photography next week, so I’ve been constructing some demos that display different computer vision algorithms based on the work I’ve been doing on Lirec. The idea is that they may serve as inspiration for how algorithmic understanding of images can be used for artistic purposes.

The code is part of the mysterious magic squares library.

## 2 thoughts on “LED tracking with a particle filter”

1. hi dave

could you explain in a couple of words how particle filter helps here? I read your explanation of pf and some other sources but have hard time mapping the statistical argo to what I actually see you doing and what I actually want to do myself.

I understand that black dots are “particles”, but what do they represent and how do they help to find / track the led? what are the “measurements” here exactly? how come when you move the led many particles are sort of stuck to it?

and what is the red square and why it’s not around the densest group of particles?

2. Hi Artm!

I think of it like this, not to say it’s entirely correct:

Each particle is a hypothosis of where the tracked object is in camera space. They contain a simple model of the light being moved by my hand, position and delta, which are updated every frame.

When a new observation from the camera comes in all the particles are scored given how light the pixel they are over is. Bad scoring particles are removed and either respawned near high scoring ones, or cast randomly around the screen.

We are trying to get the particles to represent a “probability density function” for the location of the light.

The reason that particle filters are better than gaussian estimations such as kalman filters is that they can approximate many different types of probability density functions – in this case many different shapes, although it’s a bit more complicated than that.

A concrete example in this case is where you move the light over a bright spot in the background. Some of the particles will stick to the background and others will track the light. You can in fact track many objects at the same time – this helps to prevent you getting stuck on local minima as the probability density function is so flexible.