From fc018bf7f04619f436c6fc62b34c28f2f3880239 Mon Sep 17 00:00:00 2001 From: iperov Date: Sat, 12 Mar 2022 21:55:03 +0400 Subject: [PATCH] CameraSource: fixed output resolution, fixed FPS limiter. --- apps/DeepFaceLive/backend/CameraSource.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/apps/DeepFaceLive/backend/CameraSource.py b/apps/DeepFaceLive/backend/CameraSource.py index db3cd6a..13c7471 100644 --- a/apps/DeepFaceLive/backend/CameraSource.py +++ b/apps/DeepFaceLive/backend/CameraSource.py @@ -220,21 +220,26 @@ class CameraSourceWorker(BackendWorker): if self.vcap is not None: state, cs = self.get_state(), self.get_control_sheet() - self.start_profile_timing() + self.start_profile_timing() ret, img = self.vcap.read() if ret: timestamp = datetime.now().timestamp() fps = state.fps if fps == 0 or ((timestamp - self.last_timestamp) > 1.0 / fps): - self.last_timestamp = timestamp + + if fps != 0: + if timestamp - self.last_timestamp >= 1.0: + self.last_timestamp = timestamp + else: + self.last_timestamp += 1.0 / fps ip = ImageProcessor(img) - #if state.target_width != 0: - # ip.fit_in(TW=state.target_width) - ip.ch(3).to_uint8() + w, h = _ResolutionType_wh[state.resolution] + ip.fit_in(TW=w) + rotation = state.rotation if rotation == _RotationType.ROTATION_90: ip.rotate90()