diff --git a/NeoTracker/src/Arith_PosAnalyse.cpp b/NeoTracker/src/Arith_PosAnalyse.cpp new file mode 100644 index 0000000..67a0946 --- /dev/null +++ b/NeoTracker/src/Arith_PosAnalyse.cpp @@ -0,0 +1,75 @@ +#include "Arith_PosAnalyse.h" + +ImagePosRecord::ImagePosRecord() +{ + reset(); +} + +ImagePosRecord::~ImagePosRecord() +{ +} + + +ImagePosRecord::STATUS ImagePosRecord::update(POINT32F pos) +{ + if (p_Last.x == 0 && p_Last.y == 0) + { + stPositonMove[ubEnd].x = 0; + stPositonMove[ubEnd].y = 0; + } + else + { + stPositonMove[ubEnd].x = pos.x - p_Last.x; + stPositonMove[ubEnd].y = pos.y - p_Last.y; + } + + p_Last = pos; + ubEnd = (ubEnd + 1) % TRACK_POS_REC_MAX; + nTotalCnt++; + + return Analyse(); +} + +void ImagePosRecord::reset() +{ + ubEnd = 0; + nTotalCnt = 0; + p_Last.x = 0; + p_Last.y = 0; + memset(stPositonMove, 0, sizeof(POINT32F) * TRACK_POS_REC_MAX); +} + + +ImagePosRecord::STATUS ImagePosRecord::Analyse() +{ + // + int VecFluCnt = 0; //速度波动 + int aFluCnt = 0; //加速度波动 + + if (nTotalCnt > 10) + { + for (size_t i = 0; i < MIN(TRACK_POS_REC_MAX, nTotalCnt); i++) + { + int indCurr = (ubEnd - i + TRACK_POS_REC_MAX) % TRACK_POS_REC_MAX; + int indLast = (ubEnd - i - 1 + TRACK_POS_REC_MAX) % TRACK_POS_REC_MAX; + auto movedisCurr = sqrt(stPositonMove[indCurr].x * stPositonMove[indCurr].x + stPositonMove[indCurr].y * stPositonMove[indCurr].y); + auto movedisLast = sqrt(stPositonMove[indLast].x * stPositonMove[indLast].x + stPositonMove[indLast].y * stPositonMove[indLast].y); + if (movedisCurr > 6) + { + VecFluCnt++; + } + + if (ABS(movedisCurr) > ABS(movedisLast) * 2 && ABS(movedisCurr) > 5) + { + aFluCnt++; + } + } + } + + if (VecFluCnt > 2 || aFluCnt > 0) + { + return STATUS::NOTSTABLE; + } + + return STATUS::STATBLE; +} \ No newline at end of file diff --git a/NeoTracker/src/Arith_PosAnalyse.h b/NeoTracker/src/Arith_PosAnalyse.h new file mode 100644 index 0000000..f743a91 --- /dev/null +++ b/NeoTracker/src/Arith_PosAnalyse.h @@ -0,0 +1,36 @@ +// 目标像方位置记录,并估计伺服控制状态,不稳定时不使用惯性预测 + + +#pragma once + +#include "Arith_Common.hpp" + + +class ImagePosRecord +{ + enum STATUS + { + STATBLE, + NOTSTABLE + }; +public: + ImagePosRecord(); + ~ImagePosRecord(); + +public: + STATUS update(POINT32F pos); // 更新坐标 + + void reset(); + + STATUS Analyse(); + +private: + UBYTE8 ubEnd; + SINT32 nTotalCnt; + POINT32F stPositonMove[TRACK_POS_REC_MAX]; //帧间运动 + + POINT32F p_Last; //起始点 + + // + BBOOL bStable; //稳态 +}; \ No newline at end of file diff --git a/NeoTracker/src/Arith_SkyTracker.cpp b/NeoTracker/src/Arith_SkyTracker.cpp index 80ca2e4..19fd8fa 100644 --- a/NeoTracker/src/Arith_SkyTracker.cpp +++ b/NeoTracker/src/Arith_SkyTracker.cpp @@ -362,6 +362,9 @@ TrackUnlockState SkyTracker::Track(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, { // 自动切换跟踪器 SetTrackModeAuto(img, p_GLB_Input); + + // 调整惯性预测建议 + m_posRecorder.update(m_TSky_Output.ObjectStatusDesc.ptPos); // 小面跟踪目标及背景监控 if (pSATracker && mTrakingPara.Sky_bEnableTrackSA) @@ -520,6 +523,8 @@ void SkyTracker::Cancle() memset(&m_TSky_Output.ObjectStatusKCF, 0, sizeof(OBJECTSTATUS)); memset(&m_TSky_Output.ObjectStatusDesc, 0, sizeof(OBJECTSTATUS)); + m_posRecorder.reset(); + } void SkyTracker::SetMemTrack(bool bMemFlag) @@ -918,7 +923,7 @@ void SkyTracker::SetTrackModeAuto(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input) } #endif - if (nCount >= GLB_TRACK_SMALL2FACE_THRES && bFindAreaTarget) //以338A对空抗干扰数据--双机小目标交错为例 + if (nCount >= GLB_TRACK_SMALL2FACE_THRES || bFindAreaTarget) //以338A对空抗干扰数据--双机小目标交错为例 { crfCandiRect.cx = pObjStatus->ptPos.x; crfCandiRect.cy = pObjStatus->ptPos.y; @@ -1311,4 +1316,5 @@ void SkyTracker::SkyTrackFalse_Process(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_In SkyTrkStatusInfo.nAbnormalCnt += 1; } } -} \ No newline at end of file +} + diff --git a/NeoTracker/src/Arith_SkyTracker.h b/NeoTracker/src/Arith_SkyTracker.h index 9dbec14..aff26ad 100644 --- a/NeoTracker/src/Arith_SkyTracker.h +++ b/NeoTracker/src/Arith_SkyTracker.h @@ -9,7 +9,7 @@ #include "Matcher/Fast_Matcher.h" #include "Arith_RadarInfo.h" #include "Arith_AIDMonitor.h" - +#include "Arith_PosAnalyse.h" // 决策行为 enum Act { @@ -107,6 +107,11 @@ typedef struct tagPipeMainStatusInfo SINT32 nAbnormalCnt; // 异常次数累计 }PipeMainStatusInfo; + + + + + class SkyTracker { public: @@ -181,6 +186,7 @@ public: // 产生决策 DecPolicy Decision(GD_VIDEO_FRAME_S img); + // KCF+CEND决策处理 DecPolicy TO_TrackDecisionOf_KCF_CEND(GD_VIDEO_FRAME_S img); @@ -233,6 +239,9 @@ private: void SkyTrackFalse_Process(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, OBJECTSTATUS* ObjStatus, PIPE* m_LockingPipe); private: + ImagePosRecord m_posRecorder; //pos统计 + + bool bsvmInitDone;// PipeMainClassifyInfo* pipeClassifyInfo; // 主跟踪管道对应的信息缓存,用于在告警操作中进行类别确认 diff --git a/NeoTracker/src/Arith_TrackSAObj.cpp b/NeoTracker/src/Arith_TrackSAObj.cpp index babc09c..43627f2 100644 --- a/NeoTracker/src/Arith_TrackSAObj.cpp +++ b/NeoTracker/src/Arith_TrackSAObj.cpp @@ -70,6 +70,8 @@ SA_Tracker::SA_Tracker(int nWidth, int nHeight) memset(nSimTargetNum_Counter, -1, GLB_SIMOBJ_VALID_CNT * sizeof(SINT32)); SATrkState = LockStateUnknown; // 小面记忆跟踪状态跟踪 + + } @@ -204,9 +206,14 @@ int SA_Tracker::Track(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, API_MOT_PIPE SINT32 nRealPipeNum = g_GLB_PipeProc->PIPE_GetAlarmNum(); SINT32 m_nMaxPipeNum = g_GLB_PipeProc->PIPE_GetMaxPipeNum(); SINT32 nPipeRadiusTrack = g_GLB_PipeProc->GetParam().nPipeRadiusTrack; - + SINT32 nPipeRaduisLost = g_GLB_PipeProc->GetParam().nPipeRadiusLost; + PIPE_PARAMETERS MOT_PARA = g_GLB_PipeProc->GetParam(); nTrackTargetID = -1; + // 同步管道参数 + m_TSA_Param.nPipeRadiusTrack = nPipeRadiusTrack; + m_TSA_Param.nPipeRadiusLost = nPipeRaduisLost; + //调整搜索区域大小,为分块宽高的整数倍 SetAutoSearchZone(nWidth, nHeight, p_GLB_Input); @@ -399,7 +406,7 @@ SINT32 SA_Tracker::getInterfereAreaTargteNum(RECT32S bbox) TARGET_OBJECT* pObj = &pDAT_Module->GetTargetArray()[i]; if (ABS(pObj->pfCenPos.x - nX) < MAX(50, bbox.w * 3) && - ABS(pObj->pfCenPos.x - nY) < MAX(50, bbox.h * 3)) + ABS(pObj->pfCenPos.y - nY) < MAX(50, bbox.h * 3)) { nNum++; } @@ -438,8 +445,6 @@ void SA_Tracker::SetAutoSearchZone(SINT32 nWidth, SINT32 nHeight, GLB_INPUT* p_G // 伺服太晃,直接使用短时预测。 nEnd = m_LockingPipe->ubEnd; - pPipe->ptCurrentPnt.x = pPipe->stMotionMod_mean.crnObjPrediRtNear.cx; - pPipe->ptCurrentPnt.y = pPipe->stMotionMod_mean.crnObjPrediRtNear.cy; // 取长时预测点作为管道当前位置预测 if (PIPE_EVENT_JUST_LOCK == m_LockingPipe->ubEventStatus) @@ -454,7 +459,6 @@ void SA_Tracker::SetAutoSearchZone(SINT32 nWidth, SINT32 nHeight, GLB_INPUT* p_G } - //判断管道目标是否超出视场 //if (IMGO_IsPoint16SOutImg(nWidth, nHeight, pPipe->ptCurrentPnt)) if(IMGO_IsPoint32FOutImg(nWidth, nHeight, ptCurrentPnt)) @@ -630,6 +634,8 @@ void SA_Tracker::SARegionDet(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, SINT3 DAT_PARAMETERS* pDAT_stPara = pDAT_Module->GetDatParm(); SINT32 nObjCombineDist = pDAT_stPara->nObjCombineDist; FilterMeanNL stMotionMod_mean = m_LockingPipe->stMotionMod_mean; // 使用运动模型 + TARGET_OBJECT* trackTarget = &m_LockingPipe->objHistoryList[m_LockingPipe->ubEnd];//跟踪最近的目标 + ////////////////////////////////////////////////////////////////////////// //////////////////////////小面目标检测//////////////////////////////////// BBOOL bEnableAreaObjDetect = FALSE; @@ -670,6 +676,12 @@ void SA_Tracker::SARegionDet(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, SINT3 pDST_Module->SetCombinDist(nCombinDist); + // 首次挑选使用自适应SNR阈值,尽量避免低SNR阈值下虚警 + if (trackTarget->fSNR > 9) + { + pDST_Module->SetDetSnr(MAX(trackTarget->fSNR * 0.5, 4.0f)); + } + SINT32 nSmallTargetNum = pDST_Module->Detect(img, m_TSA_Input.crCenterRect, GLB_STATUS_TRACK); // 小目标可以开面目标检测 if (bEnableAreaObjDetect) @@ -698,8 +710,8 @@ void SA_Tracker::SARegionDet(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, SINT3 //小、面目标原地合并 m_nTargetNum = MergeSmallAndAreaTarget(m_Target_Array, nSmallTargetNum, nCpNum, nCombinDist, GLB_STATUS::GLB_STATUS_TRACK); // 小面目标检测信息使用后重置,为了提高效率这里只重置个数 - pDST_Module->SetTargetNum(0); - pDAT_Module->SetTargetNum(0); + //pDST_Module->SetTargetNum(0); + //pDAT_Module->SetTargetNum(0); ////////////////////////////////////////////////////////////////////////// @@ -1178,7 +1190,7 @@ SINT32 SA_Tracker::FindMatchTarget(PIPE* pPipe, TARGET_OBJECT* ptTargetArray, SI //局部变量 FLOAT32 fSim = 0.0f; //目标相似度 FLOAT32 fSimMax = -1.0f;//目标相似度最大值 - FLOAT32 fSimThres = 0.2f; //相似度阈值 + FLOAT32 fSimThres = 0.5f; //相似度阈值 SINT32 nFrmsStep = 1; //帧间隔 TARGET_OBJECT* ptMainTarget = NULL; //主管道目标 TARGET_OBJECT* ptTarget = NULL; //候选目标 @@ -1238,6 +1250,7 @@ SINT32 SA_Tracker::FindMatchTarget(PIPE* pPipe, TARGET_OBJECT* ptTargetArray, SI // fApparentModelWeight = 0.0; //} + //统计所有当前帧目标与管道目标的灰度、与中心距离、信噪比差异 for (int i = 0; i < nFrmObjsCnt; i++) { @@ -1371,17 +1384,17 @@ SINT32 SA_Tracker::FindMatchTarget(PIPE* pPipe, TARGET_OBJECT* ptTargetArray, SI } - // 小目标特殊处理 + //// 小目标特殊处理 if (pPipe->ObjectFilter.fPxlsCnt < 9) { fSScaleChangeLowThres = 0.3; fSScaleChangeHighThres = 3.f; fAScaleChangeLowThres = 0.5; fAScaleChangeHighThres = 2.0; - nLastDiffThresX = MAX(nMoveMin, 6); - nLastDiffThresY = MAX(nMoveMin, 6); - nPredictDiffThresX = MAX(nFThreMin, 12); - nPredictDiffThresY = MAX(nFThreMin, 12); + nLastDiffThresX = MAX(nMoveMin, 4); + nLastDiffThresY = MAX(nMoveMin, 4); + nPredictDiffThresX = MAX(nFThreMin, 6); + nPredictDiffThresY = MAX(nFThreMin, 6); } @@ -1435,22 +1448,13 @@ SINT32 SA_Tracker::FindMatchTarget(PIPE* pPipe, TARGET_OBJECT* ptTargetArray, SI nLastDiffThresX = MAX(ptTarget->snSize.w / 2, nLastDiffThresX); nLastDiffThresY = MAX(ptTarget->snSize.h / 2, nLastDiffThresY); - //if (g_GLB_stPara->nWorkScene == GLB_WATCH_SKY) - //{ - // nPredictDiffThres = 70; - // nLastDiffThres = 15; - //} - //if (g_GLB_stPara->nWorkScene == GLB_WATCH_GROUND) - //{ - // nPredictDiffThres = 5; - // nLastDiffThres = 5; - //} // 非初始锁定阶段执行运动距离强逻辑 //小目标情况下,周围可能检测出干扰的相似目标(真正的目标无法检出),需要强逻辑限定 //面目标情况下,单个目标允许大范围关联,关闭距离限定;非单个目标限定关联距离 - if (PIPE_EVENT_JUST_LOCK != m_LockingPipe->ubEventStatus && + if (/*PIPE_EVENT_JUST_LOCK != m_LockingPipe->ubEventStatus && */ + m_LockingPipe->stMotionMod_mean.bTrackStable && m_SizeMode <= SizeType::SmallTarget || (m_SizeMode >= SizeType::MiddleTarget && !bSingleTarget)) { if ((ABS(ptTarget->pfCenPos.x - stMotionMod_mean.crnObjPrediRtLong.cx) > MAX(ABS(fAzSpeed) * 2, nPredictDiffThresX) @@ -1799,12 +1803,12 @@ SINT32 SA_Tracker::FindMatchPipe(SINT32 nWidth, SINT32 nHeight, PIPE* pLockingPi FLOAT32 fThres = fSimThres; if (bSingleTarget) { - fThres = 0.1f;//没有底线的跟踪 - // 超过10帧丢失,降低阈值搜索 - if (m_ObjStatus.unContiLostCnt >= 10) - { - fThres = 0.1f; - } + fThres = 0.0f;//没有底线的跟踪 + //// 超过10帧丢失,降低阈值搜索 + //if (m_ObjStatus.unContiLostCnt >= 10) + //{ + // fThres = 0.1f; + //} } else @@ -2098,8 +2102,8 @@ void SA_Tracker::UpdateObject2Tracker(TARGET_OBJECT* pTarget, GLB_INPUT* p_GLB_I //仅使用长时预测更新目标位置 pObjStatus->ptPosPre = pObjStatus->ptPos; - pObjStatus->ptPos.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cx; - pObjStatus->ptPos.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cy; + pObjStatus->ptPos.x = m_LockingPipe->ptCurrentPnt.x; //使用管道预测位置 + pObjStatus->ptPos.y = m_LockingPipe->ptCurrentPnt.y; pObjStatus->ptPosFilter = pObjStatus->ptPos; SATrkState = Locked_Losting; diff --git a/NeoTracker/src/Arith_TrackSAObj.h b/NeoTracker/src/Arith_TrackSAObj.h index 1ce5fa4..d50fec7 100644 --- a/NeoTracker/src/Arith_TrackSAObj.h +++ b/NeoTracker/src/Arith_TrackSAObj.h @@ -135,6 +135,8 @@ struct TSA_Parameters UINT16 nUseAIDetFeq; //使用AI管道更新频率 BBOOL bEnableSecDetect;//小目标二次检测开关 + + BBOOL bEnableGeoPredict;//允许惯性预测开关。 }; diff --git a/NeoTracker/src/Arith_Tracker.cpp b/NeoTracker/src/Arith_Tracker.cpp index 3e72c19..65c71bb 100644 --- a/NeoTracker/src/Arith_Tracker.cpp +++ b/NeoTracker/src/Arith_Tracker.cpp @@ -150,13 +150,21 @@ bool Tracker::Track(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, API_MOT_PIPE* // 基于窗口平均计算管道长短时预测点 Predict_ObjAglTrackPredict(&m_LockingPipe->stMotionMod_mean, img.u32Width, img.u32Height, p_GLB_Input); - //m_LockingPipe->afCurrentAgl = m_LockingPipe->stMotionMod_mean.ObjAglListsLong.arfFilter.afAngle; - //m_LockingPipe->ptCurrentPnt.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cx; - //m_LockingPipe->ptCurrentPnt.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cy; - m_LockingPipe->afCurrentAgl = m_LockingPipe->stMotionMod_mean.ObjAglListsNear.arfFilter.afAngle; - m_LockingPipe->ptCurrentPnt.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtNear.cx; - m_LockingPipe->ptCurrentPnt.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtNear.cy; + if (m_LockingPipe->stMotionMod_mean.bTrackStable) + { + m_LockingPipe->afCurrentAgl = m_LockingPipe->stMotionMod_mean.ObjAglListsLong.arfFilter.afAngle; + m_LockingPipe->ptCurrentPnt.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cx; + m_LockingPipe->ptCurrentPnt.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cy; + } + else + { + m_LockingPipe->afCurrentAgl = m_LockingPipe->stMotionMod_mean.ObjAglListsNear.arfFilter.afAngle; + m_LockingPipe->ptCurrentPnt.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtNear.cx; + m_LockingPipe->ptCurrentPnt.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtNear.cy; + } + + // 跟踪找到目标 if (m_type == GLB_SCEN_MODE::GLB_SCEN_SKY) @@ -196,9 +204,9 @@ SINT32 Tracker::MemTrack(GD_VIDEO_FRAME_S img, GLB_INPUT* p_GLB_Input, API_MOT_P // 基于窗口平均计算管道长短时预测点 Predict_ObjAglTrackPredict(&m_LockingPipe->stMotionMod_mean, img.u32Width, img.u32Height, p_GLB_Input); - m_LockingPipe->afCurrentAgl = m_LockingPipe->stMotionMod_mean.ObjAglListsLong.arfFilter.afAngle; - m_LockingPipe->ptCurrentPnt.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cx; - m_LockingPipe->ptCurrentPnt.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtLong.cy; + m_LockingPipe->afCurrentAgl = m_LockingPipe->stMotionMod_mean.ObjAglListsNear.arfFilter.afAngle; + m_LockingPipe->ptCurrentPnt.x = m_LockingPipe->stMotionMod_mean.crnObjPrediRtNear.cx; + m_LockingPipe->ptCurrentPnt.y = m_LockingPipe->stMotionMod_mean.crnObjPrediRtNear.cy; // 跟踪找到目标 if (m_type == GLB_SCEN_MODE::GLB_SCEN_SKY) diff --git a/NeoTracker/src/Common/Arith_AglPredict.cpp b/NeoTracker/src/Common/Arith_AglPredict.cpp index 2c987e9..03ff8bd 100644 --- a/NeoTracker/src/Common/Arith_AglPredict.cpp +++ b/NeoTracker/src/Common/Arith_AglPredict.cpp @@ -200,7 +200,7 @@ void Predict_ObjAglTrackPredict(FilterMeanNL* pFilter, SINT32 nWidth, SINT32 nHe pFilter->nObjPredictFarCnt = 0; pFilter->bObjPredictAbnormal = FALSE; } - if (pFilter->nObjPredictFarCnt > 5 + if (pFilter->nObjPredictFarCnt > 3 && fNLDist2 > nNLDist2Thres) { pFilter->bObjPredictAbnormal = TRUE; diff --git a/NeoTracker/src/Common/Arith_SysStruct.h b/NeoTracker/src/Common/Arith_SysStruct.h index 78d885c..23e9932 100644 --- a/NeoTracker/src/Common/Arith_SysStruct.h +++ b/NeoTracker/src/Common/Arith_SysStruct.h @@ -92,6 +92,8 @@ #define TRACK_STATUS_DEPTH_MAX 50 //目标状态监控最大深度 +#define TRACK_POS_REC_MAX 20 // 目标像方坐标记录深度 + #define GLB_GROUP_NUM_MAX 5 //组的最大个数 #define GLB_GROUP_PIPENUM_MAX 3 //组包含的管道个数(只支持3个合并) @@ -681,6 +683,7 @@ typedef struct tagFilterMeanNL SINT32 nObjTrackLostCntNear; //目标短时轨迹预测失败帧数 SINT32 nObjTrackLostCntLong; //目标长时轨迹预测失败帧数 SINT32 nAbnormalCnt; //跟踪异常计数器(连续---坏点 + BBOOL bTrackStable; //跟踪稳态判断 }FilterMeanNL; diff --git a/NeoTracker/src/Detect/API_DetectSAObj.h b/NeoTracker/src/Detect/API_DetectSAObj.h index f114227..cc5fe4f 100644 --- a/NeoTracker/src/Detect/API_DetectSAObj.h +++ b/NeoTracker/src/Detect/API_DetectSAObj.h @@ -179,6 +179,9 @@ public: // 设置小目标合并距离 virtual void SetCombinDist(SINT32 ndistance) = 0; + // 设置检测基础阈值 + virtual void SetDetSnr(FLOAT32 fSNR) = 0; + // 获取小目标检测队列 virtual TARGET_OBJECT* GetTargetArray() = 0; diff --git a/NeoTracker/src/Detect/Arith_DetectAreaObj.cpp b/NeoTracker/src/Detect/Arith_DetectAreaObj.cpp index c26c609..638052a 100644 --- a/NeoTracker/src/Detect/Arith_DetectAreaObj.cpp +++ b/NeoTracker/src/Detect/Arith_DetectAreaObj.cpp @@ -1824,8 +1824,8 @@ SINT32 DetectAreaObj::DAT_ObjsSegmentation(UINT16* pFrame, UBYTE8* pnGrayBinary, //MSSu, 20150514: 弱目标检测时,灰度、梯度二值点取并集,否则取交集 BBOOL bSeedPt = FALSE; - if (DAT_FLAG_BINARY == pnGrayBinary[nIndex] - && DAT_FLAG_BINARY == pnGradBinary[nIndex] + if ((DAT_FLAG_BINARY == pnGrayBinary[nIndex] + || DAT_FLAG_BINARY == pnGradBinary[nIndex]) && DAT_FLAG_CONNECTED != pnFlagHasSr[nIndex]) { bSeedPt = TRUE; diff --git a/NeoTracker/src/Detect/Arith_DetectSmallObj.cpp b/NeoTracker/src/Detect/Arith_DetectSmallObj.cpp index 7ae4ccd..0b74255 100644 --- a/NeoTracker/src/Detect/Arith_DetectSmallObj.cpp +++ b/NeoTracker/src/Detect/Arith_DetectSmallObj.cpp @@ -52,6 +52,28 @@ SINT32 g_DST_nFilter_5_9[DST_KERNAL_SIZE_5_9] = }; +SINT32 g_DST_nFilter_13_17[DST_KERNAL_SIZE_13_17] = +{ + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1 +}; + + DetectSmallObj::DetectSmallObj(SINT32 nWidth, SINT32 nHeight) { @@ -130,6 +152,11 @@ void DetectSmallObj::SetTargetNum(SINT32 num) m_FrmObjsCnt = num; } +void DetectSmallObj::SetDetSnr(FLOAT32 fSNR) +{ + m_DST_stPara.fgdk = fSNR; +} + DST_PARAMETERS* DetectSmallObj::GetDstParm() { return &m_DST_stPara; @@ -324,7 +351,7 @@ void DetectSmallObj::DST_Initialization(SINT32 nWidth, SINT32 nHeight, CENTERREC m_DST_stPara.fObjWHRatioMax = 5.0f; m_DST_stPara.fObjRectRatioMin = 0.2f; m_DST_stPara.nBGObjNumThres = 2; - m_DST_stPara.nBTGrayMinThres = 5; + m_DST_stPara.nBTGrayMinThres = 10; m_DST_stPara.bDimDetecting = false; m_DST_stPara.bEnableDimDetect = false; @@ -347,10 +374,13 @@ void DetectSmallObj::DST_Initialization(SINT32 nWidth, SINT32 nHeight, CENTERREC m_DST_stPara.nDetectGrayType = GLB_OBJ_GRAY_BRIGHT; // 模板参数 - m_DST_stPara.pnFilter = g_DST_nFilter_9_13; - m_DST_stPara.nFilterBGW = DST_KERNAL_SIZE_Bm_13; - m_DST_stPara.nFilterTGW = DST_KERNAL_SIZE_Tm_9; + //m_DST_stPara.pnFilter = g_DST_nFilter_9_13; + //m_DST_stPara.nFilterBGW = DST_KERNAL_SIZE_Bm_13; + //m_DST_stPara.nFilterTGW = DST_KERNAL_SIZE_Tm_9; + m_DST_stPara.pnFilter = g_DST_nFilter_5_9; + m_DST_stPara.nFilterBGW = 9; + m_DST_stPara.nFilterTGW = 5; // 申请内存 DST_MallocMemory(nWidth, nHeight, mmCenterRect); diff --git a/NeoTracker/src/Detect/Arith_DetectSmallObj.h b/NeoTracker/src/Detect/Arith_DetectSmallObj.h index b9e08a9..0ef426e 100644 --- a/NeoTracker/src/Detect/Arith_DetectSmallObj.h +++ b/NeoTracker/src/Detect/Arith_DetectSmallObj.h @@ -246,6 +246,11 @@ public: // 设置当前帧小目标检测个数 void SetTargetNum(SINT32 num); + + // 设置检测阈值 + void SetDetSnr(FLOAT32 fSNR); + + // 获取小目标检测参数 DST_PARAMETERS* GetDstParm(); diff --git a/NeoTracker/src/PIPE/Arith_MOT_PipeProc.cpp b/NeoTracker/src/PIPE/Arith_MOT_PipeProc.cpp index af3a894..e1abdbe 100644 --- a/NeoTracker/src/PIPE/Arith_MOT_PipeProc.cpp +++ b/NeoTracker/src/PIPE/Arith_MOT_PipeProc.cpp @@ -652,6 +652,14 @@ void MOT_Pipe::PIPE_UpdatePipes(TARGET_OBJECT* ptTargetArray, SINT32 pnFrmObjsCn //自适应调节“管道目标没有被找到的次数阈值” pPipe->nDelCntThres = MAX(3, pPipe->nDelCntThres); + + // 弱小目标,不容易删除 + if (pPipe->ObjectFilter.fPxlsCnt < 5) + { + pPipe->nDelCntThres = 10; + } + + if (pPipe->unLostCnt > (UINT32)pPipe->nDelCntThres) { DelPipe(pPipe); diff --git a/NeoTracker/src/Version.h.in b/NeoTracker/src/Version.h.in index 81581d3..92ad6d3 100644 --- a/NeoTracker/src/Version.h.in +++ b/NeoTracker/src/Version.h.in @@ -3,4 +3,4 @@ #pragma once #include std::string BUILD_TIME = "BUILD_TIME @build_time@"; -std::string VERSION = "BUILD_VERSION 1.3.3"; +std::string VERSION = "BUILD_VERSION 1.4.0"; diff --git a/QGuideArithStudio/src/QVideoPlayer.cpp b/QGuideArithStudio/src/QVideoPlayer.cpp index 13728f9..2ae162e 100644 --- a/QGuideArithStudio/src/QVideoPlayer.cpp +++ b/QGuideArithStudio/src/QVideoPlayer.cpp @@ -482,7 +482,7 @@ VideoStream* QVideoPlayer::OpenOneStream(QString lpszFileName) { pVid = new GDFileStream(); } - else if(extName == "raw" || extName == "xraw" || extName == "rawx" || extName == "yuv") + else if(extName == "raw" || extName == "xraw" || extName == "rawx" || extName == "yuv" || extName == "data") { // 在当前路径下寻找raw文件默认配置 int first = lpszFileName.lastIndexOf("/"); @@ -638,6 +638,7 @@ void QVideoPlayer::DrawArithResult() { return; } + // 更新指南针 UpdateCompass(m_stInputPara.stServoInfo.fServoAz, m_stInputPara.stServoInfo.fServoPt); @@ -768,7 +769,6 @@ void QVideoPlayer::DrawTrackersInfo() QGraphicsScene* scene = m_ImageViewer->imgScene; int num = m_stOutput.nTrackObjCnts; - for (size_t i = 0; i < num; i++) { auto obj = &m_stOutput.stTrackers[i]; @@ -850,6 +850,7 @@ void QVideoPlayer::DrawTrackersInfo() { str = QString::number(obj->nOutputID); } + DrawArtRect(m_ImageViewer, QPen(QColor(255, 0, 0)), bbox, str, false,15, QColor(255,0,0)); @@ -926,7 +927,7 @@ void QVideoPlayer::DrawTrackersInfo() // 查询跟踪阶段目标列表 DrawFrameRegionDetectObjs(); - // 绘制小目标极值点 + //// 绘制小目标极值点 //POINT16S* pList = ARIDLL_GetSATracker_DSTPoint(m_ArithRunner->pEOTracker, nInPipesID); //for (size_t i = 0; i < (640 / 16 * 512 / 16) * 2; i++) @@ -1014,10 +1015,10 @@ void QVideoPlayer::DrawFrameRegionDetectObjs() int cx = obj->pfCenPos.x; int cy = obj->pfCenPos.y; - //int w = MAX(15, obj->snSize.w); - //int h = MAX(15, obj->snSize.h); - int w = obj->snSize.w; - int h = obj->snSize.h; + int w = MAX(5, obj->snSize.w); + int h = MAX(5, obj->snSize.h); + //int w = obj->snSize.w; + //int h = obj->snSize.h; QRectF bbox(cx - w / 2, cy - h / 2, w, h); scene->addRect(bbox, QPen(QColor(20, 255, 147), 0.3)); str = QString::number(obj->fMatchConf, 'f', 2); @@ -1279,7 +1280,7 @@ void QVideoPlayer::PrintSkyInfo(QString str, QString strShow, ArithHandle hArith // 划分为0 - 上、1 - 右上、2 - 右、3 - 右下、4 - 下、5 - 左下、6 - 左、7 - 左上8个背景区域 auto obj = &mrnBkgBlks[i]; QRectF bbox(obj->minX, obj->minY, obj->maxX - obj->minX, obj->maxY - obj->minY); - scene->addRect(bbox, QPen(QColor(147, 20, 255), 0.3)); + //scene->addRect(bbox, QPen(QColor(147, 20, 255), 0.3)); } TSky_Output* pSky_Output = GetSkyTrackerObjectStatus(pEOTracker, obj->nInPipesID);