|
|
// 单目标对地跟踪流程测试:将TLD从算法中剥离到外部,导致API调用形式调整
|
|
|
// 读取avi视频进行测试
|
|
|
|
|
|
|
|
|
#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;
|
|
|
using std::string;
|
|
|
|
|
|
#define Test_Len 1000
|
|
|
|
|
|
int TestAPI_SOT_Ground_RGB()
|
|
|
{
|
|
|
// 产生一个仿真Y16数据
|
|
|
int nWidth = 1280;
|
|
|
int nHeight = 1024;
|
|
|
SimTargetImage factory(nWidth, nHeight);
|
|
|
|
|
|
factory.setBackGround(128, 10);
|
|
|
// 叠加一个初始目标
|
|
|
Target t;
|
|
|
t.x = 100;
|
|
|
t.y = 100;
|
|
|
t.width = 30;
|
|
|
t.height = 30;
|
|
|
t.vw = 0;
|
|
|
t.vh = 0;
|
|
|
t.vx = 1;
|
|
|
t.vy = 1;
|
|
|
t.addTexture(cow_png,cow_png_len);
|
|
|
factory.addTarget(t);
|
|
|
//
|
|
|
|
|
|
t.x = 300;
|
|
|
t.y = 250;
|
|
|
t.width = 100;
|
|
|
t.height = 100;
|
|
|
t.vw = 0;
|
|
|
t.vh = 0;
|
|
|
t.vx = 0;
|
|
|
t.vy = 0;
|
|
|
t.color = cv::Scalar(20,20,20);
|
|
|
factory.addOcc(t);
|
|
|
|
|
|
|
|
|
|
|
|
// 创建算法句柄
|
|
|
ArithHandle pTracker = STD_CreatEOArithHandle();
|
|
|
|
|
|
// 初始化为凝视-对地模式
|
|
|
ARIDLL_EOArithInitWithMode(pTracker,nWidth,nHeight,GD_PIXEL_FORMAT_E::GD_PIXEL_FORMAT_RGB_PACKED,
|
|
|
GLB_SYS_MODE::GLB_SYS_STARE,GLB_SCEN_MODE::GLB_SCEN_GROUND);
|
|
|
|
|
|
// 算法输入部分
|
|
|
ARIDLL_INPUTPARA stInputPara = { 0 };
|
|
|
stInputPara.unFrmId++;
|
|
|
stInputPara.stCameraInfo.fPixelSize = 15;
|
|
|
stInputPara.stCameraInfo.nFocus = 300;
|
|
|
|
|
|
// 算法输出部分
|
|
|
ARIDLL_OUTPUT stOutput = { 0 };
|
|
|
|
|
|
|
|
|
// 模拟算法执行流程
|
|
|
int nTrackSuc = 0;
|
|
|
cv::Mat frame;
|
|
|
for(int i = 0; i < Test_Len; i++)
|
|
|
{
|
|
|
stInputPara.unFrmId++;
|
|
|
|
|
|
factory.update();
|
|
|
cv::Mat src = factory.getImageRGB();
|
|
|
Target* gt = factory.getTarget(0);
|
|
|
|
|
|
|
|
|
|
|
|
// 构建图像类型
|
|
|
GD_VIDEO_FRAME_S img = { 0 };
|
|
|
img.enPixelFormat = GD_PIXEL_FORMAT_E::GD_PIXEL_FORMAT_RGB_PACKED;
|
|
|
img.u32Width = nWidth;
|
|
|
img.u32Height = nHeight;
|
|
|
img.u32Stride[0] = img.u32Width * 3;
|
|
|
img.u64VirAddr[0] = (unsigned char*)src.data;
|
|
|
|
|
|
|
|
|
|
|
|
// 下发面锁定指令
|
|
|
if (stInputPara.unFrmId == 3)
|
|
|
{
|
|
|
//ARIDLL_LockCommand(pTracker, gt->x,gt->y,gt->width,gt->height);
|
|
|
ARIDLL_LockTarget(pTracker, img, gt->x,gt->y,gt->width,gt->height);
|
|
|
}
|
|
|
|
|
|
|
|
|
cv::TickMeter tm;
|
|
|
tm.start();
|
|
|
|
|
|
// 运行算法主控逻辑API
|
|
|
ARIDLL_RunController(pTracker, img, stInputPara, &stOutput);
|
|
|
|
|
|
tm.stop();
|
|
|
|
|
|
printf("time:%.2f\n",tm.getTimeMilli());
|
|
|
|
|
|
#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++;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
|
|
|
printf("Suc:%d/A:%d\n",nTrackSuc,Test_Len);
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
}
|