Class PerspectiveOps

java.lang.Object
boofcv.alg.geo.PerspectiveOps

public class PerspectiveOps extends Object
Functions related to perspective geometry and intrinsic camera calibration.
  • Constructor Details

    • PerspectiveOps

      public PerspectiveOps()
  • Method Details

    • approximatePinhole

      public static CameraPinhole approximatePinhole(Point2Transform2_F64 p2n, int width, int height)
      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 width
      height - Image height
      hfov - Horizontal FOV in degrees. If <= 0 then it will be set to the vfov
      vfov - 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 width
      height - Image height
      hfov - Horizontal FOV in degrees
      Returns:
      guess camera parameters
    • scaleIntrinsic

      public static void scaleIntrinsic(CameraPinhole param, double scale)
      Multiplies each element of the intrinsic parameters by the provided scale factor. Useful if the image has been rescaled.
      Parameters:
      param - Intrinsic parameters
      scale - 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 CameraPinholeBrown given an adjustment matrix.

      KA = A*K
      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 CameraPinholeBrown class.

      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 CameraPinholeBrown given an adjustment matrix.

      KA = A*K
      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 CameraPinholeBrown class.

      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

      public static DMatrixRMaj pinholeToMatrix(double fx, double fy, double skew, double cx, double cy)
      Given the intrinsic parameters create a calibration matrix
      Parameters:
      fx - Focal length x-axis in pixels
      fy - Focal length y-axis in pixels
      skew - skew in pixels
      cx - camera center x-axis in pixels
      cy - 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

      public static void invertPinhole(DMatrix3x3 K, DMatrix3x3 Kinv)
      Analytic matrix inversion to 3x3 camera calibration matrix. Input and output can be the same matrix. Zeros are not set.
      Parameters:
      K - (Input) Calibration matrix
      Kinv - (Output) inverse.
    • pinholeToMatrix

      public static FMatrixRMaj pinholeToMatrix(float fx, float fy, float skew, float xc, float yc)
      Given the intrinsic parameters create a calibration matrix
      Parameters:
      fx - Focal length x-axis in pixels
      fy - Focal length y-axis in pixels
      skew - skew in pixels
      xc - camera center x-axis in pixels
      yc - center center y-axis in pixels
      Returns:
      Calibration matrix 3x3
    • pinholeToMatrix

      public static DMatrixRMaj pinholeToMatrix(CameraPinhole param, @Nullable @Nullable DMatrixRMaj K)
      Given the intrinsic parameters create a calibration matrix
      Parameters:
      param - Intrinsic parameters structure that is to be converted into a matrix
      K - Storage for calibration matrix, must be 3x3. If null then a new matrix is declared
      Returns:
      Calibration matrix 3x3
    • pinholeToMatrix

      public static FMatrixRMaj pinholeToMatrix(CameraPinhole param, @Nullable @Nullable FMatrixRMaj K)
      Given the intrinsic parameters create a calibration matrix
      Parameters:
      param - Intrinsic parameters structure that is to be converted into a matrix
      K - Storage for calibration matrix, must be 3x3. If null then a new matrix is declared
      Returns:
      Calibration matrix 3x3
    • pinholeToMatrix

      public static DMatrix3x3 pinholeToMatrix(CameraPinhole param, @Nullable @Nullable DMatrix3x3 K)
      Given the intrinsic parameters create a calibration matrix
      Parameters:
      param - Intrinsic parameters structure that is to be converted into a matrix
      K - 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 pixels
      height - Image height in pixels
      output - (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 pixels
      height - Image height in pixels
      output - (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 coordinates
      width - Input image's width
      height - 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_F64 should be used instead.

      Parameters:
      param - Intrinsic camera parameters
      x - 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_F64 should be used instead.

      Parameters:
      param - Intrinsic camera parameters
      x - 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 PinholeNtoP_F64 should be used instead.

      NOTE: norm and pixel can be the same instance.
      Parameters:
      param - Intrinsic camera parameters
      norm - 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 PinholeNtoP_F64 should be used instead.

      NOTE: norm and pixel can be the same instance.
      Parameters:
      K - Intrinsic camera calibration matrix
      norm - 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 PinholePtoN_F64 should be used instead.

      NOTE: norm and pixel can be the same instance.
      Parameters:
      param - Intrinsic camera parameters
      pixel - 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(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 PinholePtoN_F32 should be used instead.

      NOTE: norm and pixel can be the same instance.
      Parameters:
      param - Intrinsic camera parameters
      pixel - 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(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 PinholePtoN_F64 should be used instead.

      NOTE: norm and pixel can be the same instance.
      Parameters:
      K - Intrinsic camera calibration matrix
      pixel - 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 PinholePtoN_F64 should be used instead.

      NOTE: norm and pixel can be the same instance.
      Parameters:
      K - Intrinsic camera calibration matrix
      pixel - 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 frame
      K - 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

      public static Point2D_F64 renderPixel(DMatrixRMaj worldToCamera, Point3D_F64 X)
      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 matrix
      X - (Input) 3D point in homogeneous coordinates
      x - (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 matrix
      X - (Input) 3D point in homogeneous coordinates
      x - (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 of AssociatedPair as 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 1
      view2 - 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 of AssociatedTriple as 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 1
      view2 - Output: List of observations from view 2
      view3 - 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. 3x3
      T - 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

      public static void projectionSplit(DMatrixRMaj P, DMatrixRMaj M, Vector3D_F64 T)
      Splits the projection matrix into a 3x3 matrix and 3x1 vector.
      Parameters:
      P - (Input) 3x4 projection matrix
      M - (Output) M = P(:,0:2)
      T - (Output) T = P(:,3)
    • projectionSplit

      public static void projectionSplit(DMatrixRMaj P, DMatrix3x3 M, DMatrix3 T)
      Splits the projection matrix into a 3x3 matrix and 3x1 vector.
      Parameters:
      P - (Input) 3x4 projection matirx
      M - (Output) M = P(:,0:2)
      T - (Output) T = P(:,3)
    • projectionCombine

      public static void projectionCombine(DMatrixRMaj M, Vector3D_F64 T, DMatrixRMaj P)
      P = [M|T]
      Parameters:
      M - (Input) 3x3 matrix
      T - (Input) 3x1 vector
      P - (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

      public static double computeHFov(CameraPinhole intrinsic)
    • computeVFov

      public static double computeVFov(CameraPinhole intrinsic)
    • convertToMatrix

      public static DMatrixRMaj convertToMatrix(Se3_F64 m, DMatrixRMaj A)
      Converts the SE3 into a 3x4 matrix. [R|T]
      Parameters:
      m - (Input) transform
      A - (Output) equivalent 3x4 matrix represenation
    • extractColumn

      public static void extractColumn(DMatrixRMaj P, int col, GeoTuple3D_F64<?> a)
      Extracts a column from the camera matrix and puts it into the geometric 3-tuple.
    • insertColumn

      public static void insertColumn(DMatrixRMaj P, int col, GeoTuple3D_F64<?> a)
      Inserts 3-tuple into the camera matrix's columns
    • multTranA

      public static void multTranA(DMatrixRMaj A, DMatrixRMaj B, DMatrixRMaj C, DMatrixRMaj output)
      Computes: D = AT*B*C
      Parameters:
      A - (Input) 3x3 matrix
      B - (Input) 3x3 matrix
      C - (Input) 3x3 matrix
      output - (Output) 3x3 matrix. Can be same instance A or B.
    • multTranC

      public static void multTranC(DMatrixRMaj A, DMatrixRMaj B, DMatrixRMaj C, DMatrixRMaj output)
      Computes: D = A*B*CT
      Parameters:
      A - (Input) 3x3 matrix
      B - (Input) 3x3 matrix
      C - (Input) 3x3 matrix
      output - (Output) 3x3 matrix. Can be same instance A or B.
    • multTranA

      public static void multTranA(DMatrix3x3 A, DMatrix3x3 B, DMatrix3x3 C, DMatrix3x3 output)
      Computes: D = AT*B*C
      Parameters:
      A - (Input) 3x3 matrix
      B - (Input) 3x3 matrix
      C - (Input) 3x3 matrix
      output - (Output) 3x3 matrix. Can be same instance A or B.
    • multTranC

      public static void multTranC(DMatrix3x3 A, DMatrix3x3 B, DMatrix3x3 C, DMatrix3x3 output)
      Computes: D = A*B*CT
      Parameters:
      A - (Input) 3x3 matrix
      B - (Input) 3x3 matrix
      C - (Input) 3x3 matrix
      output - (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 line
      a1 - Unique point on a line
      a2 - Unique point on a line
      a3 - 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 line
      a1 - Unique point on a line
      a2 - Unique point on a line
      a3 - 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 1e9
      tol - (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

      public static double distance(Point4D_F64 a, Point4D_F64 b)
      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 point
      b - 3D homogneous point
      Returns:
      A distance measure
    • distance3DvsH

      public static double distance3DvsH(Point3D_F64 a, Point4D_F64 b, double tol)
      Returns the Euclidean distance between a 3D point a point homogenous coordinates. If the homogenous point is at infinity, within tolererance, then Double.POSITIVE_INFINITY is returned.
      Parameters:
      a - (Input) 3D point
      b - (Input) Homogenous point
      tol - (Input) Tolerance for point being at infinity. Closer to zero means more strict. Try 1e-8
      Returns:
      Euclidean distance
    • isBehindCamera

      public static boolean isBehindCamera(Point4D_F64 p)

      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 matrix
      K_inv - (Output) inverted calibration matrix.
    • rotateH

      public static void rotateH(DMatrixRMaj R, Point4D_F64 src, Point4D_F64 dst)
      Applies a rotation to a homogenous 3D point
      Parameters:
      R - rotation matrix.
      src - (Input) point
      dst - (Output) point. Can be same instance as src
    • rotateInvH

      public static void rotateInvH(DMatrixRMaj R, Point4D_F64 src, Point4D_F64 dst)
      Applies a rotation in reverse to a homogenous 3D point
      Parameters:
      R - rotation matrix.
      src - (Input) point
      dst - (Output) point. Can be same instance as src