coastalimagelib/supportfunctions.py
def loadMatCIRN(files, tag="CIRN"):
    """
    Requires scipy.io package

    This function reads and formats instrinsics from .mat files, in either
    CIRN camera calibration format or CIRN intrinsics format

    Args:
        files: (string) file paths to .mat intrinsics file
        tag: (string) 'CIRN' or 'CalTech', indicates format of .mat file

        Note: if CIRN, extrinsics are likely included in .mat file

    Returns:
        m: array of lists, length is number of cameras, each list contains
            intrinsics for the corresponding camera
        ex: array of lists, length is number of cameras, each list contains
            the extrinsics for the corresponding camera

    """
    from scipy.io import loadmat

    m = np.empty(len(files), object)
    ex = np.empty(len(files), object)

    # Loop through each camera
    for ind in range(len(files)):
        data = loadmat(files[ind])
        camID = files[ind]
        if tag == "CIRN":
            m[ind] = list(np.ravel(data["intrinsics"]))
            ex[ind] = list(np.ravel(data["extrinsics"]))
        else:
            mi = np.empty(11)
            mi[0] = data.nx
            # Number of pixel columns
            mi[1] = data.ny
            # Number of pixel rows
            mi[2] = data.cc[0]
            # U component of principal point
            mi[3] = data.cc[1]
            # V component of principal point
            mi[4] = data.fc[0]
            # U components of focal lengths (in pixels)
            mi[5] = data.fc[1]
            # V components of focal lengths (in pixels)
            mi[6] = data.kc[0]
            # Radial distortion coefficient
            mi[7] = data.kc[1]
            # Radial distortion coefficient
            mi[8] = data.kc[4]
            # Radial distortion coefficient
            mi[9] = data.kc[2]
            # Tangential distortion coefficients
            mi[10] = data.kc[3]
            # Tangential distortion coefficients
            m[ind] = list(np.ravel(mi))

    return m, ex

    Requires scipy.io package

    This function reads and formats instrinsics from .mat files, in either
    CIRN camera calibration format or CIRN intrinsics format

    Args:
        files: (string) file paths to .mat intrinsics file
        tag: (string) 'CIRN' or 'CalTech', indicates format of .mat file

        Note: if CIRN, extrinsics are likely included in .mat file

    Returns:
        m: array of lists, length is number of cameras, each list contains
            intrinsics for the corresponding camera
        ex: array of lists, length is number of cameras, each list contains
            the extrinsics for the corresponding camera

    
Requires scipy.io package
This function reads and formats instrinsics from .mat files, in either
CIRN camera calibration format or CIRN intrinsics format
Requires scipy . io package This function reads and formats instrinsics from . mat files in either CIRN camera calibration format or CIRN intrinsics format
def loadMatCIRN(files, tag="CIRN"):
    from scipy.io import loadmat
    m = np.empty(len(files), object)
    ex = np.empty(len(files), object)
    for ind in range(len(files)):
        data = loadmat(files[ind])
        camID = files[ind]
        if tag == "CIRN":
            m[ind] = list(np.ravel(data["intrinsics"]))
            ex[ind] = list(np.ravel(data["extrinsics"]))
        else:
            mi = np.empty(11)
            mi[0] = data.nx
            mi[1] = data.ny
            mi[2] = data.cc[0]
            mi[3] = data.cc[1]
            mi[4] = data.fc[0]
            mi[5] = data.fc[1]
            mi[6] = data.kc[0]
            mi[7] = data.kc[1]
            mi[8] = data.kc[4]
            mi[9] = data.kc[2]
            mi[10] = data.kc[3]
            m[ind] = list(np.ravel(mi))
    return m, ex
def loadMatCIRN ( files , tag = "CIRN" ) : from scipy . io import loadmat m = np . empty ( len ( files ) , object ) ex = np . empty ( len ( files ) , object ) for ind in range ( len ( files ) ) : data = loadmat ( files [ ind ] ) camID = files [ ind ] if tag == "CIRN" : m [ ind ] = list ( np . ravel ( data [ "intrinsics" ] ) ) ex [ ind ] = list ( np . ravel ( data [ "extrinsics" ] ) ) else : mi = np . empty ( 11 ) mi [ 0 ] = data . nx mi [ 1 ] = data . ny mi [ 2 ] = data . cc [ 0 ] mi [ 3 ] = data . cc [ 1 ] mi [ 4 ] = data . fc [ 0 ] mi [ 5 ] = data . fc [ 1 ] mi [ 6 ] = data . kc [ 0 ] mi [ 7 ] = data . kc [ 1 ] mi [ 8 ] = data . kc [ 4 ] mi [ 9 ] = data . kc [ 2 ] mi [ 10 ] = data . kc [ 3 ] m [ ind ] = list ( np . ravel ( mi ) ) return m , ex
Requires scipy.io package
This function reads and formats instrinsics from .mat files, in either
CIRN camera calibration format or CIRN intrinsics format
Requires scipy . io package This function reads and formats instrinsics from . mat files in either CIRN camera calibration format or CIRN intrinsics format
"""
    Requires scipy.io package

    This function reads and formats instrinsics from .mat files, in either
    CIRN camera calibration format or CIRN intrinsics format

    Args:
        files: (string) file paths to .mat intrinsics file
        tag: (string) 'CIRN' or 'CalTech', indicates format of .mat file

        Note: if CIRN, extrinsics are likely included in .mat file

    Returns:
        m: array of lists, length is number of cameras, each list contains
            intrinsics for the corresponding camera
        ex: array of lists, length is number of cameras, each list contains
            the extrinsics for the corresponding camera

    """ # Loop through each camera # Number of pixel columns # Number of pixel rows # U component of principal point # V component of principal point # U components of focal lengths (in pixels) # V components of focal lengths (in pixels) # Radial distortion coefficient # Radial distortion coefficient # Radial distortion coefficient # Tangential distortion coefficients # Tangential distortion coefficients
array of lists, length is number of cameras, each list contains
intrinsics for the corresponding camera
ex: array of lists, length is number of cameras, each list contains
the extrinsics for the corresponding camera
array of lists length is number of cameras each list contains intrinsics for the corresponding camera ex : array of lists length is number of cameras each list contains the extrinsics for the corresponding camera
m
files
(string) file paths to .mat intrinsics file
( string ) file paths to . mat intrinsics file
tag
(string) 'CIRN' or 'CalTech', indicates format of .mat file
( string ) ' CIRN ' or ' CalTech ' indicates format of . mat file
Note
if CIRN, extrinsics are likely included in .mat file
if CIRN extrinsics are likely included in . mat file