isabeli-k

Because not all Kangaroos
are Astronauts…

Day 1

Here we go…

Last Saturday, my partner pitched this project idea: “How about making a Theremin emulator that uses a webcam to track hand movements?” Now, if you’re thinking, “What on earth is a Theremin?” — well, welcome to the club! I had to look it up too. A few YouTube videos later, I learned that the Theremin is an electronic musical instrument controlled without physical contact by the performer that produces sounds that could wake the dead and possibly annoy the living. But hey, as a learning project, I figured it’d be great.

So here we are. First things first, I needed to pick the right tools for the job. After some digging, I decided to go with OpenCV and (hopefully) TensorFlow Lite. Fingers crossed they do the trick (or rather if I can handle them).

First Commit: After writing some test code, I checked if the webcam was actually working. Success! I then thought, “Great! Now let’s see how fast this thing runs.” I coded a quick FPS counter, and the terminal showed a smooth 31 FPS. Not bad! This project was actually going… well? (Famous last words, right?)

Now, for some background on my “workstation.” I sit sandwiched between two giant windows: one in front of me, the other behind. Living in the UK, I’m usually blessed with grey, cloudy skies, but today the sun decided to make a surprise appearance. My trusty webcam (a cheap and chearfull Logitech C270, if lsusb is to be believed) was catching direct light from behind.

Cue my partner, who wandered over to fiddle with the router (I’m apparently the household “Wi-Fi whisperer”). Mid-tinkering, they ended up blocking the backlight from the window. All of a sudden, my FPS reading dropped from 31 to 14. “Huh?” As soon as they moved, the frame rate jumped back up to 31. I realized that the camera performed better when it had my well-lit face to focus on, and worse when the light dimmed. I suppose my glowing personality didn’t quite cut it!

Here’s the science I uncovered:

“There’s also a direct relationship between a camera’s framerate and exposure time. Most webcams are going to shoot at 30 or 60 fps. The darker your setting, however, you’ll need a longer exposure time and a wider aperture properly illuminate your shot.

For all you math-inclined folks, the maximum framerate can’t surpass one divided by the exposure time. So for example, if the max fps of your webcam is 60, but your exposure time is 200ms (milliseconds) to get a well-lighted image, your webcam is not going to run at full fps because it’s working hard to make what’s on the screen as well-lit as possible. In other words, the framerate drops in low light to properly expose the video frames.”

(Reference: https://www.pcgamer.com/does-lighting-affect-fps-on-webcams/)

I also discovered my camera can supposedly reach 60 FPS, which means it’s lagging behind. So I have to tweak that… but not today!

By the way, the woman in the photo below is Alexandra Stepanoff playing the Theremin. 1930.

Alexandra-Stepanoff

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *