function F=ObjectiveFunction1Mirror(x0,xdata)

% load intrinsic parameters
global IN indexPOINTS;

NT=size(indexPOINTS,2);
Saux=[1 0 0 0;0 1 0 0;0 0 -1 0;0 0 0 1];

% des-vetorize
CamEST=Rt2T(rodrigues(x0(1:3)),x0(4:6));
CamEST=CamEST*Saux;
% normalize PI
auxPI=reshape(x0(7:end),3,NT);
d=sqrt(sum(auxPI.^2));
PIest=[ auxPI./[d;d;d] ; d];

reproject(NT)=struct();
auxIND=1;
for N1=1:NT
 T=ReflectTransf(PIest(1:3,N1),-PIest(4,N1))/CamEST;
 reproject(N1).x=ProjectPoints(xdata(:,auxIND:indexPOINTS(N1)),T,IN.fc,IN.cc,IN.kc,IN.alpha);
 auxIND=indexPOINTS(N1)+1;
end

F=[reproject.x];
