Looping over the runs of an object¶
This code snippet shows how to loop over the runs of an object.
C++¶
#include <eVision/EasyObject/EasyObject2/EImageEncoder.h>
using namespace eVision;
// Image constructor
EImageBW8 srcImage;
// Image encoder
EImageEncoder encoder;
// Coded image
ECodedImage2 codedImage;
// ...
// Encode the source image
encoder.Encode(srcImage, codedImage);
for (unsigned int index = 0; index < codedImage.GetObjCount(); index++)
{
// Retrieve an object from the coded image.
ECodedElement blob = codedImage.GetObj(index);
EObjectRunsIterator it = blob.GetRunsIterator();
for (it.First(); !it.IsDone(); it.Next())
{
int y = it.GetY();
int startX = it.GetStartX();
uint32_t length = it.GetLength();
}
}
C#¶
using eVision;
// Image constructor
EImageBW8 srcImage = new EImageBW8();
// Image encoder
EImageEncoder encoder = new EImageEncoder();
// Coded image
ECodedImage2 codedImage = new ECodedImage2();
// ...
// Encode the source image
encoder.Encode(srcImage, codedImage);
for (uint index = 0; index < codedImage.GetObjCount(); index++)
{
// Retrieve an object from the coded image.
ECodedElement blob = codedImage.GetObj(index);
EObjectRunsIterator it = blob.RunsIterator;
for (it.First(); !it.IsDone; it.Next())
{
int y = it.Y;
int startX = it.StartX;
uint length = it.Length;
}
}
Python¶
import eVision
# Image constructor
src_image = eVision.EImageBW8()
# Image encoder
encoder = eVision.EImageEncoder()
# Coded image
codedImage = eVision.ECodedImage2()
# ...
# Encode the source image
encoder.Encode(src_image, codedImage)
for index in range(codedImage.GetObjCount()):
# Retrieve the selected blob gravity center
blob = codedImage.GetObj(index)
it = blob.RunsIterator
it.First()
while not it.IsDone():
y = it.Y
startX = it.StartX
length = it.Length
it.Next()
See also
EObjectRunsIterator .NET C++, ECodedElement.RunsIterator .NET C++