清理编码器+死代码+可读性整理: 删除ENCODER类(含UB析构), MotorController简化为PWM+GPIO裸控制器, 移除mortor_kp/ki/kd全局变量, 排除vl53l0x/zebra_detect死代码, 修复image_cv行列写反, 清理无关include
Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus <clio-agent@sisyphuslabs.ai>
This commit is contained in:
+44
-10
@@ -495,17 +495,10 @@ static void init_lut() {
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
// 前向推理
|
||||
// 前向推理 — 模型计算体 (preproc 已由调用方完成)
|
||||
// ============================================================
|
||||
static void forward(const uint8* bgr) {
|
||||
static void model_compute() {
|
||||
float* in = m->preproc;
|
||||
for (int c=0; c<3; ++c) {
|
||||
int sc=2-c; float* ch=in+c*120*160;
|
||||
for (int y=0; y<120; ++y) {
|
||||
const uint8* row=bgr+y*160*3;
|
||||
for (int x=0; x<160; ++x) ch[y*160+x]=g_lut[row[x*3+sc]];
|
||||
}
|
||||
}
|
||||
|
||||
// stem: 3→6, s2 (fused)
|
||||
conv_bn_relu(m->stem, in, wf("s.0.weight"), nullptr,
|
||||
@@ -528,6 +521,41 @@ static void forward(const uint8* bgr) {
|
||||
conv2d(m->sz, m->sh, wf("sz.weight"), wf("sz.bias"), 15, 20, 24, 2, 1, 1, 1);
|
||||
}
|
||||
|
||||
// ── 自写 640×480 → 3×120×160 float planar (4×4 box avg + BGR→RGB + /255) ──
|
||||
static void preproc_640(const uint8* bgr) {
|
||||
float* in = m->preproc;
|
||||
const int sw=640, sh=480;
|
||||
for(int c=0;c<3;++c){
|
||||
int sc=2-c;
|
||||
float* ch = in + c*120*160;
|
||||
for(int y=0;y<120;++y){
|
||||
int iy=y*4;
|
||||
for(int x=0;x<160;++x){
|
||||
int ix=x*4, sum=0;
|
||||
for(int dy=0;dy<4;++dy)
|
||||
for(int dx=0;dx<4;++dx)
|
||||
sum += bgr[(iy+dy)*sw*3 + (ix+dx)*3 + sc];
|
||||
ch[y*160+x] = (float)sum * (1.0f/(16.0f*255.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── 原版: 160×120 BGR → 3×120×160 float planar ──
|
||||
static void preproc_160(const uint8* bgr) {
|
||||
float* in = m->preproc;
|
||||
for (int c=0; c<3; ++c) {
|
||||
int sc=2-c; float* ch=in+c*120*160;
|
||||
for (int y=0; y<120; ++y) {
|
||||
const uint8* row=bgr+y*160*3;
|
||||
for (int x=0; x<160; ++x) ch[y*160+x]=g_lut[row[x*3+sc]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// ── 内部: preproc + compute ──
|
||||
static void forward(const uint8* bgr) { preproc_160(bgr); model_compute(); }
|
||||
|
||||
// ============================================================
|
||||
// 接口
|
||||
// ============================================================
|
||||
@@ -555,7 +583,13 @@ bool model_v10_init(const char* path) {
|
||||
}
|
||||
|
||||
int model_v10_detect(const uint8* bgr, int w, int h, DetectBoxV10* boxes, int max, const float* thresh) {
|
||||
if(!g_rdy||w!=160||h!=120) return 0;
|
||||
if(!g_rdy) return 0;
|
||||
if(w==640 && h==480) {
|
||||
preproc_640(bgr);
|
||||
model_compute();
|
||||
return decode(boxes,max,thresh);
|
||||
}
|
||||
if(w!=160||h!=120) return 0;
|
||||
forward(bgr);
|
||||
return decode(boxes,max,thresh);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user