def _button_edit_cal_parameters_fired(self): cp = pargui.Calib_Params(par_path=self.par_path) cp.edit_traits(kind='modal') # at the end of a modification, copy the parameters par.copy_params_dir(self.par_path, self.active_path) self.cpar, self.spar, self.vpar, self.track_par, self.tpar, \ self.cals, self.epar = ptv.py_start_proc_c(self.n_cams)
def init_action(self, info): """ init_action - clears existing plots from the camera windows, initializes C image arrays with mainGui.orig_image and calls appropriate start_proc_c by using ptv.py_start_proc_c() """ mainGui = info.object mainGui.exp1.syncActiveDir() # synchronize the active run params dir with the temp params dir for i in range(len(mainGui.camera_list)): try: im = imread(getattr(mainGui.exp1.active_params.m_params, 'Name_{}_Image'.format(i+1))) if im.ndim > 2: im = rgb2gray(im) mainGui.orig_image[i] = img_as_ubyte(im) except IOError: print("Error reading image, setting zero image") h_img = mainGui.exp1.active_params.m_params.imx v_img = mainGui.exp1.active_params.m_params.imy temp_img = img_as_ubyte(np.zeros((h_img, v_img))) exec ("mainGui.orig_image[%d]= temp_img" % i) if hasattr(mainGui.camera_list[i], '_img_plot'): del mainGui.camera_list[i]._img_plot mainGui.clear_plots() print("\n Init action \n") mainGui.update_plots(mainGui.orig_image, is_float=False) # mainGui.set_images(mainGui.orig_image) info.object.cpar, info.object.spar, info.object.vpar, info.object.track_par, \ info.object.tpar, info.object.cals, info.object.epar = ptv.py_start_proc_c(info.object.n_cams) mainGui.pass_init = True print ("Read all the parameters and calibrations successfully ")
def _button_showimg_fired(self): print("Loading images/parameters \n") # Initialize what is needed, copy necessary things print("\n Copying man_ori.dat \n") if os.path.isfile(os.path.join(self.par_path, 'man_ori.dat')): shutil.copyfile(os.path.join(self.par_path, 'man_ori.dat'), os.path.join(self.working_folder, 'man_ori.dat')) print("\n Copied man_ori.dat \n") # copy parameters from active to default folder parameters/ par.copy_params_dir(self.active_path, self.par_path) # read from parameters self.cpar, self.spar, self.vpar, self.track_par, self.tpar, \ self.cals, self.epar = ptv.py_start_proc_c(self.n_cams) self.tpar.read(b'parameters/detect_plate.par') print(self.tpar.get_grey_thresholds()) self.calParams = par.CalOriParams(self.n_cams, self.par_path) self.calParams.read() if self.epar.Combine_Flag is True: print("Combine Flag") self.MultiParams = par.MultiPlaneParams() self.MultiParams.read() for i in range(self.MultiParams.n_planes): print(self.MultiParams.plane_name[i]) self.pass_raw_orient = True self.status_text = "Multiplane calibration." # read calibration images self.cal_images = [] for i in range(len(self.camera)): imname = self.calParams.img_cal_name[i] # for imname in self.calParams.img_cal_name: # self.cal_images.append(imread(imname)) im = imread(imname) if im.ndim > 2: im = rgb2gray(im) self.cal_images.append(img_as_ubyte(im)) self.reset_show_images() # Loading manual parameters here man_ori_path = os.path.join(self.par_path, 'man_ori.par') f = open(man_ori_path, 'r') if f is None: print('\n Error loading man_ori.par') else: for i in range(len(self.camera)): for j in range(4): self.camera[i].man_ori[j] = int(f.readline().strip()) f.close() self.pass_init = True self.status_text = "Initialization finished."