Converting an Optical Mouse Into a Digital Camera

Optical mice use image sensors similar to digital cameras, so Doctor Volt leaned into that and converted an optical mouse into a camera.

Back in the olden times, when I was but a boy, our computer mice had balls. They were mechanical devices that measured the rotation of that ball in two axes. Then optical mice came along and changed everything. They had better precision, better speed, and didn’t require cleaning. Even modern trackballs, like the kind I use to save my wrist, utilize optical sensors. Those optical sensors are similar to what you find in digital cameras, so Doctor Volt did the natural thing and converted an old optical mouse into a functioning digital camera.

An optical mouse sensor and a modern digital camera’s CMOS sensor are alike on a superficial level, because they both output a 2D array of pixels. The optical mouse looks at differences between frames to determine how far it moved and in which direction. That’s why optical mice don’t work well on very smooth, uniform surfaces: the pixels all look the same and it can’t see a difference between frames. But an optical mouse doesn’t need a very high resolution or color to do its job, so those sensors don’t come close to comparing to even the cheapest digital cameras from decades ago.

In this case, Doctor Volt used the sensor from an older optical mouse that has a resolution of 18×18 pixels. Using his trusty oscilloscope, he reverse-engineered the signal output from that sensor. It spits out an array of hex values for each of the 324 pixels for every frame. He then used an ESP32 development board to read that data and display it as an image on a web interface he had already built for another project.

The raw pixel output coming directly from the sensor is almost meaningless to human eyes, because the resolution is so low. So Doctor Volt turned to interpolation to get better results. Interpolation algorithms create new data points based on limited sets and there are several different algorithms suited to specific applications. Doctor Volt found that cubic interpolation worked well in this case. It is a bit like the “enhance video!” scenes in CSI shows and is able to create a higher resolution image based on the low-resolution frames.

That worked for things right under the sensor, but Doctor Volt wanted to use this like a camera. So he 3D-printed a mount for Raspberry Pi-style CS-mount camera lenses. That let the camera focus on subjects at a reasonable distance.

The results still aren’t great — a Game Boy Camera from the late ‘90s puts this to shame. But it is cool to see recognizable images coming from a computer mouse.


cameroncoward

Writer for Hackster News. Proud husband and dog dad. Maker and serial hobbyist. Check out my YouTube channel: Serial Hobbyism

Latest Articles