PKU-Millimeter-Wave-Radar-T.../基于点云的人体定位demo/cfar.m
2024-03-11 21:04:35 +08:00

68 lines
3.0 KiB
Matlab
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

%% 请了解什么是CFAR以及什么是2D-CFAR
function [pointList,cfarRD] = cfar(parameter,accumulateRD)
[rangeLen,dopplerLen] = size(accumulateRD);
%% doppler维度搜索
dopplerMethod = parameter.dopplerMethod;
dopplerSNR = parameter.dopplerSNR;
dopplerWinGuardLen = parameter.dopplerWinGuardLen;
dopplerWinTrainLen = parameter.dopplerWinTrainLen;
dopplerLeft = accumulateRD(:,dopplerLen - dopplerWinGuardLen - dopplerWinTrainLen + 1:dopplerLen);
dopplerRight = accumulateRD(:,1:dopplerWinGuardLen+dopplerWinTrainLen);
dopplercfar = [dopplerLeft accumulateRD dopplerRight];
dopplerCfarList = [];
for rangeIdx = 1:rangeLen
for dopplerIdx = 1:dopplerLen
dopplerCfarIdx = dopplerIdx + dopplerWinGuardLen + dopplerWinTrainLen;
leftCell = dopplercfar(rangeIdx,dopplerIdx:dopplerIdx+dopplerWinTrainLen-1);
rightCell = dopplercfar(rangeIdx,dopplerCfarIdx+dopplerWinGuardLen:dopplerCfarIdx+dopplerWinGuardLen+dopplerWinTrainLen-1);
leftNoise = mean(leftCell);
rightNoise = mean(rightCell);
noise = (leftNoise + rightNoise) / 2;
indexdb = dopplercfar(rangeIdx,dopplerCfarIdx);
targetSnr = indexdb - noise;
if targetSnr > dopplerSNR
dopplerCfarList = [dopplerCfarList dopplerIdx];
cfarRDdoppler(rangeIdx,dopplerIdx) = indexdb;
end
end
end
dopplerCfarList = unique(dopplerCfarList);
%% range维度搜索
rangeMethod = parameter.rangeMethod;
rangeSNR = parameter.rangeSNR;
rangeWinGuardLen = parameter.rangeWinGuardLen;
rangeWinTrainLen = parameter.rangeWinTrainLen;
rangeUp = accumulateRD(rangeLen - rangeWinGuardLen - rangeWinTrainLen + 1:rangeLen,:);
rangeDown = accumulateRD(1:rangeWinGuardLen+rangeWinTrainLen,:);
rangecfar = [rangeUp;accumulateRD;rangeDown];
rangeCfarList = [];
cfarRD = zeros(rangeLen,dopplerLen);
for dopplerIdx = dopplerCfarList
for rangeIdx = 1:rangeLen
rangeCfarIdx = rangeIdx + rangeWinGuardLen + rangeWinTrainLen;
upCell = rangecfar(rangeIdx:rangeIdx+rangeWinTrainLen-1,dopplerIdx);
downCell = rangecfar(rangeCfarIdx+rangeWinGuardLen:rangeCfarIdx+rangeWinGuardLen+rangeWinTrainLen-1,dopplerIdx);
upNoise = mean(upCell);
downNoise = mean(downCell);
if rangeMethod == 1
noise = (upNoise + downNoise) / 2;
indexdb = rangecfar(rangeCfarIdx,dopplerIdx);
targetSnr = indexdb - noise;
if targetSnr > rangeSNR
rangeCfarList = [rangeCfarList [rangeIdx;dopplerIdx]];
cfarRD(rangeIdx,dopplerIdx) = indexdb;
end
elseif dopplerMethod == 2
elseif dopplerMethod == 3
else
end
end
end
pointList = rangeCfarList;
end