Documentation Portal      

What are you looking for?

Learning Characters

Functional Guide | Reference: NewFont, SetTextColor, SetMinCharWidth, SetMaxCharWidth, SetMinCharHeight, SetMaxCharHeight, SetNoiseArea, LearnPatterns, BuildObjects, FindAllChars, Save

//////////////////////////////////////////////////////
// This code snippet shows how to learn characters //
// based on an image featuring a known text and //
// save the corresponding font file. //
//////////////////////////////////////////////////////
// Image constructor
EImageBW8 srcImage;
// EOCR constructor
EOCR ocr;
// Text to be learned (all digits)
// Assuming the image contains this text
const std::string text= "0123456789";
// ...
// Create a new fon
ocr.NewFont(8, 11);
// Adjust the segmentation parameters
ocr.SetTextColor(EOCRColor_BlackOnWhite);
ocr.SetMinCharWidth(15);
ocr.SetMinCharWidth(50);
ocr.SetMinCharHeight(15);
ocr.SetMinCharHeight(75);
ocr.SetNoiseArea(15);
// Segment the characters
ocr.BuildObjects(&srcImage);
ocr.FindAllChars(&srcImage);
// Learn the characters
ocr.LearnPatterns(&srcImage, text, EOCRClass_Digit);
// Save the font into a file
ocr.Save("myFont.ocr");
'//////////////////////////////////////////////////////
'// This code snippet shows how to learn characters //
'// based on an image featuring a known text and //
'// save the corresponding font file. //
'//////////////////////////////////////////////////////
' Image constructor
Dim srcImage As New EImageBW8
' EOCR constructor
Dim ocr As New EOCR
' Text to be learned (all digits)
' Assuming the image contains this text
Dim text As String
text = "0123456789"
' ...
' Create a new font
ocr.NewFont 8, 11
' Adjust the segmentation parameters
ocr.TextColor = EOCRColor_BlackOnWhite
ocr.MinCharWidth = 15
ocr.MaxCharWidth = 50
ocr.MinCharHeight = 15
ocr.MaxCharHeight = 75
ocr.NoiseArea = 15
' Segment the characters
ocr.BuildObjects srcImage
ocr.FindAllChars srcImage
' Learn the characters
ocr.LearnPatterns srcImage, text, EOCRClass_Digit
' Save the font into a file
ocr.Save "myFont.ocr"
//////////////////////////////////////////////////////
// This code snippet shows how to learn characters //
// based on an image featuring a known text and //
// save the corresponding font file. //
//////////////////////////////////////////////////////
// Image constructor
EImageBW8 srcImage= new EImageBW8();
// EOCR constructor
EOCR ocr= new EOCR();
// Text to be learned (all digits)
// Assuming the image contains this text
string text= "0123456789";
// ...
// Create a new font
ocr.NewFont(8, 11);
// Adjust the segmentation parameters
ocr.TextColor= EOCRColor.BlackOnWhite;
ocr.MinCharWidth= 15;
ocr.MaxCharWidth= 50;
ocr.MinCharHeight= 15;
ocr.MaxCharHeight= 75;
ocr.NoiseArea= 15;
// Segment the characters
ocr.BuildObjects(srcImage);
ocr.FindAllChars(srcImage);
// Learn the characters
ocr.LearnPatterns(srcImage, text, (int)EOCRClass.Digit);
// Save the font into a file
ocr.Save("myFont.ocr");

Which API shall we display?

© 2018 EURESYS s.a.  -  About Documentation  -  Open Source Licenses  -  Open eVision 2.5.1.1107