Building a Sample List

The class ESampleList contains all the information about a "customer use case".

An ESampleList is a list of ESample, where each ESample is associated to an image from the batch.
The "texts of interest" are specified as EText, the output class of the method ETextReader.Read.
You can specify a ERegion inside an ESample corresponding to the region used to read the image with ETextReader.Read. It is particularly useful if the region where the "text of interest" lies is found by some pre-processing.

The best way to create an ESampleList is through a graphic interface because you need to annotate the "texts of interest". The new Open eVision Studio provides a widget to perform this annotation painlessly. Nevertheless, you can also create the ESampleList using the API.

new Open eVision Studio widget

The new Open eVision Studio widget for the edition of an ESampleList

To manage your ESampleList:

1. Open a file explorer to add one or several images to the batch.
An ESample is created for each image added to the batch.
2. Display the list of the ESample. The ESample currently selected is highlighted.
3. Create a new EText and add it to the selected ESample.
4. Display the list of EText for the selected ESample. The EText currently selected is highlighted.
5. Create a new ETextLine and add it to the selected EText.
6. Display the list of ETextLine for the selected EText.
You must edit the string of the ETextLine from this table.
You can edit the position of the ETextLine from this table.
7. Display the image of the selected ESample, overlaid with the ETextLine of the selected EText.
You can edit the position of the ETextLine using the handles.
The orientation of the ETextLine is indicated by a small arrow.

The public API

The creation of the ESampleList using the public API is illustrated in the code snippet below.

The ESampleList created by this snippet contains a single ESample.
This ESample contains a single EText that is composed of a single ETextLine.

You can easily modify this code snippet to include more ESample, EText and ETextLine.

EasyDeepOCR expects that the rectangle of the ETextLine is tightly adjusted to the texts. There must be no margin between the text line and the border of the rectangle.

#include <Open_eVision.h>

void BuildingASampleList()
{
  ////////////////////////////////////////////////////////
  // This code snippet shows how to fill a sample list. //
  ////////////////////////////////////////////////////////
  using namespace Euresys::Open_eVision;
  namespace EDO = Euresys::Open_eVision::EasyDeepOCR;
  // Create an ESampleList
  EDO::ESampleList sampleList;
  // Create an ESample vector
  std::vector<EDO::ESample> samples(1);
  // Fill the ESample vector
  for (EDO::ESample& sample : samples)
  {
    // Set the image
    sample.SetImagePath("image.tif");
    // Create an EText vector 
    std::vector<EDO::EText> texts(1);
    // Fill the EText vector
    for (EDO::EText& text : texts)
    {
      // Create an ETextLine vector
      std::vector<EDO::ETextLine> textLines(1);
      // Fill the ETextLine vector
      for (EDO::ETextLine& textLine : textLines)
      {
        // Adjust the ERectangle around the text line
        textLine.SetRectangle(ERectangle());
        // Annotate the text line
        textLine.SetString("");
      }
      // Set the ETextLine vector
      text.SetLines(textLines);
    }
    // Set the EText vector
    sample.SetTexts(texts);
  }
  // Set the ESample vector
  sampleList.SetSamples(samples);
  // ...
}
using Euresys.Open_eVision;
using EDO = Euresys.Open_eVision.EasyDeepOCR;

static partial class Snippet
{
  static void BuildingASampleList()
  {
    ////////////////////////////////////////////////////////
    // This code snippet shows how to fill a sample list. //
    ////////////////////////////////////////////////////////
    // Create an ESampleList
    EDO.ESampleList sampleList = new EDO.ESampleList();
    // Create an ESample vector
    EDO.ESample[] samples = new EDO.ESample[1];
    // Fill the ESample vector
    foreach (EDO.ESample sample in samples) 
    {
      // Set the image
      sample.ImagePath = "image.tif";
      // Create an EText vector 
      EDO.EText[] texts = new EDO.EText[1];
      // Fill the EText vector
      foreach (EDO.EText text in texts)
      {
        // Create an ETextLine vector
        EDO.ETextLine[] textLines = new EDO.ETextLine[1];
        // Fill the ETextLine vector
        foreach (EDO.ETextLine textLine in textLines)
        {
          // Adjust the ERectangle around the text line
          textLine.Rectangle = new ERectangle();
          // Annotate the text line
          textLine.String = "";
        }
        // Set the ETextLine vector
        text.Lines = textLines;
      }
      // Set the EText vector
      sample.Texts = texts;
    }
    // Set the ESample vector
    sampleList.Samples = samples;
    // ...
  }
}
def BuildingASampleList():
  #########################################################
  ## This code snippet shows how to fill a sample list.  ##
  #########################################################
  import open_evision as oev
  from open_evision import EasyDeepOCR as EDO
  # Create an ESampleList
  sampleList = EDO.ESampleList()
  # Create an ESample vector
  samples = [EDO.ESample()]
  # Fill the ESample vector
  for sample in samples: 
    # Set the image
    sample.ImagePath = "image.tif"
    # Create an EText vector 
    texts = [EDO.EText()]
    # Fill the EText vector
    for text in texts:
      # Create an ETextLine vector
      textLines = [EDO.ETextLine()]
      # Fill the ETextLine vector
      for textLine in textLines:
        # Adjust the ERectangle around the text line
        textLine.Rectangle = oev.ERectangle()
        # Annotate the text line
        textLine.String = ""
      # Set the ETextLine vector
      text.Lines = textLines
    # Set the EText vector
    sample.Texts = texts
  # Set the ESample vector
  sampleList.Samples = samples
  # ...