You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

97 lines
2.3 KiB

// 单目标对地跟踪流程测试:将TLD从算法中剥离到外部导致API调用形式调整int argc,char *argv[]
// 读取avi视频进行测试
#include "NeoArithStandardDll.h"
#include "utils.h"
#include <iostream>
#include <memory>
#include <string.h>
#include <algorithm>
#include <thread>
#include "opencv2/opencv.hpp"
using std::cout;
using std::endl;
using std::string;
int main(int argc,char *argv[])
{
cv::VideoCapture capture(argv[1]);
printf("argv[0]:%s\n",argv[1]);
int nWidth = int(capture.get(cv::CAP_PROP_FRAME_WIDTH));
int nHeight = int(capture.get(cv::CAP_PROP_FRAME_HEIGHT));
// 创建算法句柄
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;
while(1)
{
stInputPara.unFrmId++;
capture.read(frame);
if(frame.empty())
break;
// 下发面锁定指令
if (stInputPara.unFrmId == 10)
{
ARIDLL_LockCommand(pTracker, 228*2,279*2,40,25);
}
// 构建图像类型
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] = frame.data;
// 运行算法主控逻辑API
ARIDLL_RunController(pTracker, img, stInputPara, &stOutput);
auto trackerOut = stOutput.stTrackers[0];
cv::Rect outRect;
outRect.width = MAX(15,(int)trackerOut.nObjW);
outRect.height= MAX(15, (int)trackerOut.nObjH);
outRect.x = (int)trackerOut.nX-outRect.width/2;
outRect.y = (int)trackerOut.nY-outRect.height/2;
cv::rectangle(frame,outRect,cv::Scalar(0,0,255));
//cv::resize(frame,frame,cv::Size(nWidth/2,nHeight/2));
//imshow("res",frame);
//cv::waitKey(2);
}
if(fabs(stOutput.stTrackers[0].nX - 1508) < 20 &&
fabs(stOutput.stTrackers[0].nY - 750) < 20)
{
cout << "pass" << endl;
}
return 0;
}