function data = gen_features_all(purpose, thresh)
% This function takes all the training images and returns a feature matrix P
% of them according to the threshold specified in the parameter.
dir_name = ['./' purpose '/'];
files = dir([dir_name, 'frame_*']);
num_of_files = length(files);
disp(['The number of images in training datasets: ', num2str(num_of_files) '...']);
data = [];
for i = 1:num_of_files
    filename = files(i).name;
    corners_file = ['./' purpose '_corners/' purpose '_' filename(1:end-4) '_corners.mat'];
    img = imread([dir_name, filename]);
    disp(['Generating features P from ' filename ' ...']);
    load(corners_file);
    feature_data = image_features(img, thresh, corners);
    data = [data;feature_data];
end
disp('Feature extraction complete ...');
end