%%
clear all;close all;clc

addpath ../voc-release5
addpath_recurse('../voc-release5')

startup

%%

load ../voc-release5/VOC2010/person_final

dataFolder = '/home/jorge/Escritorio/Daimler/Crossing_part06/Data/TrainingData/2012-04-02_115639_Short/RectGrabber';

list = dir(fullfile(dataFolder, '*.pgm'));

visualizemodel(model)
for n=1:length(list)
    
%     n=251;
    img = imread(fullfile(dataFolder,list(n).name));
    img = im2double(img);
    img = color(img);
    imshow(img)

    tic
    [bbox, fbbox] = process(img, model, -0.7);
    fprintf(['Detection time: ' num2str(toc) 's \n'] )

    % fbbox = reshape(fbbox,length(fbbox)/4,5)
    for i=1:size(bbox,1)
        if ~isempty(bbox)
            showboxes(img, [bbox(i,1:4) fbbox(i,:)]);
        else
            disp('No detection')
        end
        pause(1)
    end
    
end