This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

IWR1642BOOST: Needs explanation regarding piece of code used for occupancy detection algorithm

Part Number: IWR1642BOOST

I have taken the below piece of code from od_demo.m file available in the mmWave sensor toolkit.

I am having difficulty in understanding how does the below algorithm work.

please help me in this.

function [occupVec, featureVec] = zone_occupDetect(rangeAzimuth, coeffMatrix, meanVector, ... %==>>

stdVector, frameIdx, winLen, zone, numZones)
global zonePwr
global zonePwrdB

avgPwr = zeros(1, numZones);
avgPwrdB = zeros(1, numZones);

% zone-power in each frame
cirBufferIdx = mod(frameIdx-1, winLen) + 1;

% moving window index: newest sample at the end
winIdx = mod((cirBufferIdx-winLen:cirBufferIdx-1), winLen) + 1;

for zIdx = 1:numZones
% calculate zone power
rangeAzimuth_rgAzGated = rangeAzimuth(zone(zIdx).rgIdx, zone(zIdx).azIdx);
zonePwr(cirBufferIdx, zIdx) = mean(rangeAzimuth_rgAzGated(:));
zonePwrdB(cirBufferIdx, zIdx) = 10*log10(zonePwr(cirBufferIdx, zIdx));

% features: moving average of zonePwr in dB
avgPwr(zIdx) = mean(zonePwr(winIdx, zIdx));
avgPwrdB(zIdx) = 10*log10( avgPwr(zIdx) );
end

% features: power ratio in dB
pwrRatio = avgPwr / sum(avgPwr);
pwrRatiodB = 10*log10(pwrRatio);

% features: correlation coefficient between pairs
corrCoeff = corrcoef(zonePwrdB(winIdx, :));
xcorrCoeff = corrCoeff(1, 2);

% form the feature vector
featureVec = [avgPwrdB, pwrRatiodB, xcorrCoeff]; % 1 x 5 for two zones

% normalize and add one
featureVec = (featureVec - meanVector) ./ stdVector;
featureVec_ = [1, featureVec].'; % now column vector

% occupancy detection
prob = sigmoid(coeffMatrix * featureVec_);
[~, class_predict] = max(prob);
class_predict = class_predict - 1;
occupVec = de2bi(class_predict, numZones);

return

  • Hi,

    For algorithmic help, please read the TI Design Guide found here:  www.ti.com/.../TIDEP-01001

    If it's the Matlab syntax that is confusing you, I suggest taking a look at the C code for the DSS project (located with the lab you've already downloaded).  All the algorthms are running on the C674, so hopefully between the design guide, the C code and the Matlab code, you'll get a better idea of what's going on.

     -dave

  • Thanks for your apt reply.

    I am able to understand the code now. But a couple of queries still persist:

    In the configuration file how was the coefficient matrix has been generated?

    coeffMatrixRow 0 -14.409613 -8.187467 -8.019457 3.833826 4.045485 -0.539210
    coeffMatrixRow 1 -12.465002 -2.228748 -5.612140 4.324446 -7.912656 0.528747
    coeffMatrixRow 2 -9.210626 -3.004206 -0.082298 -2.949700 7.538751 0.246658
    coeffMatrixRow 3 -1.917373 2.299849 2.389683 7.035545 6.675194 -0.099186

    Also what is the purpose of the below piece of code:

    % occupancy detection
    prob = sigmoid(coeffMatrix * featureVec_);
    [~, class_predict] = max(prob);
    class_predict = class_predict - 1;
    occupVec = de2bi(class_predict, numZones);

  • Hi, please refer to the demo’s user guide in the docs directory for instructions on generating the coefficients.

    The code you show above takes the calculated feature vector and multiplies it by the pregenerated coefficient to create the binary decisions for each zone.