Files
cuframes-composer/include/cuframes_composer/cpp/layout.hpp
T
gx d8e69c6392 Phase 11b: detection-box bbox следует за камерой при смене layout
User: "при движении объект оборачивается в рамку, но функционал не
учитывает что сетки могут переключаться и координаты ячеек меняются".

Был баг: detbox-overlay хранил cell_x/y/w/h из --detection-cell CLI
(заданы при старте), при смене layout рамки рисовались по старым
координатам — мимо камеры.

Изменения:
  - overlay.h/.c: новый API cfc_overlay_detbox_set_cell_geom(ov,x,y,w,h).
    Mutex-защищённое обновление detbox config'а — composer вызывает
    перед каждым draw.
  - CameraCell: добавлено поле source_key (хранит cuframes-key камеры,
    рендерящейся в этом cell). Layout::apply передаёт его из pool entry.
  - Layout::find_camera_cell_rect(key) — возвращает Rect текущей cell
    для камеры с заданным cuframes-key (или nullptr если её нет в layout).
  - SourcePool::by_frigate_camera(name) — lookup pool-entry по
    Frigate-camera-key (frigate event'ы приходят с этим именем).
  - Composer::compose_frame: перед draw каждого DETECTION_BOXES overlay'я
    — lookup frigate→cuframes_key→layout cell rect, обновляет detbox geom.
    Если камера не в layout сейчас — cell_w/h=0, detbox draw skip'ает.

Теперь bbox от Frigate переезжает за камерой:
  - tpl_1 → bbox в full screen 1920×1080
  - tpl_3 → bbox в main 1440×810
  - tpl_4 → bbox в quad ячейке 960×540
  - камера не в layout → bbox скрыт

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-06-04 10:25:25 +01:00

63 lines
2.3 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
/* Layout — контейнер cells и оркестратор apply_template (Phase 11b).
*
* Layout::apply() принимает LayoutTemplate + список активных pool-entries
* (sorted by priority DESC) + output W×H. Создаёт нужные Cell-подклассы:
*
* CameraCell для каждой template-cell с role=CAMERA — берёт source
* по индексу из active list (active[0]=order 0, active[1]=order 1, ...)
* Если active меньше чем camera-cells — лишние cells = BlankCell.
* WidgetCell для template-cell с role=WIDGET — placeholder.
*
* Decorations добавляются здесь же:
* LabelDecoration "{key} prio={N}" в каждый CameraCell.
* LabelDecoration с именем widget'а в каждый WidgetCell.
* (Border, Badge — Phase 12+)
*
* Layout::render(stream, dst) — итеративно вызывает cell->draw().
*
* Лицензия: LGPL-2.1+
*/
#ifndef CUFRAMES_COMPOSER_CPP_LAYOUT_HPP
#define CUFRAMES_COMPOSER_CPP_LAYOUT_HPP
#include "cell.hpp"
#include "source_pool.hpp"
#include "template.hpp"
#include <memory>
#include <string>
#include <vector>
namespace cfc {
class Layout {
public:
Layout() = default;
/* Применить template — пересоздаёт cells + decorations.
* active_sorted — список pool-entries, уже отсортированный priority DESC. */
void apply(const LayoutTemplate& tpl,
const std::vector<PoolEntry*>& active_sorted,
int frame_w, int frame_h);
/* Прорисовать все cells в dst буфер. */
void render(CUstream stream, NV12Ref& dst);
const std::string& name() const noexcept { return current_name_; }
int cell_count() const noexcept { return static_cast<int>(cells_.size()); }
/* Найти текущий pixel-rect для камеры с заданным cuframes-key. NULL
* если этой камеры в layout сейчас нет. Используется detbox-overlay'ями
* для пересчёта bbox при смене layout. */
const Rect* find_camera_cell_rect(const std::string& source_key) const;
private:
std::vector<std::unique_ptr<Cell>> cells_;
std::string current_name_;
};
} // namespace cfc
#endif /* CUFRAMES_COMPOSER_CPP_LAYOUT_HPP */