Difference between revisions of "How to Calibrate Camera Optics"

From iPi Docs
Jump to: navigation, search
m
(results)
Line 92: Line 92:
  
 
== Result ==
 
== Result ==
 +
 +
Camera parameters are used to remove distortion from video. This allows to process video in [[iPi Mocap Studio]] just like video from web-camera with good optics (without significant distortion and principal point shift).
 +
 +
On the '''RESULT''' tab you can click on some frame in left panel and get preview of distortion removing ("undistorting"):
 +
<center>[[Image:camera-calibration-undistort-preview.jpg|link=]]</center>
 +
 +
As you can see, there is a big difference in geometry of boundaries because of radial distortion. As a result, part of pixels from original (top) image are not visible in undistorted (bottom) image. And in turn, on undistorted (bottom) image there are areas filled by green color: the thing is that, corresponding pixels on source (i.e. original) image are beyond of boundaries.
 +
 +
Using '''Scale''' parameter you can adjust proportion between two quantities:
 +
# how many pixels on original image are beyond boundaries of undistorted image (pixels which lay down out of green-line boundaries on the top image) 
 +
# how many pixels on undistorted image have no corresponding (source) ones on original image (green pixels on the bottom image)
 +
 +
By default scale is automatically selected to balance (1) and (2). But you can adjust it manually if needed. But be aware that low values of scale result in degradation of image quality on undistorted video (because pixel size of all objects on video becomes smaller). And high values of scale result in significant narrowing of field-of-view (FOV) after undistorting.

Revision as of 16:20, 1 August 2018

Introduction

Calibration of camera optics is required to find out the values of the following intrinsic parameters:

This procedure is strongly mandatory for modern wide-angle cameras including action cameras. The thing is that these cameras has significant distortion.

Note.png
Note: As to web-cameras usable with iPi Motion Capture (Sony PS3 Eye and Logitech C922), they have optics with low distortion and principal point shift is not significant as a rule. For this reason camera optics calibration is not required for them. But if you want, you can calibrate them and apply results of this calibration to recorded video using Build Combined Video tool of iPi Recorder application.

Recording of Calibration Video

  • Mark camera by some label to distinguish it from others.
  • Set view-angle and resolution you're going to use during motion capture session(s).
  • Tip.png
    Tip: 720p (1280 x 720) resolution is recommended for full body motion capture needs in most cases (except very large capture area).
  • Important.png
    Important! If you use GoPro action camera, please don't use SuperView mode because in this mode calibration will fail (thanks to special "dynamic stretches" from 4:3 to 16:9 format made by camera software).
  • If your camera has zoom and/or auto-focus features then these features must be turned off before calibration because this procedure is valid only for fixed optics.
  • Run iPi Recorder and click Calibrate Camera Optics button in toolbar:
camera-calibration-tool-button.png
  • To calibrate camera optics special calibration pattern is used. You have to record this pattern shown on computer screen from different view points.
  • Click Show Pattern button in toolbar of PATTERN tab of Camera Optics Calibration tool:
camera-calibration-show-pattern-button.png
  • Start video recording and shoot this pattern from different view angles. For each view:
    • Ensure the pattern fills most of the frame. It's OK if the whole screen doesn't feet into the frame.
    • Hold the camera still for a second.
  • We recommend to use the following five view angles:
View Angle How it Looks from Side How it Looks from Top How it Looks in Camera

1. Front camera-calibration-front-view-side.png camera-calibration-front-view-top.png camera-calibration-front-view-proj.png

2. From the left camera-calibration-left-view-side.png camera-calibration-left-view-top.png camera-calibration-left-view-proj.png

3. From the right camera-calibration-right-view-side.png camera-calibration-right-view-top.png camera-calibration-right-view-proj.png

4. From the top camera-calibration-top-view-side.png camera-calibration-top-view-top.png camera-calibration-top-view-proj.png

5. From the bottom camera-calibration-bottom-view-side.png camera-calibration-bottom-view-top.png camera-calibration-bottom-view-proj.png
Tip.png
Tip: You can download and examine the following sample calibration video recorded by GoPro HERO4 Silver action camera (720p, Wide view): cam1-720p-wide.MP4 (13 MB)

Processing of Calibration Video

  • Copy recorded MP4/AVI/MOV/MPEG video file to computer.
    • The best option here is to use SD-card reader. But USB cord also do the trick but slower.
  • Switch to CALIBRATION tab in Camera Optics Calibration tool in iPi Recorder and open this video by clicking Open Video button in toolbar:
camera-calibration-open-video-button.png
  • Video will be automatically converted to internal .iPiVideo file format.
  • Using "Toggle Current Frame" button in toolbar choose frames with different view angles:
    • where the pattern fills most of the frame
    • where camera is not moving significantly
    • one frame for each view angle type is enough
  • Application will show detected markers in selected frame. It's OK if some of markers weren't detected.
    • If you don't like results of detection, you can deselect the frame by clicking Toggle Current Frame button again and try different frame(s) from video.
camera-calibration-frames-selection.png
  • As soon as you choose at least three frames (we recommend to use five frames corresponding to five view angles described above) you can run calculation of camera optics parameters by clicking on Run Calibration button in toolbar.
    • Also, you can change calibration options using controls located near this button. But in most cases default values work like a charm.
  • Now you're on RESULT tab and see calculated parameters of camera optics:
camera-calibration-results-tab.png
Tip.png
Tip: You can play with sample calibration video: cam1-720p-wide.MP4 (13 MB). We recommend to choose the following frames: 50 ("front" view angle), 880 ("from the left" view angle), 1360 ("from the right" view angle), 1780 ("from the top" view angle), 2110 ("from the bottom" view angle).

Result

Camera parameters are used to remove distortion from video. This allows to process video in iPi Mocap Studio just like video from web-camera with good optics (without significant distortion and principal point shift).

On the RESULT tab you can click on some frame in left panel and get preview of distortion removing ("undistorting"):

camera-calibration-undistort-preview.jpg

As you can see, there is a big difference in geometry of boundaries because of radial distortion. As a result, part of pixels from original (top) image are not visible in undistorted (bottom) image. And in turn, on undistorted (bottom) image there are areas filled by green color: the thing is that, corresponding pixels on source (i.e. original) image are beyond of boundaries.

Using Scale parameter you can adjust proportion between two quantities:

  1. how many pixels on original image are beyond boundaries of undistorted image (pixels which lay down out of green-line boundaries on the top image)
  2. how many pixels on undistorted image have no corresponding (source) ones on original image (green pixels on the bottom image)

By default scale is automatically selected to balance (1) and (2). But you can adjust it manually if needed. But be aware that low values of scale result in degradation of image quality on undistorted video (because pixel size of all objects on video becomes smaller). And high values of scale result in significant narrowing of field-of-view (FOV) after undistorting.