How to use the plenopticam.misc.PlenopticamStatus function in plenopticam

To help you get started, we’ve selected a few plenopticam examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hahnec / plenopticam / tests / unit_test_gui.py View on Github external
def setUp(self):
        self.root = tk.Tk()
        self.cfg = PlenopticamConfig()
        self.sta = PlenopticamStatus()
        self.root.cfg = self.cfg
        self.root.sta = self.sta
        self.set_file_path()
        self.pump_events()
github hahnec / plenopticam / tests / unit_test_illum.py View on Github external
def setUp(self):

        # instantiate config and status objects
        self.cfg = PlenopticamConfig()
        self.cfg.default_values()
        self.sta = PlenopticamStatus()

        # enable options in config to cover more algorithms in tests
        self.cfg.params[self.cfg.cal_meth] = 'grid-fit'
        self.cfg.params[self.cfg.opt_vign] = True
        self.cfg.params[self.cfg.opt_rota] = True
        self.cfg.params[self.cfg.opt_refi] = True
        self.cfg.params[self.cfg.opt_pflu] = True
        self.cfg.params[self.cfg.opt_arti] = True
        self.cfg.params[self.cfg.opt_lier] = True
        self.cfg.params[self.cfg.opt_cont] = True
        self.cfg.params[self.cfg.opt_awb_] = True
        self.cfg.params[self.cfg.opt_sat_] = True
        self.cfg.params[self.cfg.opt_dbug] = True
        self.cfg.params[self.cfg.ran_refo] = [0, 1]

        # compute 3x3 viewpoints only (to reduce computation time)
github hahnec / plenopticam / tests / unit_test_cli.py View on Github external
def setUp(self):

        # set config for unit test purposes
        self.sta = PlenopticamStatus()
        self.cfg = PlenopticamConfig()
        self.cfg.reset_values()
        self.cfg.params[self.cfg.opt_dbug] = True
        self.cfg.params[self.cfg.opt_prnt] = True
github hahnec / plenopticam / plenopticam / bin / cli_script.py View on Github external
def main():

    # program info
    print("\nPlenoptiCam v%s \n" % __version__)

    # create config object
    cfg = PlenopticamConfig()
    cfg.default_values()

    # parse options
    cfg = parse_options(sys.argv[1:], cfg)

    # instantiate status object
    sta = misc.PlenopticamStatus()

    # force relative paths to be absolute
    cfg.params[cfg.lfp_path] = os.path.abspath(cfg.params[cfg.lfp_path])
    cfg.params[cfg.cal_path] = os.path.abspath(cfg.params[cfg.cal_path])

    # collect light field image file name(s) based on provided path
    if os.path.isdir(cfg.params[cfg.lfp_path]):
        lfp_filenames = [f for f in os.listdir(cfg.params[cfg.lfp_path]) if f.lower().endswith(SUPP_FILE_EXT)]
        cfg.params[cfg.lfp_path] = os.path.join(cfg.params[cfg.lfp_path], 'dummy.ext')
    elif not os.path.isfile(cfg.params[cfg.lfp_path]):
        lfp_filenames = [misc.select_file(cfg.params[cfg.lfp_path], 'Select plenoptic image')]
    else:
        lfp_filenames = [cfg.params[cfg.lfp_path]]

    if not cfg.params[cfg.cal_path]:
        # manual calibration data selection
github hahnec / plenopticam / plenopticam / lfp_reader / lfp_decoder.py View on Github external
def __init__(self, file=None, cfg=None, sta=None, **kwargs):

        # input variables
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()
        self.file = file
        self._lfp_path = kwargs['lfp_path'] if 'lfp_path' in kwargs else self.cfg.params[self.cfg.lfp_path]

        # internal variables
        self._json_dict = kwargs['json_dict'] if 'json_dict' in kwargs else {}
        self._shape = None
        self._img_buf = None

        # output variable
        self.cfg.lfpimg = {} if not hasattr(self.cfg, 'lfpimg') else self.cfg.lfpimg
        self._bay_img = None
github hahnec / plenopticam / plenopticam / lfp_aligner / cfa_outliers.py View on Github external
def __init__(self, *args, **kwargs):

        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        self._bay_img = kwargs['bay_img'] if 'bay_img' in kwargs else np.array([])
github hahnec / plenopticam / plenopticam / lfp_extractor / img_proc.py View on Github external
def correct_luma_outliers(img, n=2, perc=.2, sta=None):

    # status init
    sta = sta if sta is not None else misc.PlenopticamStatus()
    sta.status_msg('Hot pixel removal', True)

    # luma channel conversion
    luma = misc.yuv_conv(img.copy())[..., 0]

    for i in range(n, luma.shape[0]-n):
        for j in range(n, luma.shape[1]-n):
            win = luma[i-n:i+n+1, j-n:j+n+1]

            # hot pixel detection
            num_hi = len(win[win > luma[i, j]*(1-perc)])

            # dead pixel detection
            num_lo = len(win[win < luma[i, j]*(1+perc)])

            if num_hi < win.size/5 or num_lo < win.size/5:
github hahnec / plenopticam / plenopticam / lfp_extractor / img_proc.py View on Github external
def correct_outliers(img, n=2, perc=.2, sta=None):

    # status init
    sta = sta if sta is not None else misc.PlenopticamStatus()
    sta.status_msg('Hot pixel removal', True)

    for i in range(n, img.shape[0]-n):
        for j in range(n, img.shape[1]-n):
            win = img[i-n:i+n+1, j-n:j+n+1]

            # hot pixel detection
            num_hi = len(win[win > img[i, j]*(1-perc)])

            # dead pixel detection
            num_lo = len(win[win < img[i, j]*(1+perc)])

            if num_hi < win.size/5 or num_lo < win.size/5:
                # replace outlier by average of all directly adjacent pixels
                img[i, j] = (sum(sum(img[i-1:i+2, j-1:j+2]))-img[i, j])/8.
github hahnec / plenopticam / plenopticam / lfp_extractor / img_proc.py View on Github external
def proc_vp_arr(fun, vp_img_arr, **kwargs):
    ''' process viewpoint images based on provided function handle and argument data '''

    sta = kwargs['sta'] if 'sta' in kwargs else misc.PlenopticamStatus()
    cfg = kwargs['cfg'] if 'cfg' in kwargs else Config()
    msg = kwargs['msg'] if 'msg' in kwargs else 'Viewpoint process'
    sta.status_msg(msg, cfg.params[cfg.opt_dbug])

    args = [kwargs[key] for key in kwargs.keys() if key not in ('cfg', 'sta', 'msg')]

    for j in range(vp_img_arr.shape[0]):
        for i in range(vp_img_arr.shape[1]):
            vp_img_arr[j, i, :, :, :] = fun(vp_img_arr[j, i, :, :, :], *args)

            # progress update
            percentage = (i*vp_img_arr.shape[1]+(j+1))/(vp_img_arr.shape[0]*vp_img_arr.shape[1]*100)
            sta.progress(percentage, cfg.params[cfg.opt_dbug])

    return vp_img_arr
github hahnec / plenopticam / plenopticam / lfp_calibrator / centroid_drawer.py View on Github external
def __init__(self, img, centroids, cfg=None, sta=None):

        # input variables
        self._img = rgb2gry(img.copy())[..., 0] if len(img.shape) == 3 else img.copy()
        self._img = Normalizer(self._img).uint8_norm()
        self._centroids = np.asarray(centroids)
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()