|
|
|
|
@ -48,63 +48,39 @@ 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<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 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;
|
|
|
|
|
//}
|
|
|
|
|
int ARIDLL_RunController(ArithHandle hArithSrc, GD_VIDEO_FRAME_S img, ARIDLL_INPUTPARA stInputPara, ARIDLL_OUTPUT* pstOutput)
|
|
|
|
|
{
|
|
|
|
|
//算法输入信息整理【调试】
|
|
|
|
|
@ -121,14 +97,6 @@ int ARIDLL_RunController(ArithHandle hArithSrc, GD_VIDEO_FRAME_S img, ARIDLL_INP
|
|
|
|
|
|
|
|
|
|
// 获取算法指针
|
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
@ -448,7 +416,8 @@ void ARIDLL_Output(Arith_EOController* pArith, ARIDLL_OUTPUT* pstOutput)
|
|
|
|
|
|
|
|
|
|
// 返回跟踪器状态
|
|
|
|
|
pstOutput->nStatus = pArith->g_GLB_stPara.nStatus;
|
|
|
|
|
|
|
|
|
|
LOG_DEBUG("pstOutput:pstOutput->nFrmNum:{},pstOutput->nSysMode:{}, pstOutput->nStatus:{}",
|
|
|
|
|
pstOutput->nFrmNum,pstOutput->nSysMode,pstOutput->nStatus);
|
|
|
|
|
// 目标输出,统一由管道牵头输出
|
|
|
|
|
ARIDLL_OutputPipeTarget(pArith, pstOutput);
|
|
|
|
|
}
|
|
|
|
|
@ -680,10 +649,10 @@ 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);
|
|
|
|
|
pstOutput->stAlarmObjs[nAlaNum].fAz, pstOutput->stAlarmObjs[nAlaNum].fPt, pstOutput->stAlarmObjs[nAlaNum].unClsType);*/
|
|
|
|
|
pstOutput->nAlarmObjCnts++;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -889,9 +858,3 @@ 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;
|
|
|
|
|
}
|