Class PerspectiveOps


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

      Constructors 
      Constructor Description
      PerspectiveOps()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <C extends CameraPinhole>
      C
      adjustIntrinsic​(C parameters, org.ejml.data.DMatrixRMaj adjustMatrix, C adjustedParam)
      Recomputes the CameraPinholeBrown given an adjustment matrix.
      static <C extends CameraPinhole>
      C
      adjustIntrinsic​(C parameters, org.ejml.data.FMatrixRMaj adjustMatrix, C adjustedParam)
      Recomputes the CameraPinholeBrown given an adjustment matrix.
      static CameraPinhole approximatePinhole​(boofcv.struct.distort.Point2Transform2_F64 p2n, int width, int height)
      Approximates a pinhole camera using the distoriton model
      static double computeHFov​(CameraPinhole intrinsic)  
      static double computeVFov​(CameraPinhole intrinsic)  
      static georegression.struct.point.Point2D_F64 convertNormToPixel​(CameraModel param, double x, double y, georegression.struct.point.Point2D_F64 pixel)
      Convenient function for converting from normalized image coordinates to the original image pixel coordinate.
      static georegression.struct.point.Point2D_F32 convertNormToPixel​(CameraModel param, float x, float y, georegression.struct.point.Point2D_F32 pixel)
      Convenient function for converting from normalized image coordinates to the original image pixel coordinate.
      static georegression.struct.point.Point2D_F64 convertNormToPixel​(CameraModel param, georegression.struct.point.Point2D_F64 norm, georegression.struct.point.Point2D_F64 pixel)
      Convenient function for converting from normalized image coordinates to the original image pixel coordinate.
      static georegression.struct.point.Point2D_F64 convertNormToPixel​(CameraPinhole param, double x, double y, georegression.struct.point.Point2D_F64 pixel)  
      static georegression.struct.point.Point2D_F64 convertNormToPixel​(org.ejml.data.DMatrixRMaj K, georegression.struct.point.Point2D_F64 norm, georegression.struct.point.Point2D_F64 pixel)
      Convenient function for converting from normalized image coordinates to the original image pixel coordinate.
      static georegression.struct.point.Point2D_F32 convertPixelToNorm​(CameraModel param, georegression.struct.point.Point2D_F32 pixel, georegression.struct.point.Point2D_F32 norm)
      Convenient function for converting from distorted image pixel coordinate to undistorted normalized image coordinates.
      static georegression.struct.point.Point2D_F64 convertPixelToNorm​(CameraModel param, georegression.struct.point.Point2D_F64 pixel, georegression.struct.point.Point2D_F64 norm)
      Convenient function for converting from distorted image pixel coordinate to undistorted normalized image coordinates.
      static georegression.struct.point.Point2D_F64 convertPixelToNorm​(CameraPinhole intrinsic, double x, double y, georegression.struct.point.Point2D_F64 norm)  
      static georegression.struct.point.Point2D_F64 convertPixelToNorm​(org.ejml.data.DMatrixRMaj K, georegression.struct.point.Point2D_F64 pixel, georegression.struct.point.Point2D_F64 norm)
      Convenient function for converting from original image pixel coordinate to normalized< image coordinates.
      static georegression.struct.point.Point2D_F32 convertPixelToNorm​(org.ejml.data.FMatrixRMaj K, georegression.struct.point.Point2D_F32 pixel, georegression.struct.point.Point2D_F32 norm)
      Convenient function for converting from original image pixel coordinate to normalized< image coordinates.
      static org.ejml.data.DMatrixRMaj convertToMatrix​(georegression.struct.se.Se3_F64 m, org.ejml.data.DMatrixRMaj A)
      Converts the SE3 into a 3x4 matrix.
      static org.ejml.data.DMatrixRMaj createCameraMatrix​(org.ejml.data.DMatrixRMaj R, georegression.struct.point.Vector3D_F64 T, org.ejml.data.DMatrixRMaj K, org.ejml.data.DMatrixRMaj ret)
      Create a 3x4 camera matrix.
      static CameraPinholeBrown createIntrinsic​(int width, int height, double hfov)
      Creates a set of intrinsic parameters, without distortion, for a camera with the specified characteristics.
      static CameraPinhole createIntrinsic​(int width, int height, double hfov, double vfov)
      Creates a set of intrinsic parameters, without distortion, for a camera with the specified characteristics
      static WorldToCameraToPixel createWorldToPixel​(LensDistortionNarrowFOV distortion, georegression.struct.se.Se3_F64 worldToCamera)
      Creates a transform from world coordinates into pixel coordinates.
      static WorldToCameraToPixel createWorldToPixel​(CameraPinholeBrown intrinsic, georegression.struct.se.Se3_F64 worldToCamera)
      Creates a transform from world coordinates into pixel coordinates.
      static CameraPinhole estimatePinhole​(boofcv.struct.distort.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 void extractColumn​(org.ejml.data.DMatrixRMaj P, int col, georegression.struct.GeoTuple3D_F64 a)
      Extracts a column from the camera matrix and puts it into the geometric 3-tuple.
      static void homogenousTo3dPositiveZ​(georegression.struct.point.Point4D_F64 p4, double farAway, double tol, georegression.struct.point.Point3D_F64 p3)
      Converts a 3D homogenous coordinate into a non-homogenous coordinate.
      static void inplaceAdjustCameraMatrix​(double sx, double sy, double tx, double ty, org.ejml.data.DMatrixRMaj P)
      Multiplies A*P, where A = [sx 0 tx; 0 sy ty; 0 0 1]
      static void insertColumn​(org.ejml.data.DMatrixRMaj P, int col, georegression.struct.GeoTuple3D_F64 a)
      Inserts 3-tuple into the camera matrix's columns
      static double invariantAffine​(georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Point2D_F64 p2, georegression.struct.point.Point2D_F64 p3, georegression.struct.point.Point2D_F64 p4)
      Computes an invariant under affine distortion using 4 coplanar points.
      static double invariantCrossLine​(georegression.struct.point.Point2D_F64 a0, georegression.struct.point.Point2D_F64 a1, georegression.struct.point.Point2D_F64 a2, georegression.struct.point.Point2D_F64 a3)
      Computes the cross-ratio between 4 points that lie along a line.
      static double invariantCrossLine​(georegression.struct.point.Point3D_F64 a0, georegression.struct.point.Point3D_F64 a1, georegression.struct.point.Point3D_F64 a2, georegression.struct.point.Point3D_F64 a3)
      Computes the cross-ratio between 4 points that lie along a line.
      static double invariantCrossRatio​(georegression.struct.point.Point2D_F64 p1, georegression.struct.point.Point2D_F64 p2, georegression.struct.point.Point2D_F64 p3, georegression.struct.point.Point2D_F64 p4, georegression.struct.point.Point2D_F64 p5)
      Computes the cross-ratio (invariant for projective transform) using 5 coplanar points.
      static void invertPinhole​(org.ejml.data.DMatrix3x3 K, org.ejml.data.DMatrix3x3 Kinv)
      Analytic matrix inversion to 3x3 camera calibration matrix.
      static <C extends CameraPinhole>
      C
      matrixToPinhole​(org.ejml.data.DMatrixRMaj K, int width, int height, C output)
      Converts a calibration matrix into intrinsic parameters
      static <C extends CameraPinhole>
      C
      matrixToPinhole​(org.ejml.data.FMatrixRMaj K, int width, int height, C output)
      Converts a calibration matrix into intrinsic parameters
      static void multTranA​(org.ejml.data.DMatrix3x3 A, org.ejml.data.DMatrix3x3 B, org.ejml.data.DMatrix3x3 C, org.ejml.data.DMatrix3x3 output)
      Computes: D = AT*B*C
      static void multTranA​(org.ejml.data.DMatrixRMaj A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C, org.ejml.data.DMatrixRMaj output)
      Computes: D = AT*B*C
      static void multTranC​(org.ejml.data.DMatrix3x3 A, org.ejml.data.DMatrix3x3 B, org.ejml.data.DMatrix3x3 C, org.ejml.data.DMatrix3x3 output)
      Computes: D = A*B*CT
      static void multTranC​(org.ejml.data.DMatrixRMaj A, org.ejml.data.DMatrixRMaj B, org.ejml.data.DMatrixRMaj C, org.ejml.data.DMatrixRMaj output)
      Computes: D = A*B*CT
      static org.ejml.data.DMatrixRMaj pinholeToMatrix​(double fx, double fy, double skew, double cx, double cy)
      Given the intrinsic parameters create a calibration matrix
      static void pinholeToMatrix​(double fx, double fy, double skew, double cx, double cy, org.ejml.data.DMatrix3x3 K)  
      static org.ejml.data.FMatrixRMaj pinholeToMatrix​(float fx, float fy, float skew, float xc, float yc)
      Given the intrinsic parameters create a calibration matrix
      static org.ejml.data.DMatrix3x3 pinholeToMatrix​(CameraPinhole param, org.ejml.data.DMatrix3x3 K)
      Given the intrinsic parameters create a calibration matrix
      static org.ejml.data.DMatrixRMaj pinholeToMatrix​(CameraPinhole param, org.ejml.data.DMatrixRMaj K)
      Given the intrinsic parameters create a calibration matrix
      static org.ejml.data.FMatrixRMaj pinholeToMatrix​(CameraPinhole param, org.ejml.data.FMatrixRMaj K)
      Given the intrinsic parameters create a calibration matrix
      static void projectionCombine​(org.ejml.data.DMatrixRMaj M, georegression.struct.point.Vector3D_F64 T, org.ejml.data.DMatrixRMaj P)
      P = [M|T]
      static void projectionSplit​(org.ejml.data.DMatrixRMaj P, org.ejml.data.DMatrix3x3 M, org.ejml.data.DMatrix3 T)
      Splits the projection matrix into a 3x3 matrix and 3x1 vector.
      static void projectionSplit​(org.ejml.data.DMatrixRMaj P, org.ejml.data.DMatrixRMaj M, georegression.struct.point.Vector3D_F64 T)
      Splits the projection matrix into a 3x3 matrix and 3x1 vector.
      static georegression.struct.point.Point2D_F64 renderPixel​(CameraPinhole intrinsic, georegression.struct.point.Point3D_F64 X, georegression.struct.point.Point2D_F64 pixel)
      Renders a point in camera coordinates into the image plane in pixels.
      static georegression.struct.point.Point2D_F64 renderPixel​(georegression.struct.se.Se3_F64 worldToCamera, CameraPinhole K, georegression.struct.point.Point3D_F64 X, georegression.struct.point.Point2D_F64 pixel)  
      static georegression.struct.point.Point2D_F64 renderPixel​(georegression.struct.se.Se3_F64 worldToCamera, georegression.struct.point.Point3D_F64 X, georegression.struct.point.Point2D_F64 pixel)  
      static georegression.struct.point.Point2D_F64 renderPixel​(georegression.struct.se.Se3_F64 worldToCamera, org.ejml.data.DMatrixRMaj K, georegression.struct.point.Point3D_F64 X, georegression.struct.point.Point2D_F64 pixel)
      Renders a point in world coordinates into the image plane in pixels or normalized image coordinates.
      static georegression.struct.point.Point2D_F64 renderPixel​(org.ejml.data.DMatrixRMaj worldToCamera, georegression.struct.point.Point3D_F64 X)
      Computes the image coordinate of a point given its 3D location and the camera matrix.
      static georegression.struct.point.Point2D_F64 renderPixel​(org.ejml.data.DMatrixRMaj worldToCamera, georegression.struct.point.Point3D_F64 X, georegression.struct.point.Point2D_F64 pixel)  
      static georegression.struct.point.Point3D_F64 renderPixel​(org.ejml.data.DMatrixRMaj worldToCamera, georegression.struct.point.Point3D_F64 X, georegression.struct.point.Point3D_F64 pixel)  
      static georegression.struct.point.Point2D_F64 renderPixel​(org.ejml.data.DMatrixRMaj cameraMatrix, georegression.struct.point.Point4D_F64 X, georegression.struct.point.Point2D_F64 x)
      Render a pixel in homogeneous coordinates from a 3x4 camera matrix and a 2D point.
      static georegression.struct.point.Point3D_F64 renderPixel​(org.ejml.data.DMatrixRMaj cameraMatrix, georegression.struct.point.Point4D_F64 X, georegression.struct.point.Point3D_F64 x)
      Render a pixel in homogeneous coordinates from a 3x4 camera matrix and a 3D homogeneous point.
      static void scaleIntrinsic​(CameraPinhole param, double scale)
      Multiplies each element of the intrinsic parameters by the provided scale factor.
      static void splitAssociated​(java.util.List<AssociatedPair> pairs, java.util.List<georegression.struct.point.Point2D_F64> view1, java.util.List<georegression.struct.point.Point2D_F64> view2)
      Takes a list of AssociatedPair as input and breaks it up into two lists for each view.
      static void splitAssociated​(java.util.List<AssociatedTriple> pairs, java.util.List<georegression.struct.point.Point2D_F64> view1, java.util.List<georegression.struct.point.Point2D_F64> view2, java.util.List<georegression.struct.point.Point2D_F64> view3)
      Takes a list of AssociatedTriple as input and breaks it up into three lists for each view.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • PerspectiveOps

        public PerspectiveOps()
    • Method Detail

      • approximatePinhole

        public static CameraPinhole approximatePinhole​(boofcv.struct.distort.Point2Transform2_F64 p2n,
                                                       int width,
                                                       int height)
        Approximates a pinhole camera using the distoriton model
        Parameters:
        p2n - Distorted pixel to undistorted normalized image coordinates
        Returns:
      • createIntrinsic

        public static CameraPinhole createIntrinsic​(int width,
                                                    int height,
                                                    double hfov,
                                                    double vfov)
        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
        vfov - Vertical FOV in degrees
        Returns:
        guess camera parameters
      • createIntrinsic

        public static CameraPinholeBrown createIntrinsic​(int width,
                                                         int height,
                                                         double hfov)
        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,
                                                                  org.ejml.data.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,
                                                                  org.ejml.data.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 org.ejml.data.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,
                                           org.ejml.data.DMatrix3x3 K)
      • invertPinhole

        public static void invertPinhole​(org.ejml.data.DMatrix3x3 K,
                                         org.ejml.data.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 org.ejml.data.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 org.ejml.data.DMatrixRMaj pinholeToMatrix​(CameraPinhole param,
                                                                org.ejml.data.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 org.ejml.data.FMatrixRMaj pinholeToMatrix​(CameraPinhole param,
                                                                org.ejml.data.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 org.ejml.data.DMatrix3x3 pinholeToMatrix​(CameraPinhole param,
                                                               org.ejml.data.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​(org.ejml.data.DMatrixRMaj K,
                                                                  int width,
                                                                  int height,
                                                                  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​(org.ejml.data.FMatrixRMaj K,
                                                                  int width,
                                                                  int height,
                                                                  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​(boofcv.struct.distort.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 georegression.struct.point.Point2D_F64 convertNormToPixel​(CameraModel param,
                                                                                double x,
                                                                                double y,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F64 convertNormToPixel​(CameraPinhole param,
                                                                                double x,
                                                                                double y,
                                                                                georegression.struct.point.Point2D_F64 pixel)
      • convertNormToPixel

        public static georegression.struct.point.Point2D_F32 convertNormToPixel​(CameraModel param,
                                                                                float x,
                                                                                float y,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F64 convertNormToPixel​(CameraModel param,
                                                                                georegression.struct.point.Point2D_F64 norm,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F64 convertNormToPixel​(org.ejml.data.DMatrixRMaj K,
                                                                                georegression.struct.point.Point2D_F64 norm,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F64 convertPixelToNorm​(CameraModel param,
                                                                                georegression.struct.point.Point2D_F64 pixel,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F32 convertPixelToNorm​(CameraModel param,
                                                                                georegression.struct.point.Point2D_F32 pixel,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F64 convertPixelToNorm​(org.ejml.data.DMatrixRMaj K,
                                                                                georegression.struct.point.Point2D_F64 pixel,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F32 convertPixelToNorm​(org.ejml.data.FMatrixRMaj K,
                                                                                georegression.struct.point.Point2D_F32 pixel,
                                                                                georegression.struct.point.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 georegression.struct.point.Point2D_F64 convertPixelToNorm​(CameraPinhole intrinsic,
                                                                                double x,
                                                                                double y,
                                                                                georegression.struct.point.Point2D_F64 norm)
      • renderPixel

        public static georegression.struct.point.Point2D_F64 renderPixel​(georegression.struct.se.Se3_F64 worldToCamera,
                                                                         org.ejml.data.DMatrixRMaj K,
                                                                         georegression.struct.point.Point3D_F64 X,
                                                                         georegression.struct.point.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

        public static georegression.struct.point.Point2D_F64 renderPixel​(georegression.struct.se.Se3_F64 worldToCamera,
                                                                         CameraPinhole K,
                                                                         georegression.struct.point.Point3D_F64 X,
                                                                         georegression.struct.point.Point2D_F64 pixel)
      • renderPixel

        public static georegression.struct.point.Point2D_F64 renderPixel​(georegression.struct.se.Se3_F64 worldToCamera,
                                                                         georegression.struct.point.Point3D_F64 X,
                                                                         georegression.struct.point.Point2D_F64 pixel)
      • renderPixel

        public static georegression.struct.point.Point2D_F64 renderPixel​(CameraPinhole intrinsic,
                                                                         georegression.struct.point.Point3D_F64 X,
                                                                         georegression.struct.point.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 georegression.struct.point.Point2D_F64 renderPixel​(org.ejml.data.DMatrixRMaj worldToCamera,
                                                                         georegression.struct.point.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 georegression.struct.point.Point2D_F64 renderPixel​(org.ejml.data.DMatrixRMaj worldToCamera,
                                                                         georegression.struct.point.Point3D_F64 X,
                                                                         @Nullable
                                                                         georegression.struct.point.Point2D_F64 pixel)
      • renderPixel

        public static georegression.struct.point.Point3D_F64 renderPixel​(org.ejml.data.DMatrixRMaj worldToCamera,
                                                                         georegression.struct.point.Point3D_F64 X,
                                                                         @Nullable
                                                                         georegression.struct.point.Point3D_F64 pixel)
      • renderPixel

        public static georegression.struct.point.Point3D_F64 renderPixel​(org.ejml.data.DMatrixRMaj cameraMatrix,
                                                                         georegression.struct.point.Point4D_F64 X,
                                                                         @Nullable
                                                                         georegression.struct.point.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 georegression.struct.point.Point2D_F64 renderPixel​(org.ejml.data.DMatrixRMaj cameraMatrix,
                                                                         georegression.struct.point.Point4D_F64 X,
                                                                         @Nullable
                                                                         georegression.struct.point.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​(java.util.List<AssociatedPair> pairs,
                                           java.util.List<georegression.struct.point.Point2D_F64> view1,
                                           java.util.List<georegression.struct.point.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​(java.util.List<AssociatedTriple> pairs,
                                           java.util.List<georegression.struct.point.Point2D_F64> view1,
                                           java.util.List<georegression.struct.point.Point2D_F64> view2,
                                           java.util.List<georegression.struct.point.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 org.ejml.data.DMatrixRMaj createCameraMatrix​(org.ejml.data.DMatrixRMaj R,
                                                                   georegression.struct.point.Vector3D_F64 T,
                                                                   @Nullable
                                                                   org.ejml.data.DMatrixRMaj K,
                                                                   @Nullable
                                                                   org.ejml.data.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​(org.ejml.data.DMatrixRMaj P,
                                           org.ejml.data.DMatrixRMaj M,
                                           georegression.struct.point.Vector3D_F64 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)
      • projectionSplit

        public static void projectionSplit​(org.ejml.data.DMatrixRMaj P,
                                           org.ejml.data.DMatrix3x3 M,
                                           org.ejml.data.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​(org.ejml.data.DMatrixRMaj M,
                                             georegression.struct.point.Vector3D_F64 T,
                                             org.ejml.data.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,
                                                              georegression.struct.se.Se3_F64 worldToCamera)
        Creates a transform from world coordinates into pixel coordinates. can handle lens distortion
      • createWorldToPixel

        public static WorldToCameraToPixel createWorldToPixel​(LensDistortionNarrowFOV distortion,
                                                              georegression.struct.se.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 org.ejml.data.DMatrixRMaj convertToMatrix​(georegression.struct.se.Se3_F64 m,
                                                                org.ejml.data.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​(org.ejml.data.DMatrixRMaj P,
                                         int col,
                                         georegression.struct.GeoTuple3D_F64 a)
        Extracts a column from the camera matrix and puts it into the geometric 3-tuple.
      • insertColumn

        public static void insertColumn​(org.ejml.data.DMatrixRMaj P,
                                        int col,
                                        georegression.struct.GeoTuple3D_F64 a)
        Inserts 3-tuple into the camera matrix's columns
      • multTranA

        public static void multTranA​(org.ejml.data.DMatrixRMaj A,
                                     org.ejml.data.DMatrixRMaj B,
                                     org.ejml.data.DMatrixRMaj C,
                                     org.ejml.data.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​(org.ejml.data.DMatrixRMaj A,
                                     org.ejml.data.DMatrixRMaj B,
                                     org.ejml.data.DMatrixRMaj C,
                                     org.ejml.data.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​(org.ejml.data.DMatrix3x3 A,
                                     org.ejml.data.DMatrix3x3 B,
                                     org.ejml.data.DMatrix3x3 C,
                                     org.ejml.data.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​(org.ejml.data.DMatrix3x3 A,
                                     org.ejml.data.DMatrix3x3 B,
                                     org.ejml.data.DMatrix3x3 C,
                                     org.ejml.data.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,
                                                     org.ejml.data.DMatrixRMaj P)
        Multiplies A*P, where A = [sx 0 tx; 0 sy ty; 0 0 1]
      • invariantCrossLine

        public static double invariantCrossLine​(georegression.struct.point.Point3D_F64 a0,
                                                georegression.struct.point.Point3D_F64 a1,
                                                georegression.struct.point.Point3D_F64 a2,
                                                georegression.struct.point.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​(georegression.struct.point.Point2D_F64 a0,
                                                georegression.struct.point.Point2D_F64 a1,
                                                georegression.struct.point.Point2D_F64 a2,
                                                georegression.struct.point.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​(georegression.struct.point.Point2D_F64 p1,
                                                 georegression.struct.point.Point2D_F64 p2,
                                                 georegression.struct.point.Point2D_F64 p3,
                                                 georegression.struct.point.Point2D_F64 p4,
                                                 georegression.struct.point.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​(georegression.struct.point.Point2D_F64 p1,
                                             georegression.struct.point.Point2D_F64 p2,
                                             georegression.struct.point.Point2D_F64 p3,
                                             georegression.struct.point.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​(georegression.struct.point.Point4D_F64 p4,
                                                   double farAway,
                                                   double tol,
                                                   georegression.struct.point.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.