Continuous Mode

This code snippet shows how to build and draw blobs in the continuous mode context.

C++

#include <eVision/EasyObject/EasyObject2/EImageEncoder.h>
using namespace eVision;
// Size of the chunks that will be processed
int chunkWidth = 128;
int chunkHeight = 256;

// Number of chunks that will be processed
int numChunks = 100;

// Image that will contain each chunk to be encoded
EImageBW8 imageChunk(chunkWidth, chunkHeight);

// An image in which we will draw all the detected objects from all the chunks.
EImageC24A allBlobs(chunkWidth, numChunks * chunkHeight);

// Image encoder
EImageEncoder encoder;
// Coded image
ECodedImage2 codedImage;
// ...
// Enable the continuous mode
encoder.SetContinuousModeEnabled(true);

// Loop to acquire the different chunks
for (int count = 0; count < numChunks; count++)
{
  // Store the new chunk into imageChunk
  // ...

  // Encode the current chunk
  encoder.Encode(imageChunk, codedImage);

  // Draw the current objects
  EGenericDrawAdapter drawAdapter(&allBlobs);
  codedImage.Draw(&drawAdapter, 1.0f, 1.0f, 0.0f, static_cast<float>(count * chunkHeight));
}

// Flush the continuous mode
encoder.FlushContinuousMode(codedImage);

// codedImage now contains the remaining blobs that were touching the bottom of the last chunk.
EGenericDrawAdapter drawAdapter(&allBlobs);
codedImage.Draw(&drawAdapter, 1.0f, 1.0f, 0.0f, static_cast<float>(numChunks * chunkHeight));

C#

using eVision;
// Size of the chunks that will be processed
int chunkWidth = 128;
int chunkHeight = 256;

// Number of chunks that will be processed
int numChunks = 100;

// Image that will contain each chunk to be encoded
EImageBW8 imageChunk = new EImageBW8(chunkWidth, chunkHeight);

// An image in which we will draw all the detected objects from all the chunks.
EImageC24A allBlobs = new EImageC24A(chunkWidth, numChunks * chunkHeight);

// Draw adapter to draw in the image "allBlobs"
EGenericDrawAdapter drawAdapter = new EGenericDrawAdapter(allBlobs);

// Image encoder
EImageEncoder encoder = new EImageEncoder();
// Coded image
ECodedImage2 codedImage = new ECodedImage2();
// ...
// Enable the continuous mode
encoder.ContinuousModeEnabled = true;
// Loop to acquire the different chunks
for (int count = 0; count < numChunks; count++)
{
  // Store the new chunk into imageChunk
  // ...

  // Encode the current chunk
  encoder.Encode(imageChunk, codedImage);

  // Draw the current objects
  codedImage.Draw(drawAdapter, 1.0f, 1.0f, 0.0f, count * chunkHeight);
}

// Flush the continuous mode
encoder.FlushContinuousMode(codedImage);

// codedImage now contains the remaining blobs that were touching the bottom of the last chunk.
codedImage.Draw(drawAdapter, 1.0f, 1.0f, 0.0f, numChunks * chunkHeight);

Python

import eVision
# Size of the chunks that will be processed
chunkWidth = 128
chunkHeight = 256

# Number of chunks that will be processed
numChunks = 100

# Image that will contain each chunk to be encoded
imageChunk = eVision.EImageBW8(chunkWidth, chunkHeight)

# An image in which we will draw all the detected objects from all the chunks.
allBlobs = eVision.EImageC24A(chunkWidth, numChunks * chunkHeight)

# Draw adapter to draw in the image "allBlobs"
drawAdapter = eVision.EGenericDrawAdapter(allBlobs)

# Image encoder
encoder = eVision.EImageEncoder()
# Coded image
codedImage = eVision.ECodedImage2()
# ...
# Enable the continuous mode
encoder.ContinuousModeEnabled = True
# Loop to acquire the different chunks
for count in range(numChunks):
    # Store the new chunk into imageChunk
    # ...

    # Encode the current chunk
    encoder.Encode(imageChunk, codedImage)

    # Draw the current objects
    codedImage.Draw(drawAdapter, 1.0, 1.0, 0.0, count * chunkHeight)

# Flush the continuous mode
encoder.FlushContinuousMode(codedImage)

# codedImage now contains the remaining blobs that were touching the bottom of the last chunk.
codedImage.Draw(drawAdapter, 1.0, 1.0, 0.0, numChunks * chunkHeight)