crit_vanline.m

来自「使用支持向量机(svm)方法进行图像的单视度量(single view metr」· M 代码 · 共 71 行

M
71
字号
function vancrit=crit_vanline(V,Lines,i,j,whichvoted,maxrect)
p=[1; i; j];
threshold2=10;

%for each pair of VPoints
loop=[1 2 3
    1 3 2
    2 3 1];
for i=1:3
    a=loop(i,1);
    b=loop(i,2);
    c=loop(i,3);

    %check the Lines which voted for both VPs
    voted=find(whichvoted(p(a),:).*whichvoted(p(b),:));
    %if there are any lines
    if(voted)
        % if not both VPs are at infinity
        if V(a,3)~=0 || V(b,3)~=0
            % get the Vanishing line
            vanline=cross(V(a,:),V(b,:),2);
            
            %calculate the distances between voting Lines and vanishing line them
            [D,Alpha]=vpdistance2(vanline,Lines(voted,:));

%             %cool debug output
%             h=drawline(vanline,maxrect,[0 1 0],2);
%             H=drawlines(Lines(voted,:),maxrect,[1 0 1],2);
%             delete(h);
%             delete(H);

            %If the angle is too small the VP combination is illegal
            if(max(Alpha)>threshold2/180*pi)
                if(i==1)
                    % the first pair was already wrong => dont try it again
                    % with the same first VPs
                    vancrit=-1;
                else
                    % the second or third was wrong
                    vancrit=0;
                end
                
                %error found => EXIT
                return;
            end
        % if both VPs are at infinity
        else
            % there musn't be any lines voting for both
            if voted~=0
                if(i==1)
                    % the first pair was already wrong => dont try it again
                    % with the same first VPs
                    vancrit=-1;
                else
                    % the second or third was wrong
                    vancrit=0;
                end
                
                %error found => EXIT
                return;
            end
        end
    end
end

%vanishing lin criterion fulfilled
vancrit=1;



⌨️ 快捷键说明

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