Software

The sensor has two main software components: the C code on the PIC to drive the mirrors / USB and the processing / image capture software on the PC. The PIC software is a derivation of Brad Minch's PIC18F2455 USB code that accepts requests to move one mirror and generates a sine wave on the other.

Calibration

The program supports a semi-automatic calibration system that allows easy calibration of the entire system. The user simply places a flat object at a known distance. Then the PC asks the user how far away the object is and then proceeds to perform a full scan at that distance. Once that is finished, the program again prompts the user to move the object and input the new distance. In this way, one person can perform an entire system calibration in only a few minutes.

Image Subtraction

To identify where the laser appears in an image one can use a common technique of subtracting the new image from a reference image. By using our laser position control, I place the laser at the very left edge of the image, take a reference, and then use that image throughout the rest of the scan.

Processing

To find the distance to an unknown object, one needs two things: the angle of the mirror and the x-pixel location of the point. With that, the computer looks up the two closest calibration points for that mirror angle and performs a linear interpolation to compute a distance.

Libraries

The PC code is written in C++ using wxWidgets, OpenCV, and libusb.

Downloads