Managing EGrabber Parameters

This code snippet shows how to go from an EGrabber buffer to an EGrabberImageBW8, compatible with eVision processing.

C++

#include <EGrabber.h>
#include <FormatConverter.h>
#include <eVision/EGrabberBridge.h>
using namespace eVision;
using namespace Euresys;

// Construct the EGrabber objects.
// The FormatConverter is optional and will automatically convert the EGenTL buffer to
// the chosen eVision image type
// WARNING: EGrabberCallbackOnDemand and FormatConverter are using an EGenTL instance, you must dispose them before disposing it.
EGenTL genTL;
EGrabber<CallbackOnDemand> grabber(genTL);
FormatConverter converter(genTL);

// Allocate one buffer
grabber.reallocBuffers(1);

// ...

// Manage EGrabber features
// Get/set camera (RemoteModule) features of various types:
// string - integer - float.
// WARNING: The features might be specific to each camera
std::string pixelFormat = grabber.getString<RemoteModule>("PixelFormat");
grabber.setString<RemoteModule>("PixelFormat", "Mono8");

int64_t width = grabber.getInteger<RemoteModule>("Width");
grabber.setInteger<RemoteModule>("Width", 1024);

double exposureTime = grabber.getFloat<RemoteModule>("ExposureTime");
grabber.setFloat<RemoteModule>("ExposureTime", 60.0f);

// ...

// Start the grabber acquisition of one buffer
grabber.start(1);

// Get the acquired buffer
ScopedBuffer buffer(grabber);

// Convert the ScopedBuffer to an eVision data container
// Not using converter:
// EGrabberBridge::EGrabberImageBW8 image(buffer.getInfo());
EGrabberBridge::EGrabberImageBW8 image(converter, buffer.getInfo());

// ...

C#

using Euresys.EGrabber;
using eVision;
// Construct the EGrabber objects.
// WARNING: EGrabber is using an EGenTL instance,
// you must dispose of EGenTL before disposing of EGrabber.
EGenTL genTL = new EGenTL();
EGrabber grabber = new EGrabber(genTL);

// Allocate one buffer
grabber.ReallocBuffers(1);


// ...

// Manage EGrabber features
// Get/set camera (RemoteModule) features of various types:
// string - integer - float.
// WARNING: The features might be specific to each camera.
string pixelFormat = grabber.Remote.Get<string>("PixelFormat");
grabber.Remote.Set("PixelFormat", "Mono8");

int width = grabber.Remote.Get<int>("Width");
grabber.Remote.Set("Width", 1024);

float exposureTime = grabber.Remote.Get<float>("ExposureTime");
grabber.Remote.Set("ExposureTime", 60.0f);

// ...

// Start the grabber acquisition of one buffer
grabber.Start(1);

// Get the acquired buffer
using (ScopedBuffer buffer = new ScopedBuffer(grabber))
{
  ConvertedBuffer converted = buffer.Convert("Mono8");
  EImageBW8 image = new EImageBW8();
  image.UseExternalBuffer(converted.Width, converted.Height, converted.Pixels, converted.LinePitch);

  // ...
}

Python

import ctypes
import eVision
import egrabber
import egentl

# Construct the EGrabber objects.
genTL = egentl.EGenTL()
grabber = egrabber.EGrabber(genTL)

# Allocate one buffer
grabber.realloc_buffers(1)

# ...

# Manage EGrabber features
# Get/set camera (RemoteModule) features of various types:
# string - integer - float.
# WARNING: The features might be specific to each camera.
pixelFormat = grabber.remote.get("PixelFormat", dtype=str)
grabber.remote.set("PixelFormat", "Mono8")

width = grabber.remote.get("Width", dtype=int)
grabber.remote.set("Width", 1024)

exposure_time = grabber.remote.get("ExposureTime", dtype=float)
grabber.remote.set("ExposureTime", 60.0)

# ...

# Start the grabber acquisition of one buffer
grabber.start(1)

# Get the acquired buffer
with egrabber.Buffer(grabber) as buffer:
    converted = buffer.convert('Mono8')

    image = eVision.EImageBW8()
    data = ctypes.cast(converted.get_address(), ctypes.c_void_p)
    image.UseExternalBuffer(converted.width, converted.height, data, converted.line_pitch)

    # ...