Effacer les filtres
Effacer les filtres

Image recognition of numbers

20 vues (au cours des 30 derniers jours)
Eli
Eli le 9 Mar 2024
Modifié(e) : Eli le 10 Mar 2024
Hello
I'm taking a photo of some images and trying to recognize automatically what number i have.
Attaching an example where i coudn't recognize the image even though it's easy to see with the eye.
both str2double(ocrOutput.Text) and ocrOutput.WordConfidences
Are empty.
Any idea how to settle this?
ocrOutput = ocr(TEMP, 'TextLayout', 'Line', 'characterSet', '0123456789')

Réponse acceptée

Eli
Eli le 10 Mar 2024
Modifié(e) : Eli le 10 Mar 2024
So I found a solution.
Appereanly the OCR prefers white background and black charecters (and not the other way around)
so the following code does the trick:
load image
imshow(TEMP)
BW = ~imbinarize(TEMP);
imshow(BW)
ocrOutput = ocr(BW, 'TextLayout', 'word', 'characterSet', '0123456789')
ocrOutput =
ocrText with properties: Text: '297183↵↵' CharacterBoundingBoxes: [8×4 double] CharacterConfidences: [8×1 single] Words: {'297183'} WordBoundingBoxes: [11 12 638 165] WordConfidences: 0.9626 TextLines: {'297183'} TextLineBoundingBoxes: [11 12 638 165] TextLineConfidences: 0.9626

Plus de réponses (1)

Voss
Voss le 9 Mar 2024
Try changing the specified Layout type to 'word'
load image
imshow(TEMP)
ocrOutput = ocr(TEMP, 'TextLayout', 'word', 'characterSet', '0123456789')
ocrOutput =
ocrText with properties: Text: '297183↵↵' CharacterBoundingBoxes: [8×4 double] CharacterConfidences: [8×1 single] Words: {'297183'} WordBoundingBoxes: [11 12 638 165] WordConfidences: 0.9594 TextLines: {'297183'} TextLineBoundingBoxes: [11 12 638 165] TextLineConfidences: 0.9594
  1 commentaire
Eli
Eli le 9 Mar 2024
doesn't work for me for some reason:
ocrOutput =
ocrText with properties:
Text: '8↵↵'
CharacterBoundingBoxes: [3×4 double]
CharacterConfidences: [3×1 single]
Words: {'8'}
WordBoundingBoxes: [11 12 638 165]
WordConfidences: 0
TextLines: {'8'}
TextLineBoundingBoxes: [11 12 638 165]
TextLineConfidences: 0

Connectez-vous pour commenter.

Community Treasure Hunt

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

Start Hunting!

Translated by