Exemplo n.º 1
0
    def __init__(self, *args, **kwargs):

        self._vp_img_arr = kwargs['vp_img_arr'].astype(
            'float64') if 'vp_img_arr' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()
        self._M = self.cfg.params[self.cfg.ptc_leng]
Exemplo n.º 2
0
    def test_cal(self):

        # set config for unit test purposes
        sta = PlenopticamStatus()
        cfg = PlenopticamConfig()
        cfg.reset_values()
        cfg.params[cfg.opt_dbug] = False
        cfg.params[cfg.opt_prnt] = True

        for fn_lfp, fn_wht in zip(self.fnames_lfp, self.fnames_wht):

            # update file paths and calibration data in config
            cfg.params[cfg.lfp_path] = os.path.join(self.fp, fn_lfp)
            cfg.params[cfg.cal_path] = os.path.join(self.fp, fn_wht)

            # create folder (if it doesn't already exist)
            mkdir_p(os.path.splitext(cfg.params[cfg.lfp_path])[0])

            # test light field calibration
            wht_img = load_img_file(cfg.params[cfg.cal_path])
            cal_obj = LfpCalibrator(wht_img=wht_img, cfg=cfg, sta=sta)
            ret_val = cal_obj.main()
            del cal_obj

            # assertion
            self.assertEqual(True, ret_val)
Exemplo n.º 3
0
    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(
            [])
Exemplo n.º 4
0
    def setUp(self):

        # retrieve OpEx data from Hahne et al.
        url = 'https://ndownloader.figshare.com/files/5201452'
        archive_fn = os.path.join(self.fp, os.path.basename(url))
        self.download_data(url) if not os.path.exists(archive_fn) else None
        self.fnames_wht_opex = [
            'f197with4m11pxf16Final.bmp', 'f197Inf9pxFinalShift12.7cmf22.bmp'
        ]
        self.fnames_lfp_opex = [
            'f197with4m11pxFinal.bmp', 'f197Inf9pxFinalShift12.7cm.bmp'
        ]
        self.extract_archive(os.path.join(self.fp, os.path.basename(url)),
                             self.fnames_wht_opex + self.fnames_lfp_opex)

        # set config for unit test purposes
        self.sta = PlenopticamStatus()
        self.cfg = PlenopticamConfig()
        self.cfg.reset_values()
        self.cfg.params[self.cfg.opt_dbug] = False
        self.cfg.params[
            self.cfg.
            opt_prnt] = False  # prevent Travis CI to terminate after reaching 4MB logfile size
        self.cfg.params[self.cfg.opt_vign] = False
        self.cfg.params[self.cfg.opt_sat_] = True
Exemplo n.º 5
0
    def load_json(fp=None, sta=None):

        sta = sta if sta is not None else PlenopticamStatus()

        # filename and filepath handling
        if fp is not None and splitext(fp)[-1] != '.json':
            fn = splitext(basename(fp))[0] + '.json'
            fp = join(splitext(fp)[0], fn)

        # load calibration data from json file
        if exists(fp):
            try:
                with open(fp, 'r') as f:
                    json_dict = json.load(f)
            except json.decoder.JSONDecodeError:
                remove(fp)
                sta.status_msg(
                    'Calibration JSON File may be corrupted. Attempt to delete file %s'
                    % fp,
                    opt=True)
                raise PlenopticamError(
                    'Calibration JSON File may be corrupted. Attempt to delete file %s'
                    % fp)
        else:
            json_dict = None
            sta.status_msg('Provided file %s does not exist' % fp, opt=True)

        return json_dict
Exemplo n.º 6
0
    def __init__(self, img, centroids, cfg=None, sta=None):

        # input variables
        self._img = Normalizer(rgb2gray(img.copy())).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()
Exemplo n.º 7
0
    def test_cal(self):

        # set config for unit test purposes
        sta = PlenopticamStatus()
        cfg = PlenopticamConfig()
        cfg.reset_values()
        cfg.params[cfg.opt_dbug] = False
        cfg.params[
            cfg.
            opt_prnt] = False  # prevent Travis CI to terminate after reaching 4MB logfile size
        cfg.params[cfg.opt_vign] = False
        cfg.params[cfg.opt_sat_] = True

        for fn_lfp, fn_wht in zip(self.fnames_lfp, self.fnames_wht):

            # generate console output to prevent abort in Travis CI
            print(fn_wht)

            # update file paths and calibration data in config
            cfg.params[cfg.lfp_path] = os.path.join(self.fp, fn_lfp)
            cfg.params[cfg.cal_path] = os.path.join(self.fp, fn_wht)

            # create folder (if it doesn't already exist)
            mkdir_p(os.path.splitext(cfg.params[cfg.lfp_path])[0])

            # test light field calibration
            wht_img = load_img_file(cfg.params[cfg.cal_path])
            cal_obj = LfpCalibrator(wht_img=wht_img, cfg=cfg, sta=sta)
            ret_val = cal_obj.main()
            del cal_obj

            # assertion
            self.assertEqual(True, ret_val)
Exemplo n.º 8
0
    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
Exemplo n.º 9
0
 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()
Exemplo n.º 10
0
    def __init__(self, img, cfg=None, sta=None):

        # input variables
        self._img = img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()

        # internal variable
        self._map = np.zeros(self._img.shape, dtype=self._img.dtype)
Exemplo n.º 11
0
    def __init__(self, lfp_img, mic_list, rad=None, cfg=None, sta=None):

        # input and output variable
        self._lfp_img = lfp_img
        self.cfg = cfg if cfg is not None else PlenopticamConfig()
        self.sta = sta if sta is not None else PlenopticamStatus()

        # internal variables
        self._centroids = np.asarray(mic_list)
        self._rad = rad
Exemplo n.º 12
0
    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] = False
        self.cfg.params[
            self.cfg.
            opt_prnt] = False  # prevent Travis CI to terminate after reaching 4MB logfile size
        self.cfg.params[self.cfg.opt_vign] = False
        self.cfg.params[self.cfg.opt_sat_] = True
Exemplo n.º 13
0
    def __init__(self, *args, **kwargs):
        tk.Canvas.__init__(self, *args, **kwargs)
        LfpViewpoints.__init__(self, *args, **kwargs)

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

        # window dimensions
        self._ht = self.winfo_screenheight()
        self._wd = self.winfo_screenwidth()

        # window settings
        # self['bg'] = "white"
        self.master.title("PlenoptiCam Viewer")

        vp_dirs = glob.glob(os.path.join(self.cfg.exp_path, 'viewpoints_*px'))
        rf_dirs = glob.glob(os.path.join(self.cfg.exp_path, 'refo_*px'))
        try:
            self.vp_img_arr = kwargs[
                'vp_img_arr'] if 'vp_img_arr' in kwargs else get_list(
                    vp_dirs[0], vp=1)
            self.refo_stack = kwargs[
                'refo_stack'] if 'refo_stack' in kwargs else get_list(
                    rf_dirs[0], vp=0)
        except Exception as e:
            print(e)
            self.sta.status_msg(msg='\nNo valid image data found',
                                opt=self.cfg.opt_prnt)

        if hasattr(self, 'vp_img_arr'):

            # light-field related data
            self._M = self.cfg.params[
                self.cfg.ptc_leng]  #self.vp_img_arr.shape[0]  #
            self._v = self._u = self._C = self._M // 2
            self._a = 0
            self._k = -1
            self.move_coords = self.get_move_coords(
                pattern='circle', arr_dims=self.vp_img_arr.shape[:2])

        # initialize member variables
        self.vp_mode = True
        self.auto_mode = False
        self._mode_text = tk.StringVar()
        self._mode_text.set('VP' if self.vp_mode else 'RF')
        self.all_function_trigger()

        # display initial image
        self.next_frame()
Exemplo n.º 14
0
    def test_lfp(self):

        # set config for unit test purposes
        sta = PlenopticamStatus()
        cfg = PlenopticamConfig()
        cfg.reset_values()
        cfg.params[cfg.opt_dbug] = False
        cfg.params[
            cfg.
            opt_prnt] = False  # prevent Travis CI to terminate after reaching 4MB logfile size

        for fn_lfp, fn_wht in zip(self.fnames_lfp, self.fnames_wht):

            # generate console output to prevent abort in Travis CI
            print(fn_lfp)

            # update file paths and calibration data in config
            cfg.params[cfg.lfp_path] = os.path.join(self.fp, fn_lfp)
            cfg.params[cfg.cal_path] = os.path.join(self.fp, fn_wht)
            cfg.params[cfg.cal_meta] = os.path.splitext(
                cfg.params[cfg.cal_path])[0] + '.json'
            cfg.load_cal_data()

            # create folder (if it doesn't already exist)
            mkdir_p(os.path.splitext(cfg.params[cfg.lfp_path])[0])

            # test light field alignment
            lfp_img = load_img_file(cfg.params[cfg.lfp_path])
            lfp_obj = LfpAligner(lfp_img=lfp_img, cfg=cfg, sta=sta)
            ret_val = lfp_obj.main()
            lfp_img = lfp_obj.lfp_img
            del lfp_obj

            # assertion
            self.assertEqual(True, ret_val)

            # test light field extraction
            lfp_obj = LfpExtractor(lfp_img_align=lfp_img, cfg=cfg, sta=sta)
            lfp_obj.main()
            vp_img_arr = lfp_obj.vp_img_arr
            del lfp_obj

            lfp_obj = LfpRefocuser(vp_img_arr=vp_img_arr, cfg=cfg, sta=sta)
            lfp_obj.main()
            del lfp_obj

            # assertion
            self.assertEqual(True, ret_val)
Exemplo n.º 15
0
    def __init__(self, file=None, cfg=None, sta=None, **kwargs):

        # input variables
        self.cfg = cfg
        self.sta = sta if sta is not None else PlenopticamStatus()
        self.file = file
        if not self.file:
            raise LfpAttributeError('File not passed to LfcDecoder class')

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

        # output variable
        self.cfg.lfpimg = {}
        self._rgb_img = None
Exemplo n.º 16
0
    def __init__(self, *args, **kwargs):

        # instantiate config and status objects
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        # path handling: refer to folder where data will be stored
        path = kwargs['path'] if 'path' in kwargs else os.path.dirname(os.path.abspath(__file__))
        self._fp = os.path.join(path, 'data')
        self.root_path = dirname(abspath('.')) if basename((abspath('.'))) == 'tests' else abspath('.')

        # data urls
        self.host_eu_url = 'http://wp12283669.server-he.de/Xchange/illum_test_data.zip'
        self.opex_url = 'https://ndownloader.figshare.com/files/5201452'
        self.opex_fnames_wht = ['f197with4m11pxf16Final.bmp', 'f197Inf9pxFinalShift12.7cmf22.bmp']
        self.opex_fnames_lfp = ['f197with4m11pxFinal.bmp', 'f197Inf9pxFinalShift12.7cm.bmp']
Exemplo n.º 17
0
    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] = False
        self.cfg.params[self.cfg.opt_prnt] = False    # prevent Travis CI to terminate after reaching 4MB logfile size
        self.cfg.params[self.cfg.opt_vign] = True
        self.cfg.params[self.cfg.opt_sat_] = True

        # retrieve OpEx data from Hahne et al.
        self.loader = DataDownloader(cfg=self.cfg, sta=self.sta)
        self.fp = join(self.loader.root_path, 'examples', 'data')
        archive_fn = join(self.fp, basename(self.loader.opex_url))
        self.loader.download_data(self.loader.opex_url, fp=self.fp) if not exists(archive_fn) else None
        self.loader.extract_archive(archive_fn, self.loader.opex_fnames_wht + self.loader.opex_fnames_lfp)
Exemplo n.º 18
0
    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
Exemplo n.º 19
0
    def __init__(self, *args, **kwargs):

        self._vp_img_arr = kwargs['vp_img_arr'].astype(
            'float64') if 'vp_img_arr' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()
        self._M = self.cfg.params[self.cfg.ptc_leng]
        self._C = self._M // 2

        try:
            self._DIMS = self._vp_img_arr.shape if len(
                self._vp_img_arr.shape) == 3 else self._vp_img_arr.shape + (
                    1, )
        except (TypeError, AttributeError):
            pass
        except IndexError:
            self.sta.status_msg(
                'Incompatible image dimensions: Please either use KxLx3 or KxLx1 array dimensions'
            )
            self.sta.error = True
Exemplo n.º 20
0
    def __init__(self, *args, **kwargs):

        # input variables
        self._lfp_img = kwargs['lfp_img'] if 'lfp_img' in kwargs else None
        self._wht_img = kwargs['wht_img'] if 'wht_img' in kwargs else None
        self.cfg = kwargs['cfg'] if 'cfg' in kwargs else PlenopticamConfig()
        self.sta = kwargs['sta'] if 'sta' in kwargs else PlenopticamStatus()

        # add 3rd axis for 2D image
        self._lfp_img = self._lfp_img[..., np.newaxis] if len(self._lfp_img.shape) == 2 else self._lfp_img

        # convert to float
        self._lfp_img = self._lfp_img.astype('float64')
        self._wht_img = self._wht_img.astype('float64')

        self._CENTROIDS = np.asarray(self.cfg.calibs[self.cfg.mic_list])
        self._M = LfpCropper.pitch_max(self.cfg.calibs[self.cfg.mic_list])
        self._C = int((self._M-1)/2)
        self._LENS_Y_MAX = int(max(self._CENTROIDS[:, 2]))
        self._LENS_X_MAX = int(max(self._CENTROIDS[:, 3]))
        self._DIMS = self._lfp_img.shape if len(self._lfp_img.shape) == 3 else None
Exemplo n.º 21
0
    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)
        self.cfg.params[self.cfg.ptc_leng] = 3

        # skip progress prints (prevent Travis from terminating due to reaching 4MB logfile size)
        self.sta.prog_opt = False

        # print current process message (to prevent Travis from stopping after 10 mins)
        self.cfg.params[self.cfg.opt_prnt] = True

        # retrieve Lytro Illum data
        self.loader = DataDownloader(cfg=self.cfg, sta=self.sta)
        self.fp = join(self.loader.root_path, 'examples', 'data')
        archive_fn = join(self.fp, basename(self.loader.host_eu_url))
        self.loader.download_data(
            self.loader.host_eu_url,
            fp=self.fp) if not exists(archive_fn) else None
        self.loader.extract_archive(archive_fn)
Exemplo n.º 22
0
    def test_lfp(self):

        # set config for unit test purposes
        sta = PlenopticamStatus()
        cfg = PlenopticamConfig()
        cfg.reset_values()
        cfg.params[cfg.opt_dbug] = True

        for fn_lfp, fn_wht in zip(self.fnames_lfp, self.fnames_wht):

            # update file paths and calibration data in config
            cfg.params[cfg.lfp_path] = os.path.join(self.fp, fn_lfp)
            cfg.params[cfg.cal_path] = os.path.join(self.fp, fn_wht)
            cfg.params[cfg.cal_meta] = os.path.splitext(
                cfg.params[cfg.cal_path])[0] + '.json'
            cfg.load_cal_data()

            # create folder (if it doesn't already exist)
            mkdir_p(os.path.splitext(cfg.params[cfg.lfp_path])[0])

            # test light field alignment
            lfp_img = load_img_file(cfg.params[cfg.lfp_path])
            lfp_obj = LfpAligner(lfp_img=lfp_img, cfg=cfg, sta=sta)
            ret_val = lfp_obj.main()
            lfp_img = lfp_obj.lfp_img
            del lfp_obj

            # assertion
            self.assertEqual(True, ret_val)

            # test light field extraction
            lfp_obj = LfpExtractor(lfp_img_align=lfp_img, cfg=cfg, sta=sta)
            ret_val = lfp_obj.main()
            del lfp_obj

            # assertion
            self.assertEqual(True, ret_val)
Exemplo n.º 23
0
import numpy as np

from plenopticam.cfg import PlenopticamConfig
cfg = PlenopticamConfig()
cfg.params[cfg.cal_meta] = ""
cfg.load_cal_data()
mic_list = np.asarray(cfg.calibs[cfg.mic_list])

from plenopticam.misc import PlenopticamStatus
sta = PlenopticamStatus()

# do grid fitting
from plenopticam.lfp_calibrator import GridFitter
obj = GridFitter(cfg=cfg, sta=sta)
obj.main()
new_list = np.asarray(obj.grid_fit)

# plot
import matplotlib.pyplot as plt
plt.figure()
plt.plot(mic_list[:, 1], mic_list[:, 0], 'rx')
plt.plot(new_list[:, 1], new_list[:, 0], 'b+')
plt.show()
Exemplo n.º 24
0
    def test_illum(self):

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

        # skip concole output message (prevent Travis from terminating due to reaching 4MB logfile size)
        cfg.params[cfg.opt_prnt] = False

        # use pre-loaded calibration dataset
        wht_list = [file for file in os.listdir(self.fp) if file.startswith('caldata')]
        lfp_list = [file for file in os.listdir(self.fp) if file.endswith(('lfr', 'lfp'))]

        cfg.params[cfg.cal_path] = os.path.join(self.fp, wht_list[0])

        for lfp_file in lfp_list:

            print('Compute image %s' % os.path.basename(cfg.params[cfg.lfp_path]))
            cfg.params[cfg.lfp_path] = os.path.join(self.fp, lfp_file)

            # decode light field image
            lfp_obj = LfpReader(cfg, sta)
            ret_val = lfp_obj.main()
            lfp_img = lfp_obj.lfp_img
            del lfp_obj

            self.assertEqual(True, ret_val)

            # create output data folder
            mkdir_p(cfg.exp_path, cfg.params[cfg.opt_prnt])

            if not cfg.cond_meta_file():
                # automatic calibration data selection
                obj = CaliFinder(cfg, sta)
                ret_val = obj.main()
                wht_img = obj.wht_bay
                del obj

                self.assertEqual(True, ret_val)

            meta_cond = not (os.path.exists(cfg.params[cfg.cal_meta]) and cfg.params[cfg.cal_meta].lower().endswith('json'))
            if meta_cond or cfg.params[cfg.opt_cali]:
                # perform centroid calibration
                cal_obj = LfpCalibrator(wht_img, cfg, sta)
                ret_val = cal_obj.main()
                cfg = cal_obj.cfg
                del cal_obj

                self.assertEqual(True, ret_val)

            # load calibration data
            cfg.load_cal_data()

            #  check if light field alignment has been done before
            if cfg.cond_lfp_align():
                # align light field
                lfp_obj = LfpAligner(lfp_img, cfg, sta, wht_img)
                ret_val = lfp_obj.main()
                lfp_obj = lfp_obj.lfp_img
                del lfp_obj

                self.assertEqual(True, ret_val)

            # load previously computed light field alignment
            with open(os.path.join(cfg.exp_path, 'lfp_img_align.pkl'), 'rb') as f:
                lfp_img_align = pickle.load(f)

            # extract viewpoint data
            CaliFinder(cfg).main()
            obj = LfpExtractor(lfp_img_align, cfg=cfg, sta=sta)
            ret_val = obj.main()
            vp_img_arr = obj.vp_img_arr
            del obj

            self.assertEqual(True, ret_val)

            # do refocusing
            if cfg.params[cfg.opt_refo]:
                obj = LfpRefocuser(vp_img_arr, cfg=cfg, sta=sta)
                ret_val = obj.main()
                del obj

            self.assertEqual(True, ret_val)

        return True
Exemplo n.º 25
0
    def setUp(self):

        self.cfg = PlenopticamConfig()
        self.sta = PlenopticamStatus()
Exemplo n.º 26
0
    def test_illum(self):

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

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

        # compute 3x3 viewpoints only (to reduce computation time)
        cfg.params[cfg.ptc_leng] = 3

        # skip progress prints (prevent Travis from terminating due to reaching 4MB logfile size)
        sta.prog_opt = False

        # print current process message (to prevent Travis from stopping after 10 mins)
        cfg.params[cfg.opt_prnt] = True

        # use pre-loaded calibration dataset
        wht_list = [
            file for file in os.listdir(self.fp) if file.startswith('caldata')
        ]
        lfp_list = [
            file for file in os.listdir(self.fp)
            if file.endswith(('lfr', 'lfp'))
        ]

        cfg.params[cfg.cal_path] = os.path.join(self.fp, wht_list[0])

        for lfp_file in lfp_list:

            cfg.params[cfg.lfp_path] = os.path.join(self.fp, lfp_file)
            print('\nCompute image %s' %
                  os.path.basename(cfg.params[cfg.lfp_path]))

            # decode light field image
            obj = LfpReader(cfg, sta)
            ret = obj.main()

            # use third of original image size (to prevent Travis from stopping due to memory error)
            crop_h, crop_w = obj.lfp_img.shape[0] // 3, obj.lfp_img.shape[
                1] // 3
            crop_h, crop_w = crop_h + crop_h % 2, crop_w + crop_w % 2  # use even number for correct Bayer arrangement
            lfp_img = obj.lfp_img[crop_h:-crop_h, crop_w:-crop_w]
            del obj

            self.assertEqual(True, ret)

            # create output data folder
            mkdir_p(cfg.exp_path, cfg.params[cfg.opt_prnt])

            if not cfg.cond_meta_file():
                # automatic calibration data selection
                obj = CaliFinder(cfg, sta)
                ret = obj.main()
                wht_img = obj.wht_bay[
                    crop_h:-crop_h,
                    crop_w:-crop_w] if obj.wht_bay is not None else obj.wht_bay
                del obj

                self.assertEqual(True, ret)

            meta_cond = not (os.path.exists(cfg.params[cfg.cal_meta]) and
                             cfg.params[cfg.cal_meta].lower().endswith('json'))
            if meta_cond or cfg.params[cfg.opt_cali]:
                # perform centroid calibration
                obj = LfpCalibrator(wht_img, cfg, sta)
                ret = obj.main()
                cfg = obj.cfg
                del obj

                self.assertEqual(True, ret)

            # load calibration data
            cfg.load_cal_data()

            # write centroids as png file
            if wht_img is not None:
                obj = CentroidDrawer(wht_img, cfg.calibs[cfg.mic_list], cfg)
                ret = obj.write_centroids_img(
                    fn=os.path.join(cfg.exp_path, 'wht_img+mics.png'))
                del obj

                self.assertEqual(True, ret)

            #  check if light field alignment has been done before
            if cfg.cond_lfp_align():
                # align light field
                obj = LfpAligner(lfp_img, cfg, sta, wht_img)
                ret = obj.main()
                del obj

                self.assertEqual(True, ret)

            # load previously computed light field alignment
            with open(os.path.join(cfg.exp_path, 'lfp_img_align.pkl'),
                      'rb') as f:
                lfp_img_align = pickle.load(f)

            # extract viewpoint data
            CaliFinder(cfg).main()
            obj = LfpExtractor(lfp_img_align, cfg=cfg, sta=sta)
            ret = obj.main()
            vp_img_arr = obj.vp_img_arr
            del obj

            self.assertEqual(True, ret)

            # do refocusing
            if cfg.params[cfg.opt_refo]:
                obj = LfpRefocuser(vp_img_arr, cfg=cfg, sta=sta)
                ret = obj.main()
                del obj

            self.assertEqual(True, ret)

        return True