main.py 1.94 KB
Newer Older
1 2 3 4
#!/usr/bin/python
# -*- coding: utf-8 -*-
#
"""
5 6 7 8
    Read the args, creates GUI and add all actions of pynovisao.
    
    Name: main.py
    Author: Alessandro dos Santos Ferreira ( santosferreira.alessandro@gmail.com )
9
"""
10
import argparse
11

12
import interface
13

14
from pynovisao import Act
15

16 17 18 19 20 21 22 23 24 25 26 27

def get_args():
    ap = argparse.ArgumentParser()

    ap.add_argument("-d", "--dataset", required=False, help="Dataset path", default="../data/demo", type=str)
    
    ap.add_argument("-cl", "--classes", required=False, help="Classes names", default=None, type=str)
    ap.add_argument("-co", "--colors", required=False, help="Classes colors (X11 color)", default=None, type=str)
    
    return vars(ap.parse_args())


28 29
if __name__ == "__main__":
    
30
    tk = interface.TkInterface("Pynovisao")
31
    
32
    act = Act(tk, get_args())
33 34 35 36
    
    tk.add_menu("File")
    tk.add_command("Open a image", act.open_image, 'O') 
    tk.add_separator()
37 38
    tk.add_command("Add new class", act.add_class, 'A')
    tk.add_command("Set dataset path", act.set_dataset_path, 'd')
39
    tk.add_separator()
40
    tk.add_check_button("Show log", tk.toogle_log)
41 42 43 44 45 46
    tk.add_separator()
    tk.add_command("Close image", act.close_image, 'W') 
    tk.add_separator()
    tk.add_command("Quit", tk.quit, 'Q')
    
    tk.add_menu("Segmentation")
47 48
    tk.add_command("Choose segmenter", act.select_segmenter)
    tk.add_command("Configure", act.config_segmenter, 'g')
49
    tk.add_separator()
50
    tk.add_command("Execute", act.run_segmenter, 'S')
51 52
    
    tk.add_menu("Feature Extraction")
53
    tk.add_command("Select extractors", act.select_extractors, 'e')
54
    tk.add_separator()
55
    tk.add_command("Execute", act.func_not_available, 'F')
56 57 58 59 60 61 62 63 64 65 66 67 68
    
    tk.add_menu("Classification")
    tk.add_command("Configure", act.func_not_available)
    tk.add_separator()
    tk.add_command("Execute", act.func_not_available, 'C')
    
    tk.render_menu()
    
    tk.add_panel_classes( act.classes )
    
    tk.open_log()
    
    tk.show()