getting error in lane detection

I am not familiar with matlab. i had used your tutorial video no 6 and getting error in following statement
lanes=findlanes(B,h,stats);
hold off;
and i am getting following error
??? Undefined function or variable
'stats'.
can you help me resolving following error

回答 (2 件)

Walter Roberson
Walter Roberson 2015 年 8 月 8 日

0 投票

and see the lines of code there:
% Extract statistics
stats = regionprops(L,'MajorAxisLength','MinorAxisLength');
You do not appear to have done that before calling findlanes()

3 件のコメント

mustafa wala
mustafa wala 2015 年 8 月 9 日
編集済み: Image Analyst 2015 年 8 月 9 日
I am not satisfied with your answer. I had listed codes which I had used in this. You can see it below.
%%Lane Marking Identification
%%Read image
street = imread('street1.jpg');
%%Display image
figure;
gray(256);
imagesc(street1);
%%Scale image
scaled=street1*1.05;
image(scaled);
%%Threshold
level=211;
binary = scaled>level;
imagesc(binary);
%%Remove the noise
binary = bwareaopen(binary,100);
imagesc(binary)
hold on
%%Find the boundaries of objects
[B,L] = bwboundaries(binary(:,:),'noholes');
h = zeros(1,length(B));
% Plot boundaries
for K=1:length(B)
boundary = B{K};
h(K)=plot(boundary(:,2), boundary(:,1), 'g','LineWidth', 2);
end
% Extract statistics
stats = regionprops(L,'MajorAxisLength','MinorAxisLength');
%%Find lanes and delete non-lane objects
lanes=find_lanes(B,h,stats);
hold off;
Can you correct it, and give me the answer with the reasons?
Walter Roberson
Walter Roberson 2015 年 8 月 9 日
I will need to see the complete traceback of the error message. Your Question refers to a line which invokes findlanes() but your code here refers to find_lanes(), a different routine. Possibly you are using a find_lanes() that invokes findlanes() so the problem might be in your find_lanes() routine, whatever content it might happen to have.
Please show the output of
which -all find_lanes
which -all findlanes
Image Analyst
Image Analyst 2016 年 4 月 22 日
I'm not satisfied with your comment, mustafa. Please attach 'street1.jpg' so people can actually run your code.

サインインしてコメントする。

Image Analyst
Image Analyst 2015 年 8 月 9 日

0 投票

You say that it's saying stats is undefined. So change this code
% Extract statistics
stats = regionprops(L,'MajorAxisLength','MinorAxisLength');
%%Find lanes and delete non-lane objects
lanes=find_lanes(B,h,stats);
to this code:
% Extract statistics
stats = regionprops(L,'MajorAxisLength','MinorAxisLength');
whos stats
which find_lanes
whos find_lanes
%%Find lanes and delete non-lane objects
lanes=find_lanes(B,h,stats);
and tell me what it says in the command window.

7 件のコメント

mustafa wala
mustafa wala 2015 年 8 月 10 日
i tried your above statements and it gives following output in command window
'find_lanes' not found. ??? Undefined function or method 'find_lanes' for input arguments of type 'cell'.
Oghenemine Henry
Oghenemine Henry 2016 年 4 月 21 日
I always get this error message when trying to run the code. Please how do I correct this Error using bwboundaries Expected input number 1, BW, to be two-dimensional.
Error in bwboundaries>parseInputs (line 159) validateattributes(BW, {'numeric','logical'}, {'real','2d','nonsparse'}, ...
Error in bwboundaries (line 128) [BW, conn, findholes] = parseInputs(varargin{:});
Error in lanemarkings (line 21) [B,L,N]=bwboundaries(binary, 'noholes');
Image Analyst
Image Analyst 2016 年 4 月 22 日
Your BW is most likely a true color RGB image rather than a binary (logical) image. What does this say:
whos BW
Oghenemine Henry
Oghenemine Henry 2016 年 4 月 23 日
nothing appears when I type
whos BW
Image Analyst
Image Analyst 2016 年 4 月 23 日
It looks like BW is the name given by some internal functions. It looks like you called it "binary" so what does whos binary show? It probably shows that it's a color image not a "logical" binary image.
Oghenemine Henry
Oghenemine Henry 2016 年 4 月 24 日
whos binary Name Size Bytes Class Attributes
binary 568x962x3 1639248 logical
Image Analyst
Image Analyst 2016 年 4 月 24 日
binary is a 3-D volumetric image, like you're dealing with CT or MRI images or something. I don't think this should be. You should convert street to a grayscale image before you threshold it at 211.
From street, or street1, whatever you called the variable, which color channel do you want to use? Or do you want to take a weighted average?
if ndims(street)
street = rgb2gray(street);
end

サインインしてコメントする。

カテゴリ

質問済み:

2015 年 8 月 8 日

コメント済み:

2016 年 4 月 24 日

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by