Class PerspectiveOps
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic <C extends CameraPinhole>
CadjustIntrinsic(C parameters, DMatrixRMaj adjustMatrix, C adjustedParam) Recomputes theCameraPinholeBrowngiven an adjustment matrix.static <C extends CameraPinhole>
CadjustIntrinsic(C parameters, FMatrixRMaj adjustMatrix, C adjustedParam) Recomputes theCameraPinholeBrowngiven an adjustment matrix.static CameraPinholeapproximatePinhole(Point2Transform2_F64 p2n, int width, int height) Approximates a pinhole camera using the distoriton modelstatic doublecomputeHFov(CameraPinhole intrinsic) static doublecomputeVFov(CameraPinhole intrinsic) static Point2D_F64convertNormToPixel(CameraModel param, double x, double y, @Nullable Point2D_F64 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate.static Point2D_F32convertNormToPixel(CameraModel param, float x, float y, @Nullable Point2D_F32 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate.static Point2D_F64convertNormToPixel(CameraModel param, Point2D_F64 norm, @Nullable Point2D_F64 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate.static Point2D_F64convertNormToPixel(CameraPinhole param, double x, double y, @Nullable Point2D_F64 pixel) static Point2D_F64convertNormToPixel(DMatrixRMaj K, Point2D_F64 norm, @Nullable Point2D_F64 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate.static Point2D_F32convertPixelToNorm(CameraModel param, Point2D_F32 pixel, @Nullable Point2D_F32 norm) Convenient function for converting from distorted image pixel coordinate to undistorted normalized image coordinates.static Point2D_F64convertPixelToNorm(CameraModel param, Point2D_F64 pixel, @Nullable Point2D_F64 norm) Convenient function for converting from distorted image pixel coordinate to undistorted normalized image coordinates.static Point2D_F64convertPixelToNorm(CameraPinhole intrinsic, double x, double y, @Nullable Point2D_F64 norm) static Point2D_F64convertPixelToNorm(DMatrixRMaj K, Point2D_F64 pixel, @Nullable Point2D_F64 norm) Convenient function for converting from original image pixel coordinate to normalized< image coordinates.static Point2D_F32convertPixelToNorm(FMatrixRMaj K, Point2D_F32 pixel, @Nullable Point2D_F32 norm) Convenient function for converting from original image pixel coordinate to normalized< image coordinates.static DMatrixRMajConverts the SE3 into a 3x4 matrix.static DMatrixRMajcreateCameraMatrix(DMatrixRMaj R, Vector3D_F64 T, @Nullable DMatrixRMaj K, @Nullable DMatrixRMaj ret) Create a 3x4 camera matrix.static CameraPinholecreateIntrinsic(int width, int height, double hfov, double vfov, @Nullable CameraPinhole intrinsic) Creates a set of intrinsic parameters, without distortion, for a camera with the specified characteristicsstatic CameraPinholeBrowncreateIntrinsic(int width, int height, double hfov, @Nullable CameraPinholeBrown intrinsic) Creates a set of intrinsic parameters, without distortion, for a camera with the specified characteristics.static WorldToCameraToPixelcreateWorldToPixel(LensDistortionNarrowFOV distortion, Se3_F64 worldToCamera) Creates a transform from world coordinates into pixel coordinates.static WorldToCameraToPixelcreateWorldToPixel(CameraPinholeBrown intrinsic, Se3_F64 worldToCamera) Creates a transform from world coordinates into pixel coordinates.static doubledistance(Point4D_F64 a, Point4D_F64 b) Returns a distance measure between two 3D homogenous points.static doubledistance3DvsH(Point3D_F64 a, Point4D_F64 b, double tol) Returns the Euclidean distance between a 3D point a point homogenous coordinates.static CameraPinholeestimatePinhole(Point2Transform2_F64 pixelToNorm, int width, int height) Given the transform from pixels to normalized image coordinates, create an approximate pinhole model for this camera.static voidextractColumn(DMatrixRMaj P, int col, GeoTuple3D_F64<?> a) Extracts a column from the camera matrix and puts it into the geometric 3-tuple.static voidhomogenousTo3dPositiveZ(Point4D_F64 p4, double farAway, double tol, Point3D_F64 p3) Converts a 3D homogenous coordinate into a non-homogenous coordinate.static voidinplaceAdjustCameraMatrix(double sx, double sy, double tx, double ty, DMatrixRMaj P) Multiplies A*P, where A = [sx 0 tx; 0 sy ty; 0 0 1]static voidinsertColumn(DMatrixRMaj P, int col, GeoTuple3D_F64<?> a) Inserts 3-tuple into the camera matrix's columnsstatic doubleinvariantAffine(Point2D_F64 p1, Point2D_F64 p2, Point2D_F64 p3, Point2D_F64 p4) Computes an invariant under affine distortion using 4 coplanar points.static doubleinvariantCrossLine(Point2D_F64 a0, Point2D_F64 a1, Point2D_F64 a2, Point2D_F64 a3) Computes the cross-ratio between 4 points that lie along a line.static doubleinvariantCrossLine(Point3D_F64 a0, Point3D_F64 a1, Point3D_F64 a2, Point3D_F64 a3) Computes the cross-ratio between 4 points that lie along a line.static doubleinvariantCrossRatio(Point2D_F64 p1, Point2D_F64 p2, Point2D_F64 p3, Point2D_F64 p4, Point2D_F64 p5) Computes the cross-ratio (invariant for projective transform) using 5 coplanar points.static DMatrixRMajinvertCalibrationMatrix(DMatrixRMaj K, @Nullable DMatrixRMaj K_inv) Inverts a camera calibration matrix using an analytic formula that takes advantage of its structure.static voidinvertPinhole(DMatrix3x3 K, DMatrix3x3 Kinv) Analytic matrix inversion to 3x3 camera calibration matrix.static booleanChecks to see if a point in homogenous coordinates is behind the camera, including z=0.static <C extends CameraPinhole>
CmatrixToPinhole(DMatrixRMaj K, int width, int height, C output) Converts a calibration matrix into intrinsic parametersstatic <C extends CameraPinhole>
CmatrixToPinhole(FMatrixRMaj K, int width, int height, C output) Converts a calibration matrix into intrinsic parametersstatic voidmultTranA(DMatrix3x3 A, DMatrix3x3 B, DMatrix3x3 C, DMatrix3x3 output) Computes: D = AT*B*Cstatic voidmultTranA(DMatrixRMaj A, DMatrixRMaj B, DMatrixRMaj C, DMatrixRMaj output) Computes: D = AT*B*Cstatic voidmultTranC(DMatrix3x3 A, DMatrix3x3 B, DMatrix3x3 C, DMatrix3x3 output) Computes: D = A*B*CTstatic voidmultTranC(DMatrixRMaj A, DMatrixRMaj B, DMatrixRMaj C, DMatrixRMaj output) Computes: D = A*B*CTstatic DMatrixRMajpinholeToMatrix(double fx, double fy, double skew, double cx, double cy) Given the intrinsic parameters create a calibration matrixstatic voidpinholeToMatrix(double fx, double fy, double skew, double cx, double cy, DMatrix3x3 K) static FMatrixRMajpinholeToMatrix(float fx, float fy, float skew, float xc, float yc) Given the intrinsic parameters create a calibration matrixstatic DMatrix3x3pinholeToMatrix(CameraPinhole param, @Nullable DMatrix3x3 K) Given the intrinsic parameters create a calibration matrixstatic DMatrixRMajpinholeToMatrix(CameraPinhole param, @Nullable DMatrixRMaj K) Given the intrinsic parameters create a calibration matrixstatic FMatrixRMajpinholeToMatrix(CameraPinhole param, @Nullable FMatrixRMaj K) Given the intrinsic parameters create a calibration matrixstatic voidP = [M|T]static voidprojectionSplit(DMatrixRMaj P, DMatrix3x3 M, DMatrix3 T) Splits the projection matrix into a 3x3 matrix and 3x1 vector.static voidSplits the projection matrix into a 3x3 matrix and 3x1 vector.static Point2D_F64renderPixel(CameraPinhole intrinsic, Point3D_F64 X, @Nullable Point2D_F64 pixel) Renders a point in camera coordinates into the image plane in pixels.static Point2D_F64renderPixel(CameraPinhole intrinsic, Point4D_F64 X, @Nullable Point2D_F64 pixel) static @Nullable Point2D_F64renderPixel(Se3_F64 worldToCamera, @Nullable DMatrixRMaj K, Point3D_F64 X, @Nullable Point2D_F64 pixel) Renders a point in world coordinates into the image plane in pixels or normalized image coordinates.static @Nullable Point2D_F64renderPixel(Se3_F64 worldToCamera, CameraPinhole K, Point3D_F64 X, @Nullable Point2D_F64 pixel) static @Nullable Point2D_F64renderPixel(Se3_F64 worldToCamera, CameraPinhole K, Point4D_F64 X, @Nullable Point2D_F64 pixel) static @Nullable Point2D_F64renderPixel(Se3_F64 worldToCamera, Point3D_F64 X, @Nullable Point2D_F64 pixel) static Point2D_F64renderPixel(DMatrixRMaj worldToCamera, Point3D_F64 X) Computes the image coordinate of a point given its 3D location and the camera matrix.static Point2D_F64renderPixel(DMatrixRMaj worldToCamera, Point3D_F64 X, @Nullable Point2D_F64 pixel) static Point3D_F64renderPixel(DMatrixRMaj worldToCamera, Point3D_F64 X, @Nullable Point3D_F64 pixel) static Point2D_F64renderPixel(DMatrixRMaj cameraMatrix, Point4D_F64 X, @Nullable Point2D_F64 x) Render a pixel in homogeneous coordinates from a 3x4 camera matrix and a 2D point.static Point3D_F64renderPixel(DMatrixRMaj cameraMatrix, Point4D_F64 X, @Nullable Point3D_F64 x) Render a pixel in homogeneous coordinates from a 3x4 camera matrix and a 3D homogeneous point.static Point3D_F64renderPointing(Se3_F64 worldToCamera, Point3D_F64 X, @Nullable Point3D_F64 pixel) Renders an observations as a pointing vector.static voidrotateH(DMatrixRMaj R, Point4D_F64 src, Point4D_F64 dst) Applies a rotation to a homogenous 3D pointstatic voidrotateInvH(DMatrixRMaj R, Point4D_F64 src, Point4D_F64 dst) Applies a rotation in reverse to a homogenous 3D pointstatic voidscaleIntrinsic(CameraPinhole param, double scale) Multiplies each element of the intrinsic parameters by the provided scale factor.static voidsplitAssociated(List<AssociatedPair> pairs, List<Point2D_F64> view1, List<Point2D_F64> view2) Takes a list ofAssociatedPairas input and breaks it up into two lists for each view.static voidsplitAssociated(List<AssociatedTriple> pairs, List<Point2D_F64> view1, List<Point2D_F64> view2, List<Point2D_F64> view3) Takes a list ofAssociatedTripleas input and breaks it up into three lists for each view.
-
Constructor Details
-
PerspectiveOps
public PerspectiveOps()
-
-
Method Details
-
approximatePinhole
Approximates a pinhole camera using the distoriton model- Parameters:
p2n- Distorted pixel to undistorted normalized image coordinates
-
createIntrinsic
public static CameraPinhole createIntrinsic(int width, int height, double hfov, double vfov, @Nullable @Nullable CameraPinhole intrinsic) Creates a set of intrinsic parameters, without distortion, for a camera with the specified characteristics- Parameters:
width- Image widthheight- Image heighthfov- Horizontal FOV in degrees. If <= 0 then it will be set to the vfovvfov- Vertical FOV in degrees. If <= 0 then it will be set to the hfov- Returns:
- guess camera parameters
-
createIntrinsic
public static CameraPinholeBrown createIntrinsic(int width, int height, double hfov, @Nullable @Nullable CameraPinholeBrown intrinsic) Creates a set of intrinsic parameters, without distortion, for a camera with the specified characteristics. The focal length is assumed to be the same for x and y.- Parameters:
width- Image widthheight- Image heighthfov- Horizontal FOV in degrees- Returns:
- guess camera parameters
-
scaleIntrinsic
Multiplies each element of the intrinsic parameters by the provided scale factor. Useful if the image has been rescaled.- Parameters:
param- Intrinsic parametersscale- Scale factor that input image is being scaled by.
-
adjustIntrinsic
public static <C extends CameraPinhole> C adjustIntrinsic(C parameters, DMatrixRMaj adjustMatrix, C adjustedParam) Recomputes the
KA = A*KCameraPinholeBrowngiven an adjustment matrix.
Where KA is the returned adjusted intrinsic matrix, A is the adjustment matrix and K is the original intrinsic calibration matrix.NOTE: Distortion parameters are ignored in the provided
CameraPinholeBrownclass.- Parameters:
parameters- (Input) Original intrinsic parameters. Not modified.adjustMatrix- (Input) Adjustment matrix. Not modified.adjustedParam- (Output) Optional storage for adjusted intrinsic parameters. Can be null.- Returns:
- Adjusted intrinsic parameters.
-
adjustIntrinsic
public static <C extends CameraPinhole> C adjustIntrinsic(C parameters, FMatrixRMaj adjustMatrix, C adjustedParam) Recomputes the
KA = A*KCameraPinholeBrowngiven an adjustment matrix.
Where KA is the returned adjusted intrinsic matrix, A is the adjustment matrix and K is the original intrinsic calibration matrix.NOTE: Distortion parameters are ignored in the provided
CameraPinholeBrownclass.- Parameters:
parameters- (Input) Original intrinsic parameters. Not modified.adjustMatrix- (Input) Adjustment matrix. Not modified.adjustedParam- (Output) Optional storage for adjusted intrinsic parameters. Can be null.- Returns:
- Adjusted intrinsic parameters.
-
pinholeToMatrix
Given the intrinsic parameters create a calibration matrix- Parameters:
fx- Focal length x-axis in pixelsfy- Focal length y-axis in pixelsskew- skew in pixelscx- camera center x-axis in pixelscy- center center y-axis in pixels- Returns:
- Calibration matrix 3x3
-
pinholeToMatrix
public static void pinholeToMatrix(double fx, double fy, double skew, double cx, double cy, DMatrix3x3 K) -
invertPinhole
Analytic matrix inversion to 3x3 camera calibration matrix. Input and output can be the same matrix. Zeros are not set.- Parameters:
K- (Input) Calibration matrixKinv- (Output) inverse.
-
pinholeToMatrix
Given the intrinsic parameters create a calibration matrix- Parameters:
fx- Focal length x-axis in pixelsfy- Focal length y-axis in pixelsskew- skew in pixelsxc- camera center x-axis in pixelsyc- center center y-axis in pixels- Returns:
- Calibration matrix 3x3
-
pinholeToMatrix
Given the intrinsic parameters create a calibration matrix- Parameters:
param- Intrinsic parameters structure that is to be converted into a matrixK- Storage for calibration matrix, must be 3x3. If null then a new matrix is declared- Returns:
- Calibration matrix 3x3
-
pinholeToMatrix
Given the intrinsic parameters create a calibration matrix- Parameters:
param- Intrinsic parameters structure that is to be converted into a matrixK- Storage for calibration matrix, must be 3x3. If null then a new matrix is declared- Returns:
- Calibration matrix 3x3
-
pinholeToMatrix
Given the intrinsic parameters create a calibration matrix- Parameters:
param- Intrinsic parameters structure that is to be converted into a matrixK- Storage for calibration matrix, must be 3x3. If null then a new matrix is declared- Returns:
- Calibration matrix 3x3
-
matrixToPinhole
public static <C extends CameraPinhole> C matrixToPinhole(DMatrixRMaj K, int width, int height, @Nullable C output) Converts a calibration matrix into intrinsic parameters- Parameters:
K- Camera calibration matrix.width- Image width in pixelsheight- Image height in pixelsoutput- (Output) Where the intrinsic parameter are written to. If null then a new instance is declared.- Returns:
- camera parameters
-
matrixToPinhole
public static <C extends CameraPinhole> C matrixToPinhole(FMatrixRMaj K, int width, int height, @Nullable C output) Converts a calibration matrix into intrinsic parameters- Parameters:
K- Camera calibration matrix.width- Image width in pixelsheight- Image height in pixelsoutput- (Output) Where the intrinsic parameter are written to. If null then a new instance is declared.- Returns:
- camera parameters
-
estimatePinhole
public static CameraPinhole estimatePinhole(Point2Transform2_F64 pixelToNorm, int width, int height) Given the transform from pixels to normalized image coordinates, create an approximate pinhole model for this camera. Assumes (cx,cy) is the image center and that there is no skew.- Parameters:
pixelToNorm- Pixel coordinates into normalized image coordinateswidth- Input image's widthheight- Input image's height- Returns:
- Approximate pinhole camera
-
convertNormToPixel
public static Point2D_F64 convertNormToPixel(CameraModel param, double x, double y, @Nullable @Nullable Point2D_F64 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate. If speed is a concern then
PinholeNtoP_F64should be used instead.- Parameters:
param- Intrinsic camera parametersx- X-coordinate of normalized.y- Y-coordinate of normalized.pixel- Optional storage for output. If null a new instance will be declared.- Returns:
- pixel image coordinate
-
convertNormToPixel
public static Point2D_F64 convertNormToPixel(CameraPinhole param, double x, double y, @Nullable @Nullable Point2D_F64 pixel) -
convertNormToPixel
public static Point2D_F32 convertNormToPixel(CameraModel param, float x, float y, @Nullable @Nullable Point2D_F32 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate. If speed is a concern then
PinholeNtoP_F64should be used instead.- Parameters:
param- Intrinsic camera parametersx- X-coordinate of normalized.y- Y-coordinate of normalized.pixel- Optional storage for output. If null a new instance will be declared.- Returns:
- pixel image coordinate
-
convertNormToPixel
public static Point2D_F64 convertNormToPixel(CameraModel param, Point2D_F64 norm, @Nullable @Nullable Point2D_F64 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate. If speed is a concern then
NOTE: norm and pixel can be the same instance.PinholeNtoP_F64should be used instead.- Parameters:
param- Intrinsic camera parametersnorm- Normalized image coordinate.pixel- Optional storage for output. If null a new instance will be declared.- Returns:
- pixel image coordinate
-
convertNormToPixel
public static Point2D_F64 convertNormToPixel(DMatrixRMaj K, Point2D_F64 norm, @Nullable @Nullable Point2D_F64 pixel) Convenient function for converting from normalized image coordinates to the original image pixel coordinate. If speed is a concern then
NOTE: norm and pixel can be the same instance.PinholeNtoP_F64should be used instead.- Parameters:
K- Intrinsic camera calibration matrixnorm- Normalized image coordinate.pixel- Optional storage for output. If null a new instance will be declared.- Returns:
- pixel image coordinate
-
convertPixelToNorm
public static Point2D_F64 convertPixelToNorm(CameraModel param, Point2D_F64 pixel, @Nullable @Nullable Point2D_F64 norm) Convenient function for converting from distorted image pixel coordinate to undistorted normalized image coordinates. If speed is a concern then
NOTE: norm and pixel can be the same instance.PinholePtoN_F64should be used instead.- Parameters:
param- Intrinsic camera parameterspixel- Pixel coordinatenorm- Optional storage for output. If null a new instance will be declared.- Returns:
- normalized image coordinate
-
convertPixelToNorm
public static Point2D_F32 convertPixelToNorm(CameraModel param, Point2D_F32 pixel, @Nullable @Nullable Point2D_F32 norm) Convenient function for converting from distorted image pixel coordinate to undistorted normalized image coordinates. If speed is a concern then
NOTE: norm and pixel can be the same instance.PinholePtoN_F32should be used instead.- Parameters:
param- Intrinsic camera parameterspixel- Pixel coordinatenorm- Optional storage for output. If null a new instance will be declared.- Returns:
- normalized image coordinate
-
convertPixelToNorm
public static Point2D_F64 convertPixelToNorm(DMatrixRMaj K, Point2D_F64 pixel, @Nullable @Nullable Point2D_F64 norm) Convenient function for converting from original image pixel coordinate to normalized< image coordinates. If speed is a concern then
NOTE: norm and pixel can be the same instance.PinholePtoN_F64should be used instead.- Parameters:
K- Intrinsic camera calibration matrixpixel- Pixel coordinate.norm- Optional storage for output. If null a new instance will be declared.- Returns:
- normalized image coordinate
-
convertPixelToNorm
public static Point2D_F32 convertPixelToNorm(FMatrixRMaj K, Point2D_F32 pixel, @Nullable @Nullable Point2D_F32 norm) Convenient function for converting from original image pixel coordinate to normalized< image coordinates. If speed is a concern then
NOTE: norm and pixel can be the same instance.PinholePtoN_F64should be used instead.- Parameters:
K- Intrinsic camera calibration matrixpixel- Pixel coordinate.norm- Optional storage for output. If null a new instance will be declared.- Returns:
- normalized image coordinate
-
convertPixelToNorm
public static Point2D_F64 convertPixelToNorm(CameraPinhole intrinsic, double x, double y, @Nullable @Nullable Point2D_F64 norm) -
renderPixel
@Nullable public static @Nullable Point2D_F64 renderPixel(Se3_F64 worldToCamera, @Nullable @Nullable DMatrixRMaj K, Point3D_F64 X, @Nullable @Nullable Point2D_F64 pixel) Renders a point in world coordinates into the image plane in pixels or normalized image coordinates.- Parameters:
worldToCamera- Transform from world to camera frameK- Optional. Intrinsic camera calibration matrix. If null then normalized image coordinates are returned.X- 3D Point in world reference frame..pixel- (Output) storage for the rendered pixel- Returns:
- 2D Render point on image plane or null if it's behind the camera
-
renderPixel
@Nullable public static @Nullable Point2D_F64 renderPixel(Se3_F64 worldToCamera, CameraPinhole K, Point3D_F64 X, @Nullable @Nullable Point2D_F64 pixel) -
renderPixel
@Nullable public static @Nullable Point2D_F64 renderPixel(Se3_F64 worldToCamera, CameraPinhole K, Point4D_F64 X, @Nullable @Nullable Point2D_F64 pixel) -
renderPixel
@Nullable public static @Nullable Point2D_F64 renderPixel(Se3_F64 worldToCamera, Point3D_F64 X, @Nullable @Nullable Point2D_F64 pixel) -
renderPointing
public static Point3D_F64 renderPointing(Se3_F64 worldToCamera, Point3D_F64 X, @Nullable @Nullable Point3D_F64 pixel) Renders an observations as a pointing vector.- Parameters:
X- 3D Point in world reference frame.pixel- (Output) storage for the rendered pixel- Returns:
- Rendering observations as a pointing vector
-
renderPixel
public static Point2D_F64 renderPixel(CameraPinhole intrinsic, Point3D_F64 X, @Nullable @Nullable Point2D_F64 pixel) Renders a point in camera coordinates into the image plane in pixels. Does not check to see if the point is behind the camera or not- Parameters:
intrinsic- Intrinsic camera parameters.X- 3D Point in camera reference frame..pixel- (Output) Storage for output pixel. Can be null- Returns:
- 2D Render point on image plane
-
renderPixel
public static Point2D_F64 renderPixel(CameraPinhole intrinsic, Point4D_F64 X, @Nullable @Nullable Point2D_F64 pixel) -
renderPixel
Computes the image coordinate of a point given its 3D location and the camera matrix.- Parameters:
worldToCamera- 3x4 camera matrix for transforming a 3D point from world to image coordinates.X- 3D Point in world reference frame..- Returns:
- 2D Render point on image plane.
-
renderPixel
public static Point2D_F64 renderPixel(DMatrixRMaj worldToCamera, Point3D_F64 X, @Nullable @Nullable Point2D_F64 pixel) -
renderPixel
public static Point3D_F64 renderPixel(DMatrixRMaj worldToCamera, Point3D_F64 X, @Nullable @Nullable Point3D_F64 pixel) -
renderPixel
public static Point3D_F64 renderPixel(DMatrixRMaj cameraMatrix, Point4D_F64 X, @Nullable @Nullable Point3D_F64 x) Render a pixel in homogeneous coordinates from a 3x4 camera matrix and a 3D homogeneous point.- Parameters:
cameraMatrix- (Input) 3x4 camera matrixX- (Input) 3D point in homogeneous coordinatesx- (Output) Rendered 2D point in homogeneous coordinates- Returns:
- Rendered 2D point in homogeneous coordinates
-
renderPixel
public static Point2D_F64 renderPixel(DMatrixRMaj cameraMatrix, Point4D_F64 X, @Nullable @Nullable Point2D_F64 x) Render a pixel in homogeneous coordinates from a 3x4 camera matrix and a 2D point.- Parameters:
cameraMatrix- (Input) 3x4 camera matrixX- (Input) 3D point in homogeneous coordinatesx- (Output) Rendered 2D point coordinates- Returns:
- Rendered 2D point coordinates
-
splitAssociated
public static void splitAssociated(List<AssociatedPair> pairs, List<Point2D_F64> view1, List<Point2D_F64> view2) Takes a list ofAssociatedPairas input and breaks it up into two lists for each view.- Parameters:
pairs- Input: List of associated pairs.view1- Output: List of observations from view 1view2- Output: List of observations from view 2
-
splitAssociated
public static void splitAssociated(List<AssociatedTriple> pairs, List<Point2D_F64> view1, List<Point2D_F64> view2, List<Point2D_F64> view3) Takes a list ofAssociatedTripleas input and breaks it up into three lists for each view.- Parameters:
pairs- Input: List of associated triples.view1- Output: List of observations from view 1view2- Output: List of observations from view 2view3- Output: List of observations from view 3
-
createCameraMatrix
public static DMatrixRMaj createCameraMatrix(DMatrixRMaj R, Vector3D_F64 T, @Nullable @Nullable DMatrixRMaj K, @Nullable @Nullable DMatrixRMaj ret) Create a 3x4 camera matrix. For calibrated camera P = [R|T]. For uncalibrated camera it is P = K*[R|T].- Parameters:
R- Rotation matrix. 3x3T- Translation vector.K- Optional camera calibration matrix 3x3.ret- Storage for camera calibration matrix. If null a new instance will be created.- Returns:
- Camera calibration matrix.
-
projectionSplit
Splits the projection matrix into a 3x3 matrix and 3x1 vector.- Parameters:
P- (Input) 3x4 projection matrixM- (Output) M = P(:,0:2)T- (Output) T = P(:,3)
-
projectionSplit
Splits the projection matrix into a 3x3 matrix and 3x1 vector.- Parameters:
P- (Input) 3x4 projection matirxM- (Output) M = P(:,0:2)T- (Output) T = P(:,3)
-
projectionCombine
P = [M|T]- Parameters:
M- (Input) 3x3 matrixT- (Input) 3x1 vectorP- (Output) [M,T]
-
createWorldToPixel
public static WorldToCameraToPixel createWorldToPixel(CameraPinholeBrown intrinsic, Se3_F64 worldToCamera) Creates a transform from world coordinates into pixel coordinates. can handle lens distortion -
createWorldToPixel
public static WorldToCameraToPixel createWorldToPixel(LensDistortionNarrowFOV distortion, Se3_F64 worldToCamera) Creates a transform from world coordinates into pixel coordinates. can handle lens distortion -
computeHFov
-
computeVFov
-
convertToMatrix
Converts the SE3 into a 3x4 matrix. [R|T]- Parameters:
m- (Input) transformA- (Output) equivalent 3x4 matrix represenation
-
extractColumn
Extracts a column from the camera matrix and puts it into the geometric 3-tuple. -
insertColumn
Inserts 3-tuple into the camera matrix's columns -
multTranA
Computes: D = AT*B*C- Parameters:
A- (Input) 3x3 matrixB- (Input) 3x3 matrixC- (Input) 3x3 matrixoutput- (Output) 3x3 matrix. Can be same instance A or B.
-
multTranC
Computes: D = A*B*CT- Parameters:
A- (Input) 3x3 matrixB- (Input) 3x3 matrixC- (Input) 3x3 matrixoutput- (Output) 3x3 matrix. Can be same instance A or B.
-
multTranA
Computes: D = AT*B*C- Parameters:
A- (Input) 3x3 matrixB- (Input) 3x3 matrixC- (Input) 3x3 matrixoutput- (Output) 3x3 matrix. Can be same instance A or B.
-
multTranC
Computes: D = A*B*CT- Parameters:
A- (Input) 3x3 matrixB- (Input) 3x3 matrixC- (Input) 3x3 matrixoutput- (Output) 3x3 matrix. Can be same instance A or B.
-
inplaceAdjustCameraMatrix
public static void inplaceAdjustCameraMatrix(double sx, double sy, double tx, double ty, DMatrixRMaj P) Multiplies A*P, where A = [sx 0 tx; 0 sy ty; 0 0 1] -
invariantCrossLine
public static double invariantCrossLine(Point3D_F64 a0, Point3D_F64 a1, Point3D_F64 a2, Point3D_F64 a3) Computes the cross-ratio between 4 points that lie along a line. This is an invariant under projective geometry.- Parameters:
a0- Unique point on a linea1- Unique point on a linea2- Unique point on a linea3- Unique point on a line- Returns:
- cross ratio
-
invariantCrossLine
public static double invariantCrossLine(Point2D_F64 a0, Point2D_F64 a1, Point2D_F64 a2, Point2D_F64 a3) Computes the cross-ratio between 4 points that lie along a line. This is an invariant under projective geometry.- Parameters:
a0- Unique point on a linea1- Unique point on a linea2- Unique point on a linea3- Unique point on a line- Returns:
- cross ratio
-
invariantCrossRatio
public static double invariantCrossRatio(Point2D_F64 p1, Point2D_F64 p2, Point2D_F64 p3, Point2D_F64 p4, Point2D_F64 p5) Computes the cross-ratio (invariant for projective transform) using 5 coplanar points.
cross ratio = P(1,2,3)*P(1,4,5)/(P(1,2,4)*P(1,3,5))
where P() is the area of a triangle defined by the 3 points.NOTE: Perspective and projective transforms are the same thing
Nakai, Tomohiro, Koichi Kise, and Masakazu Iwamura. "Hashing with local combinations of feature points and its application to camera-based document image retrieval." Proc. CBDAR05 (2005): 87-94.
-
invariantAffine
public static double invariantAffine(Point2D_F64 p1, Point2D_F64 p2, Point2D_F64 p3, Point2D_F64 p4) Computes an invariant under affine distortion using 4 coplanar points.
invariant = P(1,3,4)/P(1,2,3)
where P() is the area of a triangle defined by the 3 points. -
homogenousTo3dPositiveZ
public static void homogenousTo3dPositiveZ(Point4D_F64 p4, double farAway, double tol, Point3D_F64 p3) Converts a 3D homogenous coordinate into a non-homogenous coordinate. Things get tricky when a point is at or "close to" infinity. This situation is handled by throwing it at some distant location. This is a reasonable approach when you can't just skip the point. It's assumed that points at infinity have a positive Z value.- Parameters:
p4- (Input) Homogenous coordinate.farAway- (Input) How far away points at infinity should be put. Application dependent. Try 1e9tol- (Input) Tolerance for defining a point at infinity. If p4 has a norm of 1 then 1e-7 is probably reasonable.p3- (output) Cartesian coordinate.
-
distance
Returns a distance measure between two 3D homogenous points. There is no well defined way to measure distance in homogenous space.distance = norm( a/norm(a) - b/norm(b) )
- Parameters:
a- 3D homogneous pointb- 3D homogneous point- Returns:
- A distance measure
-
distance3DvsH
Returns the Euclidean distance between a 3D point a point homogenous coordinates. If the homogenous point is at infinity, within tolererance, thenDouble.POSITIVE_INFINITYis returned.- Parameters:
a- (Input) 3D pointb- (Input) Homogenous pointtol- (Input) Tolerance for point being at infinity. Closer to zero means more strict. Try 1e-8- Returns:
- Euclidean distance
-
isBehindCamera
Checks to see if a point in homogenous coordinates is behind the camera, including z=0. This is made more complex as the possibility that it's at infinity needs to be explicitly checked and handled.
if a point lies on the (x-y) plane exactly it will be considered behind the camera.
- Returns:
- true if it's behind the camera (z < 0.0)
-
invertCalibrationMatrix
public static DMatrixRMaj invertCalibrationMatrix(DMatrixRMaj K, @Nullable @Nullable DMatrixRMaj K_inv) Inverts a camera calibration matrix using an analytic formula that takes advantage of its structure. K and K_inv can be the same instance.- Parameters:
K- (Input) 3x3 intrinsic calibration matrixK_inv- (Output) inverted calibration matrix.
-
rotateH
Applies a rotation to a homogenous 3D point- Parameters:
R- rotation matrix.src- (Input) pointdst- (Output) point. Can be same instance as src
-
rotateInvH
Applies a rotation in reverse to a homogenous 3D point- Parameters:
R- rotation matrix.src- (Input) pointdst- (Output) point. Can be same instance as src
-