Beispiel #1
0
 def opendir(self):
     self.parent.all_files = []
     cfg = helpers.config_to_dict(self.parent.Config, 'main')
     self.parent.input_dir = tkFileDialog.askdirectory(
         title="Select a Directory Containing Images",
         initialdir=cfg['last_in_dir'])
     self.parent.dirmode = True
     cfg['last_in_dir'] = self.parent.input_dir
     helpers.dict_to_config(cfg, self.parent.Config, True)
     valid_images = (".jpg", "jpeg", ".bmp", ".gif", ".png", ".tga")
     for f in os.listdir(self.parent.input_dir):
         if f.lower().endswith(valid_images):
             this_f = os.path.join(self.parent.input_dir, f)
             self.parent.all_files.append(this_f)
     n_img = len(self.parent.all_files)
     lbl_text = "Selected Directory: " + self.parent.input_dir
     #lbl_text += "\nDimensions (Height, Width, Colors): " + str(self.parent.img.shape)
     lbl_text += "\nNumber of Image Files in Directory: " + str(n_img)
     self.label_text.set(lbl_text)
     self.label_fname.pack(padx=5)
     print(self.parent.input_dir)
     if n_img > 0:
         self.parent.img = cv2.imread(self.parent.all_files[0])
         self.parent.img_orig = self.parent.img.copy()
         self.show_buttons()
Beispiel #2
0
    def __init__(self, master, Config):
        master.minsize(width=350, height=550)
        master.maxsize(width=1000, height=1000)
        self.all_files = []
        self.all_out_files = []
        self.img = None
        self.master = master
        self.dirmode = False
        master.title("Face Scrambler")
        cfg = helpers.config_to_dict(Config)
        self.cfg = cfg
        self.Config = Config
        self.p1 = PageLoad(self)
        self.p2 = PageOpt(self)
        self.p3 = PageScr(self)
        self.mode = 'file'
        buttonframe = tk.Frame(master)

        buttonframe.pack(side="top", fill="x", expand=False)
        self.swt_btn_text = StringVar(value="Switch to Directory Mode")
        b1 = tk.Button(buttonframe,
                       textvariable=self.swt_btn_text,
                       command=self.toggle_mode,
                       state='normal')
        b1.pack()
        self.p1.pack(fill='x', expand=True)

        self.p2.pack(fill='x', expand=True)
        self.p3.pack(fill='x', expand=True)

        return
Beispiel #3
0
 def update_config(self):
     cfg = {}
     cfg['shift_up'] = self.p2.inp_offset_y.get()
     cfg['shift_right'] = self.p2.inp_offset_x.get()
     cfg['horz_size'] = self.p2.inp_horz_size.get()
     cfg['vert_size'] = self.p2.inp_vert_size.get()
     cfg['bl_sz'] = self.p2.inp_size.get()
     helpers.dict_to_config(cfg, self.Config)
     return helpers.config_to_dict(self.Config, 'main')
Beispiel #4
0
 def select_output_directory(self):
     cfg = helpers.config_to_dict(self.parent.Config, 'main')
     try:
         init_dir = cfg['last_out_dir']
     except:
         init_dir = ''
     out_dir = tkFileDialog.askdirectory(
         title="Select a Directory Containing Images", initialdir=init_dir)
     cfg['last_out_dir'] = out_dir
     helpers.dict_to_config(cfg, self.parent.Config)
     self.out_dir = out_dir
Beispiel #5
0
 def openfile(self):
     if self.parent.mode == 'dir':
         self.opendir()
         return
     cfg = helpers.config_to_dict(self.parent.Config, 'main')
     self.file_opt['initialdir'] = cfg['last_in_dir']
     self.parent.input_file = tkFileDialog.askopenfilename(**self.file_opt)
     #self.show_button.config(state='normal')
     print(self.parent.input_file)
     if self.parent.input_file:
         self.parent.img = cv2.imread(self.parent.input_file)
         self.parent.img_orig = self.parent.img.copy()
         self.parent.dirmode = False
         dir_name = os.path.dirname(self.parent.input_file)
         cfg['last_in_dir'] = dir_name
         helpers.dict_to_config(cfg, self.parent.Config, True)
         lbl_text = "Selected File: " + self.parent.input_file
         lbl_text += "\nDimensions (Height, Width, Colors): " + str(
             self.parent.img.shape)
         self.label_text.set(lbl_text)
         self.label_fname.pack(padx=5)
         self.show_buttons()
Beispiel #6
0
 def save_manual(self):
     cfg = helpers.config_to_dict(self.parent.Config, 'main')
     if self.parent.mode == 'file':
         self.save_single(cfg)
     else:
         self.save_dir(cfg)