2
的OCR我試圖使用MATLAB的OCR
一段文字recognition.This是我的代碼 - 的一部分錯誤MATLAB
r = ocr(n1,'TextLayout','Word')
if strcmp(r.Text,char('_'))==1 | strcmp(r.Text,char('/'))==1
figure,imshow(n1);title('False image to be removed');
else
n2=imadd(n2,n1);figure,imshow(n2);title('uuu1');
end
這是我ocr
result-
r =
ocrText with properties:
Text: '/
'
CharacterBoundingBoxes: [3x4 double]
CharacterConfidences: [3x1 single]
Words: {'/'}
WordBoundingBoxes: [315 133 16 9]
WordConfidences: 0.7857
所以,識別的文本是/
,所以它應該已經進入我的代碼的if
部分。但它總是進入else
部分。我該如何解決這個問題?
據我所知,r.Text末尾有空格,必須在檢查前擦除。或者只是檢查第一個字符。 – Matt
謝謝Matt,這是問題所在。我錯過了空間。 – Joker