Problem with using while
    2 Ansichten (letzte 30 Tage)
  
       Ältere Kommentare anzeigen
    
    Abdussalam Elhanashi
 am 31 Okt. 2019
  
    
    
    
    
    Beantwortet: James Heselden
      
 am 31 Okt. 2019
            Hi Guys 
 have a problem with using while and give me an error when i run matlab for the code attached named Evaluationthedetector
Kindly looking for your assistance
Regards
load('gTruth.mat')
smokedetection = selectLabels(gTruth,'cat');
if ~isfolder(fullfile('EvaluationData'))
    mkdir EvaluationData
    addpath('EvaluationData');
    evaluationData = objectDetectorTrainingData(gTruth,...
    'SamplingFactor',10,'WriteLocation','EvaluationData');
end
imds = imageDatastore(fullfile('EvaluationData'));
numImages = height(evaluationData);
result(numImages,:) = struct('Boxes',[],'Scores',[]);
while i = 1:numImages
    % Read Image
    I = readimage(imds,numImages); 
    % Detect the object of interest
    [bboxes, scores] = detect(detector,I,'MiniBatchSize', 32);
    T = 0.54; % Define threshold here
    idx = scores >= T;
    % if there are 2 or more objects detected, show them
    if nnz(idx) >= 2
        % Retrieve those scores that surpassed the threshold
        s = scores(idx);
        % Do the same for the labels as well
        bboxes = bboxes(idx, :); % This logic doesn't change
    % Store result 
    result(i).Boxes = bboxes;
    result(i).Scores = scores;
    end
end
% Convert structure to table
results = struct2table(result);
Error: File: Evaluationthedetector.m Line: 14 Column: 9
Incorrect use of '=' operator. To assign a value to a variable, use '='. To compare values for equality, use
'=='.
0 Kommentare
Akzeptierte Antwort
  James Heselden
      
 am 31 Okt. 2019
        You are using a while loop where you should be using a for loop.
% Swap out 
while i = 1:numImages
    ...
end
% to 
for i = 1:numImages
    ...
end
Regards
James
0 Kommentare
Weitere Antworten (1)
  Sulaymon Eshkabilov
      
 am 31 Okt. 2019
        while .. end is not used correcly, use for ... end instead
for i = 1:numImages
    % Read Image
    I = readimage(imds,numImages); 
    % Detect the object of interest
    [bboxes, scores] = detect(detector,I,'MiniBatchSize', 32);
    T = 0.54; % Define threshold here
    idx = scores >= T;
    % if there are 2 or more objects detected, show them
    if nnz(idx) >= 2
        % Retrieve those scores that surpassed the threshold
        s = scores(idx);
        % Do the same for the labels as well
        bboxes = bboxes(idx, :); % This logic doesn't change
    % Store result 
    result(i).Boxes = bboxes;
    result(i).Scores = scores;
    end
end
% Convert structure to table
0 Kommentare
Siehe auch
Kategorien
				Mehr zu Language Support finden Sie in Help Center und File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


