仓库结构: edge/ 设备端(原根目录设备端代码整体移入) control/ 管理端(清理后) docs/ 文档(PRD 移入 design/) README.md 根导航(新增) 清理: - control/.brainstorm 临时草稿删除 - control 根级重复文档(API表/PRD_04)并入 docs/design/ - control/plan.md -> docs/implementation/control-plan.md - control/safesightd-linux-arm64 二进制取消版本控制(.gitignore) - edge/transform 模型转换产物归入 models/,onnx/pt 大源文件取消跟踪(.gitignore) - Readme.md(PRD) -> docs/design/PRD_Product_v1.2.md(避开 README 大小写冲突) 更新: - 根 README.md 导航、docs/README.md 文档索引 - deployment.md/检查表路径加 edge/ 前缀 - .gitignore 重写(edge/control 分区规则)
65 lines
1.6 KiB
C++
65 lines
1.6 KiB
C++
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <memory>
|
|
#include <mutex>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
#include <vector>
|
|
|
|
#include "frame/frame.h"
|
|
|
|
// SharedState is a process-wide, cross-plugin state store.
|
|
// It is implemented in a shared library so all dynamically loaded node plugins
|
|
// see the same singleton instance.
|
|
|
|
namespace rk3588 {
|
|
|
|
#if defined(_WIN32)
|
|
#if defined(RK3588_BUILD_SHARED_STATE)
|
|
#define RK3588_SHARED_STATE_API __declspec(dllexport)
|
|
#else
|
|
#define RK3588_SHARED_STATE_API __declspec(dllimport)
|
|
#endif
|
|
#else
|
|
#define RK3588_SHARED_STATE_API
|
|
#endif
|
|
|
|
struct TrackedObject {
|
|
int cls_id = -1;
|
|
int track_id = -1;
|
|
float score = 0.0f;
|
|
Rect bbox{}; // coordinates in snapshot image space (img_w/img_h)
|
|
bool confirmed = false;
|
|
};
|
|
|
|
struct TargetsSnapshot {
|
|
uint64_t update_steady_us = 0;
|
|
int img_w = 0;
|
|
int img_h = 0;
|
|
std::string model_name;
|
|
std::vector<TrackedObject> objects;
|
|
};
|
|
|
|
RK3588_SHARED_STATE_API uint64_t NowSteadyUs();
|
|
RK3588_SHARED_STATE_API std::string DefaultTrackedTargetsKey(const std::string& graph_name);
|
|
|
|
class RK3588_SHARED_STATE_API SharedState {
|
|
public:
|
|
static SharedState& Instance();
|
|
|
|
void SetTargets(std::string key, TargetsSnapshot snap);
|
|
std::shared_ptr<const TargetsSnapshot> GetTargets(const std::string& key) const;
|
|
void ClearTargets(const std::string& key);
|
|
|
|
private:
|
|
SharedState() = default;
|
|
SharedState(const SharedState&) = delete;
|
|
SharedState& operator=(const SharedState&) = delete;
|
|
|
|
mutable std::mutex mu_;
|
|
std::unordered_map<std::string, std::shared_ptr<const TargetsSnapshot>> targets_;
|
|
};
|
|
|
|
} // namespace rk3588
|