def start(self): """ Start the recording and tracking. :returns: The recording was started status code """ if not hasattr(self.params, 'destPath'): return False vidExt = os.path.splitext(self.params.destPath)[1] if vidExt not in VIDEO_FORMATS: print(('Unknow format: {}'.format(vidExt))) return False self.positions = [] # reset between runs self.distancesFromArena = [] bgStart = self.params.bgFrameIdx nBackgroundFrames = self.params.nBgFrames trackFrom = self.params.startFrameIdx trackTo = self.params.endFrameIdx if ( self.params.endFrameIdx > 0) else None threshold = self.params.detectionThreshold minArea = self.params.objectsMinArea maxArea = self.params.objectsMaxArea teleportationThreshold = self.params.teleportationThreshold nSds = self.params.nSds clearBorders = self.params.clearBorders normalise = self.params.normalise extractArena = self.params.extractArena self.tracker = GuiTracker( self, srcFilePath=None, destFilePath=self.params.destPath, threshold=threshold, minArea=minArea, maxArea=maxArea, teleportationThreshold=teleportationThreshold, bgStart=bgStart, trackFrom=trackFrom, trackTo=trackTo, nBackgroundFrames=nBackgroundFrames, nSds=nSds, clearBorders=clearBorders, normalise=normalise, plot=True, fast=False, extractArena=extractArena, cameraCalibration=self.params.calib, callback=None) self.stream = self.tracker # To comply with BaseInterface self._setDisplay() self._updateImgProvider() self.tracker.setRoi(self.roi) self.timer.start(self.timerSpeed) return True
def load(self): """ Load the video and create the GuiTracker object Also registers the analysis image providers (for the analysis tab) with QT """ self.tracker = GuiTracker(self, srcFilePath=self.params.srcPath, destFilePath=None, nBackgroundFrames=1, plot=True, fast=False, cameraCalibration=self.params.calib, callback=None) self.stream = self.tracker # To comply with BaseInterface self.tracker.roi = self.roi self.nFrames = self.tracker._stream.nFrames - 1 self.currentFrameIdx = self.tracker._stream.currentFrameIdx if self.params.endFrameIdx == -1: self.params.endFrameIdx = self.nFrames self._setDisplay() self._setDisplayMax() self._updateImgProvider()