3D visionTroubleshooting

Stereo rectification horizontal lines: fix camera order and baseline

Horizontal lines or a blank rectified stereo pair mean swapped camera order or a baseline mismatched to the calibration target distance. The tests and the fix.

LumaSpec Vision11 min read Share on LinkedIn

On this page 8 sections
  1. 01Why does a good-looking calibration produce horizontal lines?
  2. 02Which camera is camera 1 in a stereo rig?
  3. 03How far apart should the two cameras be?
  4. 04Where should the calibration target sit during capture?
  5. 05What does the blank output versus the full view tell you?
  6. 06How do you fix the rig and prove the fix worked?
  7. 07When is the hardware at fault instead of the calibration?
  8. 08Questions

You calibrated the pair, the reprojection errors look healthy, the extrinsic view shows a tidy rig — and the rectified preview returns horizontal lines of color, or a blank pair that only fills in when you force the full output view. That combination has one dominant cause set: the remap is sampling outside the source images because the camera order does not match the calibration, or the baseline is wide relative to where the calibration target sat. This guide gives you the three one-minute tests, the baseline and capture-distance numbers, and the fix, in the order that costs the least time.

Why does a good-looking calibration produce horizontal lines?

Because the fault is almost never in the calibration math. Horizontal colored lines mean the rectification remap is sampling outside the source images, and with low reprojection errors that points at camera order or a baseline that is wide for the distance the target sat at.

Rectification reprojects both images onto a common plane so a physical point lands on the same row in both; the image rectification overview on Wikipedia has the projection algebra. Your calibration produced rotation matrices, the matrices build two remap tables, and the tables are applied pixel by pixel at runtime. Colored stripes are a remap row wrapping across the whole image width; a black output is nearly every sampled coordinate landing outside the frame.

A low reprojection error rules out neither. The error is computed on the calibration pairs, in the order you fed them, so a rig fed right-camera-first converges just as happily on a consistent but mirrored geometry. And a target captured at 150 mm on a rig with a 150 mm baseline can calibrate cleanly and still be useless at 600 mm, because the poses the solver saw are not the poses you now sample.

Which camera is camera 1 in a stereo rig?

Camera 1 is the camera on the left as seen from behind the rig, looking in the same direction the cameras look. Keep that order through capture, calibration, rectification and disparity, and disparities stay positive; reverse it and depth collapses.

The swap does not have to be physical. Feeding the images in the wrong order to a calibration built the same wrong way "works" internally and fails the moment any downstream code assumes the usual left-reference layout. The fastest test costs thirty seconds: exchange the two inputs and re-run. If the stripes clear or the blank pair fills in, the geometry was never the problem — make the order permanent instead. Tape an L and an R on the housings, and pin camera identity by serial number in the capture configuration so a reboot or a re-plugged cable cannot silently reverse the pair.

Capture discipline is covered step by step in the stereo calibration from paired checkerboard images guide.

How far apart should the two cameras be?

Set the baseline between 1/10 and 1/30 of the working distance: 20-60 mm for a rig measuring at 600 mm, 33-100 mm at 1,000 mm. Under 1/30 the depth precision thins out; over 1/10, occlusion and close-range calibration fight you.

The band comes from the disparity equation:

d = f_px × B / Z ΔZ ≈ Z² / (f_px × B) (depth change per pixel of disparity error)

where B is the baseline, Z the distance to the part, f_px the focal length in pixels, d the disparity in pixels, and ΔZ the depth change that one pixel of disparity error produces. At B = Z/20 a typical rig returns around 100 px of disparity — comfortable for sub-pixel matching — and per-pixel depth uncertainty near one hundredth of the range. Where Z is measured from matters here too; the stereo triangulation world origin guide walks through the reference point.

For the same example rig at Z = 600 mm:

Baseline Disparity at 600 mm Depth per disparity pixel
20 mm (Z/30) 67 px 9 mm
30 mm (Z/20) 100 px 6 mm
60 mm (Z/10) 200 px 3 mm

Wider buys accuracy per pixel and costs overlap: occlusion zones grow on near parts and the minimum calibratable distance moves out. If a depth target pushes past Z/10, the wide baseline stereo camera selection guide covers that trade, and the stereo camera baseline distance guide works the ratio backwards from an accuracy target.

f_px comes from the lens. Pick it from part width and working distance in the calculator below; its button opens the lens finder at the result.

Lens focal length, field of view and working distance
Units
Solve for
Focal length
– mm
Field of view
– mm
Working distance
– mm
Magnification
– x
Angle of view
– °
Pixel on the part
– mm

Thin-lens model: m = sensor width / field of view, f = WD × m / (1 + m). Accurate to a few percent above about 150 mm; check the lens's minimum object distance.

Find lenses with this focal length Open the full calculator

Two identical cameras keep the intrinsics close and the remap simple. A matched pair such as the MV-CU020-90GC 2.5 MP GigE camera, global shutter, is a sound starting point for a fixed bench rig.

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
Interface
GigE
Resolution
Up to 3 MP
$309.00View partBuild a system with it

Where should the calibration target sit during capture?

Cover the distances you will measure: put half the board poses between half the working distance and the working distance itself, the rest around and slightly beyond it, tilted through all four rotations. A target captured a hand-width from the lens cannot support a rig measuring at hundreds of millimeters.

The rectifying rotations are fitted to the poses you captured, so a rig calibrated on boards at 150 mm and run at 600 mm is extrapolating — and out-of-bounds sampling is the typical result. For a 600 mm working distance, capture from roughly 300 mm out to 700 mm, and hold the working distance itself in the set: mount the rig, measure Z, and put a backdrop there. If production parts arrive anywhere from 400 to 800 mm, spread the captures across that whole span.

Keep the board sharp and large in frame at the far poses: a board that shrinks to a thumbnail at distance fails on its own, which the checkerboard target size at distance guide diagnoses. Positioning of the rig relative to the scene is the subject of the 3D camera working distance and positioning guide.

What does the blank output versus the full view tell you?

A blank pair means nearly every output pixel samples outside the source images; the full output view shows the whole remapped plane instead. Valid content that is tiny, far off-center or upside down points at an extreme rectifying rotation — swapped camera order, or a calibration that never saw your rig's geometry.

In the call your calibration tool uses, [J1, J2] = rectifyStereoImages(I1, I2, stereoParams, 'OutputView', 'full'), the full view is the diagnostic mode: it renders everything the remap touches rather than cropping to the original field. A clean pair sitting small in a corner, rotated, or inverted is the signature of geometry the images do not match. A pair that fills the frame but drifts a few pixels row-to-row is a different fault — accuracy, not geometry — and the live stereo rectification guide shows the streaming setup once the static pair is clean.

What you see Most likely cause Test that confirms it
Horizontal colored stripes in the preview Left and right feeds swapped Swap the inputs, re-run
Blank pair in the default view Remap sampling outside the images Switch to the full output view
Valid pair, tiny and off-center in the full view Calibration poses never matched the rig Re-capture boards across the working distance
Pair upside down in the full view Camera 1 is physically on the right Swap inputs, check the disparity sign
Clean in the GUI tool, blank in your code A different image order in your code path Log which serial feeds which argument

How do you fix the rig and prove the fix worked?

Swap the two inputs and re-run; if that fails, re-calibrate with boards re-captured across the working distance in your runtime camera order. Prove the fix with the row test: a feature at a given height sits on the same row in both rectified images.

  1. Label the rig: tape L and R on the housings and record which serial is which. Left is camera 1.
  2. Swap the two inputs in the failing call and re-run. If the stripes or the blank pair clear, stop and make the order permanent in the capture configuration.
  3. Check the disparity sign on a near target: with the left camera as reference it must be positive. Faults that remain after rectification are listed in the disparity map troubleshooting guide.
  4. If the swap changed nothing, re-capture 15-30 board pairs across the distance range — half of them between half the working distance and the working distance — keeping the runtime order.
  5. Re-calibrate and read the error. Aim for a mean residual well under 1 px; the calibration residual targets guide gives the pass marks.
  6. Run the row test: read one feature's row in both rectified images and require a difference of 0-1 px. Then move a target from 600 mm to 300 mm and confirm its disparity roughly doubles, 100 px to about 200 px on the example rig above.
  7. Mark both camera positions and the baseline so anyone who bumps the rig knows to say so.

When is the hardware at fault instead of the calibration?

When the rig cannot hold its geometry: a flexing baseboard, a bumped camera or a lens refocused after calibration changes the extrinsics or intrinsics that rectification depends on, and the same symptoms return. Mount both cameras on one rigid structure and re-calibrate after any contact.

Three hardware faults recreate the symptom set. A baseboard that flexes when touched changes the relative pose the calibration fixed. A bumped camera does the same in one event. A lens refocused after calibration invalidates the intrinsics, and the row test starts drifting across the day as temperature moves focus; if the drift tracks ambient temperature, the mechanism is a thermal one and the row-test trend over the day will show it.

Put both cameras on one structure. A single-base stand such as the LS-MNT-0040 machine vision camera stand — professional slide-table type, 700 mm height, 400 × 450 mm base — holds the pair rigid and lets you set the baseline by measurement instead of by eye.

Camera standsMachine vision camera stand, professional slide-table type, height 700 mm, 400 x 450 mm base (LS-MNT-0040)LS-MNT-0040
Type
Camera stands
$629.00View partBuild a system with it

Vibration is the quieter version: nothing breaks, but depth jitters. If the rectified pair is clean yet depth wobbles, the remaining causes are mechanical resonance and sensor timing — the stereo depth jitter and IMU drift troubleshooting page works through them, and the camera vibration detection guide shows how to measure the shake from frames.

If you would rather buy the geometry than build it, factory-calibrated stereo options remove the calibration step: projected structured-light and laser galvanometer cameras ship with rectification fixed at the factory baseline.

3D sensorsHikrobot MV-DPS200P-02 Projected structured-light 3D cameraMV-DPS200P-02
Type
Stereo / structured light
$8,829.00 · quotedView and quote
3D sensorsHikrobot MV-DLS300P-04 Laser galvanometer stereo cameraMV-DLS300P-04
Type
Stereo / structured light
$16,579.00 · quotedView and quote

The MV-DLS300P-04 carries a laser emitter: run it as a laser product, keep the beam away from eye level, and read the manufacturer's laser safety documentation before first power-up.

To build the pair yourself, start at the camera configurator, pick two identical bodies from the area scan cameras, or compare integrated options under 3D sensors — and put whatever you choose on one base from the camera stands before you calibrate. If a built rig still misbehaves after the tests above, the contact page reaches the applications team. The 3D topic page collects the rest of the 3D vision guides.

Questions

How many calibration image pairs does a stereo rig need?

Plan 15-30 good pairs: board flat and sharp, filling a third to two thirds of the frame, tilted so its normal points above, below, left and right of the optical axis, spread from about half the working distance to just past it. Ten marginal pairs calibrate worse than twenty sharp ones, and one blurred corner corrupts the intrinsics that rectification reuses.

Do factory-calibrated stereo cameras ever show this fault?

Rarely from geometry, because the rectification maps were computed at the factory baseline. The failure mode moves to the feed side: the left sensor enumerated as the right input after a restart, a swapped cable, or a mix-up in your capture code. Fix the order by serial number rather than port enumeration and the factory maps stay valid.

Can I rectify a stereo pair with different lenses on the two cameras?

Yes, the calibration absorbs different focal lengths, but keep them close. Mismatched lenses force the rectifying rotations to work harder, shrink the image overlap and widen the disparity search range. Two copies of the same lens keep the rectified pair nearly identical in scale, which is why a matched set is the sensible default on a fixed rig.

How often should a fixed stereo rig be re-calibrated?

After any contact, any lens refocus and any bracket change. Thermal focus drift alone moves the intrinsics across a working day, so a rig nobody touches can still need attention. A stable bench rig holds for months; run the row test weekly and re-calibrate as soon as the row difference passes about one pixel.

Why does my disparity map show negative values?

Because the right camera is acting as the reference view. With camera 1 on the right, nearer points produce negative disparities and most matching engines clamp or discard them, so the depth map collapses on close parts. Swap which image you call image 1 across capture, calibration, rectification and disparity, then re-calibrate so the extrinsics match the new order.