Wiki

Clone wiki

XMALab / X-ray Camera Calibration

Introduction

Camera calibration is required to calculate the 3D coordinates of markers from the 2D points tracked in each video. Calibration starts with images of a 2D checkerboard or 3D object with known geometry. The calibration process generates a mathematical model of the camera position and orientation in 3D space that are required to produce the images of the known object. Calibration also includes calculation of internal parameters of the camera, such as focal length. New calibration images must be recorded and a new calibration done every time a camera changes position, focus, or aperture.

X-ray Calibration Object (cube), Frame Specification file, and References file

X-ray camera calibration is best done with a 3-D calibration object containing regularly-spaced, radio-opaque spheres. Cube-shaped objects made from acrylic sheets and spacers with steel spheres (Brainerd et al., 2010) or Lego bricks with steel spheres have been shown to be effective (Manuals). A "Frame Specification" file with the xyz coordinates of the spheres is required, and the spheres must be placed very precisely within the object (to within 0.1 mm). The Frame Specification file should be a comma-separated text file (.csv) with the following format. Units can be mm or cm, but are cm in this example because cm works better with Maya.

Screen Shot 2016-02-05 at 8.34.13 AM.png

A "References" file is also required. The References file identifies four points that are marked with lead shapes, such as circle, rectangle, triangle, pentagon (sometimes known as lucky charms) in the calibration cube. The References file must be a plain text file separated by spaces with the extension .ref:

Screen Shot 2016-02-05 at 8.43.52 AM.png

Calibration in XMALab

Select the Calibration workspace. Click the shapes. After the 4th shape is clicked, the orientation of the cube will be determined and rest of the points will be found automatically. Repeat for other cameras and all images. It is best to have at least 3 sets of images of the calibration cube in different orientations.

Screen Shot 2016-02-05 at 8.57.33 AM.jpg

Check calibration residual error by clicking the blue information icon in upper right of each image. Error is in pixels and the amount of error will depend on camera resolution, calibration object, and many other factors particular to X-ray systems and specific studies. As a general matter, error less than 1-2 pixels is good enough to move forward. The ultimate test of whether the calibration is good enough is the quality of the tracked points and rigid body animations made from them. It is always possible to go back and refine the calibration process, or even apply a different set of calibration images to the tracked XY points. It is never necessary to track the XY points more than once!

calib2.png The toolbox contains tools for refining the calibration. The visualization section offers different views of the points:

  • detected cube points shows the included points in green, and any points excluded from the calibration in red
  • projected cube points shows the expected locations of the points, based on the Frame Specification file, with included points in green, excluded points in red, and points not detected in blue

The text section has options for viewing the index ID number for the points, the residual error in pixels for each point, and the residual error with color-coded magnitude.

The mouseclick mode section contains instructions for how to Toggle Outlier to include or exclude it (turn a point from green to red, or red to green), and how to add a point (correspondence) that has not yet been detected, such as a blue point in projected cube points mode or a marker with no crosshair in detected cube points mode. The Add correspondence mode (COMMAND+click in Mac OS, CONTROL+Click in Windows) can also be used to move a green detected point to the center of the sphere, if autodetection was wrong.

Note that the goal is always to have as many points marked in the visual center of the spheres as possible. The residual errors should be used to identify points that may need manual refinement, but clicking away from the center to get the residual lower just weakens the overall calibration. If a point has a persistent high error it can be excluded, particularly if there is a chance it has moved from its correct location in the cube. But beware of excluding too many points. The goal is to get the best calibration, not the lowest possible residual error, and more points generally make a better calibration.

Click on optimize camera setup if you have more than one calibration image set. It does not matter if you still do it when you have only one, it will not change anything. If you do have more than one calibration image set, and you did not optimize, you will get a red warning in the 'Marker tracking' workspace.

Press the recompute calibration button at the bottom of the toolbox to see the effect of including and excluding points.

Reset Frame button removes all points from the currently selected frame and currently selected camera (to start over). Reset Camera removes all points from all frames for the currently selected camera, and Delete Frame removes the images for all cameras from the currently selected frame (set of images).

Important Step to Check Calibration:

Use the 3D world view to confirm that the locations and orientations of the cameras makes sense. This view should reflect the actual, physical relationship between the cameras. If it does not, then the identification of points in one or more cameras is wrong.

Screen Shot 2016-02-06 at 8.06.03 AM.jpg

Updated