From 5c4d4b7b1454c21c187c35587798783ea3d30ea2 Mon Sep 17 00:00:00 2001 From: Emiliana <38952746+emilianavt@users.noreply.github.com> Date: Thu, 2 Jul 2020 01:39:46 +0200 Subject: [PATCH] Added an option to disable escapi for video input on Windows. --- facetracker.py | 6 +++++- input_reader.py | 6 +++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/facetracker.py b/facetracker.py index f4b3772..026bb0b 100644 --- a/facetracker.py +++ b/facetracker.py @@ -35,6 +35,8 @@ parser.add_argument("--gaze-tracking", type=int, help="When set to 1, experiment parser.add_argument("--face-id-offset", type=int, help="When set, this offset is added to all face ids, which can be useful for mixing tracking data from multiple network sources", default=0) parser.add_argument("--repeat-video", type=int, help="When set to 1 and a video file was specified with -c, the tracker will loop the video until interrupted", default=0) parser.add_argument("--dump-points", type=str, help="When set to a filename, the current face 3D points are made symmetric and dumped to the given file when quitting the visualization with the \"q\" key", default="") +if os.name == 'nt': + parser.add_argument("--use-escapi", type=int, help="When set to 1, escapi will be used for video input instead of OpenCV", default=1) args = parser.parse_args() os.environ["OMP_NUM_THREADS"] = "1" @@ -70,7 +72,9 @@ if args.faces >= 40: fps = 0 if os.name == 'nt': fps = args.fps -input_reader = InputReader(args.capture, args.raw_rgb, args.width, args.height, fps) + input_reader = InputReader(args.capture, args.raw_rgb, args.width, args.height, fps, use_escapi=True if args.use_escapi == 1 else False) +else: + input_reader = InputReader(args.capture, args.raw_rgb, args.width, args.height, fps, use_escapi=False) if type(input_reader.reader) == VideoReader: fps = 0 diff --git a/input_reader.py b/input_reader.py index 15feb52..d68765f 100644 --- a/input_reader.py +++ b/input_reader.py @@ -24,12 +24,12 @@ class VideoReader(): self.cap.release() class CameraReader(VideoReader): - def __init__(self, capture, width, height, fps): + def __init__(self, capture, width, height, fps, use_escapi=True): self.device = None self.width = width self.height = height self.fps = fps - if os.name == 'nt': + if os.name == 'nt' and use_escapi: escapi.init() self.device = capture self.buffer = escapi.init_camera(self.device, self.width, self.height, self.fps) @@ -88,7 +88,7 @@ class RawReader: self.open = False class InputReader(): - def __init__(self, capture, raw_rgb, width, height, fps): + def __init__(self, capture, raw_rgb, width, height, fps, use_escapi=False): self.reader = None try: if raw_rgb > 0: