The GenICamCommonSettingsUsage example is intended as an example for people who do not have that much experience with the Impact Acquire SDK or did not use the classes which wrap the GenICam™ properties of the camera yet. It shows the basic procedure of handling device settings, how the camera is being configured with the most common settings and which steps are important to configure a camera in an efficient way.
At first the Default UserSet is loaded to make sure the camera works on a specific set of settings before starting. This is a good idea once you want to bring the camera to a defined state after using different settings e.g. once you used different software before.
In the next step the exposure time is modified after it is verified that the property is supported by the camera and it is currently writable.
Afterwards the AOI of the camera is set to half of the sensor's size.
To simulate an external trigger the timers of the camera are used to generate trigger signals for the camera. Since it is possible that not every device supports as much timers or TimerTriggerSource
values, some more complex checks are necessary to make sure everything works as expected.
CounterAndTimerControl ctc = new CounterAndTimerControl(pDev);
Console.WriteLine("To avoid some cabling work, we will use an internal timer for triggering in this sample!");
Console.WriteLine("The trigger frequency will be configured to half of the max frequency the sensor would be capable of in your setup.");
Console.WriteLine();
List<string> availableTimers = new List<string>();
if(ctc.timerSelector.isValid)
{
ctc.timerSelector.getTranslationDictStrings(availableTimers);
}
double dPeriod = 0;
if (ctc.timerSelector.isValid && ctc.timerSelector.isWriteable && (availableTimers.Count >= 2) && acq.triggerSelector.isValid)
{
ctc.timerSelector.writeS("Timer1");
List<string> availableTriggerSources = new List<string>();
ctc.timerTriggerSource.getTranslationDictStrings( availableTriggerSources );
if(availableTriggerSources.Contains("Timer2End") && acq.mvResultingFrameRate.isValid)
{
dPeriod = 1000000 / (acq.mvResultingFrameRate.read() / 2);
if (dPeriod >= 300)
{
ctc.timerDuration.write(1000);
ctc.timerTriggerSource.writeS("Timer2End");
ctc.timerTriggerSource.writeS("Timer1End");
ctc.timerSelector.writeS("Timer2");
ctc.timerDuration.write(dPeriod - 1000);
acq.triggerSelector.writeS("FrameStart");
acq.triggerSource.writeS("Timer1Start");
acq.triggerMode.writeS("On");
}
else
{
Console.WriteLine("This camera does not support expected timer trigger sources! The camera will work in free run mode instead!");
}
}
}
else
{
Console.WriteLine("This camera does not support timers! The camera will work in free run mode instead!");
}
The next step shows how the analog gain of the camera's sensor can be modified. In this sample the value is set to its maximum.
As the last configuration step the digital I/Os of the camera are shown and summarized by iterating over all string elements within the property lineSelector
which defines the input or output line of the digital I/Os. The first digital output is configured to use the mvExposureAndAcquisitionActive signal to make sure the digital output is set to 'high' once the camera acquires images and exposes one.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Threading;
#if USE_DISPLAY
#endif
using mv.impact.acquire.examples.helper;
namespace mv.impact.acquire.examples
{
class GenICamInterfaceLayout
{
private static bool canRestoreFactoryDefault(
Device pDev)
{
{
return false;
}
if (!validUserSetSelectorStrings.Contains("Default"))
{
return false;
}
return true;
}
static void Main(string[] args)
{
Console.WriteLine("--------------------------------------------!!! ATTENTION !!!--------------------------------------------");
Console.WriteLine("Please be aware that the digital outputs of the camera might be enabled during the test. This might lead to unexpected behavior in case of devices which are connected to one of the digital outputs, so only proceed if you are sure that this will not cause any issue with connected hardware!");
Console.WriteLine("---------------------------------------------------------------------------------------------------------");
Console.WriteLine();
Device pDev = DeviceAccess.getDeviceFromUserInput();
if (pDev == null)
{
Console.WriteLine("Unable to continue! Press any key to end the program.");
Console.Read();
Environment.Exit(1);
}
try
{
Console.WriteLine("Initialising the device. This might take some time...");
Console.WriteLine();
}
{
Console.WriteLine(
"An error occurred while opening device " + pDev.
serial +
"(error code: " + e.Message +
").");
Console.WriteLine("Press any key to end the application...");
Console.ReadLine();
Environment.Exit(1);
}
Console.WriteLine("The camera will be configured now!");
Console.WriteLine();
if (canRestoreFactoryDefault(pDev))
{
{
Console.WriteLine("Loading the camera's default user set to avoid undefined settings!");
}
else
{
Console.WriteLine("The camera seems not to support user sets!");
}
Console.WriteLine();
}
double dExposureTime = 10000;
{
Console.WriteLine(
"Currently the exposure time is set to {0} us. Changing to {1}us ", acq.
exposureTime.
read(), dExposureTime);
Console.WriteLine();
}
{
Console.WriteLine(
"The resolution will now be adjusted to the half of width and height. The resulting AOI will be: {0}x{1} pixels", ifc.
width.
maxValue / 2, ifc.
height.
maxValue / 2);
{
Console.WriteLine("Width or Height are not writable at the moment.");
}
else
{
}
Console.WriteLine();
}
Console.WriteLine("To avoid some cabling work, we will use an internal timer for triggering in this sample!");
Console.WriteLine("The trigger frequency will be configured to half of the max frequency the sensor would be capable of in your setup.");
Console.WriteLine();
List<string> availableTimers = new List<string>();
{
}
double dPeriod = 0;
{
List<string> availableTriggerSources = new List<string>();
{
if (dPeriod >= 300)
{
}
else
{
Console.WriteLine("This camera does not support expected timer trigger sources! The camera will work in free run mode instead!");
}
}
}
else
{
Console.WriteLine("This camera does not support timers! The camera will work in free run mode instead!");
}
if (anc.
gain.isValid && anc.
gain.isWriteable)
{
}
List<string> availableIOs = new List<string>();
Console.WriteLine("Available Digital IOs:");
bool boConfiguredFirstOutput = false;
for (int i = 0; i < availableIOs.Count; i++)
{
if (!boConfiguredFirstOutput && dio.
lineMode.readS() ==
"Output")
{
dio.
lineSource.writeS(
"mvExposureAndAcquisitionActive");
boConfiguredFirstOutput = true;
}
Console.WriteLine(
"Line {0} - LineMode: {1} - LineStatus: {2} - LineSource: {3}", i.ToString(), dio.
lineMode.readS(), dio.
lineStatus.readS(), dio.
lineSource.readS());
}
Console.WriteLine();
Console.WriteLine("Press [ENTER] to end the application");
#if USE_DISPLAY
#endif
bool terminated = false;
Thread thread = new Thread(delegate ()
{
if (result !=
TDMR_ERROR.DEV_NO_FREE_REQUEST_AVAILABLE)
{
}
DeviceAccess.manuallyStartAcquisitionIfNeeded(pDev, fi);
int timeout_ms = 500;
int cnt = 0;
while (!terminated)
{
if (pRequest != null)
{
{
++cnt;
if (cnt % 100 == 0)
{
Console.WriteLine(
"Info from {0}: {1}: {2}, {3}: {4}, {5}: {6}, LineStatusAll: {7}", pDev.
serial.
read(),
{
}
else
{
}
}
#if USE_DISPLAY
# if CLR_AT_LEAST_3_DOT_5
# else
# endif
#endif
}
else
{
}
if (pPreviousRequest != null)
{
}
pPreviousRequest = pRequest;
}
}
DeviceAccess.manuallyStopAcquisitionIfNeeded(pDev, fi);
#if USE_DISPLAY
#endif
if (pRequest != null)
{
}
});
thread.Start();
Console.ReadLine();
terminated = true;
thread.Join();
#if USE_DISPLAY
#endif
}
}
}
bool isValid
Checks if the internal component referenced by this object is still valid.
Definition Component.cs:727
This class and its functions represent an actual device detected by this interface in the current sys...
Definition Device.cs:91
const int INVALID_ID
A symbolic constant to define an invalid handle.
Definition Device.cs:178
void open()
Opens a device.
Definition Device.cs:209
readonly PropertyS serial
A string property (read-only) containing the serial number of this device.
Definition Device.cs:516
EnumPropertyF< T > write(T value)
Writes one value to the property.
Definition EnumPropertyF.cs:430
T read()
Reads a value from a property.
Definition EnumPropertyF.cs:323
T maxValue
Reads the maximum value from a property.
Definition EnumPropertyF.cs:546
T minValue
Reads the minimum value from a property.
Definition EnumPropertyF.cs:567
EnumPropertyI64< T > write(T value)
Writes one value to the property.
Definition EnumPropertyI64.cs:432
T maxValue
Reads the maximum value from a property.
Definition EnumPropertyI64.cs:548
EnumPropertyI64< T > getTranslationDictStrings(List< String > sequence)
This function queries a list of valid strings for this property.
Definition EnumPropertyI64.cs:198
ReadOnlyCollection< String > listOfValidStrings
Returns a list of valid strings for this property.
Definition EnumPropertyI64.cs:617
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
int imageRequestSingle()
Sends an image request to the mv.impact.acquire.Device driver.
Definition FunctionInterface.cs:656
Request getRequest(int nr)
Returns a const pointer to the desired mv.impact.acquire.Request.
Definition FunctionInterface.cs:452
int imageRequestWaitFor(int timeout_ms)
Waits for a request object to become ready.
Definition FunctionInterface.cs:1021
int imageRequestReset(int requestCtrlNr)
Deletes all requests currently queued for the specified mv.impact.acquire.ImageRequestControl.
Definition FunctionInterface.cs:575
bool isRequestNrValid(int nr)
Check if nr specifies a valid mv.impact.acquire.Request.
Definition FunctionInterface.cs:1098
Category for the acquisition and trigger control features.
Definition mvIMPACT_acquire_GenICam.autogen.cs:1940
readonly mv.impact.acquire.PropertyI64 triggerSource
An enumerated integer property. Specifies the internal signal or physical input Line to use as the tr...
Definition mvIMPACT_acquire_GenICam.autogen.cs:2368
readonly mv.impact.acquire.PropertyF mvResultingFrameRate
A floating point property. Shows the resulting frame rate.
Definition mvIMPACT_acquire_GenICam.autogen.cs:2627
readonly mv.impact.acquire.PropertyI64 triggerSelector
An enumerated integer property. Selects the type of trigger to configure.
Definition mvIMPACT_acquire_GenICam.autogen.cs:2197
readonly mv.impact.acquire.PropertyI64 triggerMode
An enumerated integer property. Controls if the selected trigger is active.
Definition mvIMPACT_acquire_GenICam.autogen.cs:2209
readonly mv.impact.acquire.PropertyF exposureTime
A floating point property. Sets the Exposure time when ExposureMode is Timed and ExposureAuto is Off.
Definition mvIMPACT_acquire_GenICam.autogen.cs:2468
Category that contains the Analog control features.
Definition mvIMPACT_acquire_GenICam.autogen.cs:2839
readonly mv.impact.acquire.PropertyF gain
A floating point property. Controls the selected gain as an absolute physical value.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3032
Category that contains the Counter and Timer control features.
Definition mvIMPACT_acquire_GenICam.autogen.cs:4000
readonly mv.impact.acquire.PropertyF timerDuration
A floating point property. Sets the duration (in microseconds) of the Timer pulse.
Definition mvIMPACT_acquire_GenICam.autogen.cs:4589
readonly mv.impact.acquire.PropertyI64 timerSelector
An enumerated integer property. Selects which Timer to configure.
Definition mvIMPACT_acquire_GenICam.autogen.cs:4584
readonly mv.impact.acquire.PropertyI64 timerTriggerSource
An enumerated integer property. Selects the source of the trigger to start the Timer.
Definition mvIMPACT_acquire_GenICam.autogen.cs:4739
Category that contains the digital input and output control features.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3634
readonly mv.impact.acquire.PropertyI64 lineSource
An enumerated integer property. Selects which internal acquisition or I/O source signal to output on ...
Definition mvIMPACT_acquire_GenICam.autogen.cs:3868
readonly mv.impact.acquire.PropertyI64 lineMode
An enumerated integer property. Controls if the physical Line is used to Input or Output a signal.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3736
readonly mv.impact.acquire.PropertyI64 lineSelector
An enumerated integer property. Selects the physical line (or pin) of the external device connector o...
Definition mvIMPACT_acquire_GenICam.autogen.cs:3724
readonly mv.impact.acquire.PropertyI64 lineStatusAll
An integer property. Returns the current status of all available Line signals at time of polling in a...
Definition mvIMPACT_acquire_GenICam.autogen.cs:3789
readonly mv.impact.acquire.PropertyIBoolean lineStatus
A boolean property. Returns the current status of the selected input or output Line.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3746
Category that contains the User Set control features.
Definition mvIMPACT_acquire_GenICam.autogen.cs:8788
readonly mv.impact.acquire.PropertyI64 userSetSelector
An enumerated integer property. Selects the feature User Set to load, save or configure.
Definition mvIMPACT_acquire_GenICam.autogen.cs:8854
readonly mv.impact.acquire.Method userSetLoad
A method object. Loads the User Set specified by UserSetSelector to the device and makes it active.
Definition mvIMPACT_acquire_GenICam.autogen.cs:8864
UserSetControl(mv.impact.acquire.Device device)
Constructs a new mv.impact.acquire.GenICam.UserSetControl object.
Definition mvIMPACT_acquire_GenICam.autogen.cs:8792
An base class for exceptions generated by Impact Acquire.
Definition Exceptions.cs:9
static String getErrorCodeAsString(int errorCode)
Returns a string representation of a error.
Definition Exceptions.cs:48
A small helper class to administer various library search path related variables and paths.
Definition LibraryPath.cs:14
static void init()
Calling this method will add the folders containing unmanaged libraries to the systems library search...
Definition LibraryPath.cs:251
int call(List< String > callParams)
Calls an underlying driver function.
Definition Method.cs:94
IntPtr read()
Reads a value from a property.
Definition PropertyPtr.cs:49
String read()
Reads a value from a property.
Definition PropertyS.cs:144
Contains information about a captured buffer.
Definition Request.cs:77
readonly PropertyPtr imageData
A pointer property (read-only) containing the start address of the image data.
Definition Request.cs:1579
readonly PropertyI imageLinePitch
An integer property (read-only) containing the offset (in bytes) to the next line of each channel bel...
Definition Request.cs:1655
readonly EnumPropertyI< TRequestResult > requestResult
An enumerated integer property (read-only) defining the result of this request.
Definition Request.cs:1211
readonly PropertyI imageWidth
An integer property (read-only) containing the width of the image in pixels.
Definition Request.cs:1693
readonly PropertyI imageBytesPerPixel
An integer property (read-only) containing the number of bytes per pixel in this image.
Definition Request.cs:1679
bool isOK
Convenience function to check if a request has been processed successfully.
Definition Request.cs:1173
readonly PropertyI imageHeight
An integer property (read-only) containing the height of the image in pixels.
Definition Request.cs:1704
int unlock()
Unlocks the request for the driver again.
Definition Request.cs:619
Contains statistical information.
Definition Statistics.cs:10
readonly PropertyI errorCount
An integer property (read-only) containing the overall count of image requests which returned with an...
Definition Statistics.cs:82
readonly PropertyF framesPerSecond
A float property (read-only) containing the current number of frames captured per second.
Definition Statistics.cs:98
readonly PropertyF captureTime_s
A float property (read-only) containing the average time needed to capture an image.
Definition Statistics.cs:75
A class that can be used to display images in a window.
Definition ImageDisplayWindow.cs:15
readonly ImageDisplay imageDisplay
Returns a reference to the actual display object associated with this window.
Definition ImageDisplayWindow.cs:108
void Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resourc...
Definition ImageDisplayWindow.cs:85
void RemoveImage()
Removes the current image from the display.
Definition ImageDisplay.cs:327
void SetImage(IntPtr pData, int width, int height, int bipp, int pitch)
Sets the next image to display.
Definition ImageDisplay.cs:282
void Update()
Immediately redraws the current image.
Definition ImageDisplay.cs:333
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.cs:2375
This namespace contains classes and functions belonging to the GenICam specific part of the image acq...
Definition GenTLDriverConfigurator.cs:6
This namespace contains classes and functions that can be used to display images.
Definition Enumerations.cs:2
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