def newVideoInputChoosen(self, value): OTParamVideoInput.valueUpdated(self._video,value) if value: self._player.value = value self.videoInput = value if isinstance(value, OTModuleMaskFromGeometry): self._param_mi_polygons = value._all_polygons self._param_mi_mask = None
def newVideoInputChoosen(self, value): """ Event called when a user select rows using the popup menu @param value: Video module @type value: OTModule """ OTParamVideoInput.valueUpdated(self._video, value) if value.videoInput: value.videoInput.setFrame(0) self._player.value = value.videoInput
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video1 = OTParamVideoInput("Video 1") self._video2 = OTParamVideoInput("Video 2") self._player = OTParamPlayer("Video player") self._formset = [('_video1', '_video2'), "_player"] self._player.processFrame = self.processFrame self._video1.valueUpdated = self.newVideoInputChoosen
def newVideoInputChoosen(self, value): """ Event called when a user select rows using the popup menu @param value: Video module @type value: OTModule """ OTParamVideoInput.valueUpdated(self._video,value) if value.videoInput: value.videoInput.setFrame(0) self._player.value = value.videoInput self._imgWidth = float(value.videoInput.width) self._imgHeight = float(value.videoInput.height) self._trackRange.max = value.videoInput.endFrame-value.videoInput.startFrame
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModuleInputVideoPipe.__init__(self) OTPAdaptativeThresholdFilter.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") #THRESHOLD self._blockSize = OTParamSlider("Block size", 3, 3, 1000,varname='_param_tb_block_size') self._C = OTParamSlider("C", 255, 0, 510,varname='_param_tb_c') self._adaptiveMethod = OTParamCombo("Adaptive method",varname='_param_tb_adaptive_method') self._adaptiveMethod.addItem("Mean", cv2.cv.CV_ADAPTIVE_THRESH_MEAN_C) self._adaptiveMethod.addItem("Gaussian", cv2.cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C) self._th_thresholdType = OTParamCombo("ThresholdType",varname='_param_tb_threshold_type') self._th_thresholdType.addItem("THRESH_BINARY", cv2.THRESH_BINARY) self._th_thresholdType.addItem("THRESH_BINARY_INV", cv2.THRESH_BINARY_INV) #END THRESHOLD self._adaptiveMethod.valueUpdated = self.refreshValue self._blockSize.valueUpdated = self.refreshValue self._C.valueUpdated = self.refreshValue self._formset = [ '_video',"_player", ('_adaptiveMethod','_th_thresholdType'), ('_blockSize',"_C"), ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTPConvertColor.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") self._colorDomain = OTParamCombo("Colors space", varname='_param_color_domain') self._colorDomain.addItem("RGB", -1) self._colorDomain.addItem("GRAY", cv2.COLOR_BGR2GRAY) self._colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._colorDomain.valueUpdated = self.refreshValue self._formset = [ '_video', '_colorDomain', "_player", ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconbgcalc.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._jumpFrame = OTParamSlider("Frame jump step", 1000, 1, 4000) self._jump2Frame = OTParamSlider("Compare frame", 1500, 1, 4000) self._threshold = OTParamSlider("Threshold", 5, 0, 255) self._export = OTParamButton("Export") self._editMode = OTParamCheckBox("Edit mode", False) self._run = OTParamButton("Run") self._player = OTParamPlayer("Video player") self._progress = OTParamProgress() self._formset = [('_video', '_run', '_editMode', '_export'), ('_jumpFrame', '_jump2Frame', '_threshold'), "_player", "_progress"] self._run.value = self.run self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen self._export.value = self.export_clicked self._backgroundDetector = None self._progress.hide()
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'icon.jpg') OTModuleResultsPlugin.__init__(self, name, iconFile=icon_path) self._positions = OTParamPositions("Positions") self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") self._nobjects = OTParamSlider("Number of objects to track", 1, 1, 10) self._run = OTParamButton("Run") self._apply = OTParamButton("Apply changes") self._progress = OTParamProgress() #self._query.readOnly = True self._run.value = self.run self._apply.value = self.apply self._video.valueUpdated = self.newVideoInputChoosen self._player.processFrame = self.processFrame self._query.form.tableView.keyPressEvent = self.keyPressEvent self._current_row = None self._formset = [('_video', "_positions", '_nobjects', '_run'), '_player', '=', ("_results", '_apply'), "_query", "_progress"] self._progress.hide()
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'icongeo.png') OTBaseModuleGeometry.__init__(self,name, iconFile = icon_path) self._imgWidth = 0.0 self._imgHeight = 0.0 self._startPoint = None self._endPoint = None self._selectedPoly = None self._selectedPoint = None self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video") self._remove = OTParamButton("Remove") self._square = OTParamToggle("Square") self._circle = OTParamToggle("Circle") self._export = OTParamButton("Export") self._import = OTParamButton("Import") self._formset = [ '_video',"_player", ("_square", "_circle", " ","_remove"," ", "_export", "_import"), "=", "_polygons" ] self._video.valueUpdated = self.videoSelected self._square.value = self.square_toggle self._circle.value = self.circle_toggle self._remove.value = self.remove_clicked self._export.value = self.export_clicked self._import.value = self.import_clicked self._player._videoWidget.onDrag = self.onDragInVideoWindow self._player._videoWidget.onEndDrag = self.onEndDragInVideoWindow self._player._videoWidget.onClick = self.onClickInVideoWindow self._player._videoWidget.onDoubleClick = self.onDoubleClickInVideoWindow self._player.processFrame = self.processFrame
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModuleInputVideoPipe.__init__(self) OTPAdaptativeThreshold.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") #THRESHOLD self._blockSize = OTParamSlider("Block size", 3, 3, 500,varname='_param_tb_block_size') self._C = OTParamSlider("C", 0, 0, 500,varname='_param_tb_c') self._adaptiveMethod = OTParamCombo("Adaptive method",varname='_param_tb_adaptive_method') self._adaptiveMethod.addItem("Mean", cv2.cv.CV_ADAPTIVE_THRESH_MEAN_C) self._adaptiveMethod.addItem("Gaussian", cv2.cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C) self._th_colorDomain = OTParamCombo("Colors space",varname='_param_tb_color_domain') self._th_colorDomain.addItem("RGB", -1) self._th_colorDomain.addItem("Gray", cv2.COLOR_BGR2GRAY) self._th_colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._th_colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._th_colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._th_colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._th_colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._th_colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._colorComponent = OTParamCombo("Component",varname='_param_tb_color_component') self._colorComponent.addItem("A", 0) self._colorComponent.addItem("B", 1) self._colorComponent.addItem("C", 2) self._th_thresholdType = OTParamCombo("ThresholdType",varname='_param_tb_threshold_type') self._th_thresholdType.addItem("THRESH_BINARY", cv2.THRESH_BINARY) self._th_thresholdType.addItem("THRESH_BINARY_INV", cv2.THRESH_BINARY_INV) #END THRESHOLD self._th_colorDomain.valueUpdated = self.refreshValue self._colorComponent.valueUpdated = self.refreshValue self._adaptiveMethod.valueUpdated = self.refreshValue self._blockSize.valueUpdated = self.refreshValue self._C.valueUpdated = self.refreshValue self._formset = [ '_video',"_player", ('_th_colorDomain','_colorComponent','_adaptiveMethod','_th_thresholdType'), ('_blockSize',"_C"), ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) OTPFindBlobs.__init__(self) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") self._minArea = OTParamSlider("Blob min. area", 100, 0, 50000, varname='_param_min_area') self._maxArea = OTParamSlider("Blob max. area", 10000, 0, 100000, varname='_param_max_area') self._formset = [ '_video', ('_minArea','_maxArea'), "_player" ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'centre.png') super(OTModuleCircleCenter, self).__init__(name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video") self._run = OTParamButton("Run") self._formset = [('_video', '_run'), "_player"] self._video.valueUpdated = self.videoSelected self._run.value = self.__run self._center = None self._player.processFrame = self.processFrame
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) OTPSelectBiggerBlobs.__init__(self) self._video = OTParamVideoInput("Video") self._blobs = OTParamModuleConnection("Blobs", connecting=OTModuleBlobs) self._player = OTParamPlayer("Video player") self._howMany = OTParamSlider("How many?", 1, 1, 20, varname='_param_n_blobs') self._formset = ['_video','_blobs', '_howMany', "_player" ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) OTPThreshImage.__init__(self) OTPThreshBlobs.__init__(self) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") self._polygons = OTParamGeometry("Geometry") self._blockSize = OTParamSlider("Block size", 3, 3, 500,varname='_param_tb_block_size') self._C = OTParamSlider("C", 0, 0, 500,varname='_param_tb_c') self._boxWidth = OTParamSlider("Width", 0, 0, 30,varname='_param_tb_box_width') self._boxHeight = OTParamSlider("Height", 0, 0, 30,varname='_param_tb_box_height') self._adaptiveMethod = OTParamCombo("Adaptive method",varname='_param_tb_adaptive_method') self._adaptiveMethod.addItem("Mean", cv2.cv.CV_ADAPTIVE_THRESH_MEAN_C) self._adaptiveMethod.addItem("Gaussian", cv2.cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C) self._colorDomain = OTParamCombo("Colors space",varname='_param_tb_color_domain') self._colorDomain.addItem("RGB", -1) self._colorDomain.addItem("Gray", cv2.COLOR_BGR2GRAY) self._colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._colorComponent = OTParamCombo("Component",varname='_param_tb_color_component') self._colorComponent.addItem("A", 0) self._colorComponent.addItem("B", 1) self._colorComponent.addItem("C", 2) self._formset = [ ('_video','_polygons'),"_player",('_colorDomain','_colorComponent','_adaptiveMethod'), ('_boxWidth', '_boxHeight'),('_blockSize',"_C") ] self._colorDomain.valueUpdated = self.refreshValue self._colorComponent.valueUpdated = self.refreshValue self._adaptiveMethod.valueUpdated = self.refreshValue self._boxHeight.valueUpdated = self.refreshValue self._boxWidth.valueUpdated = self.refreshValue self._blockSize.valueUpdated = self.refreshValue self._C.valueUpdated = self.refreshValue self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconmask.jpg') OTModulePlugin.__init__(self, name, iconFile=icon_path) OTModuleInputVideoPipe.__init__(self) self._polygons = OTParamModuleConnection( "Polygons", connecting=OTBaseModuleGeometry) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video") self._formset = ['_video', "_polygons", "_player"] self._video.valueUpdated = self.videoSelected self._polygons.valueUpdated = self.polygonsSelected self._player.processFrame = self.processFrame self._mask_color = None self._mask_gray = None
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'radius.png') OTBaseModuleGeometry.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._circlecenter = OTParamModuleConnection( "Circle center", connecting=OTModuleCircleCenter) self._player = OTParamPlayer("Video") self._run = OTParamButton("Run") self._formset = [('_video', '_circlecenter', '_run'), "_player", "=", '_polygons'] self._video.valueUpdated = self.videoSelected self._run.value = self.__run self._radius = None self._player.processFrame = self.processFrame
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTPSplitColors.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._player = OTParamPlayer("Video player") self._colorComponent = OTParamCombo("Component", varname='_split_color_channel') self._colorComponent.addItem("A", 0) self._colorComponent.addItem("B", 1) self._colorComponent.addItem("C", 2) self._colorComponent.valueUpdated = self.refreshValue self._formset = [ '_video', '_colorComponent', "_player", ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen
def newVideoInputChoosen(self, value): OTParamVideoInput.valueUpdated(self._video,value) if value: self._player.value = value
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTPRemoveBackground.__init__(self) OTPColorFilter.__init__(self) OTPBlur.__init__(self) OTPFindBlobs.__init__(self) OTPSelectBiggerBlobs.__init__(self) OTModuleResultsPlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") self._background = OTParamBackground("Background", varname='_param_background') self._threshold = OTParamSlider("Threshold", 110, 1, 255, varname='_param_background_threshold') self._minArea = OTParamSlider("Blob min. area", 100, 0, 50000, varname='_param_min_area') self._maxArea = OTParamSlider("Blob max. area", 10000, 0, 100000, varname='_param_max_area') self._textAlgo = OTParamText( "Blob function ( Operations: [ AND: * ; OR: + ; SUB: - ; NEG: ~ ] Ex: A+B-~C )", "A*B*C", varname='_param_filter_algorithm') self._removeBg = OTParamCheckBox("Remove the background", True) self._editMode = OTParamCheckBox("Edit mode", True) self._run = OTParamButton("Run") self._player = OTParamPlayer("Video player") self._progress = OTParamProgress() self._selectBiggests = OTParamCheckBox( "Select only the biggests blobs", True) self._howMany = OTParamSlider("How many?", 1, 1, 20, varname='_param_n_blobs') self._useBlur = OTParamCheckBox("Use blur", True) self._kernelSize = OTParamSlider("Kernel size", 1, 1, 50, varname='_param_kernel_size') self._blurThreshold = OTParamSlider("Blur threshold", 110, 1, 255, varname='_param_blur_threshould') self._colorDomain = OTParamCombo("Colors space", varname='_param_color_domain') self._colorDomain.addItem("RGB", -1) self._colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._activeR = OTParamCheckBox("Active") self._activeG = OTParamCheckBox("Active") self._activeB = OTParamCheckBox("Active") self._minR = OTParamSlider("min. A", 1, 0, 255, varname='_param_a_min') self._maxR = OTParamSlider("max. A", 255, 0, 255, varname='_param_a_max') self._minG = OTParamSlider("min. B", 1, 0, 255, varname='_param_b_min') self._maxG = OTParamSlider("max. B", 255, 0, 255, varname='_param_b_max') self._minB = OTParamSlider("min. C", 1, 0, 255, varname='_param_c_min') self._maxB = OTParamSlider("max. C", 255, 0, 255, varname='_param_c_max') self._groupBlobs = OTParamCheckBox("Group blobs", True) self._maxDistance = OTParamSlider("Max. dist. between blobs", 1, 30, 300) self._groupBlobs.valueUpdated = self.groupBlobsUpdated self._colorDomain.valueUpdated = self.refreshValue self._activeR.valueUpdated = self.refreshValue self._activeG.valueUpdated = self.refreshValue self._activeB.valueUpdated = self.refreshValue self._minR.valueUpdated = self.refreshValue self._maxR.valueUpdated = self.refreshValue self._minG.valueUpdated = self.refreshValue self._maxG.valueUpdated = self.refreshValue self._minB.valueUpdated = self.refreshValue self._maxB.valueUpdated = self.refreshValue self._textAlgo.valueUpdated = self.refreshValue self._threshold.valueUpdated = self.refreshValue self._kernelSize.valueUpdated = self.refreshValue self._blurThreshold.valueUpdated = self.refreshValue self._maxArea.valueUpdated = self.refreshValue self._minArea.valueUpdated = self.refreshValue self._maxDistance.valueUpdated = self.refreshValue self._removeBg.valueUpdated = self.removeBgUpdate self._useBlur.valueUpdated = self.useBlurUpdate self._selectBiggests.valueUpdated = self.selectBiggestsUpdate self._formset = [ ('_video', '_editMode', '_run'), [ "_player", { "1. Filter colors": [ '_colorDomain', ("_minR", '_activeR', "_maxR"), ("_minG", '_activeG', "_maxG"), ("_minB", '_activeB', "_maxB"), "_textAlgo" ], "2. Remove background": ['_removeBg', '_background', '_threshold'], "3. Filter objects": [('_minArea', '_maxArea'), ('_useBlur', '_kernelSize', '_blurThreshold'), ("_selectBiggests", "_howMany")], "4. Tracking": [('_groupBlobs', '_maxDistance')], }, "=", "_results", "_query" ], "_progress" ] self._run.value = self.run self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen self._isRunning = False self._blurThreshold.hide() self._kernelSize.hide() self._background.hide() self._threshold.hide() self._progress.hide() self._howMany.hide() self._results.hide() self._query.hide() self._maxDistance.hide()
def videoSelected(self, value): OTParamVideoInput.valueUpdated(self._video, value) self.open(value) self._player.value = value self.polygonsSelected(self._polygons.value)
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'icon.jpg') OTModuleResultsPlugin.__init__(self, name, iconFile = icon_path) self._x_col = 4 #Indicate the column with the X coord self._y_col = 5 #Indicate the column with the Y coord self._frame_col = 1 #Indicate the column with the Y coord self._object_col = 6 self._current_row = None self._imgWidth = 0.0 self._imgHeight = 0.0 self._startPoint = None self._endPoint = None self._video = OTParamVideoInput("Video") self._positions = OTParamPositions("Positions") self._showPos = OTParamCheckBox("Show position") self._showTrack = OTParamCheckBox("Show track") self._trackRange = OTParamSlider("Track range", 10, 10, 1000) self._player = OTParamPlayer("Video player") self._progress = OTParamProgress() #Fields used to configure the Position draw function self._show_draw_function = OTParamToggle("Show/Hide draw function") self._draw_function = OTParamTextArea("Draw function", """def draw(frame, row): x, y = int(row[self._x_col]), int(row[self._y_col]) cv2.circle(frame, (x, y), 3, (0,255,0), thickness=2, lineType= cv2.cv.CV_AA)""") self._importFunc = OTParamButton("Import") self._exportFunc = OTParamButton("Export") #Fields used to configure the interpolation self._columns = OTParamCheckBoxList("List of columns to interpolate") self._run_interpolation = OTParamButton("Interpolate") self._run_interpolation_4_all = OTParamButton("Interpolate") #organization of the form self._formset = [ ('_video','_positions'), [ ('_columns', '_run_interpolation', '_run_interpolation_4_all'), "_draw_function", (" ", "_importFunc", "_exportFunc"), "_player", ('_showPos',"_showTrack", "_trackRange") ,"=","_results", "_query"], '_progress' ] self._trackRange.enabled = False self._showPos.value = True #setting up the fields events self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen self._positions.valueUpdated = self.newPositionsChoosen self._showTrack.valueUpdated = self.showTrackToggle self._query.selectionChanged = self.tableSelectionChanged self._trackRange.valueUpdated = self.updateTrackRange self._player._videoWidget.onEndDrag = self.onEndDragInVideoWindow self._show_draw_function.value = self.showHideDrawFunction self._importFunc.value = self.importFunction self._exportFunc.value = self.exportFunction self._run_interpolation.value = self.interpolationPositions self._run_interpolation_4_all.value = self.interpolateAllPositions #Hide fields self._draw_function.hide() self._progress.hide() self._importFunc.hide() self._exportFunc.hide() self._columns.hide() self._run_interpolation.hide() self._run_interpolation_4_all.hide() #Configure the popup menu self._query.addPopupMenuOption("-") self._query.addPopupSubMenuOption("Add", {"Interpolation": self.showColumns4Interpolation, "Duplicate row": self.addDuplicatedRow }) self._query.addPopupMenuOption("Remove", self._query.remove) self._query.addPopupMenuOption("-") self._query.addPopupMenuOption("Approximate all positions", self.approximatePositions) self._query.addPopupMenuOption("Interpolate all positions", self.showColumns4InterpolationAll) self._current_row_index = None #Variable used to read the current row when the video is playing
def __init__(self, name): icon_path = tools.getFileInSameDirectory(__file__, 'iconsubbg.jpg') OTPRemoveBackground.__init__(self) OTPColorFilter.__init__(self) OTPAdaptativeThreshold.__init__(self) OTPBlur.__init__(self) OTPFindBlobs.__init__(self) OTPSelectBiggerBlobs.__init__(self) OTPMaskImage.__init__(self) OTPCanny.__init__(self) OTModulePlugin.__init__(self, name, iconFile=icon_path) self._video = OTParamVideoInput("Video") #self._polygons = OTParamGeometry("Geometry") self._background = OTParamBackground("Background", varname='_param_background') self._threshold = OTParamSlider("Threshold", 110, 1, 255, varname='_param_background_threshold') self._minArea = OTParamSlider("Blob min. area",100, 0, 50000, varname='_param_min_area') self._maxArea = OTParamSlider("Blob max. area", 10000, 0, 100000, varname='_param_max_area') self._textAlgo = OTParamText("Blob function ( Operations: [ AND: * ; OR: + ; SUB: - ; NEG: ~ ] Ex: A+B-~C )", "A*B*C", varname='_param_filter_algorithm') self._removeBg = OTParamCheckBox("Remove the background", True) self._player = OTParamPlayer("Video player") self._selectBiggests = OTParamCheckBox("Select only the biggests blobs", True) self._howMany = OTParamSlider("How many?", 1, 1, 20, varname='_param_n_blobs') self._useBlur = OTParamCheckBox("Use blur", True) self._kernelSize = OTParamSlider("Kernel size",1, 1, 50, varname='_param_kernel_size') self._blurThreshold = OTParamSlider("Blur threshold", 110, 1, 255, varname='_param_blur_threshould') self._colorDomain = OTParamCombo("Colors space", varname='_param_color_domain') self._colorDomain.addItem("RGB", -1) self._colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._activeR = OTParamCheckBox("Active") self._activeG = OTParamCheckBox("Active") self._activeB = OTParamCheckBox("Active") self._minR = OTParamSlider("min. A", 1, 0, 255, varname='_param_a_min') self._maxR = OTParamSlider("max. A", 255, 0, 255, varname='_param_a_max') self._minG = OTParamSlider("min. B", 1, 0, 255, varname='_param_b_min') self._maxG = OTParamSlider("max. B", 255, 0, 255, varname='_param_b_max') self._minB = OTParamSlider("min. C", 1, 0, 255, varname='_param_c_min') self._maxB = OTParamSlider("max. C", 255, 0, 255, varname='_param_c_max') #THRESHOLD self._blockSize = OTParamSlider("Block size", 3, 3, 500,varname='_param_tb_block_size') self._C = OTParamSlider("C", 0, 0, 500,varname='_param_tb_c') self._boxWidth = OTParamSlider("Width", 0, 0, 30,varname='_param_tb_box_width') self._boxHeight = OTParamSlider("Height", 0, 0, 30,varname='_param_tb_box_height') self._adaptiveMethod = OTParamCombo("Adaptive method",varname='_param_tb_adaptive_method') self._adaptiveMethod.addItem("Mean", cv2.cv.CV_ADAPTIVE_THRESH_MEAN_C) self._adaptiveMethod.addItem("Gaussian", cv2.cv.CV_ADAPTIVE_THRESH_GAUSSIAN_C) self._th_colorDomain = OTParamCombo("Colors space",varname='_param_tb_color_domain') self._th_colorDomain.addItem("RGB", -1) self._th_colorDomain.addItem("Gray", cv2.COLOR_BGR2GRAY) self._th_colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._th_colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._th_colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._th_colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._th_colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._th_colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._colorComponent = OTParamCombo("Component",varname='_param_tb_color_component') self._colorComponent.addItem("A", 0) self._colorComponent.addItem("B", 1) self._colorComponent.addItem("C", 2) self._th_thresholdType = OTParamCombo("ThresholdType",varname='_param_tb_threshold_type') self._th_thresholdType.addItem("THRESH_BINARY", cv2.THRESH_BINARY) self._th_thresholdType.addItem("THRESH_BINARY_INV", cv2.THRESH_BINARY_INV) #END THRESHOLD #CANNY self._canny_apertureSize = OTParamSlider("Aperture size", 3, 3, 7, varname='_param_canny_apertureSize') self._canny_L2gradient = OTParamCheckBox("L2 gradient", True, varname='_param_canny_L2gradient') self._canny_threshould1 = OTParamSlider("Threshould 1", 0, 0, 255, varname='_param_canny_threshould1') self._canny_threshould2 = OTParamSlider("Threshould 2", 1, 0, 255, varname='_param_canny_threshould2') self._canny_colorDomain = OTParamCombo("Colors space",varname='_param_canny_color_domain') self._canny_colorDomain.addItem("RGB", -1) self._canny_colorDomain.addItem("Gray", cv2.COLOR_BGR2GRAY) self._canny_colorDomain.addItem("XYZ", cv2.COLOR_BGR2XYZ) self._canny_colorDomain.addItem("YCrCb", cv2.COLOR_BGR2YCR_CB) self._canny_colorDomain.addItem("HSV", cv2.COLOR_BGR2HSV) self._canny_colorDomain.addItem("HLS", cv2.COLOR_BGR2HLS) self._canny_colorDomain.addItem("Lab", cv2.COLOR_BGR2LAB) self._canny_colorDomain.addItem("Luv", cv2.COLOR_BGR2LUV) self._canny_colorComponent = OTParamCombo("Component",varname='_param_canny_color_component') self._canny_colorComponent.addItem("A", 0) self._canny_colorComponent.addItem("B", 1) self._canny_colorComponent.addItem("C", 2) #END CANNY self._useColors = OTParamCheckBox("Use colors filter", True) self._useThreshold = OTParamCheckBox("Use adaptative threshold", False) self._useCanny = OTParamCheckBox("Use canny algorithm", False) self._exportFindBlobs = OTParamCheckBox("Export find blobs", True) self._canny_colorDomain.valueUpdated = self.refreshValue self._canny_colorComponent.valueUpdated = self.refreshValue self._canny_apertureSize.valueUpdated = self.refreshValue self._canny_L2gradient.valueUpdated = self.refreshValue self._canny_threshould1.valueUpdated = self.refreshValue self._canny_threshould2.valueUpdated = self.refreshValue self._th_colorDomain.valueUpdated = self.refreshValue self._colorComponent.valueUpdated = self.refreshValue self._adaptiveMethod.valueUpdated = self.refreshValue self._boxHeight.valueUpdated = self.refreshValue self._boxWidth.valueUpdated = self.refreshValue self._blockSize.valueUpdated = self.refreshValue self._C.valueUpdated = self.refreshValue self._colorDomain.valueUpdated = self.refreshValue self._activeR.valueUpdated = self.refreshValue self._activeG.valueUpdated = self.refreshValue self._activeB.valueUpdated = self.refreshValue self._minR.valueUpdated = self.refreshValue self._maxR.valueUpdated = self.refreshValue self._minG.valueUpdated = self.refreshValue self._maxG.valueUpdated = self.refreshValue self._minB.valueUpdated = self.refreshValue self._maxB.valueUpdated = self.refreshValue self._textAlgo.valueUpdated = self.refreshValue self._threshold.valueUpdated = self.refreshValue self._kernelSize.valueUpdated = self.refreshValue self._blurThreshold.valueUpdated = self.refreshValue self._maxArea.valueUpdated = self.refreshValue self._minArea.valueUpdated = self.refreshValue self._removeBg.valueUpdated = self.removeBgUpdate self._useBlur.valueUpdated = self.useBlurUpdate self._selectBiggests.valueUpdated = self.selectBiggestsUpdate self._useColors.valueUpdated = self.__useColorsClicked self._useThreshold.valueUpdated = self.__useThresholdClicked self._useCanny.valueUpdated = self.__useCannyClicked self._formset = [ ('_video',' ','_useColors','_useThreshold','_useCanny'), [ "_player",{ "Remove background": [ '_removeBg','_background', '_threshold'], "Filter colors" : ['_colorDomain', ("_minR",'_activeR',"_maxR"), ("_minG",'_activeG',"_maxG"), ("_minB",'_activeB',"_maxB")], "Threshold filter": [('_th_colorDomain','_colorComponent','_adaptiveMethod','_th_thresholdType'), ('_boxWidth', '_boxHeight'),('_blockSize',"_C")], "Canny": [ ('_canny_colorDomain', '_canny_colorComponent'), '_canny_threshould1','_canny_threshould2','_canny_apertureSize','_canny_L2gradient'], "Filter objects": [ ('_minArea', '_maxArea'), ('_useBlur', '_kernelSize', '_blurThreshold'), ("_selectBiggests", "_howMany"),'_exportFindBlobs' ], },"_textAlgo" ] ] self._player.processFrame = self.processFrame self._video.valueUpdated = self.newVideoInputChoosen self._blurThreshold.hide() self._kernelSize.hide() self._background.hide() self._threshold.hide() self._howMany.hide()
def newVideoInputChoosen(self, value): OTParamVideoInput.valueUpdated(self._video, value) print type(value) if value.videoInput: self._player.value = value.videoInput value.videoInput.setFrame(0)