function [] = ComputeF_All(image1, image2)
%Joshua Stough
%COMP 290-89, Pollefeys
%Assignment 2, Computing F

%This function executes much of the code for 
%computing F automatically.

fl_1 = corner_detector(image1,800);
fl_2 = corner_detector(image2,800);
corr = find_correspondences_ZNCC(fl_1, fl_2, image1, image2, .7, 15);
overlay = drawCorrespondences_ZNCC(image1, image2, fl_1, fl_2, 500, .7, 15);

F_8_point = computeF_8point(corr)
disp('residual for the 8 point normalized.')
res = compute_residual(corr, F_8_point)

[FR, inliers] = computeF_RANSAC(corr, 1);
disp('residual for the best 7 point RANSAC solution.')
res = compute_residual(corr, FR)

disp('residual of that on the inliers')
res = compute_residual(inliers, FR)

disp('residual of the 8 point solution on the inliers')
res = compute_residual(inliers, F_8_point)

guidcorr = inliers;
F_NON_LIN = reestimateF(guidcorr, @basic_cost_nonlin)

while(res > .5)
    guidcorr = guided_matching_ZNCC(image1, image2, F_NON_LIN, fl_1, fl_2);
    F_NON_LIN = reestimateF(guidcorr, @basic_cost_nonlin)
    res = compute_residual(guidcorr,F_NON_LIN);
end
    
overlay = drawInliers(image1, guidcorr);


