def __init__(self): self._windowManager = WindowManager('benFinder', self.onKeypress) device = depth.CV_CAP_FREENECT #device = 1 print "device=%d" % device self._captureManager = CaptureManager( device, self._windowManager, True) self._captureManager.channel = depth.CV_CAP_OPENNI_BGR_IMAGE self._faceTracker = FaceTracker() self._shouldDrawDebugRects = False self._backgroundSubtract = False self._autoBackgroundSubtract = False self._curveFilter = filters.BGRPortraCurveFilter() self.background_video_img = None self.background_depth_img = None self.autoBackgroundImg = None self._ts = TimeSeries() self._frameCount = 0
def __init__(self, save=False, inFile=None): print "benFinder.__init__()" print os.path.realpath(__file__) configPath = "%s/%s" % (os.path.dirname( os.path.realpath(__file__)), self.configFname) print configPath self.cfg = ConfigUtil(configPath, self.configSection) self.debug = self.cfg.getConfigBool("debug") if (self.debug): print "Debug Mode" self._wkdir = self.cfg.getConfigStr("working_directory") if (self.debug): print "working_directory=%s\n" % self._wkdir self._tmpdir = self.cfg.getConfigStr("tmpdir") if (self.debug): print "tmpdir=%s\n" % self._tmpdir # Check if we are running from live kinect or a file. if (inFile): device = depth.CV_CAP_FILE else: device = depth.CV_CAP_FREENECT # Initialise the captureManager self._captureManager = CaptureManager(device, None, True, inFile=inFile) self._captureManager.channel = depth.CV_CAP_OPENNI_DEPTH_MAP # If we are runnign from a file, use the first frame as the # background image. if (inFile): self.saveBgImg() # If we have asked to save the background image, do that, and exit, # otherwise initialise the seizure detector. if (save): self.saveBgImg() else: self.loadBgImg() self.autoBackgroundImg = None self._status = self.ALARM_STATUS_OK self._ts = TimeSeries( tslen=self.cfg.getConfigInt("timeseries_length")) self._frameCount = 0 self._outputFrameCount = 0 self._nPeaks = 0 self._ts_time = 0 self._rate = 0 self._ws = webServer.benWebServer(self) self._ws.setBgImg( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("background_depth"))) self._ws.setChartImg( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("chart_fname"))) self._ws.setRawImg( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("raw_image_fname"))) self._ws.setMaskedImg( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("masked_image_fname"))) self._ws.setDataFname( "%s/%s" % (self._tmpdir, self.cfg.getConfigStr("data_fname"))) self._ws.setAnalysisResults({}) webServer.setRoutes(self._ws) self.run()