Files
Loongson_2k0300_SmartCar_Fr…/model/test_model.cpp

31 lines
751 B
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.
#include "model/model.hpp"
#include <cstdio>
#include <cstring>
#include <cstdlib>
int main()
{
if (!model_init("./model/nanodet.bin")) {
printf("model_init failed\n");
return 1;
}
// 造一张假 160×120×3 测试图
uint8_t* img = new uint8_t[160*120*3];
std::memset(img, 128, 160*120*3);
DetectBox boxes[16];
for (int i = 0; i < 5; ++i) {
int n = model_detect(img, 160, 120, boxes, 16, 0.3f);
printf("run %d: %d detections\n", i, n);
for (int j = 0; j < n; ++j)
printf(" cls=%d conf=%.3f xy=(%.0f,%.0f)\n",
boxes[j].cls, boxes[j].conf, boxes[j].cx, boxes[j].cy);
}
delete[] img;
model_deinit();
printf("OK\n");
return 0;
}