Impact Acquire SDK .NET
Capturing Image Data

To capture an image an instance of the class mv.impact.acquire.FunctionInterface must be created. This class can be constructed by passing a reference to the mv.impact.acquire.Device object obtained from the mv.impact.acquire.DeviceManager to the class constructor.

The function interface class provides access to most of the devices executable functions, while most of the settings (e.g. the exposure time or the trigger mode) are implemented as properties (see e.g. mv.impact.acquire.Property for details).

Getting the first image might e.g. look like that:

static void Main(string[] args)
{
{
Console.WriteLine("No device found! Unable to continue! Press any key to end the program.");
Console.Read();
Environment.Exit(1);
}
Device pDev = mv.impact.acquire.DeviceManager.getDevice(0); // get the first device found
Console.WriteLine("Initialising device {0}. This might take some time...", pDev.serial.read());
try
{
pDev.open();
}
catch (ImpactAcquireException e)
{
// this e.g. might happen if the same device is already opened in another process...
Console.WriteLine("An error occurred while opening the device " + pDev.serial +
"(error code: " + e.Message + "). Press any key to end the application...");
Console.ReadLine();
Environment.Exit(1);
}
mv.impact.acquire.FunctionInterface fi = new FunctionInterface(pDev);
// send a request to the default request queue of the device and wait for the result.
fi.imageRequestSingle();
// Start the acquisition manually if this was requested(this is to prepare the framework for data capture and tell the device to start streaming data)
if (pDev.acquisitionStartStopBehaviour.read() == TAcquisitionStartStopBehaviour.assbUser)
{
if ((result = (TDMR_ERROR)fi.acquisitionStart()) != TDMR_ERROR.DMR_NO_ERROR)
{
Console.WriteLine("'FunctionInterface.acquisitionStart' returned with an unexpected result: {0}({1})", result, ImpactAcquireException.getErrorCodeAsString(result));
}
}
// wait for results from the default capture queue
int requestNr = fi.imageRequestWaitFor(-1);
// check if the image has been captured without any problems
if (!fi.isRequestNrValid(requestNr))
{
// If the error code is -2119(DEV_WAIT_FOR_REQUEST_FAILED), the documentation will provide
// additional information under TDMR_ERROR in the interface reference
Console.WriteLine("imageRequestWaitFor failed ({0}, {1}), timeout value too small? Press any key to end the application...", requestNr, ImpactAcquireException.getErrorCodeAsString(requestNr));
Console.ReadLine();
Environment.Exit(1);
}
mv.impact.acquire.Request pRequest = fi.getRequest(requestNr);
if (!pRequest->isOK())
{
Console.WriteLine("Error: {0}", pRequest.requestResult.readS());
Environment.Exit(1);
}
// everything went well. Do whatever you like with the result
int width = pRequest->imageWidth.read();
// unlock the buffer to let the framework know that you no longer need this buffer
fi.imageRequestUnlock(requestNr);
}
Grants access to devices that can be operated by this software interface.
Definition DeviceManager.cs:157
static Device getDevice(int index)
Returns a pointer to a mv.impact.acquire.Device object.
Definition DeviceManager.cs:438
static int deviceCount
Returns the number of devices currently present in the system.
Definition DeviceManager.cs:1064
void open()
Opens a device.
Definition Device.cs:208
T read()
Reads a value from a property.
Definition EnumPropertyI.cs:342
The function interface to devices supported by this interface.
Definition FunctionInterface.cs:21
Contains information about a captured buffer.
Definition Request.cs:77
readonly PropertyI imageWidth
An integer property (read-only) containing the width of the image in pixels.
Definition Request.cs:1660
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.cs:2374
TAcquisitionStartStopBehaviour
Defines valid modes for acquisition start/stop behaviour.
Definition mvDriverBaseEnums.cs:76
This namespace contains classes and functions belonging to the image acquisition module of this SDK.
Definition Enumerations.cs:2
Definition Enumerations.cs:2
Definition Enumerations.cs:2

This sample contains everything the user needs to do to capture one image including all initialization work and error handling for every source of error one can think of.

Several example applications will provide an even better understanding of the interface.