Train User Pattern Problem

  • 425 Views
  • Last Post 14 January 2016
Andrei posted this 14 January 2016

I am trying to create custom pattern for special symbol, but has following error:

An attempt was made to access /opt/ABBYY/FREngine11/Samples/Java/TrainUserPatternSample2/costa_rica_currency.pattern past its end.

Code:

            //create pattern
        ITrainingImagesCollection imagesCollection = engine.CreateTrainingImagesCollection();
        ITrainingImage image = engine.CreateTrainingImage();
        image.setBaseLine(31);
        image.setSmallCharsHeight(22);
        IImageDocument imageDoc = engine.OpenImageFile("costa_rica_currency.bmp", null, null, null);
        IImage bwImage = imageDoc.getBlackWhiteImage();
        IRegion region = engine.CreateRegion();
        region.AddRect(0, 0, bwImage.getWidth(), bwImage.getHeight());
        image.SetImageData(imageDoc, region);
        imagesCollection.Add(image);

        String filename = "costa_rica_currency.pattern";
        createPatternFile(filename);
        engine.TrainUserPattern(filename, imagesCollection, "₡", 0, TextTypeEnum.TT_Normal);

Andrei posted this 14 January 2016

Fixed by replacing

createPatternFile(filename); //creating a new file

to

engine.CreateEmptyUserPattern(filename);

Close