Building a Sample List¶
This code snippet shows how to fill a sample list.
C++¶
#include <eVision/EasyOcr/EasyDeepOCR/ESampleList.h>
using namespace eVision;
namespace EDO = 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);
// ...
C#¶
using eVision;
using EDO = eVision.EasyDeepOCR;
// 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;
// ...
Python¶
import eVision
from 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 = eVision.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