From 38acf876313c9bf28e41acd8bc29d6115c1e9285 Mon Sep 17 00:00:00 2001 From: Nikita Kostovsky Date: Tue, 14 Jan 2025 18:04:32 +0100 Subject: refactoring --- src/camera/ov9281.cpp | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) (limited to 'src/camera') diff --git a/src/camera/ov9281.cpp b/src/camera/ov9281.cpp index bdb9f89..4d393a0 100644 --- a/src/camera/ov9281.cpp +++ b/src/camera/ov9281.cpp @@ -56,14 +56,6 @@ bool OV9281::init() m_config->orientation = libcamera::Orientation::Rotate90; - if (m_config->empty()) - { - std::cerr << __func__ << ": " << m_camera->id() << ": config is empty" - << std::endl; - - return false; - } - libcamera::StreamConfiguration &streamConfig = m_config->at(0); streamConfig.pixelFormat = OV9281::pixelFormat; @@ -71,9 +63,10 @@ bool OV9281::init() if (!validateConfig()) { - std::cerr << __func__ << ": " << m_camera->id() - << ": cannot apply default config" << std::endl; + return false; + } + if (!applyConfig()) { return false; } @@ -135,6 +128,11 @@ bool OV9281::applyConfig() return true; } +/* + * Signals operate in the libcamera CameraManager thread context, so it is + * important not to block the thread for a long time, as this blocks internal + * processing of the camera pipelines, and can affect realtime performance. + */ void OV9281::onRequestCompleted(libcamera::Request *completed_request) { using namespace libcamera; @@ -184,6 +182,9 @@ void OV9281::onRequestCompleted(libcamera::Request *completed_request) auto pixels = img->pixels(); #ifdef emit #undef emit + if (!pixels) { + std::cerr << "emit empty pixels" << std::endl; + } newPixels.emit(pixels); #define emit #endif @@ -225,7 +226,9 @@ std::vector> OV9281::search( for (const auto &camera : manager->cameras()) { - auto ov9281 = std::shared_ptr(new OV9281(camera)); + auto id = camera->id(); + auto c = manager->get(id); + auto ov9281 = std::shared_ptr(new OV9281(c)); if (!ov9281->init()) { -- cgit v1.2.3-70-g09d2