Catch Me if You Can

What is the most important thing in life except food and sleep? It’s catching laser dots. Let us try to do that.

However every time you try to catch a dot with a paw, you fail, the dot slips out. That’s a wrong way. It is better to shoot a video and detect coordinates of the dot. If you know where it is, it is yours.

We detect a laser dot in every frame. How do we do it, you will ask? We simply detect the region with maximum intensity in it, especially in the red channel.

Here is the sample frame:


We can view a color image as the 3d array (width x height x 3), that’s 3 two-dimensional pictures in red, green and blue lights respectively. Let us take the red channel only:


Guess where is maximum value here?

That’s right, where laser dot is. Actually, we can simply take the maximal possible value of a pixel in a grayscale image – 255. Here are highlighted pixels having this value:


And now grab it!!!


Got it! That was simple.

Now we can carry this operation on every frame of a video, highlighting the detected dot and drawing detected positions from the previous frames, thus having the laser dot’s motion trajectory.

Here is the whole processed video.