def main(facefilename): faces = Faces("") faces.__setstate__(common.json.loadfile(facefilename)) showedcnt = 0 # Construct one chain per face chains = [] for i, frame in enumerate(faces.frames): for face in frame: assert face.is_face() chain = [(i, face)] chains.append(FaceChain(chain)) chains.sort() facechains = FaceChains() facechains.copy_from_faces(faces) facechains.chains = chains facechains.join_nearby(1) facechains.deleteshortchains() facechains.gaussiansmoothchains() facechains.gaussiansmoothchains() print common.json.dumps(facechains.__getstate__())
def main(invideofilename, facefilename, outvideofilename): faces = Faces("") faces.__setstate__(common.json.loadfile(facefilename)) dir = tempfile.mkdtemp() try: for i, f, totframes in common.video.frames(invideofilename, maxframes=len( faces.frames)): outf = os.path.join(dir, "out%05d.jpg" % i) print >> sys.stderr, "Processing %s to %s, image %s" % ( f, outf, common.str.percent(i + 1, totframes)) print >> sys.stderr, stats() draw_faces(faces.frames[i], f, outf) # I learned this command from here: http://electron.mit.edu/~gsteele/ffmpeg/ cmd = "ffmpeg -y -r 30 -b 10000k -i %s %s" % (os.path.join( dir, 'out%05d.jpg'), outvideofilename) print >> sys.stderr, "Stitching video together as test1800.mp4" print >> sys.stderr, cmd # import time # time.sleep(30) common.misc.runcmd(cmd) print >> sys.stderr, stats() finally: print >> sys.stderr, "Removing dir %s" % dir shutil.rmtree(dir)
def main(invideofilename, facefilename, outvideofilename): faces = Faces("") faces.__setstate__(common.json.loadfile(facefilename)) dir = tempfile.mkdtemp() try: for i, f, totframes in common.video.frames(invideofilename, maxframes=len(faces.frames)): outf = os.path.join(dir, "out%05d.jpg" % i) print >> sys.stderr, "Processing %s to %s, image %s" % (f, outf, common.str.percent(i+1, totframes)) print >> sys.stderr, stats() draw_faces(faces.frames[i], f, outf) # I learned this command from here: http://electron.mit.edu/~gsteele/ffmpeg/ cmd = "ffmpeg -y -r 30 -b 10000k -i %s %s" % (os.path.join(dir, 'out%05d.jpg'), outvideofilename) print >> sys.stderr, "Stitching video together as test1800.mp4" print >> sys.stderr, cmd # import time # time.sleep(30) common.misc.runcmd(cmd) print >> sys.stderr, stats() finally: print >> sys.stderr, "Removing dir %s" % dir shutil.rmtree(dir)
def main(facefilename): faces = Faces("") faces.__setstate__(common.json.loadfile(facefilename)) showedcnt = 0 # Construct one chain per face chains = [] for i, frame in enumerate(faces.frames): for face in frame: assert face.is_face() chain = [(i, face)] chains.append(FaceChain(chain)) chains.sort() facechains = FaceChains() facechains.copy_from_faces(faces) facechains.chains = chains facechains.join_nearby(1) facechains.deleteshortchains() facechains.gaussiansmoothchains() facechains.gaussiansmoothchains() print common.json.dumps(facechains.__getstate__())