
% addpath(genpath('.'));
    


%------------------------------------------------%
% Choose Face Detector (0: Tree-Based Face Detector (p204), 1: Matlab Face Detector)
% Tree-Based Face Detector is much more accurate and suited for wild faces.
% But it is EXTREMELY slow!!
bbox_method = 0;
%------------------------------------------------%



%------------------------------------------------%
% Choose Fitting Views (0: Two-Level and Multi-View Fitting, 1: Two-Level and Single-View Fitting)
% Default : select_nview = 1 (suited for near-frontal faces)

select_nview = 0;
%------------------------------------------------%



%------------------------------------------------%
% Choose Fitting Method (1: DFRM, 2: GFRM-PO, 3: GFRM-Alternating
% Default : select_fitting = 1
% Note: For select_fitting = 3 (GFRM-Alternating), the model takes 10-15
% second to load.

select_fitting = 1;
%------------------------------------------------%



%------------------------------------------------%
% Choose Visualize (0: Do Not Display Fitting Results, 1: Display Fitting Results and Pause of Inspection)

visualize=1;
%------------------------------------------------%


%------------------------------------------------%
% Load Test Images
pause off
% image_path='test_images0/';
% image_path='V:\Joyce\downloads_backup\Downloads\BaselFaceModel\PublicMM1\matlab - Copy - Copy\';
% img_list=dir([image_path,'meanface-img.jpg']);
% img_list=[img_list; dir([image_path,'*.png'])];
% for i=1:size(img_list,1)
i=1;
    data(i).name = img_list(i).name;
    data(i).img = im2double(imread([image_path,img_list(i).name]));
    [s1 s2 s3] = size(data(i).img)
    flag=0;
    if s1<100&&s2<100
        flag=1;
    end
    if flag==0
    if s1 <200 ||s2<200
        
    data(i).img = imresize(data(i).img,max(ceil(200/s1),ceil(200/s2)));
    end
    data(i).points = []; % MAT containing 66 Landmark Locations
% end
%------------------------------------------------%

%------------------------------------------------%
%Run Demo

if select_fitting==1
    
    clm_model='model/DFRM_Model.mat';
    load(clm_model);    
    data=DFRM(clm_model,data,bbox_method,visualize);    
    figure
elseif select_fitting==2

    clm_model='model/GFRM_PO_Model.mat';
    load(clm_model);    
    data=GFRM_PO(CLM,grmf,data,bbox_method,select_nview,visualize);    
    
elseif select_fitting==3

    clm_model='model/GFRM_Alternating_Model.mat';
    disp('Loading Model...');pause(0.2);
    load(clm_model);    
    data=GFRM_Alt(CLM,grmf,data,bbox_method,select_nview,visualize);    
end
    end
%------------------------------------------------%
