why hough can't detect the lane line
2 次查看(过去 30 天)
显示 更早的评论
I try to use hough to detect the line , the right line was missing. how to solve it?
see the result
the hough detect result
code is as following
grapy_pic=rgb2gray(pic);
edge_pic=edge(grapy_pic,'canny',[0.05 0.35]);
imshow(edge_pic)
shape=size(pic);
% row coordinate
a=[shape(2)*0 shape(2)*1 shape(2)*1 0];
%column corordinate
b=[shape(1)*0.05 shape(1)*0.05 shape(1)*0.65 shape(1)*0.65 ];
%use a,b to specify the interesting area
bw=roipoly(pic,a,b);
BW=(edge_pic(:,:,1) & bw);
imshow(BW)
hold on
plot(a, b)
hold off
[H, T, R]=hough(BW') %,'RhoResolution', 1, 'ThetaResolution', 1);
P=houghpeaks(H,5);%'threshold');%,ceil(0.6*max(H(:))));
lines=houghlines(BW,T,R,P,'FillGap',4,'MinLength',5);
imagesc(pic);
hold on;
%plot(lines(5).point1(1),lines(5).point1(2),'rd')
for i=1:length(lines)
plot([lines(i).point1(1),lines(i).point2(1)],[lines(i).point1(2),lines(i).point2(2)],'Color','blue','LineWidth',4)
end
hold off
0 个评论
回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!