cube5
correlate view image (view1.jpg) with 3D model
% set cube
cube1
% orthonormal projection points = [0 0 0 1; 1 0 0 1; 1 1 0 1; 0 1 0 1; 0 0 1 1; 1 0 1 1; 1 1 1 1; 0 1 1 1]; axis equal T = view; viewinfo pc = ones(8,1)*[camtarget() 0]; p = points*T'; % orthonormal calculation xp = p(:,1); yp = p(:,2); % projective calculation %xp=p(:,1)./p(:,3); %yp=p(:,2)./p(:,3); xc = [xp(1:4); xp(1)]; yc = [yp(1:4); yp(1)]; plot(xc,yc,'b','LineWidth',2); hold on xc = [xp(5:8); xp(5)]; yc = [yp(5:8); yp(5)]; plot(xc,yc,'g','LineWidth',2); for k=0:3 plot([xp(1+k) xp(5+k)],[yp(1+k) yp(5+k)],'r','LineWidth',2); end plot(xp(1),yp(1),'ko','MarkerSize',8); hold off
camera position: -4.32091 -5.24533 4.83013 camera target: 0.5 0.5 0.5 camera up vector: 0 0 1 projection: orthographic az -40 el 30 view matrix 0.7660 -0.6428 0 0 0.3214 0.3830 0.8660 0 -0.5567 -0.6634 0.5000 0 0 0 0 1.0000
load view1 idx = [4 1 2 5 6 7 8]; xv = pts(:,1); yv = pts(:,2); xfit = polyfit(xp(idx),xv,1); yfit = polyfit(yp(idx),yv,1); fprintf('xfit %g %g\n',xfit); fprintf('yfit %g %g\n',yfit); xim = polyval(xfit,xp(idx)); yim = polyval(yfit,yp(idx)); figure(2) %plot(xim-xv,yim-yv,'kx'); show_points(xim-xv,yim-yv); axis square s = 2; ticks = linspace(-1,1,11)*s; axis([-s s -s s]) set(gca,'YTick',ticks) set(gca,'XTick',ticks) grid xlabel('x-error (pixels)'); ylabel('y-error (pixels)');
xfit 342.513 293.301 yfit -342.071 287.52