public static CameraPinholeBrown loadPinholeRadial ( String fileName ) { FileStorage fs = new FileStorage ( new File ( fileName ) . getAbsolutePath ( ) , FileStorage . READ ) ; IntPointer width = new IntPointer ( 1 ) ; IntPointer height = new IntPointer ( 1 ) ; read ( fs . get ( "image_width" ) , width , - 1 ) ; read ( fs . get ( "image_height" ) , height , - 1 ) ; Mat K = new Mat ( ) ; read ( fs . get ( "camera_matrix" ) , K ) ; Mat distortion = new Mat ( ) ; read ( fs . get ( "distortion_coefficients" ) , distortion ) ; CameraPinholeBrown boof = new CameraPinholeBrown ( ) ; boof . width = width . get ( ) ; boof . height = height . get ( ) ; DoubleRawIndexer indexerK = K . createIndexer ( ) ; boof . fx = indexerK . get ( 0 , 0 ) ; boof . skew = indexerK . get ( 0 , 1 ) ; boof . fy = indexerK . get ( 1 , 1 ) ; boof . cx = indexerK . get ( 0 , 2 ) ; boof . cy = indexerK . get ( 1 , 2 ) ; DoubleRawIndexer indexerD = distortion . createIndexer ( ) ; if ( distortion . rows ( ) >= 5 ) boof . setRadial ( indexerD . get ( 0 , 0 ) , indexerD . get ( 1 , 0 ) , indexerD . get ( 4 , 0 ) ) ; else if ( distortion . rows ( ) >= 2 ) boof . setRadial ( indexerD . get ( 0 , 0 ) , indexerD . get ( 1 , 0 ) ) ; if ( distortion . rows ( ) >= 5 ) boof . fsetTangental ( indexerD . get ( 2 , 0 ) , indexerD . get ( 3 , 0 ) ) ; return boof ; }
Loads a pinhole camera model with radian and tangential distortion in OpenCV format