|
|
// 单目标对空跟踪流程测试,关注跟踪器FPS
|
|
|
|
|
|
#include "NeoArithStandardDll.h"
|
|
|
#include "utils.h"
|
|
|
#include <iostream>
|
|
|
#include <memory>
|
|
|
#include <string.h>
|
|
|
#include <algorithm>
|
|
|
#include <thread>
|
|
|
#include "opencv2/opencv.hpp"
|
|
|
#include "TestAPI_Profile.h"
|
|
|
using std::cout;
|
|
|
using std::endl;
|
|
|
|
|
|
#define Test_Len 1000
|
|
|
|
|
|
int TestAPI_SOT_Sky_Y16()
|
|
|
{
|
|
|
// 产生一个仿真Y16数据
|
|
|
int nWidth = 640;
|
|
|
int nHeight = 512;
|
|
|
SimTargetImage factory(nWidth, nHeight);
|
|
|
|
|
|
factory.setBackGround(120, 0);
|
|
|
// 叠加一个初始目标
|
|
|
Target t;
|
|
|
|
|
|
t.x = 100;
|
|
|
t.y = 100;
|
|
|
t.width = 3;
|
|
|
t.height = 3;
|
|
|
t.vw = 0;
|
|
|
t.vh = 0;
|
|
|
t.vx = 1;
|
|
|
t.vy = 1;
|
|
|
t.color = cv::Scalar(255,255,255);
|
|
|
factory.addTarget(t);
|
|
|
//t.addTexture(cow_png,cow_png_len);
|
|
|
|
|
|
|
|
|
// 创建算法句柄
|
|
|
ArithHandle pTracker = STD_CreatEOArithHandle();
|
|
|
// 初始化为凝视-对空模式
|
|
|
ARIDLL_EOArithInitWithMode(pTracker,nWidth,nHeight,GD_PIXEL_FORMAT_E::GD_PIXEL_FORMAT_GRAY_Y16,
|
|
|
GLB_SYS_MODE::GLB_SYS_STARE,GLB_SCEN_MODE::GLB_SCEN_SKY);
|
|
|
|
|
|
// 算法输入部分
|
|
|
ARIDLL_INPUTPARA stInputPara = { 0 };
|
|
|
stInputPara.unFrmId++;
|
|
|
stInputPara.stCameraInfo.fPixelSize = 15;
|
|
|
stInputPara.stCameraInfo.nFocus = 300;
|
|
|
|
|
|
// 算法输出部分
|
|
|
ARIDLL_OUTPUT stOutput = { 0 };
|
|
|
|
|
|
|
|
|
// 模拟算法执行流程
|
|
|
int nTrackSuc = 0;
|
|
|
for (int i = 0; i < Test_Len; i++)
|
|
|
{
|
|
|
stInputPara.unFrmId++;
|
|
|
|
|
|
|
|
|
factory.update();
|
|
|
|
|
|
cv::Mat src = factory.getImageY16();
|
|
|
|
|
|
Target* gt = factory.getTarget(0);
|
|
|
|
|
|
|
|
|
// 下发点锁定指令
|
|
|
if (i == 5)
|
|
|
{
|
|
|
ARIDLL_LockCommand(pTracker, (int)gt->x, (int)gt->y,0,0);
|
|
|
}
|
|
|
|
|
|
// 构建图像类型
|
|
|
GD_VIDEO_FRAME_S img = { 0 };
|
|
|
img.enPixelFormat = GD_PIXEL_FORMAT_E::GD_PIXEL_FORMAT_GRAY_Y16;
|
|
|
img.u32Width = nWidth;
|
|
|
img.u32Height = nHeight;
|
|
|
img.u32Stride[0] = img.u32Width * 2;
|
|
|
img.u64VirAddr[0] = (UBYTE8*)src.data;
|
|
|
|
|
|
// 红外目标检测API调用
|
|
|
int targetNum = 0;
|
|
|
|
|
|
// 目标搜索仅在搜索状态执行,保持与经典对空算法一致,用于与上一版本耗时对比
|
|
|
// 新跟踪器中搜索在单独线程中不间断执行,本demo中仅展示用法,不做并行示范。
|
|
|
//if (stOutput.nStatus == GLB_STATUS_SEARCH)
|
|
|
{
|
|
|
targetNum = ARIDLL_SearchFrameTargets(pTracker, img);
|
|
|
}
|
|
|
|
|
|
// 运行算法主控逻辑API
|
|
|
ARIDLL_RunController(pTracker, img, stInputPara, &stOutput);
|
|
|
|
|
|
|
|
|
|
|
|
std::cout << gt->x << " " << gt->y << std::endl;
|
|
|
|
|
|
|
|
|
#ifdef SHOW
|
|
|
// 绘制跟踪结果
|
|
|
cv::Mat rgb = factory.getImageRGB();
|
|
|
showArithInfo(rgb,&stOutput);
|
|
|
imshow("res",rgb);
|
|
|
cv::waitKey(1);
|
|
|
#endif
|
|
|
|
|
|
if (stOutput.nStatus == GLB_STATUS_TRACK && stOutput.nTrackObjCnts == 1)
|
|
|
{
|
|
|
if (abs(stOutput.stTrackers[0].nX - gt->x) < 5 &&
|
|
|
abs(stOutput.stTrackers[0].nY - gt->y) < 5)
|
|
|
{
|
|
|
nTrackSuc++;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
if (nTrackSuc > Test_Len * 0.9)
|
|
|
{
|
|
|
cout << "pass" << endl;
|
|
|
}
|
|
|
|
|
|
printf("Suc:%d/A:%d\n",nTrackSuc,Test_Len);
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
} |