def test_combo_box(): viewer = get_image_viewer() cb = ComboBox('hello', ('a', 'b', 'c')) viewer.plugins[0] += cb assert_equal(str(cb.val), 'a') assert_equal(cb.index, 0) cb.index = 2 assert_equal(str(cb.val), 'c'), assert_equal(cb.index, 2)
def __init__(self, search_pattern): bottom_px = 60 self.bottom_px = bottom_px plugin = Plugin(image_filter=self.image_filter, dock="right") self.setup_names = ['Bottom'] self.show_orig = CheckBox('show_orig', value=False, alignment='left') plugin += self.show_orig plugin += ComboBox('setup', self.setup_names) plugin += Slider('bottom_px', 0, 500, value=self.bottom_px, value_type='int') plugin += Button("Print", callback=self.on_print_click) fnames = [path for path in glob.iglob(search_pattern, recursive=True)] images, gray_images = read_images(fnames) self.viewer = CollectionViewer(images) self.viewer += plugin
def attach(self, image_viewer): ''' Override the attaching of the plugin to the ImageViewer. This utilizes nearly identical implementation to https://github.com/scikit-image/ scikit-image/blob/master/skimage/viewer/plugins/canny.py, but changes the limits for parameter selection. ''' image = image_viewer.image imin, imax = skimage.dtype_limits(image, clip_negative=False) itype = 'float' if np.issubdtype(image.dtype, np.floating) else 'int' self.add_widget(Slider('sigma', 0, 2, update_on='release')) self.add_widget( Slider('low_threshold', imin, imax, value_type=itype, update_on='release')) self.add_widget( Slider('high_threshold', imin, imax, value_type=itype, update_on='release')) self.add_widget(ComboBox('color', self.color_names, ptype='plugin')) # Call parent method at end b/c it calls `filter_image`, which needs # the values specified by the widgets. Alternatively, move call to # parent method to beginning and add a call to `self.filter_image()` super(CannyPlugin, self).attach(image_viewer)
def __init__(self, search_pattern): blur_kernel_size = 1 cal_fnames = [ path for path in glob.iglob('camera_cal/*.jpg', recursive=True) ] cal_images, cal_gray_images = read_images(cal_fnames) self.objpoints, self.imgpoints, _ = get_chessboard_corners( cal_images, cal_gray_images) self.blur_kernel_size = blur_kernel_size self.top_left_x = top_left_x self.top_left_y = top_left_y self.top_right_x = top_right_x self.top_right_y = top_right_y self.bottom_right_x = bottom_right_x self.bottom_right_y = bottom_right_y self.bottom_left_x = bottom_left_x self.bottom_left_y = bottom_left_y plugin = Plugin(image_filter=self.image_filter, dock="right") self.setup_names = [ 'ROI poly', "ROI Transformation", 'ROI Transformed', "Final Transformation poly", 'Final Transformation', 'Final Transformed' ] self.show_orig = CheckBox('show_orig', value=False, alignment='left') plugin += self.show_orig plugin += ComboBox('setup', self.setup_names) plugin += Slider('blur_kernel_size', 0, 31, value=self.blur_kernel_size, value_type='int') plugin += Slider('top_left_x', 0, 1, value=self.top_left_x) plugin += Slider('top_left_y', 0, 1, value=self.top_left_y) plugin += Slider('top_right_x', 0, 1, value=self.top_right_x) plugin += Slider('top_right_y', 0, 1, value=self.top_right_y) plugin += Slider('bottom_right_x', 0, 1, value=self.bottom_right_x) plugin += Slider('bottom_right_y', 0, 1, value=self.bottom_right_y) plugin += Slider('bottom_left_x', 0, 1, value=self.bottom_left_x) plugin += Slider('bottom_left_y', 0, 1, value=self.bottom_left_y) plugin += Button("Print", callback=self.on_print_click) fnames = [path for path in glob.iglob(search_pattern, recursive=True)] images, gray_images = read_images(fnames) self.viewer = CollectionViewer(images) self.viewer += plugin
def __init__(self, search_pattern): self.plugin = Plugin(image_filter=self.image_filter, dock="right") self.setup_names = ['Yellow', 'White', 'Yellow / White'] self.color_spaces = ['LAB', 'HSV', 'HLS', 'LUV'] self.show_orig = CheckBox('show_orig', value=False, alignment='left') self.plugin += self.show_orig self.setup = ComboBox('setup', self.setup_names) self.color_space = ComboBox('color_space', self.color_spaces) self.sensity_range = Slider('sensity_range', 10, 100, value=sensity_range, value_type='int') self.lower_yellow_1 = Slider('lower_yellow_1', 0, 255, value=lower_yellow_1, value_type='int') self.lower_yellow_2 = Slider('lower_yellow_2', 0, 255, value=lower_yellow_2, value_type='int') self.lower_yellow_3 = Slider('lower_yellow_3', 0, 255, value=lower_yellow_3, value_type='int') self.upper_yellow_1 = Slider('upper_yellow_1', 0, 255, value=upper_yellow_1, value_type='int') self.upper_yellow_2 = Slider('upper_yellow_2', 0, 255, value=upper_yellow_2, value_type='int') self.upper_yellow_3 = Slider('upper_yellow_3', 0, 255, value=upper_yellow_3, value_type='int') self.lower_white_1 = Slider('lower_white_1', 0, 255, value=lower_white_1, value_type='int') self.lower_white_2 = Slider('lower_white_2', 0, 255, value=lower_white_2, value_type='int') self.lower_white_3 = Slider('lower_white_3', 0, 255, value=lower_white_3, value_type='int') self.upper_white_1 = Slider('upper_white_1', 0, 255, value=upper_white_1, value_type='int') self.upper_white_2 = Slider('upper_white_2', 0, 255, value=upper_white_2, value_type='int') self.upper_white_3 = Slider('upper_white_3', 0, 255, value=upper_white_3, value_type='int') self.plugin += self.setup self.plugin += self.color_space # self.plugin += self.sensity_range self.plugin += self.lower_yellow_1 self.plugin += self.lower_yellow_2 self.plugin += self.lower_yellow_3 self.plugin += self.upper_yellow_1 self.plugin += self.upper_yellow_2 self.plugin += self.upper_yellow_3 self.plugin += self.lower_white_1 self.plugin += self.lower_white_2 self.plugin += self.lower_white_3 self.plugin += self.upper_white_1 self.plugin += self.upper_white_2 self.plugin += self.upper_white_3 fnames = [path for path in glob.iglob(search_pattern, recursive=True)] images, gray_images = read_images(fnames) self.viewer = CollectionViewer(images) self.viewer.connect_event('button_press_event', self.on_filter_color) self.viewer.connect_event('key_press_event', self.on_press) self.viewer += self.plugin
def __init__(self, search_pattern): plugin = Plugin(image_filter=self.image_filter, dock="right") self.setup_names = [ 'Sobel Thresh X', 'Sobel Thresh Y', 'Sobel Thresh X / Y', 'Magnitude Thresh', 'Gradient Direction', 'Magnitude / Gradient Direction Thresh', "2 & 2", "2 | 2" ] self.show_orig = CheckBox('show_orig', value=False, alignment='left') plugin += self.show_orig plugin += ComboBox('setup', self.setup_names) plugin += Slider('grad_ksize', 0, 31, value=grad_ksize, value_type='int') plugin += Slider('grad_thresh_low', 0, 255, value=grad_thresh_low, value_type='int') plugin += Slider('grad_thresh_high', 0, 255, value=grad_thresh_high, value_type='int') plugin += Slider('mag_binary_ksize', 0, 31, value=mag_binary_ksize, value_type='int') plugin += Slider('mag_binary_thresh_low', 0, 255, value=mag_binary_thresh_low, value_type='int') plugin += Slider('mag_binary_thresh_high', 0, 255, value=mag_binary_thresh_high, value_type='int') plugin += Slider('dir_binary_ksize', 0, 31, value=dir_binary_ksize, value_type='int') plugin += Slider('dir_binary_thresh_low', 0, np.pi, value=dir_binary_thresh_low) plugin += Slider('dir_binary_thresh_high', 0, np.pi, value=dir_binary_thresh_high) fnames = [path for path in glob.iglob(search_pattern, recursive=True)] images, gray_images = read_images(fnames) self.viewer = CollectionViewer(images) self.viewer += plugin