# MagiQuest Wand Identifier

My kids recently played MagiQuest, a game wherein people run around with "magic wands" that shoot out infrared light into sensors that activate different portions of the game. Each wand shoots out a pattern of infrared light that is unique to that wand. I'd like to write a Mathematica function that can distinguish one wand from another.

My laptop's webcamera can detect the light from the wand. Using img=Dynamic[CurrentImage[]]; I can analyze a stream of "video" from the webcam (where to process img, one has to use img[[1]] as the head of img is Dynamic.)

My question is very open-ended: how do I go about building a function that detects the pattern given by a wand? So far, all I have done is create a simple function that can detect when a light is shining on the camera in a dark room (i.e., it simply knows when the wand is shining at the camera). What is missing is a way to properly analyze the stream and detect patterns, no small job.

A significant problem: my webcam detects the infrared light as white light, so any white light can throw off the camera's detection. Bonus points for showing how to hack the camera to only recognize infrared light and disregard all other light sources.

• I would be worried about the framerate (and framerate stability) of Dynamic@CurrentImage[] ... How quickly are these wands flashing? If you record video separately, it would guarantee a stable framerate somewhere between 15-30 fps depending on your webcam and recording mode. Then you can analyse the pre-recorded video with Mathematica. Mar 20, 2015 at 18:44
• @Szabolcs, the wand's IR emission is modulated at 37 kHz according to a post here Mar 20, 2015 at 18:51
• @SimonWoods I guess that settles it. It can't be done with a webcam. You could post that as an answer. Mar 20, 2015 at 18:56
• I was worried about the stability of the framerate as well, which was one of the reasons I thought I'd ask. The answer of "you can't" isn't what I was looking for, but now I know to not waste more time trying to make it work. Mar 20, 2015 at 19:44

Even if the modulation rate were much lower you would still struggle to get it working. As Szabolcs commented, there is no guarantee that the frame rate obtained with CurrentImage is stable, which would make demodulation tricky.