From 4ec2aef40921555cde5993af767125a4991c1ed0 Mon Sep 17 00:00:00 2001 From: Cyrille Nofficial Date: Sun, 14 Jan 2024 10:36:40 +0100 Subject: [PATCH] feat: display fps --- camera/oak_pipeline.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/camera/oak_pipeline.py b/camera/oak_pipeline.py index ddc6b95..614229f 100644 --- a/camera/oak_pipeline.py +++ b/camera/oak_pipeline.py @@ -5,6 +5,7 @@ import abc import datetime import logging import pathlib +import time import typing from dataclasses import dataclass @@ -344,6 +345,10 @@ class PipelineController: q_nn = dev.getOutputQueue(name=self._object_node.get_stream_name(), maxSize=queue_size, # type: ignore blocking=False) + start_time = time.time() + counter = 0 + fps = 0 + display_time = time.time() self._stop = False while True: if self._stop: @@ -355,6 +360,16 @@ class PipelineController: except Exception as ex: logger.exception("unexpected error: %s", str(ex)) + counter += 1 + if (time.time() - start_time) > 1: + fps = counter / (time.time() - start_time) + counter = 0 + start_time = time.time() + if (time.time() - display_time) >= 10: + display_time = time.time() + logger.info("fps: %s", fps) + + def _loop_on_camera_events(self, q_nn: dai.DataOutputQueue, q_rgb: dai.DataOutputQueue) -> None: logger.debug("wait for new frame")