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:

media-20170405-1

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:

media-20170405-2

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:

media-20170405

And now grab it!!!

media-20170405-3

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.