|
|
|
@ -2,7 +2,17 @@
|
|
|
|
#include "Arith_EOController.h"
|
|
|
|
#include "Arith_EOController.h"
|
|
|
|
#include "Arith_Bbox.h"
|
|
|
|
#include "Arith_Bbox.h"
|
|
|
|
#include "Version.h"
|
|
|
|
#include "Version.h"
|
|
|
|
|
|
|
|
#include <iostream>
|
|
|
|
|
|
|
|
#include <fstream> // 存文件
|
|
|
|
|
|
|
|
//#include <chrono> // 包含 chrono 库--统计耗时
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#define ACCESS access
|
|
|
|
|
|
|
|
#elif _WIN32
|
|
|
|
|
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include <io.h>
|
|
|
|
|
|
|
|
#define ACCESS _access
|
|
|
|
|
|
|
|
#endif
|
|
|
|
// 获取外部参数
|
|
|
|
// 获取外部参数
|
|
|
|
void ARIDLL_GetInputPara(Arith_EOController* pArith,int nWidth, int nHeight, ARIDLL_INPUTPARA stInputPara);
|
|
|
|
void ARIDLL_GetInputPara(Arith_EOController* pArith,int nWidth, int nHeight, ARIDLL_INPUTPARA stInputPara);
|
|
|
|
|
|
|
|
|
|
|
|
@ -38,7 +48,63 @@ void ARIDLL_EOArithInitWithMode(ArithHandle hArith, int nWidth, int nHeight, GD_
|
|
|
|
{
|
|
|
|
{
|
|
|
|
return ((Arith_EOController*)hArith)->Arith_SystemInit(nWidth, nHeight, nSysMode, nScenMode);
|
|
|
|
return ((Arith_EOController*)hArith)->Arith_SystemInit(nWidth, nHeight, nSysMode, nScenMode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
int save_Y16(ArithHandle h,GD_VIDEO_FRAME_S img, const int width, const int height, const int unFrmId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
const std::string path = "./Neolog/Ori_Y16_";
|
|
|
|
|
|
|
|
// 将Y16数据保存为二进制文件
|
|
|
|
|
|
|
|
const std::string filePath = path + std::to_string(unFrmId) + ".yuv";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::ofstream outFile(filePath, std::ios::binary);
|
|
|
|
|
|
|
|
if (!outFile.is_open())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
LOG_DEBUG("无法创建文件");
|
|
|
|
|
|
|
|
std::cerr << "无法创建文件: " << filePath << std::endl;
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outFile.write(reinterpret_cast<const char*>(img.u64VirAddr[0]), width * height * sizeof(uint16_t));
|
|
|
|
|
|
|
|
outFile.close();
|
|
|
|
|
|
|
|
LOG_DEBUG("Y16图像数据已保存到:{}", filePath);
|
|
|
|
|
|
|
|
std::cout << "Y16图像数据已保存到: " << filePath << std::endl;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
int read_y16(Arith_EOController* pArith, GD_VIDEO_FRAME_S img, const int width, const int height, const int unFrmId)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
// 创建OpenCV Mat对象存储Y16数据
|
|
|
|
|
|
|
|
cv::Mat y16Image(height, width, CV_16UC1, img.u64VirAddr[0]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 将Y16数据归一化到0-255范围(转换为8位)
|
|
|
|
|
|
|
|
cv::Mat y8Image;
|
|
|
|
|
|
|
|
double minVal, maxVal;
|
|
|
|
|
|
|
|
cv::minMaxLoc(y16Image, &minVal, &maxVal); // 找到最小值和最大值
|
|
|
|
|
|
|
|
y16Image.convertTo(y8Image, CV_8UC1, 255.0 / maxVal); // 归一化并转换为8位
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
bool read_config(Arith_EOController* pArith, const char* path)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//读配置文件
|
|
|
|
|
|
|
|
char resPath[256] = { 0 };
|
|
|
|
|
|
|
|
static std::string name = "init";
|
|
|
|
|
|
|
|
snprintf(resPath, 256, "%s/%s", path, name.c_str());
|
|
|
|
|
|
|
|
std::string configpath = std::string(path) + "/ArithPara.json";
|
|
|
|
|
|
|
|
bool read_state = false;
|
|
|
|
|
|
|
|
if (ACCESS(resPath, 0) == 0 && "reset" == name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "name = " << name << std::endl;
|
|
|
|
|
|
|
|
LOG_DEBUG("name = :{}", name);
|
|
|
|
|
|
|
|
read_state = ARIDLL_ReadSetParamFile(pArith, configpath.c_str());
|
|
|
|
|
|
|
|
name = "init";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ACCESS(resPath, 0) == 0 && "init" == name)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
std::cout << "name = " << name << std::endl;
|
|
|
|
|
|
|
|
LOG_DEBUG("name = :{}", name);
|
|
|
|
|
|
|
|
read_state = ARIDLL_ReadSetParamFile(pArith, configpath.c_str());
|
|
|
|
|
|
|
|
name = "reset";
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return read_state;
|
|
|
|
|
|
|
|
}
|
|
|
|
int ARIDLL_RunController(ArithHandle hArithSrc, GD_VIDEO_FRAME_S img, ARIDLL_INPUTPARA stInputPara, ARIDLL_OUTPUT* pstOutput)
|
|
|
|
int ARIDLL_RunController(ArithHandle hArithSrc, GD_VIDEO_FRAME_S img, ARIDLL_INPUTPARA stInputPara, ARIDLL_OUTPUT* pstOutput)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
//算法输入信息整理【调试】
|
|
|
|
//算法输入信息整理【调试】
|
|
|
|
@ -55,7 +121,21 @@ int ARIDLL_RunController(ArithHandle hArithSrc, GD_VIDEO_FRAME_S img, ARIDLL_INP
|
|
|
|
|
|
|
|
|
|
|
|
// 获取算法指针
|
|
|
|
// 获取算法指针
|
|
|
|
Arith_EOController* pArith = (Arith_EOController*)hArithSrc;
|
|
|
|
Arith_EOController* pArith = (Arith_EOController*)hArithSrc;
|
|
|
|
|
|
|
|
/*自行根据路径下文件状态,读配置文件,3588耗时:读取配置文件约2ms,不读取配置文件几乎不耗时*/
|
|
|
|
|
|
|
|
// auto start = std::chrono::steady_clock::now();
|
|
|
|
|
|
|
|
//bool state = read_config(pArith, "/nfsroot/hyc/config");
|
|
|
|
|
|
|
|
// 记录结束时间
|
|
|
|
|
|
|
|
//auto end = std::chrono::steady_clock::now();
|
|
|
|
|
|
|
|
// 计算耗时(毫秒)
|
|
|
|
|
|
|
|
//auto duration = std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count();
|
|
|
|
|
|
|
|
//std::cout << "耗时: " << duration << " 毫秒"<<" state = "<< state << std::endl;
|
|
|
|
|
|
|
|
//每秒存1帧Y16 ---- 3315测试
|
|
|
|
|
|
|
|
/*if (0 == stInputPara.unFrmId % GLB_FRM_FREQ)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
save_Y16(pArith, img, img.u32Width, img.u32Height, stInputPara.unFrmId);
|
|
|
|
|
|
|
|
read_y16(pArith, img, img.u32Width, img.u32Height, stInputPara.unFrmId);
|
|
|
|
|
|
|
|
}*/
|
|
|
|
|
|
|
|
/*******************************************************************************************/
|
|
|
|
// 系统传参
|
|
|
|
// 系统传参
|
|
|
|
ARIDLL_GetInputPara(pArith, img.u32Width, img.u32Height, stInputPara);
|
|
|
|
ARIDLL_GetInputPara(pArith, img.u32Width, img.u32Height, stInputPara);
|
|
|
|
|
|
|
|
|
|
|
|
@ -600,7 +680,7 @@ void ARIDLL_OutputPipeTarget(Arith_EOController* pArith, ARIDLL_OUTPUT* pstOutpu
|
|
|
|
{
|
|
|
|
{
|
|
|
|
memcpy(pt_detObj, &obj, sizeof(ARIDLL_OBJINFO));
|
|
|
|
memcpy(pt_detObj, &obj, sizeof(ARIDLL_OBJINFO));
|
|
|
|
int nAlaNum = pstOutput->nAlarmObjCnts;
|
|
|
|
int nAlaNum = pstOutput->nAlarmObjCnts;
|
|
|
|
LOG_DEBUG("pstOutput:stAlarmObjs[{ }]:nOutputID:{}, XYWH:[{} {} {} {}],nPipeLostCnt:{}, fAz:{},fPt:{},unClsType:{}",
|
|
|
|
LOG_DEBUG("pstOutput->stAlarmObjs:{},nOutputID:{}, XYWH:[{} {} {} {}],nPipeLostCnt:{}, fAz:{},fPt:{},unClsType:{}",
|
|
|
|
pstOutput->nAlarmObjCnts, pstOutput->stAlarmObjs[nAlaNum].nOutputID, (int)pstOutput->stAlarmObjs[nAlaNum].nX, (int)pstOutput->stAlarmObjs[nAlaNum].nY,
|
|
|
|
pstOutput->nAlarmObjCnts, pstOutput->stAlarmObjs[nAlaNum].nOutputID, (int)pstOutput->stAlarmObjs[nAlaNum].nX, (int)pstOutput->stAlarmObjs[nAlaNum].nY,
|
|
|
|
(int)pstOutput->stAlarmObjs[nAlaNum].nObjW, (int)pstOutput->stAlarmObjs[nAlaNum].nObjH, pstOutput->stAlarmObjs[nAlaNum].nPipeLostCnt,
|
|
|
|
(int)pstOutput->stAlarmObjs[nAlaNum].nObjW, (int)pstOutput->stAlarmObjs[nAlaNum].nObjH, pstOutput->stAlarmObjs[nAlaNum].nPipeLostCnt,
|
|
|
|
pstOutput->stAlarmObjs[nAlaNum].fAz, pstOutput->stAlarmObjs[nAlaNum].fPt, pstOutput->stAlarmObjs[nAlaNum].unClsType);
|
|
|
|
pstOutput->stAlarmObjs[nAlaNum].fAz, pstOutput->stAlarmObjs[nAlaNum].fPt, pstOutput->stAlarmObjs[nAlaNum].unClsType);
|
|
|
|
@ -785,7 +865,8 @@ STD_TRACKER_API ARIDLL_OBJINFO ARIDLL_LockOrUnLock(ArithHandle hArithSrc, GD_VID
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
else
|
|
|
|
{
|
|
|
|
{
|
|
|
|
obj = ARIDLL_LockTarget(pArith, img, nX, nY, 0, 0);
|
|
|
|
//obj = ARIDLL_LockTarget(pArith, img, nX, nY, 0, 0);
|
|
|
|
|
|
|
|
ARIDLL_LockCommand(pArith, nX, nY, 0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return obj;
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -808,3 +889,9 @@ STD_TRACKER_API int ARIDLL_Sort_PipeByDistance(ArithHandle hArithSrc, ARIDLL_OUT
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return Index;
|
|
|
|
return Index;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
STD_TRACKER_API bool ARIDLL_Read_Config(ArithHandle hArithSrc, const char* ConfigPath)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Arith_EOController* pArith = (Arith_EOController*)hArithSrc;
|
|
|
|
|
|
|
|
bool read_state = read_config(pArith, ConfigPath);
|
|
|
|
|
|
|
|
return read_state;
|
|
|
|
|
|
|
|
}
|