Creates a camera matching the key-value list passed using the selectionStrategy passed, e.g. for creating a camera with a known IP Address or Device User ID.
Creates a camera matching the key-value list passed using the selectionStrategy passed, e.g. for creating a camera with a known IP Address or Device User ID.
Provides access to camera information. The camera information can be updated if camera properties have changed. Camera properties may change e.g. if a GigE camera has been assigned a new IP address after reconnection.
Tries to open a connection to the camera until a timeout occurs. If the camera device is not available, the method tries to access the camera until a timeout occurs.
During the execution of this event, the connection to the camera is already open.
If an event handler called by this event throws an exception, the connection to the camera will be closed and the exception will be propagated to the caller of Open(). No other handlers will be called.
This event is fired inside the lock of the camera instance.
Called event handlers should expect exceptions if they call methods of the camera. It is safe to call Close().
If an event handler throws an exception, it will be ignored and the remaining handlers will be called.
This event is fired inside the lock of the camera instance. Event handlers should make no assumptions on the thread from which the event handler is called.
// Copy a file into a byte array:
using (Stream fs = m_camera.CreateFileStream( fileName, System.IO.FileAccess.Read ))
using (MemoryStream ms = new MemoryStream())
{
fs.CopyTo( ms );
byte [] Buffer = ms.ToArray();
}
It is not possible to access multiple files in parallel. Dispose the stream before opening the next.
Thread Safety: This method is synchronized with the lock of the camera object.
Type: Version Returns the version number of the SFNC specification that the camera complies to. If no SFNC version information is available, a version of 0.0.0.0 is returned.
If the connection to the camera is already open, the function returns successfully.
The CameraOpening event is fired. The notification of event handlers stops in case any eventhandler throws an exception.
The connection to the camera device is established.
The CameraOpened event is fired if the camera object has been opened successfully. The notification of event handlers stops in case any eventhandler throws an exception.
Opening the camera connection may fail if the camera connection has been already opened by another instance or if a physical connection could not be established. You can check the current state of a camera by calling CameraFinder::GetDeviceAccessibilityInfo
Thread Safety: This method is synchronized with the lock of the camera object.
Error Safety: Can throw exceptions if the camera cannot be opened successfully or if any of the event handlers throws an exception.
Tries to open a connection to the camera until a timeout occurs. If the camera device is not available, the method tries to access the camera until a timeout occurs.
If the camera is already open, the function returns successfully.
If the camera device is not available, the method tries to rediscover the camera by enumerating all camera devices of the same type or by checking the availability until a timeout occurs or the camera class is disposed.
If the camera is not found, the method returns or throws an exception. The action depends on the timeoutHandling parameter.
Type: System.Int32 The timeout period in milliseconds. If the SoftwareTrigger.IsDone() method does not return true within the given period, a timeout will occur. The exact timeout behavior can be set using the timeoutHandling parameter.
Type: Boolean Returns true if the camera was ready to receive a software trigger within the given time period. Otherwise, the action specified in timoutHandling is performed.
After issuing a software trigger, there is a short time period within which the camera is unable to accept another trigger. During this period, all triggers are ignored. You can use this function to poll until the camera is ready to accept a trigger.
Thread Safety: This method is synchronized with the lock of the camera object.
Creates a camera instance by enumerating all cameras connected to the system and selecting the first camera device found. If no cameras are found, an exception is thrown.
Creates a camera instance by enumerating all cameras connected to the system and selecting a camera using the selectionStrategy passed. If no cameras are found, an exception is thrown.
Use this constructor to create a specific camera using information returned by Enumerate(). If no camera is found, an exception is thrown.
Error Safety:Can throw exceptions.
Camera Constructor (IDictionary(String, String), CameraSelectionStrategy)#
Creates a camera matching the key-value list passed using the selectionStrategy passed, e.g. for creating a camera with a known IP Address or Device User ID.
Type: System.Collections.Generic.IDictionary(String, String) A collection of key-value pairs containing device information. You can use this to create a camera with a specific name, a specific IP address, etc.
Creates a camera instance by a) enumerating all cameras connected to the system, b) removing all cameras not matching the key value pairs passed in propertyKeyValueList, c) selecting a camera using the selectionStrategy passed. If no cameras are found, an exception is thrown.
Error Safety:Can throw exceptions.
// Example
// Selects a USB camera with serial number 20399956
var cameraInfoFilter = new Dictionary<string, string>
{
{CameraInfoKey.SerialNumber, "20399956"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera with known IP Address "192.168.0.101"
var cameraInfoFilter2 = new Dictionary<string, string>
{
{CameraInfoKey.DeviceIpAddress, "192.168.0.101"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
// Shown for demonstration purposes only.
// Selects a USB camera with DeviceUserID TopCamera
// See https://docs.baslerweb.com/#t=en%2Fdevice_information_parameters.htm
// or PLCamera.DeviceUserID for more information.
var cameraInfoFilter3 = new Dictionary<string, string>
{
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera model acA1920-50gc having device DeviceUserID TopCamera
var cameraInfoFilter4 = new Dictionary<string, string>
{
{CameraInfoKey.ModelName, "acA1920-50gc"},
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
using (ICamera cameraTest = new Camera(cameraInfoFilter, CameraSelectionStrategy.Unambiguous))
{
//use the camera
}
Camera Constructor (IEnumerable(KeyValuePair(String, String)), CameraSelectionStrategy)#
Creates a camera matching the key-value list passed using the selectionStrategy passed, e.g. for creating a camera with a known IP Address or Device User ID.
Type: System.Collections.Generic.IEnumerable(KeyValuePair(String, String)) A collection of key-value pairs containing device information. You can use this to create a camera with a specific name, a specific IP address, etc.
Creates a camera instance by a) enumerating all cameras connected to the system, b) removing all cameras not matching the key value pairs passed in propertyKeyValueList, c) selecting a camera using the selectionStrategy passed. If no cameras are found, an exception is thrown.
Error Safety:Can throw exceptions.
// Example
// Selects a USB camera with serial number 20399956
var cameraInfoFilter = new Dictionary<string, string>
{
{CameraInfoKey.SerialNumber, "20399956"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera with known IP Address "192.168.0.101"
var cameraInfoFilter2 = new Dictionary<string, string>
{
{CameraInfoKey.DeviceIpAddress, "192.168.0.101"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
// Shown for demonstration purposes only.
// Selects a USB camera with DeviceUserID TopCamera
// See https://docs.baslerweb.com/#t=en%2Fdevice_information_parameters.htm
// or PLCamera.DeviceUserID for more information.
var cameraInfoFilter3 = new Dictionary<string, string>
{
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.Usb}
};
// Shown for demonstration purposes only.
// Selects a GigE camera model acA1920-50gc having device DeviceUserID TopCamera
var cameraInfoFilter4 = new Dictionary<string, string>
{
{CameraInfoKey.ModelName, "acA1920-50gc"},
{CameraInfoKey.UserDefinedName, "TopCamera"},
{CameraInfoKey.DeviceType, DeviceType.GigE}
};
using (ICamera cameraTest = new Camera(cameraInfoFilter, CameraSelectionStrategy.Unambiguous))
{
//use the camera
}
Type: System.String A string containing the serial number of the camera. You can read the serial number from the label attached to the camera or by using the pylonViewer.
Creates a camera instance by enumerating all cameras connected to the system and selecting the camera matching the serial number passed. If no cameras are found, an exception is thrown.
using (ICamera camera = new Camera("20399956"))
{
//use the camera with serial number 20399956
}
Error Safety:Can throw exceptions.
Camera Constructor (String, CameraSelectionStrategy)#
Creates a camera based on the camera type (GigE, USB, etc.) using the selectionStrategy passed.
Type: System.String A string containing the camera type (GigE, USB, etc.). You can use the DeviceType class to retrieve valid strings for this parameter.
Creates a camera instance by enumerating all cameras of the specified type connected to the system and selecting a camera using the selectionStrategy passed. If no cameras are found, an exception is thrown.
using (ICamera camera = new Camera(DeviceType.Usb, CameraSelectionStrategy.FirstFound))
{
//use the first found USB camera
}
Tries to open a connection to the camera until a timeout occurs. If the camera device is not available, the method tries to access the camera until a timeout occurs.
Creates a camera matching the key-value list passed using the selectionStrategy passed, e.g. for creating a camera with a known IP Address or Device User ID.
Creates a camera matching the key-value list passed using the selectionStrategy passed, e.g. for creating a camera with a known IP Address or Device User ID.
Provides access to camera information. The camera information can be updated if camera properties have changed. Camera properties may change e.g. if a GigE camera has been assigned a new IP address after reconnection.
If 'FrameTriggerWait' can be selected for 'AcquisitionStatusSelector' and 'AcquisitionStatus' is readable, the camera device can be queried whether it is ready to accept the next frame trigger.
If the nodes mentioned above are not available and the 'SoftwareTrigger' node is readable, the camera device can be queried whether it is ready to accept the next frame trigger.
Thread Safety: This method is synchronized with the lock of the camera object.
Type: Boolean Returns true if the camera device is properly connected to the camera object while the camera object is open. Returns false if the camera object is closed.
The camera object will not automatically close itself if the connection to the camera device is lost, e.g., if the camera device is physically disconnected from the PC.
Thread Safety: This method is synchronized with the lock of the camera object.
You can use the parameter collection to configure the camera device and the camera instance through parameters. You can access parameters by their name or predefined parameter lists.
There are several predefined parameter lists available:
PLCamera
PLCameraInstance
PLStreamGrabber
PLEventGrabber
PLTransportLayer
For more information about the parameters, see the documentation for the parameter list.
You can access parameters by passing a key from a parameter list to the index operator, e.g. C#
camera.Parameters[PLCamera.Width].GetValue();
Thread Safety: This method is synchronized with the lock of the camera object.