Ask Your Question

Revision history [back]

For theory look here. In order to use solvePnP() for 3D reconstruction, we must supply 2 blocks of camera parameters: distortion coefficients and camera matrix. If images have no visible distortion, the coefficients may be set to 0. Camera matrix contains 3 values: focal length f expressed in pixels and optical center (cx, cy). Ideally, the optical center is in the center of the image. My calibration with 640x480 pictures rendered exactly that (319.5, 239.5). The only parameter which could require calibration is focal length. For me f is approx 600. It affects scaling according to formula M = f /(f - S1) where M - magnification, S1 - distance from object to lens plane, but this formula is for cameras with moving lens and focusing. Laptop pinholes have no focusing so focal length is useless. Instead, distance d between lens and sensor should be used M = d / S1. Thus scaling is proportional to d, but its exact value is not needed because we choose an arbitrary object coordinate system and solvePnP() calculates scaling factors from correspondence between object and image points.