⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 crit_camera_and_orthogonal.m

📁 使用支持向量机(svm)方法进行图像的单视度量(single view metrology)的vc++(需要用到wxwindows2.4.2)和matlab源代码.
💻 M
字号:
function probability=crit_camera_and_orthogonal(V,picsize)
%params
max_dist_of_pricniple_point_to_center=min(picsize)/2;

max_distortion_angle=pi/2/30;

%default output
orthcrit=false;
camcrit=false;

%take first the infinite
[dummy,IX]=sort(V(:,3)~=0);
V=V(IX,:);

num_infinite_vp=sum(V(:,3)==0);
switch num_infinite_vp
    
    % no infinitive vp
    case 0
        v=V(:,1:2)./repmat(V(:,3),1,2);
        % everything below is inhomogen

        %check if every angle is below 90 degrees
        loop=[1 2 3
              1 3 2
              2 3 1];
        orthcrit=true;
        for k=1:3
            a=loop(k,1);
            b=loop(k,2);
            c=loop(k,3);
            if (v(a,:)-v(c,:))*(v(b,:)-v(c,:))'<0 %maybe threshold
                orthcrit=false;
                break;
            end
        end

        if(orthcrit)
            %get principle point u
            rot=[0 1; -1 0];
            h(1,:)=(v(2,:)-v(3,:))*rot;
            h(2,:)=(v(1,:)-v(3,:))*rot;

            m=(-v(1,1)*h(2,2) +v(2,1)*h(2,2) +h(2,1)*v(1,2) -h(2,1)*v(2,2)) / (h(1,1)*h(2,2)-h(1,2)*h(2,1));
            u=m*h(1,:)+v(1,:);

            % check the distance to the center
            if(norm(u)<max_dist_of_pricniple_point_to_center)
                priciple_point_prob=1-norm(u)/max_dist_of_pricniple_point_to_center;
                
                %calculate focal length
                f=sqrt( ...
                    -(-u(1)+v(1,1)) .* (-u(1)+v(2,1))...
                    -(-u(2)+v(1,2)) .* (-u(2)+v(2,2)) );
                
                %check if exists and if inside the bondaries
                if isreal(f)
                    focal_length_prob=senseOfTheFocalLength(f,picsize);
                    camcrit= (focal_length_prob~=0);
                end
            end
        end

        
        
    % one infinitive vp
    case 1
        
        %check if vanishing line is orthogonal to the VP which lies at infinity
        vanline=cross(V(2,:),V(3,:),2);
        if abs((vanline*V(1,:)')/(norm(V(1,1:2))*norm(vanline(1,1:2))))<cos(max_distortion_angle)
            orthcrit=false;
        else
            orthcrit=true;
        end

        if(orthcrit)
            % everything below is inhomogen
            v=V(2:3,1:2)./repmat(V(2:3,3),1,2);
            
            %get principle point u
            rot=[0 1; -1 0]; 
            r=v(1,:)-v(2,:);
            h(1,:)=r*rot;
            c=[0 0];
            m=(   v(1,2)*r(1) -v(1,1)*r(2) )/( -h(1)*r(2) +h(2)*r(1));
            u=m*h;

            
            % check the distance to the center
            if(norm(u)<max_dist_of_pricniple_point_to_center*1.5) 
                %*2 because by making more vp to infvp earlier, in some cases u lies more outside the center
                priciple_point_prob=1-norm(u)/max_dist_of_pricniple_point_to_center/1.5; %with the 1.5 it works better *g*
                
                %calculate focal length
                f=sqrt( ...
                    -(-u(1)+v(1,1)) .* (-u(1)+v(2,1))...
                    -(-u(2)+v(1,2)) .* (-u(2)+v(2,2)) );

                %check if exists and if inside the bondaries
                if isreal(f)
                    focal_length_prob=senseOfTheFocalLength(f,picsize);
                    camcrit= (focal_length_prob~=0);
                end
            end
        end
        
        
    % two infinitive vp
    case 2
        %check if the 2 VP at infinity are orthogonal
        if abs((V(1,:)*V(2,:)') / ( norm(V(1,1:2))*norm(V(2,1:2)) ))  < cos(pi/2-max_distortion_angle)
            orthcrit=true;
        else
            orthcrit=false;
        end
        
        if(orthcrit)
            % check the distance to the center
            if(norm(V(3,:))<max_dist_of_pricniple_point_to_center*2)
                %*2 because by making more vp to infvp earlier, in some cases u lies more outside the center
                priciple_point_prob=1-norm(V(3,:))/max_dist_of_pricniple_point_to_center/2.5;
                
                %it is impossible to figure out the focal length
                focal_length_prob=0.9; 
                camcrit=true;
            end
        end
        
        
    % three infinitive vp
    otherwise
        % only with an unlimited focal length this would be possible
        orthcrit=false;
        camcrit=false;
end

%If the criterions are fulfilled return the probability
if(orthcrit && camcrit)
    probability=min(focal_length_prob,priciple_point_prob); %fuzzy minmax and
else
    probability=0;
end

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -