Digital Image Correlation Engine  Version 1.0
A modular, high-performance, image correlation tool used to compute full-field displacements and strains from digital images
Classes | Public Types | Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes | Friends | List of all members
DICe::Camera Class Reference

A class for camera calibration parameters and computing single camera projection based transformations. More...

#include <DICe_Camera.h>

Classes

struct  Camera_Info
 helper struct for camera initialization (cleans up of the constructors for camera class so it only needs one) More...
 

Public Types

enum  Lens_Distortion_Model {
  NO_LENS_DISTORTION = 0, OPENCV_LENS_DISTORTION, VIC3D_LENS_DISTORTION, K1R1_K2R2_K3R3,
  K1R2_K2R4_K3R6, K1R3_K2R5_K3R7, MAX_LENS_DISTORTION_MODEL, NO_SUCH_LENS_DISTORTION_MODEL
}
 
enum  Cam_Intrinsic_Param {
  CX = 0, CY, FX, FY,
  FS, K1, K2, K3,
  K4, K5, K6, P1,
  P2, S1, S2, S3,
  S4, T1, T2, MAX_CAM_INTRINSIC_PARAM,
  NO_SUCH_CAM_INTRINSIC_PARAM
}
 

Public Member Functions

 Camera (const Camera_Info &camera_info)
 constructor
 
virtual ~Camera ()
 Pure virtual destructor.
 
void set_id (const std::string &cam_id)
 
std::string id () const
 
void set_lens (const std::string &camera_lens)
 
std::string lens () const
 
void set_comments (const std::string &camera_comments)
 
std::string comments () const
 
int_t image_height () const
 gets the image height returns the height of the image in pixels
 
int_t image_width () const
 gets the image width returns the width of the image in pixels
 
int_t pixel_depth () const
 
Lens_Distortion_Model lens_distortion_model () const
 
Matrix< scalar_t, 4 > transformation_matrix () const
 
std::vector< scalar_tget_facet_params ()
 
std::vector< scalar_t > * intrinsics ()
 gets the intrinsic camera parameter values
 
scalar_t tx () const
 get the x extrinsic translation
 
scalar_t ty () const
 get the y extrinsic translation
 
scalar_t tz () const
 get the z extrinsic translation
 
const Camera_Infocamera_info () const
 
const Matrix< scalar_t, 3 > * rotation_matrix () const
 
const Matrix< scalar_t, 4 > * cam_world_trans_matrix () const
 
const Matrix< scalar_t, 4 > * world_cam_trans_matrix () const
 
void initialize ()
 prepares the tranfomation matricies
 
void sensor_to_image (const std::vector< scalar_t > &sen_x, const std::vector< scalar_t > &sen_y, std::vector< scalar_t > &image_x, std::vector< scalar_t > &image_y, const std::vector< std::vector< scalar_t > > &sen_dx, const std::vector< std::vector< scalar_t > > &sen_dy, std::vector< std::vector< scalar_t > > &image_dx, std::vector< std::vector< scalar_t > > &image_dy)
 
void sensor_to_image (const std::vector< scalar_t > &sen_x, const std::vector< scalar_t > &sen_y, std::vector< scalar_t > &image_x, std::vector< scalar_t > &image_y)
 same as above without derivatives
 
void image_to_sensor (const std::vector< scalar_t > &image_x, const std::vector< scalar_t > &image_y, std::vector< scalar_t > &sen_x, std::vector< scalar_t > &sen_y, const bool integer_locs=true)
 
void image_to_world (const std::vector< scalar_t > &image_x, const std::vector< scalar_t > &image_y, const std::vector< scalar_t > &rigid_body_params, std::vector< scalar_t > &world_x, std::vector< scalar_t > &world_y, std::vector< scalar_t > &world_z)
 
void image_to_world (const std::vector< scalar_t > &image_x, const std::vector< scalar_t > &image_y, std::vector< scalar_t > &world_x, std::vector< scalar_t > &world_y, std::vector< scalar_t > &world_z)
 
void sensor_to_cam (const std::vector< scalar_t > &sen_x, const std::vector< scalar_t > &sen_y, std::vector< scalar_t > &cam_x, std::vector< scalar_t > &cam_y, std::vector< scalar_t > &cam_z, const std::vector< scalar_t > &facet_params, std::vector< std::vector< scalar_t > > &cam_dx, std::vector< std::vector< scalar_t > > &cam_dy, std::vector< std::vector< scalar_t > > &cam_dz)
 
void sensor_to_cam (const std::vector< scalar_t > &sen_x, const std::vector< scalar_t > &sen_y, std::vector< scalar_t > &cam_x, std::vector< scalar_t > &cam_y, std::vector< scalar_t > &cam_z, const std::vector< scalar_t > &facet_params)
 same as above with no derivatives
 
void cam_to_sensor (const std::vector< scalar_t > &cam_x, const std::vector< scalar_t > &cam_y, const std::vector< scalar_t > &cam_z, std::vector< scalar_t > &sen_x, std::vector< scalar_t > &sen_y, const std::vector< std::vector< scalar_t > > &cam_dx, const std::vector< std::vector< scalar_t > > &cam_dy, const std::vector< std::vector< scalar_t > > &cam_dz, std::vector< std::vector< scalar_t > > &sen_dx, std::vector< std::vector< scalar_t > > &sen_dy)
 
void cam_to_sensor (const std::vector< scalar_t > &cam_x, const std::vector< scalar_t > &cam_y, const std::vector< scalar_t > &cam_z, std::vector< scalar_t > &sen_x, std::vector< scalar_t > &sen_y)
 same as above without derivatives
 
void cam_to_world (const std::vector< scalar_t > &cam_x, const std::vector< scalar_t > &cam_y, const std::vector< scalar_t > &cam_z, std::vector< scalar_t > &wrld_x, std::vector< scalar_t > &wrld_y, std::vector< scalar_t > &wrld_z, std::vector< std::vector< scalar_t > > &cam_dx, std::vector< std::vector< scalar_t > > &cam_dy, std::vector< std::vector< scalar_t > > &cam_dz, std::vector< std::vector< scalar_t > > &wrld_dx, std::vector< std::vector< scalar_t > > &wrld_dy, std::vector< std::vector< scalar_t > > &wrld_dz)
 
void cam_to_world (const std::vector< scalar_t > &cam_x, const std::vector< scalar_t > &cam_y, const std::vector< scalar_t > &cam_z, std::vector< scalar_t > &wrld_x, std::vector< scalar_t > &wrld_y, std::vector< scalar_t > &wrld_z)
 same as above without derivatives
 
void world_to_cam (const std::vector< scalar_t > &wrld_x, const std::vector< scalar_t > &wrld_y, const std::vector< scalar_t > &wrld_z, std::vector< scalar_t > &cam_x, std::vector< scalar_t > &cam_y, std::vector< scalar_t > &cam_z, const std::vector< std::vector< scalar_t > > &wrld_dx, const std::vector< std::vector< scalar_t > > &wrld_dy, const std::vector< std::vector< scalar_t > > &wrld_dz, std::vector< std::vector< scalar_t > > &cam_dx, std::vector< std::vector< scalar_t > > &cam_dy, std::vector< std::vector< scalar_t > > &cam_dz)
 
void world_to_cam (const std::vector< scalar_t > &wrld_x, const std::vector< scalar_t > &wrld_y, const std::vector< scalar_t > &wrld_z, std::vector< scalar_t > &cam_x, std::vector< scalar_t > &cam_y, std::vector< scalar_t > &cam_z)
 same as above without derivatives
 
scalar_t diff (const Camera &rhs) const
 compare the intrinsics and extrinsic values for a camera
 

Static Public Member Functions

static std::string to_string (Lens_Distortion_Model in)
 
static Lens_Distortion_Model string_to_lens_distortion_model (std::string &in)
 
static std::string to_string (Cam_Intrinsic_Param in)
 
static Cam_Intrinsic_Param string_to_cam_intrinsic_param (std::string &in)
 
static void transform_coordinates_in_place (std::vector< scalar_t > &x, std::vector< scalar_t > &y, std::vector< scalar_t > &z, const std::vector< scalar_t > &rigid_body_params)
 
static void transform_coordinates_in_place (std::vector< scalar_t > &x, std::vector< scalar_t > &y, std::vector< scalar_t > &z, const Matrix< scalar_t, 3 > &R, const scalar_t &tx, const scalar_t &ty, const scalar_t &tz)
 rotation matrix and translations version
 
static void transform_coordinates_in_place (std::vector< scalar_t > &x, std::vector< scalar_t > &y, std::vector< scalar_t > &z, const Matrix< scalar_t, 4 > &T)
 transformation matrix version
 

Private Member Functions

void rot_trans_transform (const Matrix< scalar_t, 4 > &RT_matrix, const std::vector< scalar_t > &in_x, const std::vector< scalar_t > &in_y, const std::vector< scalar_t > &in_z, std::vector< scalar_t > &out_x, std::vector< scalar_t > &out_y, std::vector< scalar_t > &out_z, const std::vector< std::vector< scalar_t > > &in_dx, const std::vector< std::vector< scalar_t > > &in_dy, const std::vector< std::vector< scalar_t > > &in_dz, std::vector< std::vector< scalar_t > > &out_dx, std::vector< std::vector< scalar_t > > &out_dy, std::vector< std::vector< scalar_t > > &out_dz)
 
void rot_trans_transform (const Matrix< scalar_t, 4 > &RT_matrix, const std::vector< scalar_t > &in_x, const std::vector< scalar_t > &in_y, const std::vector< scalar_t > &in_z, std::vector< scalar_t > &out_x, std::vector< scalar_t > &out_y, std::vector< scalar_t > &out_z)
 same as above with no partial derivatives
 
void prep_lens_distortion ()
 creates the image values for the inverse lens distortion
 
void prep_transforms ()
 creates the rotation/translation matricies and inverses
 

Private Attributes

Camera_Info camera_info_
 struct that holds all the initialization information
 
std::vector< scalar_tinv_lens_dis_x_
 
std::vector< scalar_tinv_lens_dis_y_
 
Matrix< scalar_t, 4 > cam_world_trans_
 
Matrix< scalar_t, 4 > world_cam_trans_
 
scalar_t zero_ish_
 

Friends

DICE_LIB_DLL_EXPORT friend bool operator== (const Camera &lhs, const Camera &rhs)
 comparison operator
 
DICE_LIB_DLL_EXPORT friend bool operator!= (const Camera &lhs, const Camera &rhs)
 comparison operator
 
DICE_LIB_DLL_EXPORT friend std::ostream & operator<< (std::ostream &os, const Camera &camera)
 overaload the ostream operator for a camera class
 

Detailed Description

A class for camera calibration parameters and computing single camera projection based transformations.

Member Enumeration Documentation

◆ Cam_Intrinsic_Param

valid intrinsic parameters index values

◆ Lens_Distortion_Model

valid lens distortion model values

Member Function Documentation

◆ cam_to_sensor()

void DICe::Camera::cam_to_sensor ( const std::vector< scalar_t > &  cam_x,
const std::vector< scalar_t > &  cam_y,
const std::vector< scalar_t > &  cam_z,
std::vector< scalar_t > &  sen_x,
std::vector< scalar_t > &  sen_y,
const std::vector< std::vector< scalar_t > > &  cam_dx,
const std::vector< std::vector< scalar_t > > &  cam_dy,
const std::vector< std::vector< scalar_t > > &  cam_dz,
std::vector< std::vector< scalar_t > > &  sen_dx,
std::vector< std::vector< scalar_t > > &  sen_dy 
)

projects camera x,y,z locations back onto the sensor overloaded with input and output first partials

Parameters
cam_xx location in cam x,y,z space
cam_yy location in cam x,y,z space
cam_zz location in cam x,y,z space
sen_xprojected x sensor location
sen_yprojected y sensor location
cam_dxfirst partials of the cam locations from previous projections
cam_dyfirst partials of the cam locations from previous projections
cam_dzfirst partials of the cam locations from previous projections
sen_dxfirst partials of the projected x sensor location
sen_dyfirst partials of the projected y sensor location

◆ cam_to_world()

void DICe::Camera::cam_to_world ( const std::vector< scalar_t > &  cam_x,
const std::vector< scalar_t > &  cam_y,
const std::vector< scalar_t > &  cam_z,
std::vector< scalar_t > &  wrld_x,
std::vector< scalar_t > &  wrld_y,
std::vector< scalar_t > &  wrld_z,
std::vector< std::vector< scalar_t > > &  cam_dx,
std::vector< std::vector< scalar_t > > &  cam_dy,
std::vector< std::vector< scalar_t > > &  cam_dz,
std::vector< std::vector< scalar_t > > &  wrld_dx,
std::vector< std::vector< scalar_t > > &  wrld_dy,
std::vector< std::vector< scalar_t > > &  wrld_dz 
)
inline

converts the camera x,y,z cooldinates to a world x,y,z coordinate system overloaded with first partials

Parameters
cam_xx location in cam x,y,z space
cam_yy location in cam x,y,z space
cam_zz location in cam x,y,z space
wrld_xx location in the world x,y,z space
wrld_yy location in the world x,y,z space
wrld_zz location in the world x,y,z space
cam_dxfirst partials of the x cam locations from previous projections
cam_dyfirst partials of the y cam locations from previous projections
cam_dzfirst partials of the z cam locations from previous projections
wrld_dxfirst partials of the x world locations
wrld_dyfirst partials of the y world locations
wrld_dzfirst partials of the z world locations

◆ cam_world_trans_matrix()

const Matrix<scalar_t,4>* DICe::Camera::cam_world_trans_matrix ( ) const
inline

gets the camera to world transformation matrix cam_world_trans 4x4 [R|T] transformation matrix {cam(x,y,z)}=[R|T]{world(x,y,z)}

◆ comments()

std::string DICe::Camera::comments ( ) const
inline

gets the camera comments returns the camera comments

◆ get_facet_params()

std::vector<scalar_t> DICe::Camera::get_facet_params ( )

returns the facet parameters from R and T (if they describe the pose estimation, likely from 2d calibration) in 3d, R and T describe a coordinate transformation, not the pose estimation of the calibration plate so this is only a useful method for 2d calibration

◆ id()

std::string DICe::Camera::id ( ) const
inline

gets the camera identifier returns the camera identifier

◆ image_to_sensor()

void DICe::Camera::image_to_sensor ( const std::vector< scalar_t > &  image_x,
const std::vector< scalar_t > &  image_y,
std::vector< scalar_t > &  sen_x,
std::vector< scalar_t > &  sen_y,
const bool  integer_locs = true 
)

converts image coordinates to sensor coordinates (lens distortion^-1, fx,fy,cx,cy)

Parameters
image_xx location after applied lens distortion
image_yy location after applied lens distortion
sen_xprojected x sensor location
sen_yprojected y sensor location
integer_locsif all image points are integers setting this flag avoids interpolation overhead

◆ image_to_world()

void DICe::Camera::image_to_world ( const std::vector< scalar_t > &  image_x,
const std::vector< scalar_t > &  image_y,
const std::vector< scalar_t > &  rigid_body_params,
std::vector< scalar_t > &  world_x,
std::vector< scalar_t > &  world_y,
std::vector< scalar_t > &  world_z 
)

helper function to convert image coordinates to world coordinates

Parameters
image_xx location after applied lens distortion
image_yy location after applied lens distortion
rigid_body_paramsprojection parameters that describe a rotation and traslation in space of a planar facet
world_xoutput world x coordinate
world_youtput world y coordinate
world_zoutput world z coordinate

◆ lens()

std::string DICe::Camera::lens ( ) const
inline

gets the camera lens identifier returns the camera lens description

◆ pixel_depth()

int_t DICe::Camera::pixel_depth ( ) const
inline

sets the pixel depth returns the pixel depth

◆ rot_trans_transform()

void DICe::Camera::rot_trans_transform ( const Matrix< scalar_t, 4 > &  RT_matrix,
const std::vector< scalar_t > &  in_x,
const std::vector< scalar_t > &  in_y,
const std::vector< scalar_t > &  in_z,
std::vector< scalar_t > &  out_x,
std::vector< scalar_t > &  out_y,
std::vector< scalar_t > &  out_z,
const std::vector< std::vector< scalar_t > > &  in_dx,
const std::vector< std::vector< scalar_t > > &  in_dy,
const std::vector< std::vector< scalar_t > > &  in_dz,
std::vector< std::vector< scalar_t > > &  out_dx,
std::vector< std::vector< scalar_t > > &  out_dy,
std::vector< std::vector< scalar_t > > &  out_dz 
)
private

generic translation/rotation transform

Parameters
in_xinput x location
in_yinput y location
in_zinput z location
out_xtransformed x location
out_ytransformed y location
out_ztransformed z location
in_dxderivitives from previous transformations
in_dyderivitives from previous transformations
in_dzderivitives from previous transformations
out_dxderivitives modifiec by the transform
out_dyderivitives modifiec by the transform
out_dzderivitives modifiec by the transform

◆ rotation_matrix()

const Matrix<scalar_t,3>* DICe::Camera::rotation_matrix ( ) const
inline

gets 3x3 rotation matrix [R]

Parameters
rotation_3x3_matrix[R] matrix transforming from the world coordinates to the camera coordinates

◆ sensor_to_cam()

void DICe::Camera::sensor_to_cam ( const std::vector< scalar_t > &  sen_x,
const std::vector< scalar_t > &  sen_y,
std::vector< scalar_t > &  cam_x,
std::vector< scalar_t > &  cam_y,
std::vector< scalar_t > &  cam_z,
const std::vector< scalar_t > &  facet_params,
std::vector< std::vector< scalar_t > > &  cam_dx,
std::vector< std::vector< scalar_t > > &  cam_dy,
std::vector< std::vector< scalar_t > > &  cam_dz 
)

projects sensor coordinates onto a plane in space described by zp,theta,phi overloaded for first partials

Parameters
sen_xx sensor location
sen_yy sensor location
cam_xprojected x location in cam x,y,z space
cam_yprojected y location in cam x,y,z space
cam_zprojected z location in cam x,y,z space
facet_paramsprojection parameters describing the plane in space (ZP, THETA, PHI)
cam_dxx location derivitives in cam x,y,z space partials wrt (ZP, THETA, PHI)
cam_dyy locatoin derivitives in cam x,y,z space partials wrt (ZP, THETA, PHI)
cam_dzz location derivitives in cam x,y,z space partials wrt (ZP, THETA, PHI)

◆ sensor_to_image()

void DICe::Camera::sensor_to_image ( const std::vector< scalar_t > &  sen_x,
const std::vector< scalar_t > &  sen_y,
std::vector< scalar_t > &  image_x,
std::vector< scalar_t > &  image_y,
const std::vector< std::vector< scalar_t > > &  sen_dx,
const std::vector< std::vector< scalar_t > > &  sen_dy,
std::vector< std::vector< scalar_t > > &  image_dx,
std::vector< std::vector< scalar_t > > &  image_dy 
)

convert sensor locations to image locations: applies lens distortion scales for fx,fy and converts to image coordiates with cx, cy with first partials

Parameters
sen_xprojected x sensor location
sen_yprojected y sensor location
image_xx location after applied lens distortion
image_yy location after applied lens distortion
sen_dxincoming location partials
sen_dyincoming location partials
image_dxoutgoing location partials lens distortion fixed value
image_dyoutgoing location partials lens distortion fixed value

◆ set_comments()

void DICe::Camera::set_comments ( const std::string &  camera_comments)
inline

sets the camera comments

Parameters
camera_commentscomments about the camera

◆ set_id()

void DICe::Camera::set_id ( const std::string &  cam_id)
inline

sets the camera identifier

Parameters
cam_idstring descripter for the camera

◆ set_lens()

void DICe::Camera::set_lens ( const std::string &  camera_lens)
inline

sets the camera lens identifier

Parameters
camera_lensstring descripter for the camera lens

◆ transform_coordinates_in_place()

static void DICe::Camera::transform_coordinates_in_place ( std::vector< scalar_t > &  x,
std::vector< scalar_t > &  y,
std::vector< scalar_t > &  z,
const std::vector< scalar_t > &  rigid_body_params 
)
static

transform coordinates according to the rbm parameters and replace input values the rigid_body_paramers should be ordered according to three euler angles and three translations (x,y,z) rigid_body_params version

◆ transformation_matrix()

Matrix<scalar_t,4> DICe::Camera::transformation_matrix ( ) const

returns a 4x4 matrix with the upper left block the rotation matrix, the right side column vector as the translations and the lower right entry as 1.0

◆ world_cam_trans_matrix()

const Matrix<scalar_t,4>* DICe::Camera::world_cam_trans_matrix ( ) const
inline

gets the world to camera transformation matrix cam_world_trans 4x4 [R|T] transformation matrix {world(x,y,z)}=[R|T]{cam(x,y,z)}

◆ world_to_cam()

void DICe::Camera::world_to_cam ( const std::vector< scalar_t > &  wrld_x,
const std::vector< scalar_t > &  wrld_y,
const std::vector< scalar_t > &  wrld_z,
std::vector< scalar_t > &  cam_x,
std::vector< scalar_t > &  cam_y,
std::vector< scalar_t > &  cam_z,
const std::vector< std::vector< scalar_t > > &  wrld_dx,
const std::vector< std::vector< scalar_t > > &  wrld_dy,
const std::vector< std::vector< scalar_t > > &  wrld_dz,
std::vector< std::vector< scalar_t > > &  cam_dx,
std::vector< std::vector< scalar_t > > &  cam_dy,
std::vector< std::vector< scalar_t > > &  cam_dz 
)
inline

converts world x,y,z coordinates to camera x,y,z coordinates overloaded with first partials

Parameters
wrld_xx location in the world x,y,z space
wrld_yy location in the world x,y,z space
wrld_zz location in the world x,y,z space
cam_xx location in cam x,y,z space
cam_yy location in cam x,y,z space
cam_zz location in cam x,y,z space
wrld_dxfirst partials of the x world locations from previous transformations
wrld_dyfirst partials of the x world locations from previous transformations
wrld_dzfirst partials of the x world locations from previous transformations
cam_dxfirst partials of the x cam locations
cam_dyfirst partials of the y cam locations
cam_dzfirst partials of the z cam locations