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()) {