using conditional operators for string matching
显示 更早的评论
J=im2uint8(im);
ocrResults = ocr(J)
recognizedText = ocrResults.Text;
TF=contains(recognizedText,'Axis Bank', 'IgnoreCase', true);
bboxes = locateText(ocrResults, 'Axis Bank', 'IgnoreCase', true);
Iocr = insertShape(J, 'FilledRectangle', bboxes);
figure;
imshow(Iocr);
disp('Axis Bank')
I am new to Matlab so I appreciate your patience regarding my noviceness.
I need to check if an OCR-ed string contains a substring and I need to check multiple substrings automatically. However I am unable to use any conditional operator as I do not understand how to use the logical output I am getting from
TF variable
Kindly assist me with this problem.
Thank you.
9 个评论
Alex Mcaulley
2019-5-8
What is the question? see this
Siddesh chaudhary
2019-5-8
Siddesh chaudhary
2019-5-8
Geoff Hayes
2019-5-8
Siddesh - you have your if/elseif block set up as
if TF == 1
% some code
elseif TF == 1
% some other code
end
The elseif block will never evaluate since it has the same condition as the first block. Perhaps you mean to do something like
if TF == 1
% some code
% TF = ...;
end
if TF == 1
% other code
end
Since in the if block you re-assign the value of TF.
Or perhaps
if TF
% some code
end
"if TF==1" is redundant. TF is a logical that is either true (1) or false (0).
@ Siddesh , select all of your code (cltr + a) and then auto-indent (ctrl + i). The indentation will help you to catch these types of issues.
Siddesh chaudhary
2019-5-8
Siddesh chaudhary
2019-5-8
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Event Functions 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
