dltReconstruct: Reconstructs the 3D position of points in two or more camera...

View source: R/dltReconstruct.R

dltReconstructR Documentation

Reconstructs the 3D position of points in two or more camera views

Description

This function takes 2D pixel coordinates of a point or points from two more camera views and uses DLT coefficients to reconstruct their position in 3D.

Usage

dltReconstruct(cal.coeff, coor.2d, min.views = 2)

## S3 method for class 'dltReconstruct'
summary(object, ...)

Arguments

cal.coeff

a matrix of DLT calibration coefficients. The columns correspond to each camera view and the column order should match the camera view order of the landmarks in coor.2d.

coor.2d

2D pixel coordinates from two or more camera views. Format can be either a landmark matrix, list or array.

min.views

the minimum number of views required for a point to be reconstructed in 3D.

object

a list of class "dltReconstruct" (the output of dltReconstruct()).

...

further arguments passed to or from other methods.

Details

This function uses DLT coefficients (calculated using dltCalibrateCameras, for example) to reconstruct the 3D position of points, based on their 2D position in two or more camera views. 2D pixel coordinates can be input as a landmark matrix (readLandmarksToMatrix), as a list (readLandmarksToList) or as an array (readLandmarksToArray).

A minimum of two views is required for 3D reconstruction although additional camera views can be used, potentially improving reconstruction accuracy. Points that are present in fewer views than specified by min.views will be assigned NA values in the returned 3D matrix (coor.3d).

After 3D reconstruction, dltReconstruct() performs the inverse operation, taking the reconstructed, 3D coordinates and solving for the 2D position of the points in each camera view. These inverse 2D coordinates are compared with the original coordinates and their difference is returned as the root-mean-square (RMS) reconstruction error (list$rmse). This error is similar to the epipolar distance (dltEpipolarDistance). The summary() function can be used to view the error by landmark.

Currently, dltReconstruct() only works with the 11-parameter DLT model.

Value

a list of class "dltReconstruct" with the following elements:

coor.3d

a 2D or 3D landmark matrix.

rmse

the root-mean-square reconstruction error (in pixels).

Note

This function was modified by A Olsen from the Matlab function dlt_reconstruct() written by T Hedrick.

Author(s)

Aaron Olsen

References

Abdel-Aziz, Y.I., Karara, H.M. (1971) Direct linear transformation into object space coordinates in close-range photogrammetry. Proc. Symp. on Close-Range Photogrammetry (University of Illinois at Urbana-Champaign).

Hedrick, T.L. (2008) Software techniques for two- and three-dimensional kinematic measurements of biological and biomimetic systems. Bioinspiration & Biomimetics, 3 (034001).

For a general overview of DLT: http://kwon3d.com/theory/dlt/dlt.html

See Also

dltCalibrateCameras, readLandmarksToMatrix, readLandmarksToList,

readLandmarksToArray, dltEpipolarDistance

Examples

## GET THE FILE DIRECTORY FOR EXTRA R PACKAGE FILES
fdir <- paste0(path.package("StereoMorph"), "/extdata/")

## SET FILE PATH TO CALIBRATION COEFFICIENTS IN TWO CAMERA STEREO SETUP
cc_file <- paste0(fdir, "cal_coeffs.txt")

## LOAD COEFFICIENTS
cal.coeff <- as.matrix(read.table(file=cc_file))

## GET LANDMARKS IN FIRST CAMERA VIEW
lm_files <- paste0(fdir, c("lm_2d_a1_v1.txt", "lm_2d_a1_v2.txt"))

## READ LANDMARKS INTO MATRIX
lm.matrix <- readLandmarksToMatrix(file=lm_files, row.names=1)

## RECONSTRUCT LANDMARKS IN 3D (MATRIX INPUT)
dlt_recon <- dltReconstruct(cal.coeff=cal.coeff, coor.2d=lm.matrix)


## OTHER POSSIBLE LANDMARK FORMAT INPUTS ##
## READ LANDMARKS INTO LIST
lm.list <- readLandmarksToList(file=lm_files, row.names=1)

## RECONSTRUCT LANDMARKS IN 3D (LIST INPUT)
dlt_recon <- dltReconstruct(cal.coeff=cal.coeff, coor.2d=lm.list)

## READ LANDMARKS INTO ARRAY
lm.array <- readLandmarksToArray(file=lm_files, row.names=1)

## RECONSTRUCT LANDMARKS IN 3D (ARRAY INPUT)
dlt_recon <- dltReconstruct(cal.coeff=cal.coeff, coor.2d=lm.array)

aaronolsen/StereoMorph documentation built on June 2, 2022, 4:09 a.m.