How to use the plenopticam.lfp_calibrator.LfpCalibrator 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_illum.py View on Github external
# create output data folder
            mkdir_p(self.cfg.exp_path, self.cfg.params[self.cfg.opt_prnt])

            if not self.cfg.cond_meta_file():
                # automatic calibration data selection
                obj = CaliFinder(self.cfg, self.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 (exists(self.cfg.params[self.cfg.cal_meta]) and self.cfg.params[self.cfg.cal_meta].lower().endswith('json'))
            if meta_cond or self.cfg.params[self.cfg.opt_cali]:
                # perform centroid calibration
                obj = LfpCalibrator(wht_img, self.cfg, self.sta)
                ret = obj.main()
                self.cfg = obj.cfg
                del obj

                self.assertEqual(True, ret)

            # load calibration data
            self.cfg.load_cal_data()

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

                self.assertEqual(True, ret)
github hahnec / plenopticam / plenopticam / scripts / metrics / wht_img_plt_script.py View on Github external
if cal_opt:
        # decode light field image
        lfp_obj = lfp_reader.LfpReader(cfg)
        lfp_obj.main()
        lfp_img = lfp_obj.lfp_img[:, :-16]
        del lfp_obj

    # automatic calibration data selection
    obj = lfp_calibrator.CaliFinder(cfg)
    obj.main()
    wht_img = obj.wht_bay[:, :-16]
    del obj

    if cal_opt:
        # perform centroid calibration
        cal_obj = lfp_calibrator.LfpCalibrator(wht_img, cfg)
        cal_obj.main()
        cfg = cal_obj.cfg
        del cal_obj
    else:
        # convert Bayer to RGB representation
        if len(wht_img.shape) == 2 and 'bay' in cfg.lfpimg:
            # perform color filter array management and obtain rgb image
            cfa_obj = CfaProcessor(bay_img=wht_img, cfg=cfg)
            cfa_obj.bay2rgb()
            wht_img = cfa_obj.rgb_img
            del cfa_obj

    # ensure white image is monochromatic
    wht_img = rgb2gry(wht_img)[..., 0] if len(wht_img.shape) is 3 else wht_img

    # load calibration data
github hahnec / plenopticam / plenopticam / gui / widget_ctrl.py View on Github external
def cal(self):

        # perform centroid calibration
        cal_obj = lfp_calibrator.LfpCalibrator(self.wht_img, self.cfg, self.sta)
        cal_obj.main()
        self.cfg = cal_obj.cfg
        del cal_obj
github hahnec / plenopticam / plenopticam / bin / cli_script.py View on Github external
if cfg.cond_auto_find():
            # automatic calibration data selection
            extractor = lfp_calibrator.CaliFinder(cfg, sta)
            extractor.main()
            wht_img = extractor.wht_bay
        else:
            # load white image calibration file
            wht_img = misc.load_img_file(cfg.params[cfg.cal_path])
            # save settings configuration
            cfg.save_params()

        # perform calibration if previously computed calibration data does not exist
        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
            calibrator = lfp_calibrator.LfpCalibrator(wht_img, cfg, sta)
            calibrator.main()
            cfg = calibrator.cfg

        # load calibration data
        cfg.load_cal_data()

        #  check if light field alignment has been done before
        if cfg.cond_lfp_align():
            # align light field
            aligner = lfp_aligner.LfpAligner(lfp_img, cfg, sta, wht_img)
            aligner.main()
            lfp_img_align = aligner.lfp_img
        else:
            lfp_img_align = None

        # extract viewpoint data
github hahnec / plenopticam / plenopticam / lfp_calibrator / calibrate_folder.py View on Github external
def calibrate_folder(cfg, sta):

    tarnames = [f for f in listdir(cfg.params[cfg.cal_path])
                if isfile(join(cfg.params[cfg.cal_path], f)) and f.lower().endswith(".tar")]

    for tarname in tarnames:

        tar_obj = tarfile.open(tarname, mode='r')

        for member in tar_obj.getmembers():
            wht_img = tar_obj.extractfile(member)
            LfpCalibrator(wht_img, cfg) #save metacalib.json

            # check interrupt status
            if sta.interrupt:
                return False

    return True