def __init__(self, *args, **kwargs): super().__init__('Computer vision algorithm example') #Definition of the forms fields self._videofile = ControlFile('Video') self._outputfile = ControlText('Results output file') self._threshold = ControlSlider('Threshold', default=114, minimum=0, maximum=255) self._blobsize = ControlSlider('Minimum blob size', default=110, minimum=100, maximum=2000) self._player = ControlPlayer('Player') self._runbutton = ControlButton('Run') #Define the function that will be called when a file is selected self._videofile.changed_event = self.__video_file_selection_event #Define the event that will be called when the run button is processed self._runbutton.value = self.run_event #Define the event called before showing the image in the player self._player.process_frame_event = self.__process_frame #Define the organization of the Form Controls self._formset = [('_videofile', '_outputfile'), '_threshold', ('_blobsize', '_runbutton'), '_player']
def __init__(self, parent=None): super(GeometryFromThreshold, self).__init__('Find geometry using a threshold on the image', parent_win=parent) self._filename = ControlFile('Video file name') self._player = ControlPlayer('Player') self._threshold = ControlSlider('Movement threshold', default=10, minimum=0, maximum=255) self._epsilon = ControlSlider('Epsilon', default=10, minimum=1, maximum=255) self._add_contour = ControlButton('add contour') self._formset = [ '_filename', ('_threshold', '_epsilon', '_add_contour'), '_player' ] self._filename.changed_event = self.__filename_changed self._player.process_frame_event = self.__processFrame self._threshold.changed_event = self._player.refresh self._epsilon.changed_event = self._player.refresh self._add_contour.value = self.__add_contours self._filename.value = '/home/ricardo/bitbucket/single-fly-tracker/Circle_and_Square.avi' self._contours = []
def __init__(self, parent=None): super(BackgroundFinderWindow, self).__init__('Background finder', parent_win=parent) self.mainwindow = parent self.set_margin(5) self.setMinimumHeight(400) self.setMinimumWidth(400) self._panel = ControlEmptyWidget('Videos') self._image = ControlImage('Image') self._progress = ControlProgress('Progress') self._apply = ControlButton('Apply', checkable=True) self._matrixSize = ControlSlider('Gaussian blur matrix size', default=5, minimum=1, maximum=11) self._sigmaX = ControlSlider('Gaussian blur sigma X', default=5, minimum=1, maximum=11) self._jump_2_frame = ControlSlider('Jump n frames', default=100, minimum=1, maximum=10000) self._cmp_jump = ControlSlider('Compare with frame in front', default=100, minimum=1, maximum=10000) self._threshold = ControlSlider('Threshold', default=5, minimum=0, maximum=255) self._formset = [[ '_panel', '||', [ ('_matrixSize', '_sigmaX'), ('_jump_2_frame', '_cmp_jump', '_threshold'), '_image', ], ], '_apply', '_progress'] self.videos_dialog = VideosDialog(self) self._panel.value = self.videos_dialog self.videos_dialog.interval_visible = False self._apply.value = self.__apply_event self._apply.icon = conf.ANNOTATOR_ICON_PATH self._progress.hide()
def __init__(self, *args, **kwargs): super().__init__('Electrospinner') #Definition of the forms fields self._temperature_goal = ControlSlider('Temperature Goal (F)', default=0, minimum=0, maximum=400) self._soak_time = ControlSlider('Temperature Goal (F)', default=0, minimum=0, maximum=400) self._runbutton = ControlButton('Run')
def __init__(self, parent=None): BaseWidget.__init__(self, 'Motion counter', parent_win=parent) self.set_margin(5) self.setMinimumHeight(300) self.setMinimumWidth(500) self._player = ControlPlayer('Player') self._datasets = ControlEmptyWidget('Paths', default=DatasetsDialog()) self._backgrounds = ControlEmptyWidget('Backgrounds', default=ObjectsDialog()) self._show_diff = ControlCheckBox('Show diffs boxes') self._threshold = ControlSlider('Threshold', default=5, minimum=1, maximum=255) self._radius = ControlSlider('Radius', default=30, minimum=1, maximum=200) self._apply = ControlButton('Apply', checkable=True) self._compare = ControlCombo('Compare with') self._progress = ControlProgress('Progress') self._formset = [ '_datasets', '=', '_compare', '_backgrounds', ('_threshold', '_radius', '_show_diff'), '_player', '_apply', '_progress' ] self._compare.add_item('Last frame', 1) self._compare.add_item('First frame', 2) self._compare.add_item('Background image', 3) self.load_order = ['_threshold', '_radius', '_show_diff'] self._backgrounds.value.datasets_filter = lambda x: isinstance( x, Image) self._datasets.value.datasets_filter = lambda x: isinstance( x, (Contours, Path)) self._player.process_frame_event = self.__process_frame_event self._datasets.value.video_selection_changed_event = self.__video_selection_changed_event self._compare.changed_event = self.__compare_changed_event self._apply.value = self.__apply_btn_event self._apply.icon = conf.ANNOTATOR_ICON_MOTION self._progress.hide() self._backgrounds.hide()
def __init__(self): super(Example1, self).__init__('dir examples') self.parent = None self._directory = ControlDir('Choose a directory') self._file = ControlFile('Choose a file') self._filetree = ControlFilesTree('Choose a file') self._image = ControlImage('Image') self._boundaries = ControlBoundingSlider('Bounding', horizontal=True) self._button = ControlButton('Click') self._button.value = self.onButtonClick # self._directory.value=self.onButtonClick self._checkbox = ControlCheckBox('Choose a directory') self._checkboxList = ControlCheckBoxList('Choose a file') self._player = ControlPlayer('Choose a file') self._slider = ControlSlider('Slider') self._player.show() self._checkboxList.value = [('Item 1', True), ('Item 2', False), ('Item 3', True)] self._combobox = ControlCombo('Choose a item') self._list = ControlList('List label') self._progress = ControlProgress('Progress bar') self._visvisVolume = ControlVisVisVolume('Visvis') self._timeline = ControlEventTimeline('Timeline') self._combobox.add_item('Item 1', 'Value 1') self._combobox.add_item('Item 2', 'Value 2') self._combobox.add_item('Item 3', 'Value 3') self._combobox.add_item('Item 4') self._list.value = [('Item1', 'Item2', 'Item3',), ('Item3', 'Item4', 'Item5',)] imageWithVolume = np.zeros((100, 100, 100), np.uint8) imageWithVolume[30:40, 30:50, :] = 255 imageWithVolume[30:40, 70:72, :] = 255 self._visvisVolume.value = imageWithVolume self._visvis = ControlVisVis('Visvis') values1 = [(i, random.random(), random.random()) for i in range(130)] values2 = [(i, random.random(), random.random()) for i in range(130)] self._visvis.value = [values1, values2] self.formset = [ '_visvis' , '_directory' , '_button' , '_file' , '_boundaries' , '_filetree' , '_image' , '_slider' , ('_checkboxList', '_player') , ('_checkbox', ' ') , ('_combobox', ' ') , '_progress' , '=' , ('_visvisVolume', '||', '_list') , '_timeline' ]
def __init__(self, **kwargs): BaseWidget.__init__(self, 'Adaptative threshold') Class.__init__(self, **kwargs) try: self.layout().setContentsMargins(10, 5, 10, 5) self.setMinimumHeight(100) except: pass self._field_adaptive_threshold_method = ControlCombo('Method') self._field_adaptive_threshold_type = ControlCombo('Type') self._field_adaptive_threshold_block_size = ControlSlider( 'Block size', default=self._param_adaptivethreshold_block_size, minimum=3, maximum=2999) self._field_adaptive_threshold_c = ControlSlider( 'C', default=self._param_adaptivethreshold_c, minimum=0, maximum=500) self._formset = [('_field_adaptive_threshold_method', '_field_adaptive_threshold_type'), ('_field_adaptive_threshold_block_size', '_field_adaptive_threshold_c')] self._field_adaptive_threshold_method.add_item( 'ADAPTIVE_THRESH_MEAN_C', cv2.ADAPTIVE_THRESH_MEAN_C) self._field_adaptive_threshold_method.add_item( 'ADAPTIVE_THRESH_GAUSSIAN_C', cv2.ADAPTIVE_THRESH_GAUSSIAN_C) self._field_adaptive_threshold_type.add_item('THRESH_BINARY_INV', cv2.THRESH_BINARY_INV) self._field_adaptive_threshold_type.add_item('THRESH_BINARY', cv2.THRESH_BINARY) self._field_adaptive_threshold_method.value = self._param_adaptivethreshold_method self._field_adaptive_threshold_type.value = self._param_adaptivethreshold_type self._field_adaptive_threshold_method.changed_event = self.__adaptative_threshold_changed_evt self._field_adaptive_threshold_type.changed_event = self.__adaptative_threshold_changed_evt self._field_adaptive_threshold_block_size.changed_event = self.__adaptative_threshold_changed_evt self._field_adaptive_threshold_c.changed_event = self.__adaptative_threshold_changed_evt
def __init__(self, parent=None): super(SmoothPathsWindow, self).__init__('Smooth paths', parent_win=parent) self.mainwindow = parent self.set_margin(5) self.setMinimumHeight(400) self.setMinimumWidth(800) self._datasets_panel = ControlEmptyWidget('Paths') self._progress = ControlProgress('Progress') self._apply = ControlButton('Apply', checkable=True) self._winsize = ControlSlider('Window size', minimum=3, default=3, maximum=100) self._order = ControlSlider('Order', minimum=0, default=0, maximum=10) self._deriv = ControlSlider('Derivative', minimum=0, default=0, maximum=10) self._rate = ControlSlider('Rate', minimum=0, default=0, maximum=10) self._formset = [ '_datasets_panel', '=', '_winsize', '_order', '_deriv', '_rate', ' ', '_apply', '_progress' ] self.load_order = ['_datasets_panel'] self.datasets_dialog = DatasetsDialog(self) self._datasets_panel.value = self.datasets_dialog self.datasets_dialog.datasets_filter = lambda x: isinstance( x, (Path, Value)) self._apply.value = self.__apply_event self._apply.icon = conf.ANNOTATOR_ICON_PATH self._progress.hide()
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) TypeSingleChannelImage.__init__(self) self._video = ModuleConnection("Video", connecting=TypeBWVideoPipe) self._player = ControlPlayer("Video player") self._min = ControlSlider("Min", default=1, minimum=0, maximum=255) self._max = ControlSlider("Max", default=255, minimum=0, maximum=255) self._formset = [ '_video', "_player", '_min', '_max' ] self._player.processFrame = self.processFrame self._video.changed = self.newVideoInputChoosen self._min.changed = self._player.refresh self._max.changed = self._player.refresh
def __init__(self, parent=None): super(FindOrientationWindow, self).__init__('Estimate countour orientation', parent_win=parent) self.mainwindow = parent self.set_margin(5) self.setMinimumHeight(300) self.setMinimumWidth(300) self._panel = ControlEmptyWidget('Videos') self._progress = ControlProgress('Progress') self._apply = ControlButton('Apply', checkable=True) self._debug = ControlCheckBox('Create all the intermediate values') self._min_steps = ControlSlider('Minimum steps', default=20, minimum=1, maximum=1000) self._min_dist = ControlSlider('Minimum distance', default=30, minimum=1, maximum=1000) self._panel.value = self.contours_dialog = DatasetsDialog(self) self.contours_dialog.datasets_filter = lambda x: isinstance( x, Contours) self._formset = [ '_panel', ('_min_steps', '_min_dist'), '_debug', '_apply', '_progress' ] self._apply.value = self.__apply_event self._apply.icon = conf.ANNOTATOR_ICON_PATH self._progress.hide()
def __init__(self, **kwargs): BaseWidget.__init__(self, 'Biggests blobs') Class.__init__(self, **kwargs) try: self.layout().setContentsMargins(10, 5, 10, 5) self.setMinimumHeight(55) except: pass self._n_blobs = ControlSlider('Find n blobs', default=1, minimum=1, maximum=10) self._formset = ['_n_blobs'] self._n_blobs.changed_event = self.__n_blobs_changed_evt
def __init__(self): super().__init__('Student Info') self.set_margin(10) self.formset = [] leftside = [] leftside.append('Target GPA') self.slider = ControlSlider('', 2.5, 1.0, 4.0) leftside.append('slider') leftside.append('Current Enrollment: ') leftside.append(str(len(university.students))) leftside.append('Max Enrollment: ') leftside.append(str(university.capacity())) self.pbar = ControlProgress() self.pbar.min = 0 self.pbar.max = university.capacity() self.pbar.value = len(university.students) leftside.append('pbar') leftside.append('Average GPA: ') # need to add grad_rate leftside.append('2.3') leftside.append('Graduation Rate: ') leftside.append(str(university.grad_rate)) leftside.append('Average Morale: ') # need to add morale leftside.append('78%') # need to add morale to value self.morale_pbar = ControlProgress() self.morale_pbar.min = 0 self.morale_pbar.max = 100 self.morale_pbar.value = 78 leftside.append('morale_pbar') self.mylist = ControlList('Students') self.mylist.horizontal_headers = ['Name', 'GPA', 'Morale'] for student in university.students: self.mylist += (student.name, student.gpa, student.morale) self.formset.append((leftside, ' ', 'mylist'))
def __init__(self): BaseWidget.__init__(self, 'window') #Definition of the forms fields self._sld_blur = ControlSlider("Alpha", min=0) self._sld_blur.max = 100 self.colorize = ControlButton("Colorize By AI") self.classify = ControlButton("Image Detection") self.b_classify = ControlButton("Object Detection batch") #Define the controller action self.classify.value = self._detection_event self.colorize.value = self.__colorizeAction self._sld_blur.changed_event = self.appliedAlph_event self.b_classify.value = self._detections_event
def __init__(self, **kwargs): BaseWidget.__init__(self, 'Path mask') Class.__init__(self, **kwargs) try: self.layout().setContentsMargins(10, 5, 10, 5) self.setMinimumHeight(105) except: pass self._control_pathmask_radius = ControlSlider('Mask radius', default=30, minimum=1, maximum=600) self._control_pathmask_sel_paths_btn = ControlButton('Select paths to filter') self._formset = [ 'info:This filter will apply circular masks around paths. For each input video only its paths will be used.', ('_control_pathmask_sel_paths_btn', '_control_pathmask_radius') ] self._control_pathmask_radius.changed_event = self.__control_pathmask_radius_changed_event
def __init__(self, **kwargs): BaseWidget.__init__(self, 'MorphologyEx close') Class.__init__(self, **kwargs) self._use_morphologyexclose = ControlCheckBox('Use MorphologyEx Close') self._field_morphologyexclose_kernel_size = ControlSlider( 'Kernel size', default=self._param_morphologyexclose_kernel_size, minimum=3, maximum=51) try: self.layout().setContentsMargins(10, 5, 10, 5) self.setMinimumHeight(50) except: pass self._formset = [('_use_morphologyexclose', '_field_morphologyexclose_kernel_size')] self._field_morphologyexclose_kernel_size.changed_event = self.__update_param_morphologyex_kernel_size
def __init__(self): super(NourrissonStep3, self).__init__('Suivi nourrisson Step 3') #Definition of the forms fields self._gender = ControlCombo('Genre') self._gender.add_item("Fille", "f") self._gender.add_item("Garçon", "g") self._age = ControlSlider("Age (en mois)") self._age.min = 0 self._age.max = 60 self._weight = ControlNumber("Poids (en kg)") self._weight.min = 0 self._weight.max = 50 self._weight.decimals = 1 self._weight.step = 0.1 self._weight.value = 0.0 self._height = ControlNumber("Taille (en cm)") self._height.min = 0 self._height.max = 200 self._height.decimals = 1 self._height.step = 0.1 self._height.value = 0.0 self._skull = ControlNumber("Pérmiètre cranien (en cm)") self._skull.min = 0 self._skull.max = 100 self._skull.decimals = 1 self._skull.step = 0.1 self._skull.value = 0.0 #Define the button action self._button = ControlButton('Vérifier les constantes') self._button.value = self.__buttonAction BaseWidget.isFullScreen = False
def __init__(self, **kwargs): BaseWidget.__init__(self, 'Path mask') Class.__init__(self, **kwargs) try: self.layout().setContentsMargins(10, 5, 10, 5) self.setMinimumHeight(170) except: pass self._control_pathmask_radius = ControlSlider('Mask radius', default=30, minimum=1, maximum=600) self._panel = ControlEmptyWidget('Panel', default=DatasetsDialog() ) self._panel.value.interval_visible = False self._panel.value.datasets_filter = lambda x: isinstance(x, (Contours,Path) ) self._panel.value.datasets_changed_event = self.__update_paths self._formset = [ '_panel', '_control_pathmask_radius', ] self._control_pathmask_radius.changed_event = self.__control_pathmask_radius_changed_event
def __init__(self, parent=None): super(VideosExporterGui, self).__init__('Videos exporter', parent_win=parent) self.set_margin(5) self.setMinimumHeight(400) self.setMinimumWidth(400) self._toolbox = ControlToolBox('Tool') self._panel_area = ControlEmptyWidget('Set the object area', default=DatasetsDialog(self)) self._panel_colors = ControlEmptyWidget('Set the object color', default=DatasetsDialog(self)) self._panel_imgs = ControlEmptyWidget('Set the video background', default=ImagesDialog(self)) #### path panel ################################################ self._panel_path = ControlEmptyWidget('Set the object path', default=DatasetsDialog(self)) self._drawpath = ControlCheckBox('Draw paths') ################################################################ #### draw events ############################################### self._drawevents = ControlCheckBoxList('Events') self._eventstitles = ControlCheckBox('Draw titles') self._evtsreload1 = ControlButton('Reload events') ################################################################ #### split by events ########################################### self._splitevents = ControlCheckBoxList('Events') self._evtsreload2 = ControlButton('Reload events') ################################################################ self._codec = ControlCheckBox('Force AVI') self._outdir = ControlDir('Output directory') self._outfile = ControlText('Output file name') self._player = ControlPlayer('Player') self._progress = ControlProgress('Progress') self._apply = ControlButton('Export video(s)', checkable=True) self._apply.icon = conf.ANNOTATOR_ICON_PATH self._apply.enabled = False self._usefixedsize = ControlCheckBox('Use a fixed size') self._usefixedcolor = ControlCheckBox('Use a fixed color') self._radius = ControlSlider('Circle radius', default=10, minimum=1, maximum=300) self._color = ControlText('BGR color', default='255,255,255') self.formset = [('_toolbox', '||', '_player'), '=', '_outdir', ('_outfile', '_codec'), '_apply', '_progress'] self._toolbox.value = [ ('Path', [self._panel_path, self._drawpath]), ('Circle (optional)', [self._panel_area, (self._usefixedsize, self._radius)]), ('Circle color (optional)', [self._panel_colors, (self._usefixedcolor, self._color)]), ('Background (optional)', [self._panel_imgs]), ('Draw events (optional)', [self._evtsreload1, self._drawevents, self._eventstitles]), ('Split files by events (optional)', [self._evtsreload2, self._splitevents]), ] self._panel_path.value.datasets_filter = lambda x: isinstance( x, (Contours, Path)) #self._panel_area.value.datasets_filter = lambda x: isinstance(x, Value ) self._panel_colors.value.datasets_filter = lambda x: isinstance( x, (Contours, Path)) and hasattr(x, 'has_colors_avg' ) and x.has_colors_avg ### Set the controls events ############################################# self._evtsreload1.value = self.__reload_events self._evtsreload2.value = self.__reload_events self._outfile.changed_event = self.outputfile_changed_event self._usefixedsize.changed_event = self.__usefixedsize_changed_event self._usefixedcolor.changed_event = self.__usefixedcolor_changed_event self._splitevents.selection_changed_event = self.outputfile_changed_event self._panel_path.value.video_selection_changed_event = self.__video_selection_changed_event self._codec.changed_event = self.__video_selection_changed_event ## function from VideosExporterProcess class self._apply.value = self.apply_event ## function from VideosExporterPreview class self._player.process_frame_event = self.player_processframe_event self._evtsreload1.icon = conf.ANNOTATOR_ICON_REFRESH self._evtsreload2.icon = conf.ANNOTATOR_ICON_REFRESH self._progress.hide() self._radius.hide() self._color.hide() self.__check_areatab_event()
def __init__(self, title=''): self._points_values = None #used to map a color for each tracking point super(SceneApp, self).__init__(title) ##### CONTROLS ############################################################################## self._scene_file = ControlFile('Scene') self._scene_toggle_objs_list = ControlButton('Show/Hide objects', checkable=True) self._scene_objs_list = ControlCheckBoxList('Objects') self._scene_opengl = ControlOpenGL('OpengGL Scene') self._scene_points_alfa = ControlSlider('Transparency', 10, 0, 100) self._scene_bg_color = ControlCombo('Background color') self._scene_apply_colorBnds = ControlButton('Apply colors boundaries') self._scene_points_size = ControlCombo('Points size') self._scene_obj_color = ControlText('Object color') ############################################################################################# self._modules_tabs.update({ 'Heat map': [('_heatmapColor', ' | ', 'Filters:', '_toggleHeatmapVars', '_toggleSphereVisibility', '_sphere', ' | ', '_apply2Heatmap', ' '), ('_heatmapVarsList', '_heatmapVars', '_heatmapHigherVarsValues', '_heatMapMinVar', '_heatmapVarsBnds', '_heatMapMaxVar'), ({ '1:Map': ['_heatmap'], '0:Scene': [[('_scene_file', ' ', '_scene_toggle_objs_list', ' ', '_scene_bg_color', ' | ', '_scene_points_size', ' | ', '_scene_apply_colorBnds'), '_scene_points_alfa', '_scene_obj_color', '_scene_objs_list'], '=', '_scene_opengl'] }, '_heatmapColorsBnds')] }) ############################################################################################# self._scene_bg_color += ('White', '1,1,1,1.0') self._scene_bg_color += ('Gray', '0.3,0.3,0.3,1.0') self._scene_bg_color += ('Black', 'None') self._scene_points_size += '1' self._scene_points_size += '3' self._scene_points_size += '6' self._scene_points_size += '8' self._scene_objs_list.hide() self._scene_obj_color.hide() self._scene_objs_list.changed = self.__changed_objects_list_event self._scene_toggle_objs_list.value = self.__toggle_objects_list_event self._scene_points_alfa.changed = self.__changed_scene_points_alfa_event self._scene_bg_color.changed = self.__changed_background_color_event self._scene_apply_colorBnds.value = self.__scene_apply_color_bnds_event self._scene_points_size.changed = self.__changed_scene_points_size_event self._scene_objs_list.selectionChanged = self.__selectionchanged_object_list_event self._scene_obj_color.changed = self.__changed_object_color_event self._scene = None self._scene_file.changed = self.__scene_file_selected self._scene_opengl.clear_color = 1, 1, 1, 1
def __init__(self): super(KaryML_Main, self).__init__(self.APP_NAME) self._app_title = ControlLabel(self.APP_NAME) self._input_image_path = ControlFile('Input image') self._pairs_path = ControlFile('Expected karyotype (optional)') self._features_label = ControlLabel("Chose features to be extracted") self._f1_check_box = ControlCheckBox(label=self.LENGTH_FEATURE, default=True) self._f1_check_box.changed_event = self._f1_check_box_changed self._f2_check_box = ControlCheckBox(label=self.CENTROMERIC_INDEX_FEATURE, default=True) self._f2_check_box.changed_event = self._f2_check_box_changed self._f3_check_box = ControlCheckBox(label=self.BANDING_PATTERN_FEATURE, default=True) self._f3_check_box.changed_event = self._f3_check_box_changed self._f4_check_box = ControlCheckBox(label=self.AREA_FEATURE, default=True) self._f4_check_box.changed_event = self._f4_check_box_changed self._eu_dist = ControlButton(EUCLIDEAN_DISTANCE) self._we_eu_dist = ControlButton(WEIGHTED_EUCLIDEAN_DISTANCE) self._man_dist = ControlButton(MANHATTAN_DISTANCE) self._dist_label = ControlLabel(label="Distance to use: " + EUCLIDEAN_DISTANCE.upper(), default="Distance to use: " + EUCLIDEAN_DISTANCE) self._f1_w = ControlSlider(label="Chromosome length", default=25, minimum=0, maximum=100, visible=False) self._f2_w = ControlSlider(label=" Centromeric Index", default=25, minimum=0, maximum=100, visible=False) self._f3_w = ControlSlider(label=" Banding pattern", default=25, minimum=0, maximum=100, visible=False) self._f4_w = ControlSlider(label="Chromosome area", default=25, minimum=0, maximum=100, visible=False) self._epochs_no = ControlSlider(label=" Epochs Nr.", default=200000, minimum=50000, maximum=400000) self._rows = ControlSlider(label=" Map rows", default=50, minimum=10, maximum=100) self._cols = ControlSlider(label="Map columns", default=50, minimum=10, maximum=100) self.errors_label_text = ControlLabel(label="Errors:", default="Errors:", visible=True) self.errors_label = ControlLabel(label="Errors", default="", visible=False) self.info_label_text = ControlLabel(label="Info:", default="Info:", visible=True) self.info_label = ControlLabel(label="Info", default="", visible=False) self._button = ControlButton('Start {}'.format(self.APP_NAME)) self._button.value = self._runKarySomAction self._eu_dist.value = self.__dist_changed_eu self._we_eu_dist.value = self.__dist_changed_we_eu self._man_dist.value = self.__dist_changed_man self.t = None
class KaryML_Main(BaseWidget): LENGTH_FEATURE = "Chromosome length" AREA_FEATURE = "Chromosome area" CENTROMERIC_INDEX_FEATURE = "Centromeric Index" BANDING_PATTERN_FEATURE = "Banding pattern" FEATURES = [ LENGTH_FEATURE, CENTROMERIC_INDEX_FEATURE, BANDING_PATTERN_FEATURE ] APP_NAME = 'KaryML Framework' def __init__(self): super(KaryML_Main, self).__init__(self.APP_NAME) self._app_title = ControlLabel(self.APP_NAME) self._input_image_path = ControlFile('Input image') self._pairs_path = ControlFile('Expected karyotype (optional)') self._features_label = ControlLabel("Chose features to be extracted") self._f1_check_box = ControlCheckBox(label=self.LENGTH_FEATURE, default=True) self._f1_check_box.changed_event = self._f1_check_box_changed self._f2_check_box = ControlCheckBox(label=self.CENTROMERIC_INDEX_FEATURE, default=True) self._f2_check_box.changed_event = self._f2_check_box_changed self._f3_check_box = ControlCheckBox(label=self.BANDING_PATTERN_FEATURE, default=True) self._f3_check_box.changed_event = self._f3_check_box_changed self._f4_check_box = ControlCheckBox(label=self.AREA_FEATURE, default=True) self._f4_check_box.changed_event = self._f4_check_box_changed self._eu_dist = ControlButton(EUCLIDEAN_DISTANCE) self._we_eu_dist = ControlButton(WEIGHTED_EUCLIDEAN_DISTANCE) self._man_dist = ControlButton(MANHATTAN_DISTANCE) self._dist_label = ControlLabel(label="Distance to use: " + EUCLIDEAN_DISTANCE.upper(), default="Distance to use: " + EUCLIDEAN_DISTANCE) self._f1_w = ControlSlider(label="Chromosome length", default=25, minimum=0, maximum=100, visible=False) self._f2_w = ControlSlider(label=" Centromeric Index", default=25, minimum=0, maximum=100, visible=False) self._f3_w = ControlSlider(label=" Banding pattern", default=25, minimum=0, maximum=100, visible=False) self._f4_w = ControlSlider(label="Chromosome area", default=25, minimum=0, maximum=100, visible=False) self._epochs_no = ControlSlider(label=" Epochs Nr.", default=200000, minimum=50000, maximum=400000) self._rows = ControlSlider(label=" Map rows", default=50, minimum=10, maximum=100) self._cols = ControlSlider(label="Map columns", default=50, minimum=10, maximum=100) self.errors_label_text = ControlLabel(label="Errors:", default="Errors:", visible=True) self.errors_label = ControlLabel(label="Errors", default="", visible=False) self.info_label_text = ControlLabel(label="Info:", default="Info:", visible=True) self.info_label = ControlLabel(label="Info", default="", visible=False) self._button = ControlButton('Start {}'.format(self.APP_NAME)) self._button.value = self._runKarySomAction self._eu_dist.value = self.__dist_changed_eu self._we_eu_dist.value = self.__dist_changed_we_eu self._man_dist.value = self.__dist_changed_man self.t = None @staticmethod def set_message(label, message): label.value = message label.show() def get_number_of_selected_features(self): return len([2 ** j for j in range(4) if [self._f1_check_box, self._f2_check_box, self._f3_check_box, self._f4_check_box][j].value]) def _runKarySomAction(self): """Button action event""" dist_lbl = self.manage_pre_run_gui() self.errors_label.hide() if self.get_number_of_selected_features() < 1: self.set_message(self.errors_label, "At least one feature is required") return cfg = self.__initialize_cfg(dist_lbl) if dist_lbl == WEIGHTED_EUCLIDEAN_DISTANCE and self.get_sum_of_weights() != 100: self.set_message(self.errors_label, "Sum of weights must be 100") return if not os.path.exists(self._input_image_path.value): self.set_message(self.errors_label, "Image path {} doesn't exists".format(self._input_image_path.value)) return print("Start processing using cfg:") pprint.pprint(cfg) self.t = Thread(target=start_process_for_one_image, args=[cfg["input"], cfg["mdist"], "", sum(cfg["features"]), cfg["epochs"], cfg["rows"], cfg["cols"], cfg["weights"], self]) self.t.start() msg = "" if not os.path.isfile(self._pairs_path.value): msg += "Expected karyotype missing or file not exists. PrecKar value won't be calculated." else: msg += "Karyotype file found. Will compute PrecKar value" dir_path = '.'.join(self._input_image_path.value.split('.')[:-1]) if not os.path.isdir(dir_path): os.makedirs(dir_path) shutil.copy2(self._pairs_path.value, os.path.join(dir_path, "pairs.txt")) self.set_message(self.info_label, msg + "\n" + "Start KarySOM for current configuration. Processing...") def manage_pre_run_gui(self): if self.info_label.visible is True: self.info_label.hide() if self._dist_label.value.split()[len(self._dist_label.value.split()) - 2] == "Weighted": dist_lbl = " ".join(self._dist_label.value.split()[len(self._dist_label.value.split()) - 2:]) else: dist_lbl = self._dist_label.value.split()[len(self._dist_label.value.split()) - 1] return dist_lbl def __initialize_cfg(self, dist_lbl): cfg = {"distance": dist_lbl, "feature_names": [self.FEATURES[i] for i in [j for j in range(3) if [self._f1_check_box.value, self._f2_check_box.value, self._f3_check_box.value, self._f4_check_box.value][j]]], "features": [2 ** j for j in range(4) if [self._f1_check_box, self._f2_check_box, self._f3_check_box, self._f4_check_box][j].value], "epochs": self._epochs_no.value, "input": self._input_image_path.value, "pairs": self._pairs_path.value, "rows": self._rows.value, "cols": self._cols.value, "weights": dict()} if self._f1_check_box.value: cfg["weights"][1] = self._f1_w.value / 100 if self._f2_check_box.value: cfg["weights"][2] = self._f2_w.value / 100 if self._f3_check_box.value: cfg["weights"][3] = self._f3_w.value / 100 if self._f4_check_box.value: cfg["weights"][4] = self._f4_w.value / 100 cfg["mdist"] = False if dist_lbl == MANHATTAN_DISTANCE: cfg["mdist"] = True return cfg def __dist_changed_eu(self): self._dist_label.value = "Distance to use: " + EUCLIDEAN_DISTANCE self._dist_label.label = "Distance to use: " + EUCLIDEAN_DISTANCE.upper() self._f1_w.hide() self._f2_w.hide() self._f3_w.hide() self._f4_w.hide() self.info_label.hide() def __dist_changed_we_eu(self): self._dist_label.value = "Distance to use: " + WEIGHTED_EUCLIDEAN_DISTANCE self._dist_label.label = "Distance to use: " + WEIGHTED_EUCLIDEAN_DISTANCE.upper() if self._f1_check_box.value: self._f1_w.show() if self._f2_check_box.value: self._f2_w.show() if self._f3_check_box.value: self._f3_w.show() if self._f4_check_box.value: self._f4_w.show() self.info_label.hide() def __dist_changed_man(self): self._dist_label.value = "Distance to use: " + MANHATTAN_DISTANCE self._dist_label.label = "Distance to use: " + MANHATTAN_DISTANCE.upper() self._f1_w.hide() self._f2_w.hide() self._f3_w.hide() self._f4_w.hide() self.info_label.hide() def get_sum_of_weights(self): weights_sum = 0 if self._f1_check_box.value: weights_sum += self._f1_w.value if self._f2_check_box.value: weights_sum += self._f2_w.value if self._f3_check_box.value: weights_sum += self._f3_w.value if self._f4_check_box.value: weights_sum += self._f4_w.value return weights_sum def _f1_check_box_changed(self): if self._f1_check_box.value and "weighted" in self._dist_label.value.lower(): self._f1_w.show() else: self._f1_w.hide() def _f2_check_box_changed(self): if self._f2_check_box.value and "weighted" in self._dist_label.value.lower(): self._f2_w.show() else: self._f2_w.hide() def _f3_check_box_changed(self): if self._f3_check_box.value and "weighted" in self._dist_label.value.lower(): self._f3_w.show() else: self._f3_w.hide() def _f4_check_box_changed(self): if self._f4_check_box.value and "weighted" in self._dist_label.value.lower(): self._f4_w.show() else: self._f4_w.hide()
def __init__(self): super(MultipleBlobDetection, self).__init__('Multiple Blob Detection') # Definition of the forms fields self._videofile = ControlFile('Video') self._outputfile = ControlText('Results output file') self._threshold_box = ControlCheckBox('Threshold') self._threshold = ControlSlider('Binary Threshold') self._threshold.value = 114 self._threshold.min = 1 self._threshold.max = 255 self._roi_x_min = ControlSlider('ROI x top') self._roi_x_max = ControlSlider('ROI x bottom') self._roi_y_min = ControlSlider('ROI y left') self._roi_y_max = ControlSlider('ROI y right') # self._blobsize = ControlSlider('Minimum blob size', 100, 100, 2000) self._player = ControlPlayer('Player') self._runbutton = ControlButton('Run') self._start_frame = ControlText('Start Frame') self._stop_frame = ControlText('Stop Frame') self._color_list = ControlCombo('Color channels') self._color_list.add_item('Red Image Channel', 2) self._color_list.add_item('Green Image Channel', 1) self._color_list.add_item('Blue Image Channel', 0) self._clahe = ControlCheckBox('CLAHE ') self._dilate = ControlCheckBox('Morphological Dilation') self._dilate_type = ControlCombo('Dilation Kernel Type') self._dilate_type.add_item('RECTANGLE', cv2.MORPH_RECT) self._dilate_type.add_item('ELLIPSE', cv2.MORPH_ELLIPSE) self._dilate_type.add_item('CROSS', cv2.MORPH_CROSS) self._dilate_size = ControlSlider('Dilation Kernel Size', default=3, min=1, max=10) self._dilate_size.value = 5 self._dilate_size.min = 1 self._dilate_size.max = 10 self._erode = ControlCheckBox('Morphological Erosion') self._erode_type = ControlCombo('Erode Kernel Type') self._erode_type.add_item('RECTANGLE', cv2.MORPH_RECT) self._erode_type.add_item('ELLIPSE', cv2.MORPH_ELLIPSE) self._erode_type.add_item('CROSS', cv2.MORPH_CROSS) self._erode_size = ControlSlider('Erode Kernel Size') self._erode_size.value = 5 self._erode_size.min = 1 self._erode_size.max = 10 self._open = ControlCheckBox('Morphological Opening') self._open_type = ControlCombo('Open Kernel Type') self._open_type.add_item('RECTANGLE', cv2.MORPH_RECT) self._open_type.add_item('ELLIPSE', cv2.MORPH_ELLIPSE) self._open_type.add_item('CROSS', cv2.MORPH_CROSS) self._open_size = ControlSlider('Open Kernel Size') self._open_size.value = 20 self._open_size.min = 1 self._open_size.max = 40 self._close = ControlCheckBox('Morphological Closing') self._close_type = ControlCombo('Close Kernel Type') self._close_type.add_item('RECTANGLE', cv2.MORPH_RECT) self._close_type.add_item('ELLIPSE', cv2.MORPH_ELLIPSE) self._close_type.add_item('CROSS', cv2.MORPH_CROSS) self._close_size = ControlSlider('Close Kernel Size', default=19, min=1, max=40) self._close_size.value = 20 self._close_size.min = 1 self._close_size.max = 40 self._LoG = ControlCheckBox('LoG - Laplacian of Gaussian') self._LoG_size = ControlSlider('LoG Kernel Size') self._LoG_size.value = 20 self._LoG_size.min = 1 self._LoG_size.max = 60 self._progress_bar = ControlProgress('Progress Bar') # Define the function that will be called when a file is selected self._videofile.changed_event = self.__video_file_selection_event # Define the event that will be called when the run button is processed self._runbutton.value = self.__run_event # Define the event called before showing the image in the player self._player.process_frame_event = self.__process_frame self._error_massages = {} # Define the organization of the Form Controls self.formset = [ ('_videofile', '_outputfile'), ('_start_frame', '_stop_frame'), ('_color_list', '_clahe', '_roi_x_min', '_roi_y_min'), ('_threshold_box', '_threshold', '_roi_x_max', '_roi_y_max'), ('_dilate', '_erode', '_open', '_close'), ('_dilate_type', '_erode_type', '_open_type', '_close_type'), ('_dilate_size', '_erode_size', '_open_size', '_close_size'), ('_LoG', '_LoG_size'), ('_runbutton', '_progress_bar'), '_player' ] self.is_roi_set = False
def __init__(self, parent=None): super(ContoursImagesWindow, self).__init__('Contour images', parent_win=parent) self.mainwindow = parent self.set_margin(5) self.setMinimumHeight(400) self.setMinimumWidth(800) self._contourspanel = ControlEmptyWidget('Contours datasets') self._progress = ControlProgress('Progress', visible=False) self._apply = ControlButton('Apply', checkable=True) self._toolbox = ControlToolBox('Toolbox') self._exportdir = ControlDir('Export images to folder', default='images-from-contour') #### mask ###################################################### self._usemaskimg = ControlCheckBox('Apply a mask to the image') self._usemaskdilate = ControlCheckBox('Dilate the mask and apply it to the image') self._maskdilatesize = ControlSlider('Dilate size', default=0, minimum=0, maximum=100) self._usemaskellipse = ControlCheckBox('Apply the min. ellipse as a mask to the image') self._usemaskcircular = ControlCheckBox('Apply a circular mask to the image') self._maskcircularsize = ControlSlider('Circular radius', default=0, minimum=0, maximum=100) self._usemaskrect = ControlCheckBox('Apply the min. rect as a mask to the image') ################################################################ #### margin #################################################### self._margin = ControlSlider('Margin size', default=0, minimum=0, maximum=100) ################################################################ #### imagesize ################################################# self._imagesize = ControlSlider('Image size', default=0, minimum=0, maximum=400) ################################################################ #### cut ####################################################### self._usecut = ControlCheckBox('Cut image') self._cutx = ControlBoundingSlider('X cut', default=(10,30), minimum=0, maximum=1000) self._cuty = ControlBoundingSlider('Y cut', default=(10,30), minimum=0, maximum=1000) ################################################################ #### use stretch ############################################### self._usestretch = ControlCheckBox('Stretch image') ################################################################ #### filter per events ######################################### self._eventslst = ControlCheckBoxList('Events', enabled=True) self._reloadevts = ControlButton('Reload events', enabled=True, default=self.__reload_events_btn_evt) ################################################################ #### rotation ################################################## self._userotup = ControlCheckBox('Turn the contour always up') self._userotdown = ControlCheckBox('Turn the contour always down') self._usefixedangle = ControlCheckBox('Use a fixed orientation') self._fixedangle = ControlSlider('Rotate the images using a fixed angle', enabled=True, default=0, minimum=0, maximum=360) self._usedatasetangle = ControlCheckBox('Use the orientation of other contour') self._datasetanglepanel = ControlEmptyWidget('Datasets for the orientation', enabled=True) ################################################################ #### image position ############################################ self._useposdataset = ControlCheckBox('Use a dataset to center the image') self._datasetpospanel = ControlEmptyWidget('Datasets for the image position', enabled=True) ################################################################ self.formset = [ '_toolbox', '_exportdir', '_apply', '_progress' ] self.load_order = [ '_contourspanel','_userotup', '_userotdown', '_exportdir','_usemaskimg','_usemaskdilate','_usemaskellipse','_usemaskellipse', '_usemaskcircular', '_maskcircularsize', '_usemaskrect', '_margin', '_imagesize', '_usestretch', '_eventslst', '_usefixedangle', '_fixedangle', '_usedatasetangle', '_datasetanglepanel', '_useposdataset', '_datasetpospanel', '_usecut', '_cuty', '_cutx' ] #datasets painel self.datasets_dialog = DatasetsDialog(self) self.datasets_dialog.datasets_filter = lambda x: isinstance(x, Contours ) self._contourspanel.value = self.datasets_dialog self.posdatasets_dialog = DatasetsDialog(self) self.posdatasets_dialog.datasets_filter = lambda x: isinstance(x, (Contours,Path) ) self._datasetpospanel.value = self.posdatasets_dialog self.orientdatasets_dialog = DatasetsDialog(self) self.orientdatasets_dialog.datasets_filter = lambda x: isinstance(x, Contours ) self.orientdatasets_dialog.interval_visible = False self._datasetanglepanel.value = self.orientdatasets_dialog self._apply.value = self.__apply_event self._apply.icon = conf.ANNOTATOR_ICON_PATH self._imagesize.changed_event = self.__image_size_changed_evt self._toolbox.value = [ ('Extract from contours',( self.datasets_dialog, )), ('Mask',( self._usemaskimg, (self._usemaskdilate,self._maskdilatesize), (self._usemaskcircular,self._maskcircularsize), (self._usemaskellipse,self._usemaskrect), )), ('Margin, image size and stretch image',( self._usestretch, self._margin, self._imagesize, self._usecut, self._cutx, self._cuty )), ('Rotate images',( (self._userotup, self._userotdown), (self._usefixedangle, self._fixedangle), self._usedatasetangle, self._datasetanglepanel )), ('Center images',( self._useposdataset, self._datasetpospanel, )), ('Export images per events',( self._reloadevts, self._eventslst, )), ] self.__reload_events_btn_evt() self.__image_size_changed_evt()
def __init__(self, timelineWidget=None, parent_win=None): super(GraphsProperties, self).__init__('Graphs properties', parent_win=parent_win) self.setContentsMargins(10, 10, 10, 10) self._mainwindow = parent_win self._timeline = timelineWidget #self.setMaximumWidth(300) # Definition of the forms fields self._graphs_list = ControlList('Graphs list') self._name = ControlText('Name') self._min_value = ControlNumber('Min', default=0, minimum=-sys.float_info.max, maximum=sys.float_info.max) self._max_value = ControlNumber('Max', default=0, minimum=-sys.float_info.max, maximum=sys.float_info.max) self._values_zoom = ControlSlider('Amplitude', default=100, minimum=60, maximum=400) self._values_top = ControlNumber('Bottom', default=0, minimum=-1000, maximum=1000) self._remove_graph_btn = ControlButton('Remove graph') self._value = ControlLabel() self._pickcolor = ControlButton('Pick color', default=self.__pickcolor_evt) self._graphs_list.readonly = True self._formset = [ (['_graphs_list', '_remove_graph_btn'], '||', [ ' ', '_name', ('_min_value', '_max_value', ' '), ('_values_top', '_pickcolor'), '_values_zoom', 'info:Choose one graph and move the mouse over \nthe timeline to visualize the coordenates.', '_value' ]), ] self._graphs_list.select_entire_row = True self._graphs_list.item_selection_changed_event = self.__graphs_list_selection_changed self._loaded = False self._current_selected_graph = None self._name.changed_event = self.__save_graphs_changes self._min_value.changed_event = self.__save_graphs_changes self._max_value.changed_event = self.__save_graphs_changes self._values_zoom.changed_event = self.__save_graphs_changes self._values_top.changed_event = self.__save_graphs_changes self._name.enabled = False self._min_value.enabled = False self._max_value.enabled = False self._values_zoom.enabled = False self._values_top.enabled = False self._remove_graph_btn.enabled = False self._pickcolor.enabled = False self._remove_graph_btn.value = self.__remove_chart
class VideosExporterGui(BaseWidget, VideosExporterPreview, VideosExporterProcess): def __init__(self, parent=None): super(VideosExporterGui, self).__init__('Videos exporter', parent_win=parent) self.set_margin(5) self.setMinimumHeight(400) self.setMinimumWidth(400) self._toolbox = ControlToolBox('Tool') self._panel_area = ControlEmptyWidget('Set the object area', default=DatasetsDialog(self)) self._panel_colors = ControlEmptyWidget('Set the object color', default=DatasetsDialog(self)) self._panel_imgs = ControlEmptyWidget('Set the video background', default=ImagesDialog(self)) #### path panel ################################################ self._panel_path = ControlEmptyWidget('Set the object path', default=DatasetsDialog(self)) self._drawpath = ControlCheckBox('Draw paths') ################################################################ #### draw events ############################################### self._drawevents = ControlCheckBoxList('Events') self._eventstitles = ControlCheckBox('Draw titles') self._evtsreload1 = ControlButton('Reload events') ################################################################ #### split by events ########################################### self._splitevents = ControlCheckBoxList('Events') self._evtsreload2 = ControlButton('Reload events') ################################################################ self._codec = ControlCheckBox('Force AVI') self._outdir = ControlDir('Output directory') self._outfile = ControlText('Output file name') self._player = ControlPlayer('Player') self._progress = ControlProgress('Progress') self._apply = ControlButton('Export video(s)', checkable=True) self._apply.icon = conf.ANNOTATOR_ICON_PATH self._apply.enabled = False self._usefixedsize = ControlCheckBox('Use a fixed size') self._usefixedcolor = ControlCheckBox('Use a fixed color') self._radius = ControlSlider('Circle radius', default=10, minimum=1, maximum=300) self._color = ControlText('BGR color', default='255,255,255') self.formset = [('_toolbox', '||', '_player'), '=', '_outdir', ('_outfile', '_codec'), '_apply', '_progress'] self._toolbox.value = [ ('Path', [self._panel_path, self._drawpath]), ('Circle (optional)', [self._panel_area, (self._usefixedsize, self._radius)]), ('Circle color (optional)', [self._panel_colors, (self._usefixedcolor, self._color)]), ('Background (optional)', [self._panel_imgs]), ('Draw events (optional)', [self._evtsreload1, self._drawevents, self._eventstitles]), ('Split files by events (optional)', [self._evtsreload2, self._splitevents]), ] self._panel_path.value.datasets_filter = lambda x: isinstance( x, (Contours, Path)) #self._panel_area.value.datasets_filter = lambda x: isinstance(x, Value ) self._panel_colors.value.datasets_filter = lambda x: isinstance( x, (Contours, Path)) and hasattr(x, 'has_colors_avg' ) and x.has_colors_avg ### Set the controls events ############################################# self._evtsreload1.value = self.__reload_events self._evtsreload2.value = self.__reload_events self._outfile.changed_event = self.outputfile_changed_event self._usefixedsize.changed_event = self.__usefixedsize_changed_event self._usefixedcolor.changed_event = self.__usefixedcolor_changed_event self._splitevents.selection_changed_event = self.outputfile_changed_event self._panel_path.value.video_selection_changed_event = self.__video_selection_changed_event self._codec.changed_event = self.__video_selection_changed_event ## function from VideosExporterProcess class self._apply.value = self.apply_event ## function from VideosExporterPreview class self._player.process_frame_event = self.player_processframe_event self._evtsreload1.icon = conf.ANNOTATOR_ICON_REFRESH self._evtsreload2.icon = conf.ANNOTATOR_ICON_REFRESH self._progress.hide() self._radius.hide() self._color.hide() self.__check_areatab_event() ########################################################################### ### UTILS ################################################################# ########################################################################### def __reload_events(self): """ Find all the events available on the timeline """ timeline = self.parent().timeline rows = timeline.rows events = {} for row in rows: for event in row.events: events[event.title] = True events = sorted(events.keys()) loaded_events = dict(self._drawevents.items) self._drawevents.value = [(e, loaded_events.get(e, False)) for e in events] loaded_events = dict(self._splitevents.items) self._splitevents.value = [(e, loaded_events.get(e, False)) for e in events] ########################################################################### ### EVENTS ################################################################ ########################################################################### def show(self): """ Load the events when the window is oppened """ super(VideosExporterGui, self).show() self.__reload_events() def __check_areatab_event(self): """ Activate or deactivate the color tab """ if len(list(self._panel_area.value.datasets) ) > 0 or self._usefixedsize.value: self._toolbox.set_item_enabled(2, True) else: self._toolbox.set_item_enabled(2, False) def __usefixedcolor_changed_event(self): if self._usefixedcolor.value: self._color.show() self._panel_colors.hide() else: self._color.hide() self._panel_colors.show() def __usefixedsize_changed_event(self): self.__check_areatab_event() if self._usefixedsize.value: self._radius.show() self._panel_area.hide() else: self._radius.hide() self._panel_area.show() def outputfile_changed_event(self): """ Update the output filename """ filename = self._outfile.value video = self._panel_path.value.selected_video if video is not None: filename = filename if len(filename) > 0 else video.filename videofilepath, video_extension = os.path.splitext(video.filename) outfilepath, outfile_extension = os.path.splitext(filename) names = [outfilepath] if len(outfilepath) > 0 else [] if '{videoindex}' not in outfilepath: names.append('{videoindex}') if len(list(self._splitevents.value)) > 0: if '{event}' not in outfilepath: names.append('{event}') if '{start}' not in outfilepath: names.append('{start}') if '{end}' not in outfilepath: names.append('{end}') self._outfile.value = ('-'.join(names) + video_extension) self._apply.enabled = True else: self._apply.enabled = False def __video_selection_changed_event(self): """ Activate the video preview """ video = self._panel_path.value.selected_video if video is not None: self._player.value = video.video_capture def get_object_area(self, path, areas, index): try: if self._usefixedsize.value: area = (self._radius.value**2 * math.pi) elif len(areas) > 0: a = areas[0] if isinstance(a, Value): area = a.get_value(index) else: area = a.get_area_value(index) else: area = path.get_area_value(index) return area except: return None def get_object_color(self, path, colors, index): try: if self._usefixedcolor.value: color = tuple(eval(self._color.value)) elif len(colors) > 0: color = colors[0].get_color_avg(index) else: color = path.get_color_avg(index) if color is None: raise Exception() except: color = 255, 255, 255 return color