coastalimagelib/supportfunctions.py
def deBayerParallel(i, cams, rawPaths, frame=0, numFrames=0):
    """
    Requires argusIO

    This function converts frames at one timestamp for multiple cameras
    stored in .raw files to matrices formatted for use in this toolbox

    Args:
        rawPaths (list of strings): paths from which to load .raw files
        frame (int): start frame in .raw file to deBayer
        savePaths (list of strings): optional, paths to save each debayered
            frame to drive as .png, .jpg, etc if desired
            Save paths must include the full filename and file extension
        numFrames: number of frames to deBayer from start frame ("frame"),
            (optional- leave out if only debayering one frame)

    Returns:
        outmat (ndarray): NxMxK matrix of deBayered images, NxM is height
            and width of frame, K is number of cameras

    Based on argusIO code written by Dylan Anderson.

    """
    import argusIO_v2
    import multiprocessing as mp

    cameras = dict()
    frames = dict()

    pool = mp.Pool(mp.cpu_count())
    results = []

    for p in range(len(cams)):
        # how many raw frames to skip
        cameras[cams[p]] = argusIO_v2.cameraIO(
            cameraID=cams[p],
            rawPath=rawPaths[p],
            startFrame=frame,
            nFrames=numFrames
        )
        pool.apply_async(cameras[cams[p]].readRaw())

    pool.close()
    pool.join()

    for p in range(len(cams)):
        cameras[cams[p]].deBayer()
        del cameras[cams[p]].raw
        frames[cams[p]] = cameras[cams[p]].imGrayCV

    s = frames[cams[0]][:, :, 0].shape
    outmats = np.zeros((s[0], s[1], len(cams), numFrames))

    for p in range(len(cams)):
        outmats[:, :, p, :] = frames[cams[p]][:, :, :].astype(np.uint8)

    return outmats

    Requires argusIO

    This function converts frames at one timestamp for multiple cameras
    stored in .raw files to matrices formatted for use in this toolbox

    Args:
        rawPaths (list of strings): paths from which to load .raw files
        frame (int): start frame in .raw file to deBayer
        savePaths (list of strings): optional, paths to save each debayered
            frame to drive as .png, .jpg, etc if desired
            Save paths must include the full filename and file extension
        numFrames: number of frames to deBayer from start frame ("frame"),
            (optional- leave out if only debayering one frame)

    Returns:
        outmat (ndarray): NxMxK matrix of deBayered images, NxM is height
            and width of frame, K is number of cameras

    Based on argusIO code written by Dylan Anderson.

    
Requires argusIO
This function converts frames at one timestamp for multiple cameras
stored in .raw files to matrices formatted for use in this toolbox
Requires argusIO This function converts frames at one timestamp for multiple cameras stored in . raw files to matrices formatted for use in this toolbox
def deBayerParallel(i, cams, rawPaths, frame=0, numFrames=0):
    import argusIO_v2
    import multiprocessing as mp
    cameras = dict()
    frames = dict()
    pool = mp.Pool(mp.cpu_count())
    results = []
    for p in range(len(cams)):
        cameras[cams[p]] = argusIO_v2.cameraIO(
            cameraID=cams[p],
            rawPath=rawPaths[p],
            startFrame=frame,
            nFrames=numFrames
        )
        pool.apply_async(cameras[cams[p]].readRaw())
    pool.close()
    pool.join()
    for p in range(len(cams)):
        cameras[cams[p]].deBayer()
        del cameras[cams[p]].raw
        frames[cams[p]] = cameras[cams[p]].imGrayCV
    s = frames[cams[0]][:, :, 0].shape
    outmats = np.zeros((s[0], s[1], len(cams), numFrames))
    for p in range(len(cams)):
        outmats[:, :, p, :] = frames[cams[p]][:, :, :].astype(np.uint8)
    return outmats
def deBayerParallel ( i , cams , rawPaths , frame = 0 , numFrames = 0 ) : import argusIO_v2 import multiprocessing as mp cameras = dict ( ) frames = dict ( ) pool = mp . Pool ( mp . cpu_count ( ) ) results = [ ] for p in range ( len ( cams ) ) : cameras [ cams [ p ] ] = argusIO_v2 . cameraIO ( cameraID = cams [ p ] , rawPath = rawPaths [ p ] , startFrame = frame , nFrames = numFrames ) pool . apply_async ( cameras [ cams [ p ] ] . readRaw ( ) ) pool . close ( ) pool . join ( ) for p in range ( len ( cams ) ) : cameras [ cams [ p ] ] . deBayer ( ) del cameras [ cams [ p ] ] . raw frames [ cams [ p ] ] = cameras [ cams [ p ] ] . imGrayCV s = frames [ cams [ 0 ] ] [ : , : , 0 ] . shape outmats = np . zeros ( ( s [ 0 ] , s [ 1 ] , len ( cams ) , numFrames ) ) for p in range ( len ( cams ) ) : outmats [ : , : , p , : ] = frames [ cams [ p ] ] [ : , : , : ] . astype ( np . uint8 ) return outmats
Requires argusIO
This function converts frames at one timestamp for multiple cameras
stored in .raw files to matrices formatted for use in this toolbox
Requires argusIO This function converts frames at one timestamp for multiple cameras stored in . raw files to matrices formatted for use in this toolbox
"""
    Requires argusIO

    This function converts frames at one timestamp for multiple cameras
    stored in .raw files to matrices formatted for use in this toolbox

    Args:
        rawPaths (list of strings): paths from which to load .raw files
        frame (int): start frame in .raw file to deBayer
        savePaths (list of strings): optional, paths to save each debayered
            frame to drive as .png, .jpg, etc if desired
            Save paths must include the full filename and file extension
        numFrames: number of frames to deBayer from start frame ("frame"),
            (optional- leave out if only debayering one frame)

    Returns:
        outmat (ndarray): NxMxK matrix of deBayered images, NxM is height
            and width of frame, K is number of cameras

    Based on argusIO code written by Dylan Anderson.

    """ # how many raw frames to skip
outmat (ndarray): NxMxK matrix of deBayered images, NxM is height
and width of frame, K is number of cameras
outmat ( ndarray ) : NxMxK matrix of deBayered images NxM is height and width of frame K is number of cameras
i
cams
rawPaths
paths from which to load .raw files
paths from which to load . raw files
frame
start frame in .raw file to deBayer
start frame in . raw file to deBayer
numFrames
number of frames to deBayer from start frame ("frame"),
(optional- leave out if only debayering one frame)
number of frames to deBayer from start frame ( " frame " ) ( optional - leave out if only debayering one frame )
savePaths
optional, paths to save each debayered
frame to drive as .png, .jpg, etc if desired
Save paths must include the full filename and file extension
optional paths to save each debayered frame to drive as . png . jpg etc if desired Save paths must include the full filename and file extension