def get_npimage(cam, img):
    """Get the most recent image from a camera as a numpy 
    array.

    Parameters
    ----------
    cam : ximea.xiapi.Camera
        A ximea api Camera object.
    img : ximea.xiapi.Image
        A ximea api Image container object

    Returns
    -------
    npimg : numpy.ndarray
        The most recently acquired image from the camera 
        as a numpy array.

    """
    cam.get_image(img, timeout = 2000)                  
    npimg = img.get_image_data_numpy()
    return npimg