function identifyTracks5(actFile, calFile, track)

modelSize = 49;
minTrackLen = 8;

dirBase = dir([actFile '.1.*.pgm']);
numberFrames = size(dirBase, 1);

for cam=1:8
  camFile = [calFile sprintf('%d', cam) '.Pmat.cal'];
  Pe(:, :, cam) = load(camFile);
end;

pointsName = [actFile '.points.mat'];
eval(['load ' pointsName ' humanBody ptNumber mkCode;']);

numberTracks = size(track, 1);
trackLength = sum((track>0)');
[Len, Index] = sort(-trackLength);
numberCompletes = max((Len == -numberFrames) .* [1:numberTracks]);
numberNonCompletes = max((Len <= -minTrackLen) .* [1:numberTracks]);

foundID = zeros(modelSize);
idTrkName = [actFile '.idTrk.mat'];
if (exist(idTrkName))
  eval(['load ' idTrkName ' trackID;']);
  trk = size(trackID, 1)+1;
  for t=1:trk-1
    if (trackID(t))      
      foundID(trackID(t)) = 1;
    end;
  end;
else
  trk = 1;
end;
while ((sum(foundID) < modelSize) & (trk <= 2*modelSize))
  curTrk = Index(trk);
  fprintf('Labeling iteration %2d (Len = %2d)\n', trk, -Len(trk));
  
  minFrm = min(find(track(curTrk,:)>0));
  maxFrm = max(find(track(curTrk,:)>0));
  frm = round((minFrm + maxFrm)/2);

  for cam=1:8
    frmFile = [actFile '.' sprintf('%d', cam)  '.' sprintf('%05d', frm-1) '.pgm'];
    Io = imread(frmFile, 'pgm');
    dim = size(Io);
    subplot(2, 4, cam), imshow(rot90(Io));
    hold on;
    x(1, 1) = humanBody(1, track(curTrk, frm), frm);
    x(2, 1) = humanBody(2, track(curTrk, frm), frm);
    x(3, 1) = humanBody(3, track(curTrk, frm), frm);
    x(4, 1) = 1;
    A1 = Pe(:, :, cam);
    p1 = A1*x;
    p1 = p1./(p1(3, 1));
    plot(p1(2,1), dim(2)-p1(1,1), 'ro');
  end;
  id = input('Track ID ([0]-None [-1]-Quit [-2]-Previous): ');

  if (id == -1)
    idTrkName = [actFile '.idTrk.mat'];
    eval(['save '  idTrkName ' trackID;']);
    return;
  elseif (id == -2)
    trk = trk-1;
  else      
    trackID(trk) = id;
    if (id)      
      foundID(id) = 1;
    end;
    clf;      
  
    idTrkName = [actFile '.idTrk.mat'];
    eval(['save '  idTrkName ' trackID;']);
  
    trk = trk+1;
  end;
end;

fprintf('Labeling done.\n');

numberTracks = size(track, 1);
trackLength = sum((track>0)');
[Len, Index] = sort(-trackLength);
numberTracks = max((Len <= -4) .* [1:numberTracks]);

finalTrack = zeros(modelSize, numberFrames);
cleanTrack = zeros(modelSize, numberFrames);
for trk=1:size(trackID, 2)
  if (trackID(trk) ~= 0)
    curTrk = Index(trk);      
    for frm=1:numberFrames
      if (~(finalTrack(trackID(trk), frm) && track(curTrk, frm)))
        finalTrack(trackID(trk), frm) = track(curTrk, frm);
      else
        %fprintf('Intersection in Track %d Frame %d\n', trk, frm);
      end;
    end;
  end;
end;

trackName = [actFile '.finalTrack.mat'];
eval(['save '  trackName ' finalTrack;']);

cleanName = [actFile '.cleanTrack.mat'];
eval(['save '  cleanName ' cleanTrack;']);