3D visionTroubleshooting

Extrinsics view fails: cameraParameters needs intrinsics, world points

Why showExtrinsics fails with pose vectors alone: cameraParameters needs intrinsics and the target's world points before the extrinsics view renders.

LumaSpec Vision9 min read Share on LinkedIn

On this page 9 sections
  1. 01What the stack trace tells you
  2. 02The three field groups a pose view reads
  3. 03Test each missing field before you rebuild
  4. 04The fix, step by step
  5. 05Worked example: focal length from millimetres to pixels
  6. 06Checks before the next call
  7. 07When the field set is complete but the picture is wrong
  8. 08Keep the intrinsics with every extrinsic set
  9. 09Questions

You calibrated the camera outside MATLAB — a C library, a Python script, another tool — and carried the results over as rotation and translation vectors. The viewer then stops before drawing anything: showExtrinsics fails inside computeConvexHull with "Index exceeds matrix dimensions". The vectors are not the problem; everything the object never received is. This guide names the fields a pose view actually reads, shows why the target's geometry is one of them, converts an external calibration into a complete object with the pixel arithmetic shown, and ends with the checks that catch the failure before MATLAB does.

What the stack trace tells you

The failing call builds the object from two name-value pairs and nothing else:

% om: double, N-by-3 — one Rodrigues (axis-angle) rotation vector per image
% T : double, N-by-3 — one translation per image, in the board's length units
cam = cameraParameters('RotationVectors', om, 'TranslationVectors', T);
showExtrinsics(cam, 'patternCentric');

The constructor accepts it: pose vectors alone make a valid partial object. It dies later, while the inputs are parsed, before anything is drawn. parseInputs hands the object to computeConvexHull, which takes the convex hull of the calibration target's world points to decide how much of the world to show. With poses only, that array has zero rows, the hull routine indexes past its end, and MATLAB reports an index error instead of anything about a missing field.

Two conclusions follow. First, your rotation and translation data is probably fine — the failure is absence of data, not bad data. Second, the view style is no escape: the hull runs during input parsing, ahead of any drawing, so 'cameraCentric' meets the same empty array. Choose the view for the physics instead — patternCentric when the target sat still and the camera moved, cameraCentric when the camera was fixed and the target moved.

The three field groups a pose view reads

A pose view reads three groups of fields, and the failing object carries only the first.

Poses. One rotation vector and one translation per calibration image. The rotation vector is the Rodrigues form — a unit axis scaled by the angle in radians — not a 3-by-3 matrix; if your source stores matrices, convert each to its vector before it goes into 'RotationVectors'. The translation carries length units, and they must match the target geometry. Camera pose: rotation vector to rotation matrix, tvec units works through the conversion and the unit convention.

Intrinsics. Focal length in pixels, principal point in pixels, distortion coefficients, image size in pixels. The viewer draws each camera as a frustum whose proportions come from these numbers; without them the camera has no shape, and projection, measurement and hand-eye transfer all need them later. Once you hold a full extrinsic matrix with matching intrinsics, drawing the frustum yourself is a few lines: Visualize a camera pose frustum from an extrinsic matrix.

Target geometry. The world points of the board: one row per dot or corner, in board coordinates, with z = 0 for a flat target. Every plate in the figure is this single geometry placed by its pose — 12 calibration images draw 12 plates from one point set, and an empty set draws the error instead.

Test each missing field before you rebuild

In order of how often each is the culprit:

Order Empty or wrong Quick test Fix
1 World points of the target The world-point array has zero rows Transcribe the board's point coordinates from its drawing
2 Intrinsics: focal length, principal point, image size Focal length is blank or still in millimetres Convert to pixels with the formula below, then set them
3 Pose shape or units om is not N-by-3, or T is in metres while the board is in millimetres Convert matrices to Rodrigues vectors; scale T to board units

Row 1 is the error in the question. Rows 2 and 3 usually surface after row 1 is fixed — a frustum with no size, or plates drawn inside the camera.

The fix, step by step

  1. Collect from the external calibration: focal length (millimetres or pixels), principal point in pixels, distortion coefficients, image size in pixels, one rotation and translation per image, and the board geometry. If the poses came from measured scene points rather than a board, Extrinsic calibration without checkerboard: use measured scene points covers what stands in for the target geometry.
  2. Convert the focal length to pixels if it arrived in millimetres — the arithmetic is the worked example below.
  3. Build one object carrying everything, poses first, then intrinsics, then world points, in a single length unit.
cam = cameraParameters('RotationVectors', om, 'TranslationVectors', T);
% Add to this same object, with the pairs listed in the cameraParameters reference:
%   intrinsics   — focal length in px, principal point in px,
%                  distortion coefficients, image size in px
%   world points — one row per target point, board units, z = 0
showExtrinsics(cam, 'patternCentric');
  1. Keep the counts straight: N images, N rows in om, N rows in T, and one world-point set for the single board.
  2. Call showExtrinsics and count what appears. N poses must draw N plates, and every camera must stand off the target by roughly the working distance you shot at. If both hold, the object is complete.

Worked example: focal length from millimetres to pixels

Cameras publish their resolution, and the sensor's optical format gives its width. For a concrete object, take a 12 MP USB3 camera delivering 4000 × 3000 on a 1/1.7" sensor — the LS-CMR-0166 is exactly that.

Area scan cameras12 MP USB3 area scan camera, IMX226, 1/1.7" rolling shutter, 30 fps, 4000 × 3000 resolution (LS-CMR-0166)LS-CMR-0166
Sensor format
1/1.7"
Interface
USB3
Resolution
12 MP
Shutter
Rolling
$560.00View partBuild a system with it

A 1/1.7"-type sensor has an active area of about 7.6 × 5.7 mm, 9.5 mm on the diagonal; use 7.6 mm as the width. The example external calibration reports a 6 mm lens.

p = sensor width / pixels across = 7.6 mm / 4000 px = 0.0019 mm/px = 1.9 µm f_px = f_mm / p = 6 mm / 0.0019 mm = 3158 px principal point to start = (4000 / 2, 3000 / 2) = (2000, 1500) px

Cross-check from the other direction: 6 × 4000 / 7.6 = 3158 px. Those three values — 3158 px of focal length, the (2000, 1500) px principal point and the 4000 × 3000 image size — are the intrinsics the viewer reads. How far a recovered focal length can be trusted is a separate question: Focal length from camera calibration: accuracy you can trust.

The world points must also be measurable in the source images, or the poses behind them are weak. At a 250 mm working distance, that 6 mm lens covers 250 × 7.6 / 6 = 317 mm across 4000 px, which is 0.079 mm per pixel; a 0.5 mm dot then spans 0.5 / 0.079 = 6.3 px, comfortably above the 3 px floor for stable detection.

Camera resolution for the smallest feature
Units
Pixels needed
–
Sensor size
– MP
Smallest sensor that fits
–
Pixel on the part
– mm
Pixels across the feature, that sensor
–

Pixels needed = field / feature × pixels per feature on each axis (field incl. margin). The lens must resolve the pixels too: Nyquist = 1000 / (2 × pixel µm) lp/mm.

Find cameras with enough pixels Open the full calculator

The board geometry comes from its drawing, never from memory: for a 76 × 76 mm dot grid with 0.5 mm dots, the row and column pitches on the drawing define every world point you type. The LS-LXR-0029 is one such board.

Lens accessoriesCalibration boards and depth-of-field rulers, dot diameter 0.5 mm, dot grid, 76 x 76 mm (LS-LXR-0029)LS-LXR-0029
Type
Calibration targets
$189.00View partBuild a system with it

If the source images carry dot patterns rather than checkerboards, MATLAB dot pattern camera calibration: detect the points yourself shows how to pull out the image points that the world points must match.

Checks before the next call

  • om: N-by-3 doubles, one Rodrigues vector per image, matrices converted first.
  • T: N-by-3 doubles, in the same unit as the board points — millimetres most often.
  • World points: one row per target point, z = 0 for a flat board, transcribed from the drawing revision on file.
  • Intrinsics: focal length in px, principal point in px, image size in px — pixels throughout, nothing in millimetres left over.
  • Counts: N poses, N plates drawn, one board geometry.
  • Distortion: measured coefficients when you have them, zeros only for this view.

When the field set is complete but the picture is wrong

  • Plates inside the camera, a world a thousand times too small. T is in metres while the board is in millimetres. Test: one translation should read near the shooting distance, 250 rather than 0.25. Fix: scale T by 1000.
  • Every camera at the same point. om was filled from 3-by-3 matrices read column by column. Fix: convert each matrix to its axis-angle vector, one row per pose.
  • Only some plates appear. The pose arrays are shorter than the image set. Fix: recount the rows in om and T and rebuild.
  • Plates jump between neighbouring images. The world points do not match the pattern actually imaged — wrong drawing revision or wrong pitch. Fix: transcribe the geometry from the drawing that was on the rig that day.

Keep the intrinsics with every extrinsic set

The dependency you met in a viewer follows the data everywhere: extrinsics-only refinement, stereo and hand-eye transfer all assume the intrinsics are already fixed and known — Stereo calibration with fixed intrinsics: extrinsics only is the same rule in a second setting. Save one file per calibration: intrinsics, image size, board revision, poses, date. Re-check the board itself on a schedule; Calibration target recertification: justifying a longer interval covers when that is due.

If the intrinsics you carried over are the weak link, start with a camera whose full sensor data is published in area scan cameras or run the camera step of the configurator. Calibration boards live in lens accessories. For a dataset you cannot complete, reach the team through the contact page.

Questions

Can showExtrinsics run with rotation and translation vectors only?

No. The pose pairs place the cameras, but the viewer also reads the target's world points — patternCentric hulls them to set the world extent — and the intrinsics, which give each camera drawing its shape. An object with poses alone parses until computeConvexHull meets an empty world-point array and stops with an index error. Add the intrinsics and one board geometry, and the call renders.

How do I convert a focal length in millimetres to pixels?

Divide the focal length by the pixel pitch. With a 7.6 mm sensor width, 4000 pixels across it and a 6 mm lens, the pitch is 7.6 / 4000 = 0.0019 mm and the focal length is 6 / 0.0019 = 3158 px. Only the sensor width and the pixel count set the result; the working distance never enters an intrinsic.

Is zero distortion acceptable when the source gave no coefficients?

For this 3-D pose view, yes. The drawing is schematic, and a fraction of a percent of distortion moves plate corners by a few pixels, invisible at view scale. For projection, measurement or hand-eye work, zeros are not a stand-in for measured coefficients — run a real intrinsic calibration first and carry its coefficients with the poses.

Why an index error instead of a message about missing fields?

Because no field is missing in the constructor's eyes. The object exists, its pose fields are set, and the world-point field is simply empty — zero rows. computeConvexHull then indexes into an array with no rows, and array indexing is what fails, not field validation. The message names the symptom; the empty array is the cause.

Do the world points repeat for every calibration image?

No. One board gives one world-point set — its geometry in board coordinates, z = 0 for a flat target — reused for every image. Each image contributes one rotation vector and one translation: 12 images mean 12 rows in each pose array against the single geometry. Every plate drawn is that one geometry placed by its pose.

Does switching to cameraCentric avoid the error?

No. The hull of the target points is computed while the inputs are parsed, before the view style matters, so the same empty field fails both modes. After the object carries intrinsics and world points, both views work from it with no per-view fields; the modes differ only in which frame is held fixed — world or camera.