def reset(self):
     """
     Resets settings to factory settings (defaults)
     :return: None
     """
     self.settings = Settings()
     self.init_settings()
 def apply(self):
     """
     Gather data into settings variable and set it as the result
     :return: None
     """
     self.__result = Settings(
         float(self.harris_score_threshold_spinbox.get()),
         float(self.harris_free_parameter_spinbox.get()),
         int(float(self.neighborhood_size_spinbox.get())), self.mark_color,
         int(float(self.canny_min_threshold_entry.get())),
         int(float(self.canny_max_threshold_entry.get())),
         bool(self.rect_mark_check_var.get()),
         int(float(self.dilate_size_spinbox.get())), self.quality_var.get())
예제 #3
0
class Manager():
    __metaclass__ = ABCMeta
    conf = Settings().settings

    def __init__(self, manager, data=None):
        self.manager = manager
        self.data = data

    @abstractmethod
    def parse(self):
        pass

    def needIndex():
        if Manager.conf['info_license'] == True or \
           Manager.conf['info_author'] == True or \
           Manager.conf['info_homepage_url'] == True or \
           Manager.conf['info_code_url'] == True:
            return True
        return False

    def needLicense():
        if Manager.conf['info_license'] == True:
            return True
        return False

    def needAuthor():
        if Manager.conf['info_author'] == True:
            return True
        return False

    def needHpUrl():
        if Manager.conf['info_homepage_url'] == True:
            return True
        return False

    def needCodeUrl():
        if Manager.conf['info_code_url'] == True:
            return True
        return False
예제 #4
0
def corners_and_line_intersection_detector(img,
                                           console_consumer=None,
                                           progress_consumer=None,
                                           is_using_canny=False,
                                           is_applying_gauss=False,
                                           settings=Settings()):
    """
    Main entry point to the Harris Detector algorithm
    We call this method from main frame in order to open an image, detect corners in it, and return both the image and
    a copy of the image with the corners marked out
    :param img: Image to work on
    :param console_consumer: A lambda / function to handle status updates
    :param progress_consumer: A lambda / function to handle progress updates
    :param is_using_canny: Whether we should detect edges using Canny Edge Detection before Harris Detector, or not
    :param is_applying_gauss: Whether to apply Gaussian Blur before executing Harris Corner Detector
    :param settings: Settings to know how to execute the algorithm
    :return: image, image_with_marks
    """
    start = timer()
    progress = do_progress(progress_consumer, 0, 5)

    success = False

    if img is None:
        log(console_consumer, 'Specified image was None')
        image = None
    else:
        image = img.copy()
        if is_applying_gauss:
            log(console_consumer, 'Applying Gaussian Blur...')
            image = apply_gaussian_blur(
                image)  # yields either 3D or 2D, depends on the image
            progress = do_progress(progress_consumer, progress, 10)

        if is_using_canny:
            log(console_consumer, 'Running Canny Edge Detection...')
            image = cv2.Canny(image, settings.canny_min_thresh,
                              settings.canny_max_thresh)  # yields 2D
            progress = do_progress(progress_consumer, progress, 10)

        log(console_consumer, 'Detecting corners...')
        harris_scores = find_harris_corners(image,
                                            settings.harris_free_parameter,
                                            settings.neighborhood_size,
                                            console_consumer)
        progress = do_progress(progress_consumer, progress, 10)

        if harris_scores is None:
            log(console_consumer,
                'Error has occurred while detecting corners. Result was None')
            image = None
        else:
            success = True
            image = img.copy()
            if image.ndim == 2:
                image = cv2.cvtColor(image, cv2.COLOR_GRAY2BGR)

            # Mark the corners
            log(console_consumer, 'Marking detected interest points...')
            if settings.corners_quality == HIGH_QUALITY:
                helper_image = enhance_corners_accuracy(
                    harris_scores, image, settings)
                progress = do_progress(progress_consumer, progress, 10)
                mark_corners(image, helper_image, settings, progress_consumer,
                             progress)
            else:
                # Faster marking, low quality
                if settings.is_using_rect_mark:
                    mark_corners_with_rect(image, harris_scores, settings,
                                           progress_consumer, progress)
                else:
                    # Mark with dots
                    harris_scores = cv2.dilate(harris_scores, None)
                    image[harris_scores > settings.harris_score_threshold *
                          harris_scores.max()] = settings.corners_color[::-1]

    time_took = timer() - start
    do_progress(progress_consumer, 0, 100)
    log(console_consumer,
        'Corners detection ended in %.2f seconds. Result:' % time_took,
        'Success' if success else 'Fail')
    return img, image
예제 #5
0
from util.settings import Settings
from manager import classify_manager
from output import classify_output
from github import Github


def get_manager_from_path(path):
    return path.split('/')[-1].replace('.', '_').lower()


args = argparser.parse()
library_info_list = []
manager_files = []

timestamp = datetime.now().strftime("%Y/%m/%d %H:%M:%S")
conf = Settings().settings

for repo in conf['target_repositories']:

    git = Github(args.token)
    manager_paths = git.search_files(repo, conf['target_manager'])
    for path in manager_paths:
        manager_files.append({'path': path, 'data': git.get_files(repo, path)})

    for file in manager_files:
        print('processing: ' + file['path'] + ' ...')
        manager = classify_manager.new_manager(
            get_manager_from_path(file['path']), file['data'])
        if not manager:
            continue
        lib_list = manager.parse()
예제 #6
0
    def __init__(self, master):
        tk.Frame.__init__(self, master)
        master.config(background=ctl.BACKGROUND_COLOR)
        toplevel = self.winfo_toplevel()
        toplevel.title('Corners Detector')
        toplevel.iconbitmap(os.path.abspath(os.path.join('resource', 'corners-icon.ico')))

        # Declare all of the instance attributes here, and initialize them in separate methods for code separation
        # Keep them as attributes so we will not have issues with garbage collection. Especially with the PhotoImage
        self.settings = Settings().load()
        self.__title_frame = None  # tk.Frame
        self.__action_frame = None  # tk.Frame
        self.__status_frame = None  # tk.Frame
        self.__figure_frame = None  # tk.Frame
        self.__title = None  # tk.Label
        self.__status_bar = None  # tk.Label
        self.__progress_bar = None  # tk.Progressbar
        self.__settings_button = None  # tk.Button
        self.__go_button = None  # tk.Button
        self.__open_file_button = None  # tk.Button
        self.__popup_image_button = None  # tk.Button
        self.__settings_button_tooltip = None  # view.tooltip.Tooltip
        self.__go_button_tooltip = None  # view.tooltip.Tooltip
        self.__open_file_button_tooltip = None  # view.tooltip.Tooltip
        self.__popup_image_button_tooltip = None  # view.tooltip.Tooltip
        self.__file_path_entry_tooltip = None  # view.tooltip.Tooltip
        self.__canny_check_var = None  # tk.IntVar  - to hold the value of the canny edge checkbox
        self.__canny_checkbutton = None  # tk.Checkbutton
        self.__gauss_check_var = None  # tk.IntVar  - to hold the value of the gaussian checkbox
        self.__gauss_checkbutton = None  # tk.Checkbutton
        self.__file_path_entry = None  # tk.Entry
        self.__magnifying_icon = None  # tk.PhotoImage
        self.__play_icon = None  # tk.PhotoImage
        self.__popout_icon = None  # tk.PhotoImage
        self.__settings_icon = None  # tk.PhotoImage
        self.__figure = None  # A reference to pyplot figure, so we can destroy it when there is a new input
        self.__style = None  # tk.ttk.Style
        self.__running = False  # Indication of when we wait for the Harris Detector worker to finish
        self.__image = None  # A reference to the input image. It is being set by the Harris Detector action
        self.__processed_image = None  # A reference to the processed image (outcome). It is being set by the Harris Detector action
        self.__error = False  # Indication for a failure during Harris Detector algorithm
        self.progress_text_format = '{0}%'

        self.__style = Style(master)
        self.__style.theme_use('clam')
        self.__style.configure("Horizontal.TProgressbar", foreground='#E0E0E0', background=ctl.ACCEPT_COLOR,
                               troughcolor=ctl.BACKGROUND_TOOLTIP_COLOR, bordercolor=ctl.ACCEPT_COLOR,
                               lightcolor=ctl.ACCEPT_COLOR, darkcolor=ctl.ACCEPT_COLOR)
        self.__style.configure('TButton', font=ctl.FONT_BUTTON, borderwidth='1', background=ctl.BACKGROUND_COLOR, relief='FLAT')
        self.__style.configure('TLabel', font=ctl.FONT_REGULAR)
        self.__style.map('TButton', background=[('active', '!disabled', '#4E6067')])
        self.__style.map('TCombobox', foreground=[('readonly', '!disabled', ctl.FOREGROUND_EDITOR_COLOR)])
        self.__style.map('TCombobox', background=[('readonly', '!disabled', ctl.BACKGROUND_EDITOR_COLOR)])
        self.__style.map('TCombobox', fieldbackground=[('readonly', '!disabled', ctl.BACKGROUND_EDITOR_COLOR)])
        self.__style.map('TCombobox', lightcolor=[('readonly', '!disabled', 'black')])
        self.__style.map('TCombobox', darkcolor=[('readonly', '!disabled', 'black')])
        self.__style.map('TCombobox', bordercolor=[('readonly', '!disabled', '#E0E0E0')])
        master.option_add("*TCombobox*Listbox*Background", ctl.BACKGROUND_EDITOR_COLOR)
        master.option_add("*TCombobox*Listbox*Foreground", ctl.FOREGROUND_EDITOR_COLOR)

        self.create_title_section(master)
        self.create_action_section(master)
        self.create_status_section(master)
        self.create_workarea_section(master)

        master.bind('<Return>', self.on_enter_pressed)
        master.geometry("800x600")