diff --git a/flandmark/script/annotate.py b/flandmark/script/annotate.py index 15d60a4fe66004fdea07c8f4ec3e36326354655a..9ab65cf455e7e4572c94031daa580844c77c4033 100644 --- a/flandmark/script/annotate.py +++ b/flandmark/script/annotate.py @@ -89,7 +89,17 @@ def main(): parser.error("Input video file '%s' cannot be read" % args.video) output = sys.stdout + if args.output is not None: + dirname = os.path.dirname(args.output) + + if dirname and not os.path.exists(dirname): + try: + os.makedirs(dirname) + except OSError as exc: + if exc.errno == errno.EEXIST: pass + else: raise + output = open(args.output, 'wt') op = Localizer()