You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: compute_reproj_error.m
    path of file: ./repos/ORB-MATLAB
    
    the code of the file until where you have to start completion: function [val,loc] = compute_reproj_error(pts1,pts2,H,thres)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Compute Homography reprojection error
% 
%   Inputs - pts1 : points from frame 1
%            pts2 : corresponding points in frame 2
%            H : Homography matrix
%            thres: threshold for inliers

    
function [val,loc] = compute_reproj_error(pts1,pts2,H,thres)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%   Compute Homography reprojection error
% 
%   Inputs - pts1 : points from frame 1
%            pts2 : corresponding points in frame 2
%            H : Homography matrix
%            thres: threshold for inliers
%
%   Output- val : mean reprojection error in L2 distance (euclidean metric)
%           loc : index for inliears
%
%                       Juheon Lee (21/06/2018)
%               Feel Free to redistribute! 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if nargin <4
   thres = 3;
end