Home > analysis > detection_analysis.m

detection_analysis

PURPOSE ^

SYNOPSIS ^

This is a script file.

DESCRIPTION ^

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 load _param/_report;
0002 load _param/_wbc_2010_06_15.mat;
0003 
0004 P = initParam('wbc');
0005 COL_OFFSET = 3; % first column is for seq, second is for Id, the third column is for number of frames occupied.
0006 TP = 1;
0007 FN = 2;
0008 FP = 3;
0009 
0010 % Total number of tracks in GT set
0011 nTracks = 0;
0012 for f = 1: P.MAX_SEQUENCE
0013     nTracks = nTracks + length(unique(SS(f).Rich.tracksGT(:,1)));
0014 end
0015 tracksMatrix = zeros(nTracks,P.MAX_POSITION_PER_TRACK);
0016 speedsMatrix = NaN*ones(nTracks,P.MAX_POSITION_PER_TRACK);
0017 radialMatrix = zeros(nTracks,P.MAX_POSITION_PER_TRACK);
0018 temporMatrix = zeros(nTracks,P.MAX_POSITION_PER_TRACK);
0019 counter = 0;
0020 
0021 %% Loop each folder
0022 for f = 1: P.MAX_SEQUENCE
0023     % Loop each sub sequence
0024     maskPath = strcat(P.IFOLDERS(f).Name,'/amask.png');
0025     mask = imread(maskPath);
0026 
0027     trackIds = unique(SS(f).Rich.tracksGT(:,1));
0028     nTracksPerSeq = length(trackIds);
0029     tracksMatrixPerSeq = zeros(nTracksPerSeq, P.MAX_POSITION_PER_TRACK);
0030     radialMatrixPerSeq = zeros(nTracksPerSeq, P.MAX_POSITION_PER_TRACK);
0031     temporMatrixPerSeq = zeros(nTracksPerSeq, P.MAX_POSITION_PER_TRACK);
0032     
0033     tracksMatrixPerSeq(:,1:3) = [f*ones(nTracksPerSeq,1) trackIds 3*zeros(nTracksPerSeq,1)];
0034     radialMatrixPerSeq(:,1:3) = [f*ones(nTracksPerSeq,1) trackIds 3*zeros(nTracksPerSeq,1)];
0035     temporMatrixPerSeq(:,1:3) = [f*ones(nTracksPerSeq,1) trackIds 3*zeros(nTracksPerSeq,1)];
0036     
0037    speedsMatrixPerSeq = NaN*ones(nTracksPerSeq, P.MAX_POSITION_PER_TRACK); 
0038    speedsMatrixPerSeq(:,1:3) = [f*ones(nTracksPerSeq,1) trackIds 3*zeros(nTracksPerSeq,1)];
0039    
0040    for t = 1: size(speedsMatrixPerSeq,1)
0041       id = speedsMatrixPerSeq(t,2);
0042       gtPos = SS(f).Rich.tracksGT(SS(f).Rich.tracksGT(:,1)==id,[3,4]);
0043       for po = 1: size(gtPos,1)-1
0044         col = speedsMatrixPerSeq(t,3)+4;
0045         speedsMatrixPerSeq(t,col) = sqrt( (gtPos(po+1,1)-gtPos(po,1))^2 + ...
0046             (gtPos(po+1,2) - gtPos(po,2))^2 );
0047         speedsMatrixPerSeq(t,3) = speedsMatrixPerSeq(t,3)+1;
0048       end
0049    end
0050    
0051    for s = 1: size(P.IFOLDERS(f).Ra,1)
0052        % Loop through each frame in a sub sequence
0053        frStart = P.IFOLDERS(f).Ra(s,1);
0054        frEnd   = P.IFOLDERS(f).Ra(s,2);
0055        for fr = frStart: frEnd
0056            frIndex  = fr - frStart + 1 + COL_OFFSET;
0057            clc; disp(strcat('Processing...dataset_', num2str(f),...
0058                ' - sequence_',num2str(s),...
0059                ' - frame_',num2str(fr)));
0060             
0061            %get image
0062 %            im = im_get(P.IFOLDERS(f).Name,fr,P.EXTENSION);
0063            
0064 %             auPositions = SS(f).Rich.frames(SS(f).Rich.frames(:,1)==fr,[2,3]);
0065 %             [auPositions imConfidence] = imdetect(im,mask, P.FILTER_SIZE, P.KERNEL_SIZE, P.THR_RM, P.THR_SIZE);
0066             
0067             
0068             % Load confident image
0069             imConfName = strcat(P.IFOLDERS(f).Name,'/CONF/CONF_',...
0070                 P.IFOLDERS(f).Name,num2str(fr),'.mat');
0071             imConf = load(imConfName);
0072             imConfidence = imConf.imConf;
0073             
0074             % Load teporal different image
0075             tdName = strcat(P.IFOLDERS(f).Name,'/TD/TD_',...
0076                 P.IFOLDERS(f).Name,num2str(fr),'.png');            
0077             imTd = imread(tdName);
0078             
0079             auPositions = wbc(14).sequence(f).frames(wbc(14).sequence(f).frames(:,1)==fr,[3,4]);            
0080             gtTracks = SS(f).Rich.tracksGT(SS(f).Rich.tracksGT(:,2)==fr,[1,3,4]);
0081             gtPositions = round(gtTracks(:,2:3));
0082             gtTracks = round(gtTracks);
0083             gtTrackIds = gtTracks(:,1);
0084              
0085             [tpIndex, fnIndex, fpIndex] = classify_detection_positions ...
0086                              ( auPositions, gtPositions, P.MATCH_DISTANCE);
0087                                                                         
0088             if ~isempty(tpIndex)  
0089                 tpIds = gtTrackIds(tpIndex);
0090                 for i = 1: length(tpIds)
0091                     tpInd = tracksMatrixPerSeq(:,2)==tpIds(i);
0092                     frame = tracksMatrixPerSeq(tpInd,3)+ 1 ;
0093                                         
0094                     tracksMatrixPerSeq(tpInd, frame+ COL_OFFSET) = TP;
0095                     tracksMatrixPerSeq(tpInd, 3) = frame;
0096                     
0097                     %find out what rm value for that position
0098                     col = gtTracks(gtTracks(:,1)==tpIds(i),2);
0099                     row = gtTracks(gtTracks(:,1)==tpIds(i),3);
0100                     rmValue = imConfidence(row, col);
0101                     radialMatrixPerSeq(tpInd, frame+ COL_OFFSET) = rmValue;
0102                     radialMatrixPerSeq(tpInd, 3) = frame;
0103                     
0104                     %find out what td value for that position
0105                     col = gtTracks(gtTracks(:,1)==tpIds(i),2);
0106                     row = gtTracks(gtTracks(:,1)==tpIds(i),3);
0107                     tdValue = imTd(row, col);
0108                     temporMatrixPerSeq(tpInd, frame+ COL_OFFSET) = tdValue;
0109                     temporMatrixPerSeq(tpInd, 3) = frame;
0110                 end
0111             end
0112 
0113             if ~isempty(fnIndex)
0114                 fnIds = gtTrackIds(fnIndex);
0115                 for i = 1: length(fnIds)
0116                     fnInd = tracksMatrixPerSeq(:,2)==fnIds(i);
0117                     frame = tracksMatrixPerSeq(fnInd,3)+ 1 ;
0118                     
0119                     tracksMatrixPerSeq(fnInd,frame+ COL_OFFSET) = FN;
0120                     tracksMatrixPerSeq(fnInd, 3) = frame;
0121                     
0122                     %find out what rm value for that position
0123                     col = gtTracks(gtTracks(:,1)==fnIds(i),2);
0124                     row = gtTracks(gtTracks(:,1)==fnIds(i),3);
0125                     rmValue = imConfidence(row, col);
0126                     radialMatrixPerSeq(fnInd, frame+ COL_OFFSET) = rmValue;
0127                     radialMatrixPerSeq(fnInd, 3) = frame;
0128                     
0129                     %find out what rm value for that position
0130                     col = gtTracks(gtTracks(:,1)==fnIds(i),2);
0131                     row = gtTracks(gtTracks(:,1)==fnIds(i),3);
0132                     tdValue = imTd(row, col);
0133                     temporMatrixPerSeq(fnInd, frame+ COL_OFFSET) = tdValue;
0134                     temporMatrixPerSeq(fnInd, 3) = frame;
0135                 end
0136             end     
0137                         
0138        end
0139    end
0140    
0141    tracksMatrix(counter+1: counter + nTracksPerSeq, :) = tracksMatrixPerSeq;
0142    speedsMatrix(counter+1: counter + nTracksPerSeq, :) = speedsMatrixPerSeq;
0143    radialMatrix(counter+1: counter + nTracksPerSeq, :) = radialMatrixPerSeq;
0144    temporMatrix(counter+1: counter + nTracksPerSeq, :) = temporMatrixPerSeq;
0145    counter = counter + nTracksPerSeq;
0146 
0147    
0148 end
0149 
0150 save _param/_detectionAnalysis tracksMatrix speedsMatrix radialMatrix temporMatrix

Generated on Thu 17-Mar-2011 14:45:51 by m2html © 2005