Testing The Living Headlights app at home

Do not run out onto the highway at night to point your laptop's webcam into the headlights! We can devise more convenient and safer ways to test The Living Headlights, even if you have no car or do not drive.

A pair of LED flashlights is a good proxy for a pair of headlights. A flashlight with many LEDs (for example, 19) is preferable because it creates a denser circle of light that is more likely to be detected as exactly one blob. To ensure that the distance between the two flashlights remains constant, we can attach them to a rigid object, such as a board, using brackets, clamps, or tape. Here is an image of my flashlight holder, seen from the side:

Testing The Living Headlights app at home

The next image shows a frontal view of the flashlight holder, including a decorative grill:

Testing The Living Headlights app at home

Set up the lights in front of the webcam (parallel to the webcam's lens), run the app, and make sure that the lights are being detected. Then, using a tape measure, find the distance between the webcam and the center point between the front of the lights, as seen in the following image:

Testing The Living Headlights app at home

Type the distance in the text field and click on Calibrate. Then, move the lights nearer to the camera or farther from the camera (but keep them parallel to the camera's lens). Check that the app is updating the distance estimate appropriately.

To simulate colored car lights, place a thick piece of colored glass in front of the flashlights, as close to the light source as possible. Stained glass (the kind used in church windows) works well and you can find it in craft supply stores. Colored lens filters for photography or videography should also work. They are widely available, new or used, from camera stores. Colored acetate or other thin materials do not work well, as the LED lights are very intense. Here is an image of my lighting setup with an orange or amber colored stained glass filter:

Testing The Living Headlights app at home

Here is a screenshot showing the app's analysis of the same lighting setup:

Testing The Living Headlights app at home

Check that the app is reporting an appropriate color for the detected lights. Depending on your particular camera's color rendition, you might find that you need to adjust some of the hue and saturation thresholds in your detectAndEstimateDistance method. You might also want to experiment with adjusting the attributes of your SimpleBlobDetector_Params object (in the initializer) to see their effects on the detection of lights and other blobs.

Once we are satisfied that the app is working well with our homemade apparatus, we can step up to a more realistic level of testing!