Add async model thread, vision FPS throttle, configurable FPS, .gitignore __pycache__

This commit is contained in:
2026-05-25 11:04:05 +08:00
parent 28d9c6da58
commit 610f0a7549
8 changed files with 503 additions and 55 deletions

View File

@@ -1,11 +1,31 @@
#pragma once
#include "types.hpp"
// TFLM 模型推理接口 — 占位实现,后续接入模型
// 用法:
// 1. 将 .tflite 模型转为 C header 数组放入 model/ 目录
// 2. 实现 model_init() / model_infer()
// 3. 在 element.cpp 中调用
// NanoDetHeatV4 检测结果
struct DetectBox {
int cls; // 0=红绿灯, 1=锥桶, 2=人行道
float conf; // 置信度 [0,1]
float cx, cy; // 中心像素坐标 (160×120)
float w, h; // 宽高像素
};
bool model_init();
void model_infer(const uint8* image, int w, int h, float* output, int num_classes);
// 初始化模型, 加载权重
// weight_path: nanodet.bin 路径
// 返回 true 成功
bool model_init(const char* weight_path);
// 运行推理, 返回检测框数量
// bgr: RGB 图像数据 (H×W×3, uint8, [0,255])
// w, h: 图像尺寸 (必须 160×120)
// boxes: 输出检测框数组
// max: 最大检测框数
// th: 置信度阈值 (推荐 0.6~0.8)
int model_detect(const uint8* bgr, int w, int h,
DetectBox* boxes, int max,
float th);
// 释放模型内存
void model_deinit();
// 模型就绪标志
bool model_ready();