Added a bit more exception handling.

This commit is contained in:
Emiliana 2020-08-11 12:29:31 +02:00
parent d30b7ecd98
commit 0885df2da9

View file

@ -116,6 +116,7 @@ try:
target_duration = 1. / float(fps)
repeat = args.repeat_video != 0 and type(input_reader.reader) == VideoReader
need_reinit = 0
failures = 0
source_name = input_reader.name
while repeat or input_reader.is_open():
if not input_reader.is_open() or need_reinit == 1:
@ -161,6 +162,7 @@ try:
if not args.video_out is None:
out = cv2.VideoWriter(args.video_out, cv2.VideoWriter_fourcc('F','F','V','1'), 24, (width,height))
try:
inference_start = time.perf_counter()
faces = tracker.predict(frame)
if len(faces) > 0:
@ -326,6 +328,16 @@ try:
with open(args.dump_points, "w") as fh:
fh.write(repr(points))
break
failures = 0
except Exception as e:
if e.__class__ == KeyboardInterrupt:
if args.silent == 0:
print("Quitting")
break
traceback.print_exc()
failures += 1
if failures > 30:
break
duration = time.perf_counter() - frame_time
while duration < target_duration: