SfM output to VRML for ICM file
Posted: Mon Jan 09, 2012 3:43 pm
I'm using an SfM program suite (N. Snavely's Bundler (0,4), Y. Furukawa's PMVS2 or CMVS) with multiple images to make PLY output. To paraphrase the manual: a pinhole camera model is used; the parameters obtained for each camera are a focal length (f), two radial distortion parameters (k1 and k2), a rotation (R), and translation (t). The formula for projecting a 3D point X into a camera (R, t, f) is:
P = R * X + t (conversion from world to camera coordinates)
p = -P / P.z (perspective division)
p' = f * r(p) * p (conversion to pixel coordinates)
where P.z is the third (z) coordinate of P. In the last equation, r(p) is a function that computes a scaling factor to undo the radial distortion:
r(p) = 1.0 + k1 * ||p||^2 + k2 * ||p||^4.
This gives a projection in pixels, where the origin of the image is the center of the image, the positive x-axis points right, and the positive y-axis points up (in addition, in the camera coordinate system, the positive z-axis points backwards, so the camera is looking down the negative z-axis, as in OpenGL). Radial distortion in each image is removed with an intermediate step before running CVMS.
I want to display the images draped over the point cloud from the PLY file from CMVS or PMVS2 using CloudCompare to make an approximate orthophoto with the Z axis vertical. The PLY appears to display correctly in CC. I can compute the FOV from the focal length and image sizes. How should I convert the R, X and t values as above to get the VRML fields for the ICM file required by CloudCompare correctly?
P = R * X + t (conversion from world to camera coordinates)
p = -P / P.z (perspective division)
p' = f * r(p) * p (conversion to pixel coordinates)
where P.z is the third (z) coordinate of P. In the last equation, r(p) is a function that computes a scaling factor to undo the radial distortion:
r(p) = 1.0 + k1 * ||p||^2 + k2 * ||p||^4.
This gives a projection in pixels, where the origin of the image is the center of the image, the positive x-axis points right, and the positive y-axis points up (in addition, in the camera coordinate system, the positive z-axis points backwards, so the camera is looking down the negative z-axis, as in OpenGL). Radial distortion in each image is removed with an intermediate step before running CVMS.
I want to display the images draped over the point cloud from the PLY file from CMVS or PMVS2 using CloudCompare to make an approximate orthophoto with the Z axis vertical. The PLY appears to display correctly in CC. I can compute the FOV from the focal length and image sizes. How should I convert the R, X and t values as above to get the VRML fields for the ICM file required by CloudCompare correctly?