From 8f3abd0141735e7487419c307046560a40bab49c Mon Sep 17 00:00:00 2001 From: Chi Huu Huynh <73843190+Chi-EEE@users.noreply.github.com> Date: Thu, 18 Apr 2024 18:18:58 +0100 Subject: [PATCH] Move checking fps --- app/rpi/common/src/car/system/device/CameraDevice.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/rpi/common/src/car/system/device/CameraDevice.cpp b/app/rpi/common/src/car/system/device/CameraDevice.cpp index f57c783c..5de5229f 100644 --- a/app/rpi/common/src/car/system/device/CameraDevice.cpp +++ b/app/rpi/common/src/car/system/device/CameraDevice.cpp @@ -19,17 +19,17 @@ namespace car::system::device } void CameraDevice::update() { - const auto now = std::chrono::steady_clock::now(); - if ((now - this->last).count() < this->configuration->getCameraFpsInterval()) { + std::lock_guard lock(this->camera_mutex_); + if (!this->connected_ || this->camera_ == nullptr || !this->camera_->isOpened()) { this->frame_buffer_ = ""; return; } - this->last = now; - std::lock_guard lock(this->camera_mutex_); - if (!this->connected_ || this->camera_ == nullptr || !this->camera_->isOpened()) { + const auto now = std::chrono::steady_clock::now(); + if ((now - this->last).count() < this->configuration->getCameraFpsInterval()) { this->frame_buffer_ = ""; return; } + this->last = now; cv::Mat frame; (*this->camera_) >> frame; if (frame.empty()) {