Can I train a symbol as special character with ocr?

9 views (last 30 days)
Hi there,
I'm trying to recognize a dial symbol as a special character so I can locate it when I use the ocr function.
However, is not recognizing that symbol at all.
This is my image after training the model. I wanted to locate the green symbol.
Is there another way to do this?
Do you have any suggestion @Image Analyst?
Best

Answers (1)

Shashank Gupta
Shashank Gupta on 3 Feb 2021
Hi Pedro,
I think you need to train an ocr to compensate for the symbol. you can refer to ocrTrain App in MATLAB. you manually have to collect enough data and train a classifier. After training you can export the file and use it in typical ocr workflow.
I hope this helps.
Cheers.
  1 Comment
Frank
Frank ongeveer 14 uur ago
Edited: Walter Roberson ongeveer 13 uur ago
Hi Shashank,
I am new on matlab ocr ... I need the character "§" in base model "german" ...
I tried to extend model "german" by "§" (which is included in the "english" model, but not in german model).
I have labeled one image with two character symbols and another one with three symbols of "§", each is 25 x 37 pixels black on wthite background with good contrast.
I tried to train base model "german" (often called cdsTrain) with the 3-symbol image and "cdsValidation" with the 2-symbol image by using trainOCR-function. See gTruth-object attached ...
But the result is matlab stops (emdless loop) and must be killed ... See atached screenshot.
Do I need more training data perhaps? What went wrong with my approach?
Is there a possibility to merge "german" and "english" models to have the "§" from "english" also for german text ...?
Here is the simple code, I tried:
labelName = "Paragraph";
attributeName = "Paragr";
[imds,boxds,txtds] = ocrTrainingData(gTruth,labelName,attributeName);
cds = combine(imds,boxds,txtds);
outputDir = "C:\Data\Fuzzylogic\Mathlab\Projekte\OCR\OCR-Test\Train_Paragraph\OCRModel";
if ~exist(outputDir, "dir")
mkdir(outputDir);
end
checkpointsDir = "C:\Data\Fuzzylogic\Mathlab\Projekte\OCR\OCR-Test\Train_Paragraph\Checkpoints";
if ~exist(checkpointsDir, "dir")
mkdir(checkpointsDir);
end
cdsTrain = subset(cds, 1); % 3 symbols at one image
cdsValidation = subset(cds, 2); % 2 symbols at another image
ocrOptions = ocrTrainingOptions(GradientDecayFactor=0.9, ...
MaxEpochs=20, VerboseFrequency=160, CharacterSetSource="base-model", ...
CheckpointPath=checkpointsDir, ValidationData=cdsValidation, ...
OutputLocation=outputDir);
outputModelName = "paragraph";
baseModel = "german";
outputModel = trainOCR(cdsTrain, outputModelName, baseModel, ocrOptions);
Thank you very much!
Frank from Berlin

Sign in to comment.

Tags

Community Treasure Hunt

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

Start Hunting!