image thumbnail

image connectivity graph - SfM

by

 

This code developed to compute and visualize the connectivity between images in SfM

[vib]=visibilitytesting(Tx,Ty,Tz,w2,p2,k2,P,f,Ro,No)
function [vib]=visibilitytesting(Tx,Ty,Tz,w2,p2,k2,P,f,Ro,No)
 vib=zeros(1,3); 
 PP=[P,(1:size(P,1))'];
 
for j=1: size(Tx,1) %%% all cameras
C= [Tx(j,1) ,Ty(j,1),Tz(j,1)] ;
visiblePtInds=HPR(PP(:,1:3),C,Ro);
Pk=PP(visiblePtInds,:);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
pp=[];kk=0;

for i=1:size(Pk,1) 
mw=[1 0 0;0 cos(w2(j,1)) sin(w2(j,1)) ;0 -sin(w2(j,1)) cos(w2(j,1))];
mp=[cos(p2(j,1)) 0 -sin(p2(j,1));0 1 0;sin(p2(j,1)) 0 cos(p2(j,1))];
mk=[cos(k2(j,1)) sin(k2(j,1)) 0;-sin(k2(j,1)) cos(k2(j,1)) 0;0 0 1];
m=mk*mp*mw; 
dx1 =Pk(i,1)-Tx(j,1);
dy1 =Pk(i,2)-Ty(j,1);
dz1 =Pk(i,3)-Tz(j,1);
q =m(3,1)*dx1 +m(3,2)*dy1 +m(3,3)*dz1 ;
r =m(1,1)*dx1 +m(1,2)*dy1 +m(1,3)*dz1 ;
s =m(2,1)*dx1 +m(2,2)*dy1 +m(2,3)*dz1 ;
      
    x=-f*r /q ;% i=poit;j=image
    y=-f*s /q ; 
%%% camera format=20*14mm
if x<10 && x>-10 && y<7 && y> -7 
   kk=kk+1;
   pp(kk,1)=Pk(i,1);
   pp(kk,2)=Pk(i,2);
   pp(kk,3)=Pk(i,3);
     seen=2; 
    vib=[vib;No(j,1) Pk(i,4) seen    ];
 else
    seen=1;
    vib=[vib;No(j,1) Pk(i,4) seen    ];
 end
end
vib(1,:)=[];
 %%%%%%%Visualize tha vissible points related to the cameras orienation %%%
figure (1)
   plot3(C(:,1), C(:,2) ,C(:,3),'ko');hold on
   plot3(P(:,1), P(:,2) ,P(:,3),'b.');hold on
   plot3(pp(:,1), pp(:,2) ,pp(:,3),'r*');hold on
text(C(:,1), C(:,2) ,C(:,3),num2str(j));hold on
axis image
axis off
hold off
end
close(1)


    
 
  

Contact us