diff options
| author | Nikita Kostovsky <nikita@kostovsky.me> | 2025-01-14 18:04:32 +0100 |
|---|---|---|
| committer | Nikita Kostovsky <nikita@kostovsky.me> | 2025-01-14 18:04:32 +0100 |
| commit | 38acf876313c9bf28e41acd8bc29d6115c1e9285 (patch) | |
| tree | dc59c6c26006f740e1990150f920f4032734fc13 /src/camera | |
| parent | 201d98f63131242bb8871ed0c4a3ae9ebd4ef030 (diff) | |
refactoring
Diffstat (limited to 'src/camera')
| -rw-r--r-- | src/camera/ov9281.cpp | 25 |
1 files changed, 14 insertions, 11 deletions
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<std::shared_ptr<OV9281>> OV9281::search( for (const auto &camera : manager->cameras()) { - auto ov9281 = std::shared_ptr<OV9281>(new OV9281(camera)); + auto id = camera->id(); + auto c = manager->get(id); + auto ov9281 = std::shared_ptr<OV9281>(new OV9281(c)); if (!ov9281->init()) { |
