Projects / Optical metrology
Case study · Computer vision · Optical alignment

Laser Spot Alignment Vision

A webcam and a short Python program that answer an alignment question objectively: where is the center of the reference, where is the center of the laser spot, and how far apart are they? It takes a few hundred dollars of equipment at most, and it replaces a judgment call with a number.

The problem

People judge a laser spot's center by eye, and the eye is easily fooled by scatter and a bright, spread-out spot. Two observers can disagree, and neither leaves a record.

What I built

A system that locates a printed reference circle once, then repeatedly computes the laser spot's center, measures the offset, and gives an audible result while saving an annotated image of every decision.

The result

Pixel-level pass/fail against a ±12-pixel window on a 2304 × 1536 image. It stayed reliable with a bright television changing picture in the same frame.

2304 × 1536webcam image
±12 pxalignment window in x and y
3audible states: aligned, off, no spot
0custom optics or special cameras
Everyspot measurement saved as an image

The test setup

Everything is off the shelf. Click either photo to see it full size.

Test bench: a laptop running Python, a webcam on a flexible yellow tripod, a green laser pointer in a blue holder, and a printed circle target on a white board showing the green laser spot
The bench: laptop running the Python vision code, a Logitech C920s webcam on a flexible tripod, a green laser pointer in a clamp, and a printed circle target with the laser spot on it. Blue-tinted plastic over the beam acts as an inexpensive density filter so the spot doesn't saturate the camera.
Overhead view of the same bench: webcam on its tripod beside the laptop, the laser in its holder, and the target board across the table
From above: laptop and camera in the foreground, the laser in its clamp, and the target board across the table. The cluttered room behind the target was deliberate, to test circle detection in a busy, low-light scene.
Live results

Aligned and misaligned, as the system sees them

The blue circle is the detected reference, the red dot is its center, and the small dot in the spot is the computed laser center.

Laser spot on a printed circle pattern, with the detected circle in blue and the two center marks together
Within the window: the computed laser center falls inside ±12 pixels of the reference center.
Laser spot on the printed circle pattern with the computed spot center visibly offset from the reference center
Outside the window: the system records the miss and sounds a different tone.
Method

From a camera frame to a measured offset

CaptureWebcam at full resolution
→
Find referenceMedian filter, Hough circle transform
→
Classify spot pixelsGreen must clearly exceed red and blue
→
Compute centerCentroid of qualifying pixels
→
CompareOffset against ±12 pixels
→
ReportTone and annotated image
The setup
  • Logitech C920 webcam, a laptop running Python, a printed circle pattern and a green laser pointer
  • Colored plastic in front of the laser serves as an inexpensive neutral-density filter, so the spot doesn't saturate the camera
  • The reference circle is found once and reused, and only the laser center is recomputed for each frame
What the testing showed
  • A pixel counts as laser light only if its green value is high and both red and blue are below 70% of it. That simple rule, with the circle located first, held up with a changing television image in view
  • In one sample the spot was within 7 pixels of center. In another it missed by 10 pixels in x and 13 in y, which correctly failed the window
  • Scatter makes the computed center differ from where a person would put it. That's the point: the measurement is repeatable and documented, even when it disagrees with the eye
Applying it to your process

Objective alignment checks

  • Optical bench and laser alignment verification
  • Alignment of laser marking, cutting and measurement tools
  • Automated pass/fail stations with an image record for quality
  • A low-cost prototype before specifying a commercial beam profiler

For full beam-quality measurement, see Automated Beam-Quality Analysis.

Technology

Stack

PythonOpenCVHough circle transformNumPyPILLogitech C920

Need a measurement instead of a judgment call?

Simple vision systems can often replace expensive instruments or subjective checks.

Start a conversation

← Back to all projects