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

📄 joinbelow.asv

📁 车道检测中弯道的检测
💻 ASV
字号:
function [array n1 n2]=JoinBelow(LineStruct,s)
%合并下半部分的拟合直线,LineStruct表示直线的struct数组,s表示struct的数量
for(i=1:s)
    if(LineStruct(i).flag==1)
        for(j=1:s)
            if(LineStruct(j).flag==1 && i~=j)
                k1=LineStruct(i).fn(1);
                k2=LineStruct(j).fn(1);
                if(k1*k2>0 && abs(k1-k2)<0.5)
                    d=1000;
                    if(LineStruct(i).low.y<LineStruct(j).top.y)
                        a = LineStruct(i);
%                         aa=a;
                        b = LineStruct(j);
%                         xx=(b.top.y-a.fn(2))/a.fn(1);
%                         d=abs(xx-b.top.x);
                    elseif(LineStruct(i).top.y>LineStruct(j).low.y)
                        a=LineStruct(j);
%                         aa=a;
                        b=LineStruct(i);
%                         xx=(b.top.y-a.fn(2))/a.fn(1);
%                         d=abs(xx-b.top.x);
                    else
                         LineStructNull.StyleFlag=0;
                         LineStruc
                         a=LineStructNull;
                    end
                        aa=a;
                        xx=(b.top.y-a.fn(2))/a.fn(1);
                        d=abs(xx-b.top.x);
                    if(d<40)
                        a.fn(1) = (a.top.y-b.low.y)/(a.top.x-b.low.x);
                        a.fn(2) = a.top.y-a.fn(1)*a.top.x;
                        a.low = b.low;
                        a.length = (a.top.y-b.low.y)*(a.top.y-b.low.y)+(a.top.x-b.low.x)*(a.top.x-b.low.x);
                        if(isequal(aa,LineStruct(i))==1)
                            LineStruct(i) = a;
                            LineStruct(j).flag=0;
                            LineStruct(j).length=0;
                        else
                            LineStruct(j) = a;
                            LineStruct(i).flag=0;
                            LineStruct(i).length=0;
                        end
                    end
                end
            end
        end
    end
end

% tempa=0;
% tempb=0;
% nMax=0;
% nMax2=0;
for(iSort=1:s)
    lengthArray(i) = LineStruct(iSort).length;
end;
[xs,idx] = sort(lengthArray);
xFirst = LineStruct(idx(s)).low.x;
iSecond=s-1;
if(xFirst<100)
    while(LineStruct(idx(iSecond)).low.x<100)
        iSecond=iSecond-1;
    end
else
    while(LineStruct(idx(iSecond)).low.x>100)
        iSecond=iSecond-1;
    end
end


        
% for(i=1:s)
%     if(LineStruct(i).length>tempa)
%         tempa=LineStruct(i).length;
%         nMax=i;
%     end
% end
% 
% for(i=1:s)
%     if(LineStruct(i).length>tempb && i~=nMax)
%         tempb=LineStruct(i).length;
%         nMax2=i;
%     end
% end
array=LineStruct;
n1=idx(s);
n2=idx(iSecond);

⌨️ 快捷键说明

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