def showAnnots(): cfg = main.getConfigs() videos, videoRange = main.prepareVideosList(cfg) videoName = videos[videoRange[0]][1] annotFilename = os.path.splitext(videoName)[0]+".tag" if not os.path.isfile(annotFilename): return annotsl, annots = Cmn.parseAnnotations(file(annotFilename), None, "farne") print annots[2] return
def processOutputs(cfg, videos, videoRange, actions, settings): #videoRange = videoRange[:1] if "writeOverallReport" in actions: reportLoc = cfg["othr"]["outputsPref"][1:] + ("/overall_%s.tsv" % cfg["method"]) reportFileName = VideoQueue.initOverallReport(cfg, cfg["othr"]["codeDirectory"] + "/"+ reportLoc) reportFileNameT1 = VideoQueue.initOverallReportTable1(cfg) for vi in videoRange: videoDescription, videoName = videos[vi] print vi, videoDescription, videoName outputFileName = VideoQueue.prepareOutputFileName(cfg["othr"]["codeDirectory"], cfg["othr"]["outputsPref"], videoName) try: varsDict = VideoQueue.readOutputsToVariables(cfg, outputFileName) except IOError, e: print "breaking" print traceback.format_exc() break if "postProcessLogLine" in actions or "displayDetectionCoverage" in actions or "writeOverallReport" in actions or "displayPupilDisplacement" in actions or "postProcessTracking" in actions: #if cfg["method"] == "farneback": annotFilename = "%s.tag" % os.path.splitext(videoName)[0].replace("/eyeMon", "") annotFilenameL = "%s.txt" % os.path.splitext(videoName)[0].replace("/eyeMon", "") annotFilename1 = "%s.v1" % os.path.splitext(videoName)[0].replace("/eyeMon", "") if os.path.isfile(annotFilename): annotsl, annots = Cmn.parseAnnotations(file(annotFilename), None, "farne") if os.path.isfile(annotFilenameL): videoLen = float(file(annotFilenameL, "rb").read().strip().split("\n")[-1].split(" ")[1]) annots[-1]["length"] = videoLen else: annots[-1]["length"] = -1 elif os.path.isfile(annotFilename1): annotsl, annots = Cmn.parseAnnotationsMy(file(annotFilename1), None, "farne") if "poli1person10" in annotFilename1: annots[-1]["glasses"] = True else: annots[-1]["glasses"] = False if os.path.isfile(annotFilenameL): videoLenS = float(file(annotFilenameL, "rb").read().strip().split("\n")[0].split(" ")[1]) videoLenE = float(file(annotFilenameL, "rb").read().strip().split("\n")[-1].split(" ")[1]) annots[-1]["length"] = (videoLenE-videoLenS) else: annots[-1]["length"] = -1 if "displayDetectionCoverage" in actions: if cfg["method"] == "farneback": dc = Cmn.detectionCoverageF(annotsl, varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"]) Cmn.displayDetectionCoverageF1(dc, annotsl) pass #Cmn.displayDetectionCoverage(varsDict["l"], varsDict["r"], varsDict["o"]) elif cfg["method"] == "templ": pass elif cfg["method"] == "blackpixels": pass if "signalProcessing" in actions: #print repr(varsDict["tCors"]) print repr([x["fn"] for x in varsDict["tCors"]]) print print print repr([x["lcor"] for x in varsDict["tCors"]]) print print print repr([x["rcor"] for x in varsDict["tCors"]]) pass if "writeOverallReport" in actions: dc = Cmn.detectionCoverageF(annotsl, varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"]) ppd = Farne.processPupilDisplacement(varsDict["tracking"], dc, annotsl, annots) VideoQueue.writeOverallReport(reportFileName, videoDescription, videoName, vi, annotsl, annots, varsDict, ppd) VideoQueue.writeOverallReportTable1(reportFileNameT1, videoDescription, videoName, vi, annotsl, annots, varsDict, ppd) if "postProcessLogLine" in actions: if cfg["method"] == "farneback": if 'annotsl' in locals(): dc = Cmn.detectionCoverageF(annotsl, varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"]) else: dc = None Farne.postProcessLogLine( varsDict["fFlows"], varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"], True, dc, varsDict["tracking"], videoName, settings['pltSettings'] ) elif cfg["method"] == "templ": Templ.postProcessLogLine( varsDict["tCors"], varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"], True, videoName, settings['pltSettings'] ) elif cfg["method"] == "blackpixels": Blackpixels.postProcessLogLine( varsDict["bPixes"], varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"], True, videoName, settings['pltSettings'] ) if "displayPupilDisplacement" in actions: if cfg["method"] == "farneback": dc = Cmn.detectionCoverageF(annotsl, varsDict["lBlinks"], varsDict["rBlinks"], varsDict["jBlinks"]) ppd = Farne.processPupilDisplacement(varsDict["tracking"], dc, annotsl, annots) Farne.displayPupilDisplacement(ppd)