A first example
This example creates a grabber and displays basic information about the interface,
device, and remote device modules it contains. This is the C# version of the first C++ EGrabber
example:
using System;
namespace FirstExample {
class ShowInfo {
const int CARD_IX = 0;
const int DEVICE_IX = 0;
static void showInfo() {
using (Euresys.EGenTL gentl = new Euresys.EGenTL()) { // 1
using (Euresys.EGrabberCallbackOnDemand grabber =
new Euresys.EGrabberCallbackOnDemand(gentl, CARD_IX, DEVICE_IX)) { // 2
String card = grabber.getStringInterfaceModule("InterfaceID"); // 3
String dev = grabber.getStringDeviceModule("DeviceID"); // 4
long width = grabber.getIntegerRemoteModule("Width"); // 5
long height = grabber.getIntegerRemoteModule("Height"); // 5
System.Console.WriteLine("Interface: {0}", card);
System.Console.WriteLine("Device: {0}", dev);
System.Console.WriteLine("Resolution: {0}x{1}", width, height);
}
}
}
static void Main() {
try { // 6
showInfo();
} catch (System.Exception e) { // 6
System.Console.WriteLine("error: {0}", e.Message);
}
}
}
}
- Create a
Euresys.EGenTL
object. This involves the following operations:- locate and dynamically load the Coaxlink GenTL producer
(
coaxlink.cti
); - retrieve pointers to the functions exported by
coaxlink.cti
; - initialize
coaxlink.cti
.
- locate and dynamically load the Coaxlink GenTL producer
(
- Create a
Euresys.EGrabberCallbackOnDemand
object. The constructor needs thegentl
object we've just created. It also takes as optional arguments the indices of the interface and device to use. - Use GenApi to find out the ID of the Coaxlink
card. Notice the
InterfaceModule
suffix ingetString
InterfaceModule
. This indicates that we want an answer from the interface module. - Similarly, find out the ID of the device. This time, we use
getString
DeviceModule
to target the device module. - Finally, read the camera resolution. This time, we use
getInteger
RemoteModule
because values must be read from the camera. EGrabber
uses exceptions to report errors, so we wrap our code inside atry ... catch
block.
Example of program output:
Interface: PC1633 - Coaxlink Quad G3 (2-camera) - KQG00014
Device: Device0
Resolution: 4096x4096