A depth camera that images the far wall cleanly and returns holes exactly where your part sits is not broken, and the part is not at fault. Auto gain is exposing for the background, the projector's return from a close surface arrives several times brighter than anything the loop metered for, and those pixels clip into invalid depth. Back the part off to about a metre and it reappears, patchy but present. This guide gives the causes in order of likelihood, the sensor options that set IR gain and exposure by hand, a worked case that cut gain from 400 to 100 and recovered the 0.6 m minimum range, and the checks that keep the far scene alive afterwards.
The symptom: near range invalid, far range clean
The failure is distance-driven, and that signature separates it from the other depth problems. At 0.6 m the part's pixels return invalid depth — zeros, holes, or a low confidence flag. At 1.0 to 1.1 m the same part, same lighting and same pose fills in. The far background stays solid throughout.
Open the IR or mono stream if your SDK exposes one and the mechanism becomes visible: the near surface sits pinned at the top of the code range while the background sits mid-scale. A pinned pixel cannot produce a correlation peak, so the matcher discards it. In the field case below, the device's stated minimum was 0.6 m; usable depth only started at 1.0 to 1.1 m until gain was corrected.
Why auto gain kills the near range
An IR projector lights the scene, and the imager receives back, per pixel, light in proportion to 1/r². Halve the standoff and the same surface returns four times the signal. The auto exposure and gain loop meters the whole frame or a large region of it, so the background — the majority of pixels — sets the level, and the near part arrives already overexposed.
Structured-light metrology work treats exposure as a first-order input to measurement quality, and scanner error studies list exposure time and gain alongside aperture as drivers of dataset noise, so this setting carries as much weight as any optical choice. Between the 1.1 m at which the case camera worked and the 0.6 m it needed, returned light grows by (1.1 / 0.6)² = 3.36, about 3.4 times. No setting chosen for the far scene survives that on its own.
Causes in order of likelihood
- Auto gain serving the background. The most likely cause whenever the far scene is clean and the near part clips in the IR stream. Test: hold a matte white target at the near range and watch the IR image; a target pinned at the code ceiling confirms it.
- A high fixed default gain. The field unit shipped at a gain of 400, tuned for mid-range targets; the SDK's own sample works at 100. Test: query the option's current value before changing anything.
- Depth mode extending the minimum. On this camera family the minimum depth distance is a function of depth resolution, and the lowest mode reaches closest. Test: switch to the lowest depth mode and retest at the near range before touching gain.
- Light starvation, the opposite failure. Dark, matte or IR-absorbing parts return too little signal at every distance. Test: double the exposure; if the holes shrink everywhere, you need more light, not less gain.
- Auto exposure unavailable. On the field unit the auto-exposure options were not supported at all, so the camera could never protect itself. Test: enumerate the sensor's supported options first; that list is the boundary of what you can tune.
The fix: manual IR gain, then exposure
The gain and exposure options live on the depth sensor, and on this SDK family their names carry the imager generation and the left–right IR pair rather than the word "gain": the options are r200_lr_gain and r200_lr_exposure. Ask the device which options it supports, set the values with the stream stopped, then start streaming — the same initialization order that fixes 2D cameras, as set manual exposure before streaming covers. In a two-imager rig, set each imager separately; setting auto exposure per stereo camera in a depth rig shows the per-sensor pattern.
int ir_gain = 100; // device default was 400
int ir_exposure = 70; // SDK sample value, in device counts
if (depth_sensor.supports_option(r200_lr_gain)) {
depth_sensor.set_option(r200_lr_gain, ir_gain);
}
The test that proves it: with the stream running, hold a matte white target at the failing range and check the IR image's brightest pixels. Before the change they pin at the code ceiling; after it they should peak in the top quarter of the range without touching it. Keep your eyes out of the emitter line while you work at close range — the IR projector runs at full power invisibly.
If the unit cannot be tuned into range, the standoff is wrong for its envelope. A projected structured-light 3D camera such as the MV-DPS200P-02 or a laser galvanometer stereo unit such as the MV-DLS300P-04 covers a different envelope; industrial 3D camera selection: stereo, ToF or structured light matches sensor type to standoff.
- Type
- Stereo / structured light
- Type
- Stereo / structured light
Worked case: recovering 0.6 m depth by cutting gain 400 to 100
Inputs. Stated minimum range: 0.6 m. Usable range before the change: 1.0 to 1.1 m, found by backing the target away until depth filled. Default IR gain: 400, read from the option. New IR gain: 100. Exposure: untouched — the auto-exposure options were unsupported on this unit, and the SDK sample's companion value of 70 counts was not needed.
Rule. Signal per pixel scales with gain × exposure / r². To image at r₂ a target that only worked at r₁, cut gain by at least (r₁ / r₂)² so the near signal lands at or below the level already known to work.
Arithmetic. Light growth from 1.1 m to 0.6 m: (1.1 / 0.6)² = 1.833² = 3.36. Gain cut: 400 / 100 = 4. Net near signal after the change: 3.36 / 4 = 0.84 of the working level — 16% of margin, enough to clear the clipping without starving the pixel.
Result. Solid depth at 0.6 m, far scene unchanged, because the background had light to spare.
Decision. Every halving of standoff costs a factor of 4 in gain or exposure. When the needed cut runs past the gain option's minimum, take the rest out of exposure; when both sit at their floor, drop to the lowest depth mode. Both checks — near target below the code ceiling, far background above the noise floor — must pass on one setting.
Resolution is the second lever
Depth resolution sets the minimum range through the matcher's disparity search limit:
Halving the pixel resolution halves f_pixels, so with the same disparity limit the minimum range halves — the family's guidance to run the lowest mode (QVGA-class, 320 × 240) for the closest depth is this geometry, not a workaround. The price is precision: depth uncertainty grows with Z² / (f_pixels × baseline), so reach gained this way arrives as coarser Z steps. Use the low mode to close a range nothing else reaches; return to full resolution when depth values feed a tolerance decision, and read 3D point cloud x y z resolution settings without distortion before resampling anything.
When lowering gain is the wrong fix
Dark or IR-absorbing parts fail everywhere, not just near. Starvation and clipping sit at opposite ends of the same curve. If the part returns no depth at any standoff and raising exposure shrinks the holes, the answer is more light — a brighter projector setting, a longer exposure within the frame budget, or a shorter standoff — never less gain.
Shiny curved parts clip locally. Glints saturate individual pixels wherever the specular lobe lands, and a gain cut helps only slightly. Change the geometry: tilt the part a few degrees or cross-polarize the path. Edges add their own artifact — flying pixels between object and background in stereo depth — which no gain value removes.
ToF cameras follow different rules. A time-of-flight unit measures phase, and its near limit comes from the modulation scheme and multipath rather than disparity search; gain still clips, but the stereo geometry above does not transfer. The MV-DT01WMU is a ToF sensing camera of this kind.
- Type
- Depth / ToF camera
External lighting moves the knob to the controller. When the IR light is a separate unit rather than a built-in projector, intensity belongs to the light controller, not the camera: halving the standoff calls for a quarter of the light output. A 2-channel 24 V digital controller such as the LS-CTL-0487, rated 240 W, dims the illuminator straight from the program.
- Output
- Constant current, Constant voltage 24 V
- Channels
- 2 channels
- Control
- Digital
Checks before you lock the setting
- Enumerate the supported options first. The field unit exposed no auto-exposure options at all; manual was not a preference but the only mode.
- Set values with the stream stopped, start, and judge on the image: near-target peak below the code ceiling, far background above the noise floor.
- Log gain, exposure and the firmware version together. Option behaviour shifts when firmware and SDK drift apart; 3D camera header version mismatch covers the alignment.
- Retest the far scene. The cut that saves 0.6 m can starve 4 m; if both ends must work, bracket exposures and merge the depth — structured-light scanners commonly stack at least three exposures for exactly this.
- Watch the frame rate after raising exposure: at 30 fps the frame budget is 1 / 30 s ≈ 33 ms, and exposure above it caps the rate, as depth camera frame rate drops when exposure caps the FPS explains.
- Leave every auto mode off in production. Drifting auto gain caused this failure, and camera image brightness drifts over time shows the same root cause on 2D cameras.
- Mask residual invalid pixels with the confidence map instead of interpolating; 3D camera confidence image values: decode bitflags and mask bad pixels gives the decoding.
Position the camera so the part sits inside the corrected range with margin, not at its edge — the 3D camera working distance and positioning guide covers standoff, angle and mount. Then work through the 3D sensors category or the camera finder for a unit whose range brackets your part, and if the numbers still do not close, send the part, the standoff and the two gain readings through the contact page — we will size the sensor with you.
Laser profilers and stereo 3D cameras
170 models · from $699.00Questions
What IR gain value should I set first on a depth camera?
Start at a quarter of the default and step from there: the field case moved from 400 to 100 in one step and recovered 0.6 m. If the default is unknown, open the option in the SDK, note its minimum, and halve the current value until the near target stops clipping in the IR image. Stop as soon as depth fills; going lower only starves the far scene.
Why does the camera expose for the background instead of my part?
The metering region covers the whole frame or a large region of interest, and the background usually owns most of its pixels, so the loop settles on a gain that mid-tones the far scene. Your part occupies few pixels and returns several times more light per pixel, so it clips before the loop reacts. Some cameras let you shrink or move the metering region onto the part; where that option does not exist, manual gain is the stable answer.
Is the exposure option in microseconds?
Not on this family: the sample writes 70 in device counts. The count-to-time mapping is internal to the sensor, so treat exposure steps as relative values rather than durations. One practical consequence: gain changes brightness without touching integration time, so gain never adds motion blur, while a longer exposure does. Work in gain first when the part or rig moves, and reach for exposure when the signal is simply too small.
Will lowering the depth resolution really bring the minimum range closer?
On stereo and structured-light cameras, yes. The minimum range is focal length in pixels times baseline, divided by the largest disparity the matcher searches; a lower pixel count shrinks that focal length. A QVGA-class mode at 320 × 240 halves it against VGA, so the minimum range roughly halves too. Depth precision falls by the same factor, so drop resolution only to close a range nothing else reaches.
My black plastic part gives no depth at any distance. Is this the same problem?
No — that is light starvation, the opposite failure. Clipping from excess gain breaks only the near range; a low-return part fails at every distance. Raise exposure first, then gain, and give the projector a clean angle on the surface. If the material absorbs the IR band outright, no gain setting rescues it: change the lighting wavelength or move to a laser-line profiler, which brings its own illumination.
Can I repair the missing depth pixels in software afterwards?
No. A clipped pixel never produced a correlation peak, so there is no disparity to recover; interpolation invents geometry and fails any repeatability test. Mask the invalid pixels with the confidence map and fix the capture instead — gain down, exposure down, or the lowest depth mode. Software fill is acceptable for display only, never for a measured value.



