From b9cebc5aa385452ada391247e801daa6e251a125 Mon Sep 17 00:00:00 2001 From: 11566hyc <123456789> Date: Tue, 11 Feb 2025 10:34:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E6=9F=A5=E7=9B=AE=E6=A0=87=E6=A3=80?= =?UTF-8?q?=E6=B5=8B=E5=BC=82=E5=B8=B8=EF=BC=8C=E6=96=B0=E5=A2=9E=E4=BF=9D?= =?UTF-8?q?=E5=AD=98Y16=E5=9B=BE=E5=83=8F=E6=B5=8B=E8=AF=95=E7=94=A8?= =?UTF-8?q?=E5=87=BD=E6=95=B0=EF=BC=8C=E6=96=B0=E5=A2=9E=E6=A0=B9=E6=8D=AE?= =?UTF-8?q?=E5=8A=A8=E6=80=81=E6=96=87=E4=BB=B6=E6=98=AF=E5=90=A6=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E8=AF=BB=E5=8F=96=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Console_SOT_Ground_extTLD_RGB.cpp | 2 +- NeoTracker/src/Arith_Detector.cpp | 2 +- NeoTracker/src/NeoArithStandardDll.cpp | 97 ++++++++++++++++++- NeoTracker/src/NeoArithStandardDll.h | 7 +- 4 files changed, 99 insertions(+), 9 deletions(-) diff --git a/NeoTracker/console_test/Console_SOT_Ground_extTLD_RGB.cpp b/NeoTracker/console_test/Console_SOT_Ground_extTLD_RGB.cpp index a26a3f2..e89d895 100644 --- a/NeoTracker/console_test/Console_SOT_Ground_extTLD_RGB.cpp +++ b/NeoTracker/console_test/Console_SOT_Ground_extTLD_RGB.cpp @@ -328,7 +328,7 @@ int main() if (2 == bcmd) { // 解锁传统跟踪器 - ARIDLL_unLockCommand(pTracker, SelectCX, SelectCY, 0); + ARIDLL_unLockCommand(pTracker); #if TEST_WITH_AIT // 解锁AI跟踪器 g_GLB_AITracker->stopTrack(); diff --git a/NeoTracker/src/Arith_Detector.cpp b/NeoTracker/src/Arith_Detector.cpp index 6117648..086caf5 100644 --- a/NeoTracker/src/Arith_Detector.cpp +++ b/NeoTracker/src/Arith_Detector.cpp @@ -52,7 +52,7 @@ BBOOL Detectors::Init(SINT32 nWidth, SINT32 nHeight, CENTERRECT mmCenterRect) mDetPara.bEnableDetcetSmallTarget = true; mDetPara.bEnableDetcetAreaTarget = true; mDetPara.bEnableDetcetDimTarget = false; - mDetPara.fSmallDetectGDK = 5; + mDetPara.fSmallDetectGDK = 7.0; //适配3315,避免小目标过多 diff --git a/NeoTracker/src/NeoArithStandardDll.cpp b/NeoTracker/src/NeoArithStandardDll.cpp index 00e21a8..c659932 100644 --- a/NeoTracker/src/NeoArithStandardDll.cpp +++ b/NeoTracker/src/NeoArithStandardDll.cpp @@ -2,7 +2,17 @@ #include "Arith_EOController.h" #include "Arith_Bbox.h" #include "Version.h" - +#include +#include // 存文件 +//#include // 包含 chrono 库--统计耗时 +#ifdef __linux__ +#include +#define ACCESS access +#elif _WIN32 +#include +#include +#define ACCESS _access +#endif // 获取外部参数 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); } +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(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) { //算法输入信息整理【调试】 @@ -52,10 +118,24 @@ int ARIDLL_RunController(ArithHandle hArithSrc, GD_VIDEO_FRAME_S img, ARIDLL_INP LOG_ERROR("{0}, {1}, {2}, Imgage format not support width stride", __FILE__, __FUNCTION__, __LINE__); return -1; } - + // 获取算法指针 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(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); @@ -600,7 +680,7 @@ void ARIDLL_OutputPipeTarget(Arith_EOController* pArith, ARIDLL_OUTPUT* pstOutpu { memcpy(pt_detObj, &obj, sizeof(ARIDLL_OBJINFO)); 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, (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); @@ -785,7 +865,8 @@ STD_TRACKER_API ARIDLL_OBJINFO ARIDLL_LockOrUnLock(ArithHandle hArithSrc, GD_VID } 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; } @@ -807,4 +888,10 @@ STD_TRACKER_API int ARIDLL_Sort_PipeByDistance(ArithHandle hArithSrc, ARIDLL_OUT } } 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; } \ No newline at end of file diff --git a/NeoTracker/src/NeoArithStandardDll.h b/NeoTracker/src/NeoArithStandardDll.h index 70695fa..9ebd996 100644 --- a/NeoTracker/src/NeoArithStandardDll.h +++ b/NeoTracker/src/NeoArithStandardDll.h @@ -440,8 +440,11 @@ STD_TRACKER_API ARIDLL_OBJINFO ARIDLL_LockOrUnLock(ArithHandle hArithSrc, GD_VID **********************************************************/ STD_TRACKER_API int ARIDLL_Sort_PipeByDistance(ArithHandle hArithSrc, ARIDLL_OUTPUT* pstOutput); -/*获取编译时间和版本信息*/ -STD_TRACKER_API std::string Get_Version_Time(); +/********************************************************* +* 功能描述:根据动态文件是否存在,进行配置文件加载 --- 动态文件默认为init,并在 init <----> reset 之间循环使用 +*********************************************************/ +STD_TRACKER_API bool ARIDLL_Read_Config(ArithHandle hArithSrc, const char* ConfigPath); + #ifdef __cplusplus } #endif