Files
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

44 lines
1.5 KiB
C++
Raw Permalink 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.
/* CameraCell — рисует кадр из cuframes-источника в свой Rect (Phase 11b).
*
* Cell держит non-owning указатель на cfc_source_t (живёт в SourcePool
* композитора). На каждом draw_content():
* 1. cfc_source_get_latest — snapshot последнего кадра в VRAM
* 2. если ACTIVE/STALE — cfc_cugrid_resize_nv12 в свою geom_
* 3. если DEAD/CONNECTING — пропуск (cell остаётся blacked out)
*
* Decorations (label, border) рисуются в Cell::draw() поверх content'а.
*
* Лицензия: LGPL-2.1+
*/
#ifndef CUFRAMES_COMPOSER_CPP_CAMERA_CELL_HPP
#define CUFRAMES_COMPOSER_CPP_CAMERA_CELL_HPP
#include "../source.h"
#include "cell.hpp"
#include <string>
namespace cfc {
class CameraCell : public Cell {
public:
CameraCell(const Rect& geom, cfc_source_t* source, std::string source_key = {})
: Cell(geom), source_(source), source_key_(std::move(source_key)) {}
void set_source(cfc_source_t* src) noexcept { source_ = src; }
cfc_source_t* source() const noexcept { return source_; }
const std::string& source_key() const noexcept { return source_key_; }
protected:
void draw_content(CUstream stream, NV12Ref& dst) override;
private:
cfc_source_t* source_; /* non-owning — pool владеет */
std::string source_key_;
};
} // namespace cfc
#endif /* CUFRAMES_COMPOSER_CPP_CAMERA_CELL_HPP */