Calibrate Camera
Helper module to calibrate a given sensor+lens combo, which allows ArUco and other modules to do 3D pose estimation.
By Laurent Ittiitti@usc.eduhttp://jevois.orgGPL v3
 Language: C++Supports mappings with USB output: YesSupports mappings with NO USB output: Yes 
 Video Mapping:   YUYV 320 495 30.0 YUYV 320 240 30.0 JeVois DemoArUco YUYV 640 975 20.0 YUYV 640 480 20.0 JeVois DemoArUco

Module Documentation

Just follow the on-screen prompts to calibrate your camera. The calibration results will be saved into /jevois[pro]/share/camera/ on microSD and will be automatically loaded when using a machine vision module that uses camera calibration, for example DemoArUco or FirstVision.

The basic workflow is:

  • print a calibration board and affix is to a good planar surface (e.g., an acrylic board, aluminum board, etc). Or buy a board, for example from https://calib.io or similar.
  • decide which sensor, resolution, and lens you want to calibrate. The sensor should be detected at boot time (check engine::camerasens system parameter). The lens can be set manually through the engine::cameralens parameter. The default lens is called "standard". For the resolution, edit videomappings.cfg and add a mode for the CalibrateCamera module that will use the same resolution as the one you want to use later for machine vision. Several commented-out examples are already in videomappings.cfg, so likely you can just uncomment one of them. Then run the corresponding version of the CalibrateCamera module.
  • set the parameters to match the board type, board width and height in number of tiles, tile size in the unit that you want to later use to estimate distance to detected objects (e.g., in millimeters, inches, etc), and possibly ChArUco marker size and dictionary.
  • point the camera towards the board so that the full board is in the camera view. Click 'grab'. Change the viewpoint and repeat at least 5 times. Use various 3D viewpoints.
  • click 'calibrate' and the calibration will be computed and saved to microSD for that sensor, resolution, and lens. It will be ready to be loaded by modules that want to use it.

The default settings are for a 11x7 Chess Board that was created using the online generator at https://calib.io and which you can get from http://jevois.org/data/calib.io_checker_260x200_7x11_23.pdf - When you print the board, make sure you print at 100% scale. You should confirm that the checks in the printout are 23mm x 23mm.

An alternate chess board with fewer checks may be desirable at low resolutions, such as the 7x5 chess board at http://jevois.org/data/calib.io_checker_260x200_5x7_36.pdf - if you use it, set board size to '7 5', and square size to '36' to match it.

If you are using a wide-angle fish-eye lens with a lot of distortion, turn on the fishEye parameter.

You can also use a ChArUco board, though we have actually obtained worse reprojection errors with these boards. You can print the board at http://jevois.org/data/calib.io_charuco_260x200_5x7_36_27_DICT_4X4.pdf at 100% scale, and you should confirm that the checks in the printout are 36mm x 36mm, and the ArUco patterns within the white checks are 27mm x 27mm. If you use it, you need to set the board type, size, marker size, and square size parameters to match it. An alternate board with more ChArUcos is at http://jevois.org/data/calib.io_charuco_260x200_7x11_23_17_DICT_4X4.pdf

ParameterTypeDescriptionDefaultValid Values
(CalibrateCamera) patternPatternType of calibration board pattern to usePattern::ChessBoardPattern_Values
(CalibrateCamera) dictionaryaruco::DictArUco dictionary to usearuco::Dict::D4X4_50aruco::Dict_Values
(CalibrateCamera) squareSizefloatSize of each tile (check) in user-chosen units (e.g., mm, inch, etc). The unit used here is the one that will be used once calibrated to report 3D coordinates of objects relative to the camera23.0f-
(CalibrateCamera) markerSizefloatChArUco marker size in user-chosen units (e.g., mm, inch, etc). The unit used here is the one that will be used once calibrated to report 3D coordinates of objects relative to the camera27.0f-
(CalibrateCamera) boardSizecv::SizeBoard size [width height] in number of horizontal and vertical tiles/disks. (Note: for asymmetric circle grid, count the number of disks on each row, then the number of rows). The product width * height should be the total number of tiles/disks on the grid.){ 117 }
(CalibrateCamera) aspectRatiofloatFixed aspect ratio value to use when non-zero, or auto when 0.00.0F-
(CalibrateCamera) zeroTangentDistboolAssume zero tangential distortion coefficients P1, P2 and do not try to optimize them, i.e., assume board is exactly planartrue-
(CalibrateCamera) fixPrincipalPointboolFix principal point at center, otherwise find its locationtrue-
(CalibrateCamera) fishEyeboolUse fisheye model. Should be true if using a wide-angle lens that produces significant barrel distortion, otherwise falsefalse-
(CalibrateCamera) winSizeunsigned charHalf of search window size for sub-pixel corner refinement11-
(CalibrateCamera) fixK1boolFix (do not try to optimize) K1 radial distortion parameterfalse-
(CalibrateCamera) fixK2boolFix (do not try to optimize) K2 radial distortion parameterfalse-
(CalibrateCamera) fixK3boolFix (do not try to optimize) K3 radial distortion parameterfalse-
(CalibrateCamera) fixK4boolFix (do not try to optimize) K4 radial distortion parameterfalse-
(CalibrateCamera) fixK5boolFix (do not try to optimize) K5 radial distortion parameter (not used by fisheye lenses)false-
(CalibrateCamera) fixK6boolFix (do not try to optimize) K6 radial distortion parameter (not used by fisheye lenses)false-
(CalibrateCamera) showUndistortedboolOnce calibrated, show undistorted image instead of original capturefalse-
(CalibrateCamera) grabboolGrab one image, try to detect the calibration pattern, and add to list of detected patterns so far. Click this for at least 5 images showing your calibration board under various viewpoints. When enough boards have been successfully captured, click 'calibrate'false-
(CalibrateCamera) calibrateboolCalibrate using all the grabbed boards so far. You first need to grab enough good views of your calibration board before you can calibrate.false-
Detailed docs:CalibrateCamera
Copyright:Copyright (C) 2024 by Laurent Itti, iLab and the University of Southern California
License:GPL v3
Distribution:Unrestricted
Restrictions:None
Support URL:http://jevois.org/doc
Other URL:http://iLab.usc.edu
Address:University of Southern California, HNB-07A, 3641 Watt Way, Los Angeles, CA 90089-2520, USA