OpenCVModel.apply_distortion

giant.camera_models.opencv_model:

OpenCVModel.apply_distortion(pinhole_locations)[source]

This method applies the distortion model to the specified pinhole (gnomic) locations in the image frame.

In general this function is not used by the user and the higher level project_onto_image() is used which calls this method (along with a few others) instead. In cases were it is desirable to use this method the pinhole locations should be input as a shape (2,) or shape (2, n) array of unitless image plane locations. The output from this function is the unitless distorted image plane locations.

For the OpenCV model, the conversion from gnomic to distorted points is defined as

\[\begin{split}\mathbf{x}_I' = \frac{1+k_1r^2+k_2r^4+k_3r^6}{1+k_4r^2+k_5r^4+k_6r^6}\mathbf{x}_I + \left[\begin{array}{c} 2p_1x_Iy_I+p_2(r^2+2x_I^2)+s1r^2+s2r^4 \\ p_1(r^2+2y_I^2) + 2p_2x_Iy_I +s3r^2+s4r^4\end{array}\right]\end{split}\]

where \(\Delta\mathbf{x}_I'\) is the distorted gnomic locations, \(k_{1-6}\) are radial distortion coefficients, \(p_{1-2}\) are the tangential distortion coefficients, \(s_{1-4}\) are thin prism distortion coefficients, \(\mathbf{x}_I\) is the unitless gnomic location, and \(r = \sqrt{\mathbf{x}_I^T\mathbf{x}_I}\) is the radial distance from the optical axis.

Parameters:

pinhole_locations (Sequence | ndarray) – The unitless image plane location of points to be distorted as a shape (2,) or (2, n) array.

Returns:

The unitless distorted locations of the points on the image plane as a shape (2,) or (2, n) array.

Return type:

ndarray