Exemple #1
0
    def process(self):

        # reset
        self.var_init()

        # status update
        self.sta.status_msg('Loading data', self.cfg.params[self.cfg.opt_prnt])
        self.sta.progress(None, self.cfg.params[self.cfg.opt_prnt])

        # disable button activity
        self.toggle_btn_list(self.all_btn_list)
        self.cmd_wid.btn_list[3].config(text='Stop')

        # read light field photo and calibration source paths
        self.fetch_paths()

        # remove output folder if option is set
        misc.rmdir_p(
            self.cfg.exp_path) if self.cfg.params[self.cfg.dir_remo] else None

        # remove calibrated light-field if calibration or devignetting option is set
        if self.cfg.params[self.cfg.opt_cali] or self.cfg.params[
                self.cfg.opt_vign]:
            misc.rm_file(join(self.cfg.exp_path, 'lfp_img_align.pkl'))
            if self.cfg.params[self.cfg.opt_cali]:
                misc.rm_file(self.cfg.params[self.cfg.cal_meta])

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

        # put tasks in the job queue to be run
        for task_info in ((self.load_lfp, self.cfg.cond_load_limg,
                           self.cfg.params[self.cfg.lfp_path]),
                          (self.auto_find, self.cfg.cond_auto_find),
                          (self.load_lfp, self.cfg.cond_load_wimg,
                           self.cfg.params[self.cfg.cal_path],
                           True), (self.cal, self.cfg.cond_perf_cali),
                          (self.cfg.load_cal_data, self.cfg.cond_lfp_align),
                          (self.lfp_align,
                           self.cfg.cond_lfp_align), (self.load_pickle_file,
                                                      True), (self.lfp_extract,
                                                              True),
                          (self.lfp_refo,
                           self.cfg.params[self.cfg.opt_refo]), (self.finish,
                                                                 True)):
            self.job_queue.put(task_info)

        # start polling
        self.after(POLLING_RATE, self.poll)

        # cancel if file paths not provided
        self.sta.validate(checklist=[
            self.cfg.params[self.cfg.lfp_path],
            self.cfg.params[self.cfg.cal_path]
        ],
                          msg='Canceled due to missing image file path')
    def test_read_error(self):

        # folder and path handling
        fp = os.path.join(
            os.path.dirname(os.path.dirname(os.path.abspath(__file__))),
            'examples', 'data')
        os.makedirs(fp) if not os.path.exists(fp) else None

        # create dummy file with wrong file format
        self.cfg.params[self.cfg.lfp_path] = os.path.join(fp, 'test_dummy.lfp')
        with open(self.cfg.params[self.cfg.lfp_path], 'a'):
            os.utime(self.cfg.params[self.cfg.lfp_path], None)

        with self.assertRaises(PlenopticamError) as exc:
            reader = LfpReader(cfg=self.cfg, sta=self.sta)
            reader.main()

        self.assertEqual("'dict' object has no attribute 'startswith'",
                         str(exc.exception))

        # remove dummy data after test
        rm_file(self.cfg.params[self.cfg.lfp_path])
        rmdir_p(self.cfg.exp_path)
Exemple #3
0
    def remove_dummy_file(self):
        """ remove dummy data after test """

        rm_file(self.cfg.params[self.cfg.lfp_path])
        rmdir_p(self.cfg.exp_path)