I have been thinking about it and came to the obvious conclusion that Santa´s job is quite difficult these days. It is not only the insane single milestone planning (who was the programme manager?). It is also the crazy requests of his customers. So I have decided to give Santa a hand this year and see what I can think of. Flying and fighting are both rather dangerous activities for children, so instead of the real thing, he will just have to make do with a similar experience.
Many will have noticed the "Hour of Code" campaign this year. One of the videos actually says that being able to program is the closest thing we have to superpowers (min 4:58). Well, that´s what I need! Therefore the solution is relatively simple, write a program that makes him think he is flying with a broom or fighting as a Jedi Knight. Easy peasy? Not quite, but not impossible.
The idea was to create a program that streams video from the webcam to the screen, tracking the plastic lightsaber and overlaying a light on it. The result may not be professional, but the effects is still kind of nice to see in real time. In order to do this I have used cv2, yet another great library available in Python. After a bit of googling, I noticed that all I have to do is to convert the RGB frames to HSV, threshold the image to single out the area with the selected colour and create a mask which can later be coloured whichever way I want. After a couple of nights
But here we are, a working copy of the program (simple colour, no glow, sorry) to play with. From here, creating a chroma key background and tweaking the code to let him think he is flying on a broom should be a breeze! And not a minute too late.
Special thanks to the people maintaing and contributing to docs.opencv.org and stackoverflow.com. It´s always great to stand on the shoulders of giants.