why can't my OCR code identify the license plate on the code?
Show older comments
the programming that I made did not experience errors, and for some reason the OCR output did not appear, instead the word "NaN" appeared continuously. please help me to fix it.
I = imread(image1.png);
crop=imcrop(I);
I2 = rgb2gray(crop);
K = im2bw(I2, 0.6);
bw = im2bw(crop);
canny = edge(bw, 'Canny');
figure, imshow(I), title('Original image');
figure,imshow(bw), title ('binerisasi');
figure,imshow(canny), title ('canny');
figure, imshow(crop), title ('cropping');
figure, imshow(I2), title ('grayscale');
figure, imshow(K), title ('thresholding');
ocrOutput = ocr(I, 'TextLayout', 'Line', 'characterSet', '0123456789');
outputNum = str2double(ocrOutput.Text)
ocrImage = insertObjectAnnotation(I, 'rectangle', ocrOutput.WordBoundingBoxes, ...
ocrOutput.WordConfidences);
figure, imshow(ocrImage), title ('OCR');
4 Comments
Walter Roberson
on 1 Sep 2023
I = imread(image1.png);
In order for that to work, image1 would have to be a struct with a field named png -- or else image1 would have to be an object with a property or method named png .
Note: it would probably be easier for us to debug if you attached the image.
Amelinda Callista
on 2 Sep 2023
I don't have CVT, but it seems to work just fine, depending on what region is selected.
I = imread('images.jpeg');
% irrelevant code omitted
% pick a region
%ocrOutput = ocr(I,[67 55 169 46],'characterset','0':'9');
ocrOutput = ocr(I,[128 88 43 14],'characterset','0':'9');
outputNum = str2double(ocrOutput.Text)
ocrImage = insertObjectAnnotation(I, 'rectangle', ocrOutput.WordBoundingBoxes, ...
ocrOutput.WordConfidences);
figure, imshow(ocrImage), title ('OCR');
Amelinda Callista
on 6 Sep 2023
Edited: Amelinda Callista
on 6 Sep 2023
Accepted Answer
More Answers (0)
Categories
Find more on Convert Image Type in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!