Cameras & sensorsTroubleshooting

Traffic light colors flicker or shift: fix exposure against LED PWM

A traffic light's color drifts or drops out on camera. Set exposure to a mains multiple, lock white balance and trim denoise to stop the flicker.

LumaSpec Vision10 min read Share on LinkedIn

On this page 9 sections
  1. 01Decide first: two symptoms, two settings
  2. 02Why the red turns yellowish
  3. 03Why the color vanishes and creeps back
  4. 04Worked example: 30 fps camera, 8 ms exposure, red signal on 50 Hz mains
  5. 05Set exposure to a multiple of the half-cycle
  6. 06Lock the color pipeline so the shift stays gone
  7. 07When you control the LED, remove the beat at the source
  8. 08The next step
  9. 09Questions

A camera that watches traffic signals — for intersection monitoring, signal-state detection or driving-data collection — throws up two failures that look like sensor faults. Red reads back yellowish, and the lit color drops out of some frames and then creeps back although the signal never changed. Both are camera-side effects, and both are fixed with settings rather than hardware swaps. The dropout is a beat between the signal's LED driver and your exposure window; the hue shift is the color pipeline — auto white balance and chroma denoise — reacting to a small source whose brightness changes frame to frame. This guide gives you the exposure values to set on 50 Hz and 60 Hz supplies, the order in which to test the color settings, and a pass bar to confirm the fix.

Decide first: two symptoms, two settings

Fix the exposure first, then judge color. A source whose brightness holds still leaves the color pipeline nothing to chase, and most of the yellowish cast goes with it. The table maps each symptom to its cause and the value that fixes it; the sections after it give the tests in the order that finds the fault fastest.

Symptom Most likely cause Setting Value to set
Red reads yellowish Auto white balance and chroma denoise reacting to a source whose brightness changes frame to frame White balance, chroma denoise Fixed gains calibrated on a gray patch; chroma denoise at minimum
Lit color drops out, then creeps back Beat between the signal's LED driver and the exposure window Exposure, manual A whole multiple of 10 ms (50 Hz mains) or 8.33 ms (60 Hz mains)

One number drives the whole fix: an exposure that is a whole multiple of the half-cycle integrates the same light in every frame, at any frame rate. That is 10 ms on 50 Hz mains and 8.33 ms on 60 Hz.

Why the red turns yellowish

Three causes, in order of likelihood.

Auto white balance re-locking. Auto white balance recomputes red and blue gains from scene statistics, and an intersection scene never stops changing: sky, asphalt, headlights, and the signal itself switching. When the red blob dims for a few frames — the beat below guarantees it — the statistics move and the gains move with them, dragging the hue. Test: lock white balance to fixed gains, run ten minutes, and see whether the cast stops wandering. The lock auto white balance procedure covers the calibration; hold the gains at runtime the way the runtime exposure and white balance control walkthrough shows.

Chroma and luma denoise. ISP denoise averages chroma across pixels and frames. A small saturated blob against gray road or dark sky gets blended toward its surroundings, and the blending strengthens exactly when the blob dims. Test: set chroma denoise to minimum and compare the lit lens frame by frame. These knobs live in the camera SDK's image-quality block, not the ROS layer, and many ROS drivers never expose them — check the driver parameter list before assuming the setting is missing, and set it at SDK level if you have to.

Chroma subsampling in the compressed stream. A compressed topic, typically H.264-class with 4:2:0 chroma subsampling, halves chroma resolution and smears a small saturated source, most visibly while it changes between frames. It shifts hue mildly; it does not remove the light. Test: subscribe to the raw image topic locally and compare. If raw is clean, raise encoder bitrate and keyframe rate, or run detection on raw and compress only the recording — the ROS compression parameter diagnosis covers the topic-side checks.

Why the color vanishes and creeps back

A signal head is an LED module driven from the mains. Full-wave rectification makes the driver's output ripple at twice the mains frequency: 100 Hz on a 50 Hz supply, 120 Hz on 60 Hz. Many modules dim further — night dimming is the common case — by chopping the output, so the light is genuinely off for part of every cycle. Your exposure integrates whatever the module emits during its window. If the window is not a whole number of chop periods long, each frame catches a different mix of on- and off-time, and brightness swings frame to frame. The camera free-runs against the mains, so the sampled phase slides slowly: the blob fades out over several frames and recovers, which is exactly the slow disappear-and-return in the recording.

T = 1 / (2 × f_mains) → 10 ms (50 Hz), 8.33 ms (60 Hz) exposure = k × T, k = 1, 2, 3…

Rolling shutter does not break the rule: rows start at different times, but an exposure spanning whole periods makes every row integrate complete cycles, so rows match as well as frames do. The same beat explains camera image flicker from mains beat and triggers, frame-to-frame brightness changes on mains lighting and the black bars a mismatched exposure leaves in some frames.

Worked example: 30 fps camera, 8 ms exposure, red signal on 50 Hz mains

Inputs, with where each comes from:

  • Supply 50 Hz → ripple at 100 Hz, period T = 10 ms (the physics above).
  • Driver chops at that 100 Hz with a 25% on-duty — an illustrative value in the range deep-dimming signal modules use; substitute your measured duty where you have one.
  • Camera at 30 fps, free-running → frame period 1000 ms ÷ 30 = 33.33 ms (typical traffic-facing camera).
  • Exposure 8 ms, chosen by auto exposure in daylight (typical default).

The rule: light captured per frame = the overlap of the exposure window with the driver's on-window, as a fraction of the exposure time.

The arithmetic:

  • On-window = 25% × 10 ms = 2.5 ms; off-window = 10 − 2.5 = 7.5 ms.
  • Worst phase — the exposure starts just as the on-window ends: captured on-time = max(0, 8 − 7.5) = 0.5 ms → 0.5 ÷ 8 = 6% of a constantly-lit reading.
  • Best phase — the window covers the whole on-window: 2.5 ÷ 8 = 31%.
  • Red brightness swings about 5:1 between frames, so the blob reads as present, dim or gone.
  • The phase walks: frames start 33.33 ms apart, and 33.33 mod 10 = 3.33 ms, so the window slides a third of the chop cycle each frame. The dark phase returns every 10 ÷ 3.33 ≈ 3 frames — about ten times a second — and clock-versus-mains drift stretches that into the slow fade.

The fix: exposure = 10 ms (k = 1). Every frame integrates exactly one chop period and captures exactly 2.5 ms of on-time: 25% of full-on, in every frame, wherever the window starts. Brightness variance collapses to the module's own driver tolerance. If the blob needs more signal, use 20 ms (k = 2) — at 30 fps that still leaves 13.33 ms of frame time for readout.

Decision: 10 ms and 20 ms are flicker-free on this driver; 8 ms, 5 ms and anything auto exposure picks are not. Price in the motion cost: 10 ms smears a car at 50 km/h — 13.9 m/s — by 13.9 × 0.010 = 139 mm. Irrelevant for signal state, decisive if the same camera reads plates.

Set exposure to a multiple of the half-cycle

  1. Take exposure off auto and set a whole multiple of the half-cycle: 10, 20 or 30 ms on 50 Hz mains; 8.33, 16.67 or 25 ms on 60 Hz.
  2. Leave readout room: keep the exposure a few milliseconds under the frame period. At 30 fps that means 10 ms first, 20 ms if the blob needs more signal; 30 ms leaves only 3.33 ms of headroom.
  3. Lock gain too. Auto gain re-brightens the dim frames and re-couples the color pipeline to the beat — the auto exposure and auto gain behavior on color cameras page explains the coupling.
  4. If flicker survives a correct multiple, the module chops at a driver frequency above the mains ripple. Measure it: drop exposure to about 0.5 ms, run the highest frame rate the pipeline allows, and read the on/off period off the blob ROI across 50 frames. Set exposure to a whole multiple of that period.
  5. Verify: record 200 frames of the static scene with the signal lit, compute the per-frame mean of the red channel in a small ROI on the lit lens, and require a standard deviation at or below 2% of the mean. Repeat for green and amber.

Lock the color pipeline so the shift stays gone

Locking is a calibration, not a menu flick. Put a gray patch where the camera sees it under real scene lighting, set white balance once against it, and store the gains as fixed values. Keep chroma denoise low on small saturated sources; luma denoise can stay at its default. Then treat the settings as part of the station: a firmware or driver update can reset image-quality defaults, re-enable auto white balance, and the cast returns with it.

When you control the LED, remove the beat at the source

On your own indicators — status lamps, panel lights, tower lights on a test station — remove the beat instead of dodging it. Drive the indicator with DC, or strobe it so it emits only inside the exposure window. A strobed light also runs brighter within its overdrive and duty cycle limits, and the controller has to match strobe duty cycle to the exposure. PWM dimming changes brightness, not hue, so a chopped indicator still shows the right color — brightness is what the beat eats. Where the hue itself matters, pick the emitter by dominant wavelength rather than by rated color temperature (white LED color temperature for repeatable inspection).

The next step

If the exposure multiple holds and the gains stay locked, the fix is permanent: it works at any frame rate and on raw or compressed topics alike. If the camera cannot hold manual exposure, fixed gain and locked white balance at once, choose one that can — the area scan cameras finder filters by those controls, and the configurator starts at the camera step:

Build the whole station

The configurator matches a camera, lens, light, light controller and cables to each other, step by step, and lists only parts that fit what you already picked.

Start with the camera

Re-run the variance test on the bench before the camera goes up. For a second opinion on a stubborn unit, reach the applications team through the contact page, and the cameras topic page collects the neighboring checks.

Questions

Does a higher frame rate stop the color dropout?

No. Frame rate changes how often the sampled phase repeats, not how much light each frame integrates. A 60 fps camera with a 16 ms exposure still catches a changing mix of LED on- and off-time. The exposure duration is the lever: keep it at a whole multiple of the driver period and the dropout stops at any frame rate you run.

What exposure values work on 60 Hz mains?

Use whole multiples of 8.33 ms: 8.33, 16.67 or 25 ms. At 60 fps only 16.67 ms fits per frame, so 8.33 ms is the practical choice there; at 30 fps, 16.67 or 25 ms both leave margin. Confirm with the red-channel spread test: under 2% standard deviation across 200 frames means the beat is gone.

Why does the red signal look orange even in stable frames?

Traffic-signal red is a narrow-band LED near 625 nm, and auto white balance judges it against a daylight scene. If the red gain is calibrated low, the blob renders orange in every stable frame. Calibrate gains on a gray patch under the real lighting, lock them, and confirm an IR-cut filter is fitted; missing IR filtration inflates red under sunlight.

Can I repair the dropped-out frames in software afterwards?

Only partially. A frame that landed during the driver's off phase contains none of the signal's light, so no post-processing recovers it. Per-frame normalization can even out brightness for a detector, but the color information in a dropout frame is gone. Fix the exposure window first; then software correction has real data to work with.

My camera has an anti-flicker mode. Is that enough?

Usually yes for mains-driven sources: a 50/60 Hz anti-flicker mode snaps exposure to the same 10 ms or 8.33 ms multiples recommended here. Check two things: that the mode is enabled rather than auto-detected, and that it survives firmware updates which reset image settings. If the signal head chops at a driver frequency above the mains ripple, the mode cannot match it and you need the manual multiple.