Code samples for findContours (Automatically generated by the Every Method demo).
// Automated test of findContours - Typical Values
// TIEVisionImage.findContours - Mode: ievEXTERNAL, Contours: 164, Drawn (area >= 500): 3
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().threshold( 0, 255, ievTHRESH_BINARY or ievTHRESH_OTSU );
contours := bmp.GetIEVisionImage().findContours( ievEXTERNAL, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 164
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 0, 0, 255 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - Alpha Channel - Typical Values
// TIEVisionImage.findContours - Mode: ievEXTERNAL, Contours: 64, Drawn (area >= 500): 1
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().threshold( 0, 255, ievTHRESH_BINARY or ievTHRESH_OTSU );
contours := bmp.GetIEVisionImage().findContours( ievEXTERNAL, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 64
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 0, 0, 255 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - 32-Bit RGBA - Typical Values
// TIEVisionImage.findContours - Mode: ievEXTERNAL, Contours: 1, Drawn (area >= 500): 1
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().threshold( 0, 255, ievTHRESH_BINARY or ievTHRESH_OTSU );
contours := bmp.GetIEVisionImage().findContours( ievEXTERNAL, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 1
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 0, 0, 255 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - 1-bit - Typical Values
// TIEVisionImage.findContours - Mode: ievEXTERNAL, Contours: 8144, Drawn (area >= 500): 3
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().threshold( 0, 255, ievTHRESH_BINARY or ievTHRESH_OTSU );
contours := bmp.GetIEVisionImage().findContours( ievEXTERNAL, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 8144
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 0, 0, 255 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - Random Values
// TIEVisionImage.findContours - Mode: ievLIST, Contours: 336, Drawn (area >= 5500): 0
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().canny( 50, 150 );
contours := bmp.GetIEVisionImage().findContours( ievLIST, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 336
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 5500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 255, 255, 0 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - Alpha Channel - Random Values
// TIEVisionImage.findContours - Mode: ievLIST, Contours: 345, Drawn (area >= 5500): 0
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().canny( 50, 150 );
contours := bmp.GetIEVisionImage().findContours( ievLIST, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 345
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 5500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 255, 255, 0 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - 32-Bit RGBA - Random Values
// TIEVisionImage.findContours - Mode: ievLIST, Contours: 392, Drawn (area >= 5500): 0
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().canny( 50, 150 );
contours := bmp.GetIEVisionImage().findContours( ievLIST, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 392
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 5500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 255, 255, 0 ), i, 2 );
ImageEnView1.Update();

// Automated test of findContours - 1-bit - Random Values
// TIEVisionImage.findContours - Mode: ievLIST, Contours: 14426, Drawn (area >= 5500): 1
// findContours requires a binary 8bit, 1 channel image
bmp := TIEBitmap.Create( ImageEnView1.IEBitmap );
bmp.PixelFormat := ie8g;
bmp.GetIEVisionImage().canny( 50, 150 );
contours := bmp.GetIEVisionImage().findContours( ievLIST, ievCHAIN_APPROX_SIMPLE, IEVisionPoint( 0, 0 )); // Found count: 14426
bmp.Free();
for i := 0 to contours.size() - 1 do
if IEVisionLib().createMath().contourArea( TIEVisionVectorPoint( contours.getObj( i ))) >= 5500 then
IEVisionLib().createDrawing().drawContours( ImageEnView1.IEBitmap.GetIEVisionImage(), contours, IEVisionScalar( 255, 255, 0 ), i, 2 );
ImageEnView1.Update();
