def videodump(slug, outputtype, groundplane, fields=None): logger.debug(os.getcwd()) query = session.query(Video).filter(Video.slug == slug) if query.count() != 1: raise ValueError("Invalid video slug") video = query.one() #mergemethod = merge.userid groundplane = (groundplane == 1) mergemethod = merge.getpercentoverlap(groundplane) if fields is None: if groundplane: fields = dumptools.GROUND_PLANE_FORMAT else: fields = dumptools.DEFAULT_FORMAT fields = fields.split() data = dumptools.getdata(video, True, mergemethod, 0.5, None, groundplane) outfile = tempfile.TemporaryFile() if outputtype == "json": dumptools.dumpjson(outfile, data, groundplane, fields) elif outputtype == "xml": dumptools.dumpxml(outfile, data, groundplane, fields) else: dumptools.dumptext(outfile, data, groundplane, fields) outfile.seek(0) text = outfile.readlines() outfile.close() return text
def getdata(self, args): video = session.query(Video).filter(Video.slug == args.slug) if video.count() == 0: print "Video {0} does not exist!".format(args.slug) raise SystemExit() video = video.one() mergemethod = merge.getpercentoverlap(args.groundplane) if args.merge_method == "id": mergemethod = merge.userid workers = None if args.worker: workers = set(args.worker) return video, dumptools.getdata(video, args.merge, mergemethod, args.merge_threshold, workers, args.groundplane)