Learning Characters

Sorry, this code snippet is currently not available in ActiveX / Visual Basic.

//////////////////////////////////////////////////////
// This code snippet shows how to learn characters  //
// based on an image featuring a known text and     //
// save the corresponding character database        //
//////////////////////////////////////////////////////
// Load an Image
EImageBW8 image;
image.Load("image.tif");
// Attach a ROI to the image
EROIBW8 roi;
roi.Attach(&image, 50, 224, 340, 96);
// Create an EOCR2 instance
EOCR2 ocr2;
// Set the required parameters
ocr2.SetCharsWidthRange(EIntegerRange(25,25));
ocr2.SetCharsHeight(37);
ocr2.SetTextPolarity(EasyOCR2TextPolarity_WhiteOnBlack);
ocr2.SetTopology(".{10}\n.{3} .{4}");
// Learn from the reference image:
//   1) Detect the text in the image
EOCR2Text text = ocr2.Detect(roi);
//   2) Set the true values of the text
text.SetText("Bt121KPJ80\n786 9512");
//   3) Add the characters to the character database
ocr2.Learn(text);
// Save the character database
ocr2.SaveCharacterDatabase("myDB.o2d");
// Alternatively, save the model file.
// This will store the character database and the parameter settings
Ocr2.Save("myModel.o2m");
//////////////////////////////////////////////////////
// This code snippet shows how to learn characters  //
// based on an image featuring a known text and     //
// save the corresponding character database        //
//////////////////////////////////////////////////////
// Load an Image
EImageBW8 image = new EImageBW8();
image.Load("image.tif");
// Attach a ROI to the image
EROIBW8 roi = new EROIBW8();
roi.Attach(image, 50, 224, 340, 96);
// Create an EOCR2 instance
EOCR2 ocr2 = new EOCR2();
// Set the required parameters
ocr2.CharsWidthRange = new EIntegerRange(25,25);
ocr2.CharsHeight = 37;
ocr2.TextPolarity = EasyOCR2TextPolarity.WhiteOnBlack;
ocr2.Topology = ".{10}\n.{3} .{4}";
// Learn from the reference image:
//   1) Detect the text in the image
EOCR2Text text = ocr2.Detect(roi);
//   2) Set the true values of the text
text.Text = "Bt121KPJ80\n786 9512";
//   3) Add the characters to the character database
ocr2.Learn(text);
// Save the character database
ocr2.SaveCharacterDatabase("myDB.o2d");
// Alternatively, save the model file.
// This will store the character database and the parameter settings
ocr2.Save("myModel.o2m");
// Cleanup
text.Dispose();
ocr2.CharsWidthRange.Dispose();
ocr2.Dispose();
roi.Dispose();
image.Dispose();

The image used in this code snippet