Cameras & sensorsTroubleshooting

Auto white balance drift between frames: use one-shot instead

Continuous auto white balance re-weights red and blue gain every frame, so color drifts between frames. Rank the causes, apply one-shot mode, verify the fix.

LumaSpec Vision11 min read Share on LinkedIn

On this page 10 sections
  1. 01The symptom: the cast grows capture by capture
  2. 02What continuous auto white balance does every frame
  3. 03Rank the causes, then test each
  4. 04The fix: one-shot on a neutral reference
  5. 05Worked example: a warm part filling 70% of the frame
  6. 06Verify with a 100-frame drift test
  7. 07Which mode belongs where
  8. 08When one-shot is not the fix
  9. 09The decision, per case
  10. 10Questions

Each capture looks slightly warmer than the last, and after twenty parts a color threshold that passed an hour ago starts failing. The camera is not degrading: continuous auto white balance re-estimates the red and blue gains from every frame, and a machine-vision scene gives it bad statistics to estimate from. This guide shows you how to confirm the mode is the cause, how to switch to one-shot balance (BalanceWhiteAuto = Once in GenICam), how much a dominant part color biases the result, and how to verify the fix with a drift test. It applies to color GigE area scan cameras, USB3 cameras and smart cameras alike.

The symptom: the cast grows capture by capture

A single frame looks fine. Across a session the hue walks — in the classic case toward orange, a little more with every image — until gray surfaces read clearly warm and thresholds fail. Two details mark it as a mode problem rather than a hardware fault: the scene sits still while the color moves, and the wander resets the moment you switch the white balance mode. Brightness-only drift with the hue steady is a different fault, covered in camera image brightness drifts over time: turn every auto mode off. You may also see a step at every scene change: a new part entering the frame moves the gains more than ten idle frames did.

What continuous auto white balance does every frame

Auto white balance must decide, from the image alone, what neutral looks like. It cannot see the light, so it assumes the frame average is neutral — the gray-world assumption — or equalizes the brightest low-saturation patches. A camcorder scene with dozens of colors satisfies that roughly; a machine-vision station does not. One part, one color, one background: the average is whatever the part is, and the algorithm corrects away from it.

In GenICam, the feature standard behind GigE Vision and USB3 Vision cameras, the mode is the BalanceWhiteAuto feature with three values: Off, Once and Continuous. Continuous is the camcorder behavior: re-estimate and apply on every frame. Per-frame estimates carry sensor noise, and implementations often smooth them over several frames, so a static scene wanders slowly instead of snapping. Auto exposure and auto gain feed the same loop: when they change integration or gain per frame, the channel statistics move and the balance chases them. That pixel-weighting question is covered in auto exposure and auto gain on color cameras: which pixels count.

Rank the causes, then test each

Work down the list; the first row explains most cases.

Likely cause Test Reading
BalanceWhiteAuto set to Continuous Capture 100 frames of a static gray card and plot the per-frame mean of R and B Means wander more than 1-2 counts (8-bit) while the scene sits still: the mode is the cause
Scene composition changes part to part The same plot while loading different parts A step at every part change: scene statistics, not noise
Light output or spectrum moves Freeze the gains (Off plus fixed BalanceRatio) and keep capturing the same card for 30 minutes Still drifts with gains frozen: the light or its warm-up, not the camera
Auto exposure or auto gain also active Turn both off, repeat the 100-frame plot Drift stops: the exposure loop was feeding the balance loop

If the drift is periodic rather than one-way — bands that come and go — check mains flicker first: camera image flickers: causes and fixes for mains beat and triggers. A constant-current stage from the light controllers range cuts the flicker path and the supply-induced wander; the warm-up part is handled by waiting.

The fix: one-shot on a neutral reference

  1. Place a matte gray card under the production light, in focus, covering about a third of the frame. Give the light 10-15 minutes of warm-up first, so the balance is taken against a settled LED.
  2. Set BalanceWhiteAuto to Once. The camera balances on the next captured frame and then holds the gains.
  3. Read the gains back: pick the channel with BalanceRatioSelector (typically Red and Blue) and record both BalanceRatio values in your station configuration.
  4. Set BalanceWhiteAuto to Off and write those two values at every startup. Nothing can move them now — not the scene, not the warm-up transient, not a mode race with auto exposure.
  5. Remove the card and run the drift test in the next section. If you would rather derive one fixed value and keep it, the lock auto white balance to a fixed value article walks that variant.

Smart cameras expose the same three modes in their imaging settings, labelled auto, one-push and manual; the names differ, the behavior does not. If your camera hides the gain read-back, the FAQ fallback does the same job by hand. And if you are speccing a color station, these are the typical starting points:

Area scan camerasHikrobot MV-CU020-90GC 2.5 MP Area Scan Camera, GigE, GMAX4002, ColorMV-CU020-90GC
Sensor format
1/1.7"
Lens mount
C-mount
$309.00View part
Area scan camerasHikrobot MV-CS200-10GC 20 MP Area Scan Camera, GigE, IMX183, Color, BasicMV-CS200-10GC
Sensor format
1"
Lens mount
C-mount
$739.00View part
Smart cameras & vision sensorsHikrobot MV-SC3050XC-16M-ATN-H 5 MP color vision sensorMV-SC3050XC-16M-ATN-H
Interface
Fast Ethernet
Resolution
5 MP
$1,809.00View part

Worked example: a warm part filling 70% of the frame

Most implementations balance the whole frame: they fix the green gain and choose the red and blue gains so each channel's frame mean lands on the green frame mean. That gray-world model is enough to show the size of the bias. Real cameras weight pixels differently — center weighting and highlight rejection are common — so read these numbers as the scale of the mechanism, not as a promise for your camera.

Inputs, in 8-bit counts: the gray card reads R = G = B = 120. The warm plastic part fills 70% of the frame and reads R = 190, G = 150, B = 110. The card covers the remaining 30%. These are bench-typical values; read your own first frame and substitute.

mean_C = 0.3 × card_C + 0.7 × part_C gain_R = mean_G / mean_R gain_B = mean_G / mean_B

Applying it:

  • mean_G = 0.3 × 120 + 0.7 × 150 = 36 + 105 = 141
  • mean_R = 0.3 × 120 + 0.7 × 190 = 36 + 133 = 169
  • mean_B = 0.3 × 120 + 0.7 × 110 = 36 + 77 = 113
  • gain_R = 141 / 169 = 0.834, gain_B = 141 / 113 = 1.248

The neutral card now reads R = 120 × 0.834 = 100 and B = 120 × 1.248 = 150: a 50-count blue bias on the one surface your thresholds treat as neutral. The algorithm pushed away from the warm part and cooled everything else. Now the next product's smaller part fills 50% of the frame instead of 70%:

  • mean_G = 0.5 × 120 + 0.5 × 150 = 60 + 75 = 135
  • mean_R = 0.5 × 120 + 0.5 × 190 = 60 + 95 = 155
  • mean_B = 0.5 × 120 + 0.5 × 110 = 60 + 55 = 115
  • gain_R = 135 / 155 = 0.871, gain_B = 135 / 115 = 1.174

On the card that is R = 120 × 0.871 = 104 and B = 120 × 1.174 = 141, against 100 and 150 before: a 9-count swing in blue and about 4 in red from a scene change alone, with the light untouched. If your color thresholds sit inside ±10 counts, continuous auto white balance cannot hold them across ordinary part-mix changes. The swing scales with how far the part sits from neutral and how much its coverage changes, so run the same three lines with your part's counts before trusting continuous mode near a color threshold. Freeze the gains; that is the whole decision.

Verify with a 100-frame drift test

Freeze the gains, put the gray card back, and capture 100 frames — about 3.3 s at 30 fps. Plot the per-frame mean of each channel. Accept when frame-to-frame means hold within 1 count and a straight-line fit across the 100 frames shows no slope. Then let the station run a 30-minute soak: R, G and B means must not move more than 3 counts in total.

A station that passes both will hold color thresholds; a station that fails the soak with gains frozen has a light problem, not a camera problem. To carry evidence per part, read the gains at startup and write them into the image header or recipe record — programmatic camera white balance control: verify settings shows the read-back pattern.

Which mode belongs where

Mode (BalanceWhiteAuto) What it does Use it when
Continuous Re-estimates gains from every frame Bench setup, preview and focusing; stations where the spectrum genuinely changes and color is only ever relative
Once (one-shot) Balances on the next frame, then holds Installation calibration, after a light or lens change, per-batch re-balance
Off plus BalanceRatio Gains fixed by your written values Production color inspection, color matching, any measurement with count-level color thresholds

Frozen gains only hold color while the light holds still. Calibrate after 10-15 minutes of warm-up, shroud the station from ambient, and drive the light from a constant-current stage so intensity does not wander with the supply. The LS-CTL-0180 is a 4-channel constant-current controller rated 120 W for 24 V lights:

Light controllersConstant current controller, 4 ch, 120 W, 89 x 147 mm, for 24 V lights (LS-CTL-0180)LS-CTL-0180
Output
Constant current
Channels
4 channels
Control
Digital
Feature
Constant current
$359.00View partBuild a system with it

If the spectrum itself matters and not just intensity, pick the light by its color specification first — white LED color temperature: specify repeatable inspection explains what to ask for.

When one-shot is not the fix

  • Gains frozen and the color still moves: the light is moving, not the camera. Re-run the gray-card soak with BalanceRatio written and the mode Off; if R, G and B still walk, hunt the light — warm-up, a leaking window, ambient mixing with production lighting, an LED nearing end of life. Shroud or replace, then re-run the one-shot.
  • The cast is periodic: bands that appear and vanish track the mains or another machine's drive. That is the flicker fault from the causes table, and it is fixed on the drive side, not in white balance.
  • You would rather correct in software: with stable gains, a software white balance against a captured reference is deterministic and reversible, at the cost of headroom. The trade-offs sit in light balancing filter or software white balance for color correction.
  • Gains read back but the image ignores them: another auto mode is repainting color after the fact. Color gain and hue show no visual effect: stop auto first is the article for that override.

The decision, per case

  • Gradual cast across captures on a static scene, thresholds failing late in a session: BalanceWhiteAuto to Once on a warm, in-focus gray card, record the two BalanceRatio values, set the mode to Off and write them at startup. About fifteen minutes of work, and the drift is gone.
  • Scene composition changes part to part and thresholds are count-level: the same freeze, calibrating on the card only, then the 30-minute soak before release.
  • Gains frozen and the color still moves: stop adjusting the camera. Fix the light — constant-current drive, warm-up window, shrouding — then re-run the one-shot and the soak.
  • A color station still on the bench: continuous is fine for setup; switch to one-shot before the first production part.

For new hardware, the camera finder filters color models by interface and shutter, and the configurator starts the chain at the camera step. More camera-side fixes sit on the cameras topic page.

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

If a station keeps drifting after the light is settled, send the 100-frame plot through the contact page and we will help you read it.

Questions

Does one-shot white balance survive a camera power cycle?

Do not rely on it. Gains revert to the camera's stored parameter set at power-up, and a one-shot you ran in the lab is not in that set. Read BalanceRatio for red and blue after the one-shot, store the two values in your station configuration, and write them back at every startup with BalanceWhiteAuto set to Off. The calibration then lives in your file, not in the camera's memory.

What reference should the one-shot balance against?

A matte neutral target under the production light: an 18% gray card or a white ceramic tile. Keep it below sensor clipping — a blown highlight carries no color information and skews the estimate — and let it cover about a third of the frame, in focus. Avoid colored targets, glossy metal and the part itself unless your software balances scene-relative by design.

Why does the drift turn the image orange, not blue?

The cast runs opposite to whatever color dominates the scene average. Auto white balance pushes away from the dominant tint: a scene full of cool, blue-ish content — bare steel, blue solder mask, cold-white background — makes the loop raise the red gain, and gray surfaces drift orange. Dominant warm content does the reverse and pushes images cyan. Reading the cast direction tells you which color is swamping the statistics.

My camera only offers auto and manual white balance. What then?

Do the one-shot by hand: aim at the gray card, let auto white balance converge on a captured frame, read the resulting red and blue gains, copy them into the manual gain fields, then switch the auto mode off. The result is identical to a one-shot — a balance taken once and frozen. If the software gives you no gain read-back, capture the balanced frame and keep it as your reference image.

How often should the one-shot be repeated?

Anchor it to events, not to the calendar: re-run after any change to the light — a new model, a replaced LED, a changed current or pulse width — after a lens or filter change, and whenever the logged gray-card check moves more than 2 counts. With the mode Off and fixed BalanceRatio values, nothing drifts on its own; a station that passes the 30-minute soak needs no schedule.