Transitioning from FlyCapture2 to Spinnaker SDK
Benefits of Spinnaker
The Spinnaker SDK is developed based on GenICam. GenICam provides a unified application programming interface to users of machine vision cameras. An introduction to GenICam can be found on EMVA’s website.
Some of the key benefits of using the Spinnaker SDK include:
Forward Compatibility
- Features are loaded dynamically from the camera. When we introduce new camera features, you don't have to recompile your application.
- New machine vision standards are following GenICam (USB3 Vision, GigE Vision). Spinnaker allows you to write more generic code that can be easily migrated to future standards.
- Follows SFNC (standard feature naming convention).
New Graphical User Interface
- There is a new class of GUI controls that allows you to add individual GUI elements to your applications
Backwards Compatibility
- Source compatibility—Newer minor versions of Spinnaker will not require developers to change their existing code. You can simply recompile your application with a newer version of Spinnaker.
- Functional compatibility—Newer versions of Spinnaker will not remove any functionality.
- Binary compatibility—You can run C++ or C based applications by swapping new Spinnaker binaries (DLL) with the old binaries. (This only applies to Spinnaker binaries which have the same major and minor version.)
Differences between Spinnaker and FlyCapture2 Support
The Spinnaker SDK is recommended for users developing new vision applications. Spinnaker provides users with many powerful features to streamline their development process. Users of USB 2.0 and IEEE1394 cameras still require FlyCapture2. The following table summarizes the differences between the features, cameras and platforms supported by Spinnaker and FlyCapture2.
Spinnaker | FlyCapture2 | ||
Feature Support | Feature Search | Yes | No |
GenICam Compliant | Yes | No | |
Dynamic Feature Loading | Yes | No | |
Standard Feature Naming Convention | Yes | No | |
Serial on GPIO | Yes | Yes | |
PWM on GPIO | Yes | Yes | |
Camera Support | Blackfly S, Dragonfly S, Firefly S/DL, Forge, Oryx | Yes | No |
USB 3.1 Cameras: GS3-U3, BFLY-U3, CM3-U3, FL3-U3 | Yes | Yes | |
GigE Cameras: GS3-PGE, BFLY-PGE, FL3-GE | Yes | Yes | |
USB 2.0 Cameras | No | Yes | |
IEEE 1394 Cameras | No | Yes | |
Ladybug (use the Ladybug SDK) | No | Yes | |
Bumblebee (use the Triclops SDK) | No | Yes | |
Platform Support | Windows | Yes | Yes |
Linux | Yes | Yes | |
ARM | Yes | Yes |
Terminology Changes
FlyCapture2 | Spinnaker | Notes |
Brightness | Black Level | The output of the camera when not illuminated |
Exposure | Exposure Compensation | Changes the target grey value the camera tries to achieve with auto exposure time and/or auto gain |
Shutter | Exposure Time | The amount of time that the camera's electronic shutter stays open |
Packet Size | GevSCPSPacketSize | The packet size, in bytes, to send on the selected channel for a GVSP transmitter or receiver |
Packet Delay | GevSCPD | The delay to insert between each packet for this stream channel |
Trigger Mode 0 | TriggerSelector → FrameStart AcquisitionMode → Continuous |
Each frame is triggered by external software or hardware trigger source. Sensor exposure time is controlled by exposure time setting (shutter in FlyCapture2). |
Trigger Mode 1 | ExposureMode → TriggerWidth AcquisitionMode → Continuous |
Same as Trigger Mode 0 except sensor exposure time is controlled by length of external trigger pulse |
Trigger Mode X | Logic Block | Logic Block allows you to define any internal logic, including custom trigger modes For more information see Using Logic Blocks. |
Memory Channel | User Set | Allows storing of camera settings in non-volatile memory |
High Dynamic Range (HDR) | Sequencer | The cycling of frames with different settings (such as gain and exposure) in order to capture the darkest and brightest portions of the scene For more information see Using the Sequencer. |
Frame Buffer | Transfer Control | Allows control over the transfer of image data to the host |
Video Mode | Image Format Control | Binning/decimation and image size settings. |
Mirror/Flip | Reverse X / Reverse Y | The flipping (either horizontally or vertically) of the image sent from the camera |
One Shot | AcquisitionMode: Single Frame | Set the camera to capture a single image when started |
Multi Shot | AcquisitionMode: Multi Frame | Set the camera to capture a defined number of images when started. |
Pulse Width Modulation (PWM) | Counters and Timers (Blackfly S and Oryx only) | Send a specified number of pulses with programmable high an low duration over GPIO For more information see Using Counters and Timers |
Pixel Format: Mono 12 |
Pixel Format: Mono12 Packed (IIDC-msb) Mono12 Packed |
|
Pixel Format: Raw8 |
Pixel Format: Bayer(format)8 |
Format is dependent on the bayer pattern of the camera (for example, GB or GR) |
Pixel Format: Raw12 |
Pixel Format: Bayer(format)12 Packed (IIDC-msb) Bayer(format)12 Packed |
Format is dependent on the bayer pattern of the camera (for example, GB or GR) |
Pixel Format: Raw16 |
Pixel Format: Bayer(format)16 |
Format is dependent on the bayer pattern of the camera (for example, GB or GR) |
Pixel Format: YUV411 |
Pixel Format: YCbCr 411 8 |
|
Pixel Format: YUV422 |
Pixel Format: YCbCr 422 8 |
|
Pixel Format: YUV444 |
Pixel Format: YCbCr 8 |
|
Diagnostics: Image consistency errors |
Error logging HAL_IMAGE_CONSISTENCY_ERROR |
For information about Spinnaker logging see Using Logging in Spinnaker |
Diagnostics: Image conversion errors |
Error logging The input pixel format is not supported for conversion to the desired output format |
|
Diagnostics: Dropped images |
Buffer Underrun Count | |
Diagnostics: Skipped images |
Transmit Queue Overflow Count | |
Diagnostics: Number of bus arrivals/removals |
Error logging Device Arrival/Removal Event Received |
Examples
Included with both the FlyCapture SDK and the Spinnaker SDK are a number of source code examples to help you get started. These examples are provided for C, C++, C#, and VB.NET languages and are precompiled for your convenience.
The table below describes the available Spinnaker SDK examples. Where appropriate, the FlyCapture2 equivalent example is identified.
Spinnaker Example | Description | |
Acquisition | Enumerate, start acquisition, and grab images Similar to FlyCapture2: FlyCapture2Test |
|
Trigger* | Trigger Similar to FlyCapture2: AsyncTriggerEx |
|
ImageFormatControl* | Configure a custom image size and format Similar to FlyCapture2: CustomImageEx |
|
Exposure* | Configure a custom exposure time Similar to FlyCapture2: ExtendedShutterEx |
|
AcquisitionMultipleCamera | How to capture images from multiple cameras simultaneously Similar to FlyCapture2: MultipleCameraEx (FireWire only) |
|
SaveToAVI | Save images in AVI format Similar to FlyCapture2: SaveImageToAVIEx |
|
ImageEvents | Image events Similar to FlyCapture2: ImageEventEx (FireWire only) |
|
Sequencer (Blackfly S and Oryx) | Capture multiple images with different parameters in a sequence Similar to FlyCapture2: HighDynamicRange |
|
SpinSimpleGUI_MFC | Graphical User Interface for evaluating and setting camera parameters Similar to FlyCapture2: FlyCapture2GUI |
|
ChunkData | How to get chunk data on an image, either from the nodemap or from the image itself | |
DeviceEvents | Create a handler to access device events | |
Enumeration* | Enumerate interfaces and cameras | |
EnumerationEvents | Explore arrival and removal events on interfaces and the system | |
GenTLInfo_QuickSpin* | How to access node information from interfaces and cameras | |
Logging | Create a logging event handler | |
LookupTable | Configure lookup tables for the customization and control of individual pixels | |
NodeMapCallback | Create, register, use, and unregister callbacks | |
NodeMapInfo | How to retrieve node map information | |
*Also available in QuickSpin |
Nodes
Nodes are known as properties in FlyCapture2.
Every GenICam compliant camera has an XML description file. The XML describes camera registers, their interdependencies, and all other information needed to access high-level features without the need for low level register read and write operations. These features include Gain, Exposure Time, Image Format, and others. The elements of a camera description file are represented as software objects called Nodes. A Nodes map is a list of nodes created dynamically at run time.
To access camera properties such as setting image width:
C++ GenAPI |
GenApi::INodeMap & nodeMap = cam.GetNodeMap(); CIntegerPtr width = nodeMap.GetNode("Width"); width->SetValue(new_width_val); |
C# GenAPI |
NodeMap map = cam.GetNodeMap(); |
C API |
spinCameraGetNodeMap(hCam,&hNodeMap); //spinCamera hCam spinNodeHandle hNode; |
QuickSpin API and Accessing Camera Parameters
Generic programming with GenICam requires developers to know feature names before using them. Spinnaker provides the QuickSpin API, which helps developers write their applications hassle free. The QuickSpin API consists of a list of static functions integrated into the Camera class.
QuickSpin works best with new camera families like the Blackfly S, Oryx and Firefly. Due to the hardcoded nodenames there may be problems when used with cameras from older families.
All camera parameters can be accessed through the camera pointer object.
Most camera parameters (all items in camera.h) can be accessed using the QuickSpin API.
For parameters not handled by QuickSpin API, you can access them via GenAPI. GenAPI is an open source API for configuring GenICam cameras. GenAPI is maintained by the European Machine Vision Association.
Note: QuickSpin API and GenAPI are available for C++ and C# only. They are not available for C.
Below is an example comparison of inquiring camera gain via GenAPI and QuickSpin API.
C++ GenAPI |
Spinnaker::GenApi::INodeMap & nodeMap = cam->GetNodeMap(); |
C++ QuickSpin API |
float quickGainVal = cam->Gain.GetValue(); |
C# GenAPI |
INodeMap map = cam.GetNodeMap(); |
C# QuickSpin API |
doublequickGainVal = cam.Gain.Value; |
C Spinnaker API |
error = spinNodeMapGetNode(hNodeMap,"Gain",&hNode); |
Event Handling
Events are known as callbacks in FlyCapture2.
Spinnaker introduces two event classes: interface events and device events.
Interface Event
The interface event class is a new feature that is responsible for registering and deregistering user defined interface events such as device arrival and removal.
Interface Event C++ |
class InterfaceEventsHandler : public InterfaceEvent public : void OnDeviceArrival() std::cout<< "A Camera Arrived" << std::endl; }; void OnDeviceRemoval( uint64_tdeviceSerialNumber ) std::cout<< "A Camera was removed with serial number: " << }; }; InterfaceEventsHandler handler; |
Interface Event C# |
class InterfaceEventListener : ManagedInterfaceEvent protectedoverridevoid OnDeviceArrival() Console .Out.WriteLine( "A new device has arrived!" ); } protected override void OnDeviceRemoval( UInt64 serialNumber) Console.Out.WriteLine( "A device with serial number {0} has been removed!" , } } |
Interface Event C |
>Interface event (arrival and removal) handling for C is registered by using the below functions: spinArrivalEventCreate() spinRemovalEventCreate() A detailed example for C interface event is included in Spinnaker source code example: EnumerationEvent_C.cpp |
Device Event
The device event class is responsible for registering and deregistering user defined device events such as start or end of exposure.
Device Event C++ |
// Select the Exposure End event // Turn on the Event notification for Exposure End Event // Once Exposure End Event is detected, the OnDeviceEvent function will be called public : void OnDeviceEvent( GenICam::gcstring eventNameeventId ) std::cout << "Got Device Event with " << eventName << " and ID=" << GetDeviceEventId() << std::endl; } }; // Register event handler |
Device Event C# |
// Set EventSelector to ExposureEnd // Set EventNotification to true // After registering the below device event on the camera, OnDeviceEvent will be automatically called once ExposureEnd event is detected protected override voidOnDeviceEvent( string eventName) Console .Out.WriteLine( "Got Device Event with Name=" + eventName + " and ID= {0}" , GetDeviceEventId()); } } |
Device Event C |
// Create and register ExposureEvent spinEvent eventExposureEnd = NULL; error = spinEventCreate(&eventExposureEnd, onSpecificDeviceEvent, NULL); error = spinCameraRegisterEvent(hCam, eventExposureEnd, "EventExposureEnd"); // Create a function to occur upon specific event occurrences; void onSpecificDeviceEvent(const char* pEventName, void* pUserData) |
Chunk Data
Chunk data replaces embedded image info in FlyCapture2.
Chunk data is extra information that the camera can append to each image besides image data. Examples of chunk data include frame counter, image width, image height and exposure time.
C++ Enable Chunk Data |
Cam->ChunkSelector Cam->ChunkEnable.SetValue(true); Cam->ChunkModeActive.SetValue(true); |
C++ Retrieve Chunk Data |
const ChunkData& chunkData = rawImage->GetChunkData(); float64_t currentExposure = chunkData.GetExposureTime(); |
C# Enable Chunk Data |
cam.ChunkSelector.Value = ChunkSelectorEnums.ExposureTime.ToString(); cam.ChunkEnable.Value = true; cam.ChunkModeActive.Value = true; |
C# Retrieve Chunk Data |
String currentExposure = rawImage.ChunkData.ExposureTime.ToString(); |
C# Graphical User Interface API
For applications that want to take advantage of Spinnaker's graphical user elements, graphical user interface (GUI) controls are available. GUI controls are divided into static and dynamic categories. Static GUI controls include the CameraSelectionDialog, display window, and property grid window. Dynamic GUI control capability is built into the camera's firmware. Therefore, new firmware has the ability to add GUI controls to the same application, without recompiling.
Static GUI Dialogs |
|
//To show image drawing window GUIFactory AcquisitionGUI = new GUIFactory (); AcquisitionGUI.ConnectGUILibrary(cam); ImageDrawingWindow AcquisitionDrawing = AcquisitionGUI.GetImageDrawingWindow(); AcquisitionDrawing.Connect(cam); AcquisitionDrawing.Start(); AcquisitionDrawing.ShowModal(); |
|
//To show camera selection window GUIFactory AcquisitionGUI = newGUIFactory (); AcquisitionGUI.ConnectGUILibrary(cam); CameraSelectionWindow camSelection = AcquisitionGUI.GetCameraSelectionWindow(); camSelection.ShowModal(true); |
|
//To show property grid window GUIFactory AcquisitionGUI = new GUIFactory (); AcquisitionGUI.ConnectGUILibrary(cam); PropertyGridWindow propWindow = AcquisitionGUI.GetPropertyGridWindow(); propWindow.Connect(cam); propWindow.ShowModal(); |
Dynamic GUI Control |
|
GUIFactory dynamicGUI = new GUIFactory (); dynamicGUI.ConnectGUILibrary(cam); // Get dialog name via dynamicGUI.GetDialogNameList() Window dlg = dynamicGUI.GetDialogByName(dialogName); dlg.Owner = Window .GetWindow(this ); dlg.Show(); |
Logging
Spinnaker supports five levels of logging:
- Error—failures that are non-recoverable (this is the default level)
- Warning—failures that are recoverable without user intervention
- Notice—information about events such as camera arrival or disconnect, camera initialize, camera start/stop, or modification of a feature
- Info—information about recurring events that are generated with every image
- Debug—information that can be used to troubleshoot the system
You can define the logging level that you want to monitor. Levels are inclusive, that is, if you monitor debug level error, you also monitor all logging levels above it.
For a complete C++ and C# example of Logging, please see Spinnaker SDK source code examples. By default, Spinnaker SDK's SpinView application saves all logging data to:
C:\ProgramData\Spinnaker\Logs
Programmer's Section
For programmers not familiar with GenICam API, you can take a look at the standard at EMVA.org
Spinnaker re-engineered the way we perceived camera features in FlyCapture2. Camera features and properties are named according to standard feature naming convention (SFNC). The table below compares the Spinnaker SDK features with those in the FlyCapture2 SDK.
For example, IIDC register read and write is no longer available. Instead, camera properties are accessed through the GenICam node map.
Even though It is possible to access the camera's IIDC register using Spinnaker ReadPort/WritePort, we do not encourage this approach. Most camera properties can be accessed through the GenICam node map.
FlyCapture2 Feature Comparison with Spinnaker
FlyCapture2 Features | Spinnaker Features | Notes |
IIDC register read and write Source Code Example: |
GenICam node map get/set values Source Code Example: |
This feature is typically used to access camera settings or control the camera's state. |
Embedded image info Source Code Example: |
Chunk data Source Code Example: |
This feature allows the camera to add image metadata to the transmission. |
ImageEvents Source Code Example: |
GenICam message or event channel Source Code Example: |
This feature is used to signal the user when certain events such as image arrival has happened. |
FC2Config struct such as grab mode and num_buffer Source Code Example: |
Stream Node map Source Code Example: |
This feature can be used to set buffer mode and the number of buffers. |
Error return code Source Code Example: |
Exceptions Source Code Example: |
New error handling approach uses exceptions instead of error codes. |
Format7 packet size to control bandwidth Source Code Example: |
DeviceLinkLayerThroughputLimit | This feature defines the total available bandwidth that can be allocated for the camera. |
Imaging mode (i.e., Format7 mode 1) Source Code Example: |
Binning controls in GenICam | This feature refers to the camera's binning mode where overall resolution is reduced to achieve faster frame rate or brighter image. |
Events callback Source Code Example: |
Register event class with overloaded functions Source Code Example: |
This feature refers to bus event callbacks such as camera arrival and camera removal callback. |
GUID to identify and track cameras Source Code Example: |
Unique camera class Source Code Example: |
You must use this identifier to access camera features in the SDK. |
C++ Features
These tables provide a comparison of popular features used in FlyCapture2 C++ API and Spinnaker C++ API.
Enumeration
The snippet below detects the number of cameras connected and enumerates them from an index.
FlyCapture2 C++ API |
BusManager busMgr; |
Spinnaker C++ GenAPI |
SystemPtr system = System::GetInstance(); |
Asynchronous Hardware Triggering
The snippet below does the following:
- Enables Trigger Mode
- Configures GPIO0/Line0 as the trigger input source
- Specifies the trigger signal polarity as an active high (rising edge) signal
FlyCapture2 C++ API |
TriggerMode mTrigger; mTrigger.mode = 0; cam.SetTriggerMode(&mTrigger); |
Spinnaker C++ QuickSpin API |
Cam->TriggerMode.SetValue(Spinnaker::TriggerModeEnums::TriggerMode_On); Cam->TriggerSource.SetValue(Spinnaker::TriggerSourceEnums::TriggerSource_Line0); Cam->TriggerSelector.SetValue(Spinnaker::TriggerSelectorEnums::TriggerSelector_FrameStart); Cam->TriggerActivation.SetValue(Spinnaker::TriggerActivationEnums::TriggerActivation_RisingEdge); |
Spinnaker C++ GenAPI |
CEnumerationPtr triggerMode = nodeMap.GetNode("TriggerMode"); triggerMode->SetIntValue(triggerMode->GetEntryByName("On")->GetValue()); CEnumerationPtr triggerSource = nodeMap.GetNode("TriggerSource"); triggerSource->SetIntValue(triggerSource->GetEntryByName("Line0")->GetValue()); CEnumerationPtr triggerSelector = nodeMap.GetNode("TriggerSelector"); triggerSelector->SetIntValue(triggerSelector->GetEntryByName("FrameStart")->GetValue()); CEnumerationPtr triggerActivation = nodeMap.GetNode("TriggerActivation"); triggerActivation->SetIntValue(triggerActivation->GetEntryByName("RisingEdge")->GetValue()); |
Setting Black Level
Black level is known as brightness in FlyCapture2.
BlackLevel is the GenICam feature that represents the DC offset that is applied to the video signal. This example compares the mechanism used to set this feature in both environments.
FlyCapture2 C++ API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is set up to use absolute value control. //Set the absolute value of brightness to 1.5%. //Set the property. |
Spinnaker C++ QuickSpin API |
// Brightness is called black level in GenICam //Set the absolute value of brightness to 1.5%. |
Spinnaker C++ GenAPI |
CEnumerationPtr blackLevelSelector = nodeMap.GetNode("BlackLevelSelector"); CFloatPtr blackLevel = nodeMap.GetNode("BlackLevel"); |
Setting Exposure Time
Exposure time is known as shutter in FlyCapture2.
ExposureTime refers to the amount of time that the camera's electronic shutter stays open. This example sets your camera's exposure/shutter time to 20 milliseconds.
FlyCapture2 C++ API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is on. //Ensure auto-adjust mode is off. //Ensure the property is set up to use absolute value control. //Set the absolute value of shutter to 20 ms. //Set the property. |
Spinnaker C++ QuickSpin API |
// Turn off auto exposure //Set exposure mode to "Timed" //Set absolute value of shutter exposure time to 20000 microseconds |
Spinnaker C++ GenAPI |
CEnumerationPtr exposureAuto = nodeMap.GetNode("ExposureAuto"); CEnumerationPtr exposureMode = nodeMap.GetNode("ExposureMode"); CFloatPtr exposureTime = nodeMap.GetNode("ExposureTime"); |
Setting Gain
The following code snippet adjusts gain to 10.5 dB.
FlyCapture2 C++ API |
//Declare a Property struct. //Define the property to adjust. //Ensure auto-adjust mode is off. //Ensure the property is set up to use absolute value control. //Set the absolute value of gain to 10.5 dB. //Set the property. |
Spinnaker C++ QuickSpin API |
//Turn auto gain off //Set gain to 10.5 dB |
Spinnaker C++ GenAPI |
CEnumerationPtr gainAuto = nodeMap.GetNode("GainAuto"); CFloatPtr gainValue = nodeMap.GetNode("Gain"); |
Setting Gamma
The following code snippet adjusts gamma to 1.5.
FlyCapture2 C++ API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is on. //Ensure the property is set up to use absolute value control. //Set the absolute value of gamma to 1.5. //Set the property. |
Spinnaker C++ QuickSpin API |
// Set the absolute value of gamma to 1.5 |
Spinnaker C++ GenAPI |
CFloatPtr gamma = nodeMap.GetNode("Gamma"); |
Setting White Balance
The following code snippet adjusts the white balance's red and blue channels.
FlyCapture2 C++ API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is on. //Ensure auto-adjust mode is off. //Set the white balance red channel to 500. //Set the white balance blue channel to 850. //Set the property. |
Spinnaker C++ QuickSpin API |
//Set auto white balance to off //Select blue channel balance ratio //Set the white balance blue channel to 2 //Set the white balance red channel to 2 |
Spinnaker C++ GenAPI |
CEnumerationPtr balanceWhiteAuto = nodeMap.GetNode("BalanceWhiteAuto"); CEnumerationPtr balanceRatioSelector = nodeMap.GetNode("BalanceRatioSelector"); CFloatPtr balanceRatio = nodeMap.GetNode("BalanceRatio"); balanceRatioSelector->SetIntValue(balanceRatioSelector->GetEntryByName("Red")->GetValue()); |
Accessing Raw Bayer Data
Raw image data can be accessed programmatically via the getData method of the FlyCapture2 and Spinnaker Image class. In 8 bits per pixel modes such as BayerRG8, the first byte represents the pixel at [row 0, column 0], the second byte at [row 0, column 1], and so on. Image data always starts in the top left corner of the image.
FlyCapture2 C++ API |
// Read the BAYER_TILE_MAPPING register 0x1040 to determine the current Bayer output format (RGGB, GRBG, and so on). Using a Bayer format of RGGB, for example, the getData method returns the following (assuming char* data = rawImage.GetData(); and an Image object rawImage): // Assuming image is 640 x 480 |
Spinnaker C++ API |
// Assuming image is 640 x 480 resolution. The current pixel format as well as PixelColorFilter indicate the Bayer Tile Mapping for the camera. For example, BayerRG8 is RGGB. ImagePtr pResultImage = cam.GetNextImage(); unsigned char* data = (unsigned char*)pResultImage->GetData(); // Assuming image is 640 x 480 |
Setting Number of Software Buffers
The following code snippet adjusts the number of buffers that the driver initializes for buffering images on your PC to 11 (default is 10).
FlyCapture2 C++ API |
|
Spinnaker C++ API |
Spinnaker::GenApi::INodeMap & sNodeMap = cam->GetStreamNodeMap(); |
C# Features
These tables provide a comparison of popular features used in FlyCapture2 C# API and Spinnaker C# API.
Enumeration
The snippet below detects the number of cameras connected and enumerates them from an index.
FlyCapture2 C# API |
ManagedBusManager busMgr = new ManagedBusManager(); |
Spinnaker C# GenAPI |
IList<IManagedCamera> camList = system.GetCameras(); |
Asynchronous Hardware Triggering
The snippet below does the following:
- Enables Trigger Mode
- Configures GPIO0/Line0 as the trigger input source
- Specifies the trigger signal polarity as an active high (rising edge) signal
FlyCapture2 C# API |
// Get current trigger settings // Set camera to trigger mode 0 // Set the trigger mode |
Spinnaker C# QuickSpin API |
cam.TriggerMode.Value = TriggerModeEnums.On.ToString(); |
Spinnaker C# GenAPI |
IEnum triggerMode = nodeMap.GetNode<IEnum>("TriggerMode"); IEnum triggerSource = nodeMap.GetNode<IEnum>("TriggerSource"); IEnum triggerSelector = nodeMap.GetNode<IEnum>("TriggerSelector"); IEnum triggerActivation = nodeMap.GetNode<IEnum>("TriggerActivation"); |
Setting Black Level
Black level is known as brightness in FlyCapture2.
BlackLevel is the GenICam feature that represents the DC offset that is applied to the video signal. This example compares the mechanism used to set this feature in both environments.
FlyCapture2 C# API |
//Declare a Property struct. // Assuming cam is a managedCamera that has been initialized |
Spinnaker C# QuickSpin API |
// Black Level is also referred to as brightness // Set Black Level to an absolute value of 1.5% |
Spinnaker C# GenAPI |
IEnum blackLevelSelector = nodeMap.GetNode<IEnum>("BlackLevelSelector"); IFloat blackLevel = nodeMap.GetNode<IFloat>("BlackLevel"); |
Setting Exposure Time
Exposure time is known as shutter in FlyCapture2.
ExposureTime refers to the amount of time that the camera's electronic shutter stays open. This example sets your camera's exposure/shutter time to 20 milliseconds.
FlyCapture2 C# API |
//Declare a Property struct. // Assuming cam is a managedCamera that has been initialized |
Spinnaker C# QuickSpin API |
// Turn off auto exposure // Set exposure mode to "Timed" // Set exposure to 20000 microseconds |
Spinnaker C# GenAPI |
IEnum exposureAuto = nodeMap.GetNode<IEnum>("ExposureAuto"); IEnum exposureMode = nodeMap.GetNode<IEnum>("ExposureMode"); IFloat exposureTime = nodeMap.GetNode<IFloat>("ExposureTime"); |
Setting Gain
The following code snippet adjusts gain to 10.5 dB.
FlyCapture2 C# API |
//Declare a Property struct. // Assuming cam is a managedCamera that has been initialized |
Spinnaker C# QuickSpin API |
//Turn auto gain off //Set gain to 10.5 dB |
Spinnaker C# GenAPI |
IEnum gainAuto = nodeMap.GetNode<IEnum>("GainAuto"); IFloat gainValue = nodeMap.GetNode<IFloat>("Gain"); |
Setting Gamma
The following code snippet adjusts gamma to 1.5.
FlyCapture2 C# API |
//Declare a Property struct. // Assuming cam is a managedCamera that has been initialized |
Spinnaker C# QuickSpin API |
// Set the absolute value of gamma to 1.5 |
Spinnaker C# GenAPI |
IFloat gamma = nodeMap.GetNode<IFloat>("Gamma"); |
Setting White Balance
The following code snippet adjusts the white balance's red and blue channels.
FlyCapture2 C# API |
//Declare a Property struct. // Assuming cam is a managedCamera that has been initialized // Get current trigger settings |
Spinnaker C# QuickSpin API |
// Set auto white balance to off // Select blue channel balance ratio // Set the white balance blue channel to 2 |
Spinnaker C# GenAPI |
IEnum balanceWhiteAuto = nodeMap.GetNode<IEnum>("BalanceWhiteAuto"); IEnum balanceRatioSelector = nodeMap.GetNode<IEnum>("BalanceRatioSelector"); IFloat balanceRatio = nodeMap.GetNode<IFloat>("BalanceRatio"); |
Accessing Raw Bayer Data
Raw image data can be accessed programmatically via the getData method of the FlyCapture2 and Spinnaker Image class. In 8 bits per pixel modes such as BayerRG8, the first byte represents the pixel at [row 0, column 0], the second byte at [row 0, column 1], and so on. Image data always starts in the top left corner of the image.
FlyCapture2 C# API |
// Read the BAYER_TILE_MAPPING register 0x1040 to determine the current Bayer output format (RGGB, GRBG, and so on). Using a Bayer format of RGGB, for example, the getData method returns the following (assuming byte* data = rawImage.data; and an Image object data): // Assuming image is 640 x 480 |
Spinnaker C# API |
Unsafe // Assuming image is 640 x 480 resolution with bayer tile RGGB |
Setting Number of Software Buffers
The following code snippet adjusts the number of image buffers that the driver initializes for buffering images on your PC to 11 (default is 10).
FlyCapture2 C# API |
FC2Config bufferSetting; |
Spinnaker C# API |
INodeMap sNodeMap = cam.GetTLStreamNodeMap(); |
C Features
These tables provide a comparison of popular features used in FlyCapture2 C API and Spinnaker C API.
Enumeration
The snippet below detects the number of cameras connected and enumerates them from an index.
FlyCapture2 C API |
fc2PGRGuid guid; |
Spinnaker C API |
spinCamera hCamera = NULL; |
Asynchronous Hardware Triggering
The snippet below does the following:
- Enables Trigger Mode
- Configures GPIO0/Line0 as the trigger input source
- Specifies the trigger signal polarity as an active high (rising edge) signal
FlyCapture2 C API |
fc2TriggerMode mTrigger; mTrigger.mode = 0; fc2SetTriggerMode( context, & mTrigger); |
Spinnaker C API |
spinNodeHandle hTriggerMode = NULL; err = spinNodeMapGetNode(hNodeMap, "TriggerMode", &hTriggerMode); spinNodeHandle hTriggerSelector = NULL; err = spinNodeMapGetNode(hNodeMap, "TriggerSelector", &hTriggerSelector); spinNodeHandle hTriggerActivation = NULL; err = spinNodeMapGetNode(hNodeMap, "TriggerActivation", &hTriggerActivation); |
Setting Black Level
Black level is known as brightness in FlyCapture2.
BlackLevel is the GenICam feature that represents the DC offset that is applied to the video signal. This example compares the mechanism used to set this feature in both environments.
FlyCapture2 C API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is set up to use absolute value control. //Set the absolute value of brightness to 1.5%. //Set the property. |
Spinnaker C API |
// Black Level is also referred to as brightness err = spinNodeMapGetNode(hNodeMap, "BlackLevelSelector", &hBlackLevelSelector); //Set the absolute value of brightness to 1.5%. |
Setting Exposure Time
Exposure time is known as shutter in FlyCapture2.
ExposureTime refers to the amount of time that the camera's electronic shutter stays open. This example sets your camera's exposure/shutter time to 20 milliseconds.
FlyCapture2 C API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is on. //Ensure auto-adjust mode is off. //Ensure the property is set up to use absolute value control. //Set the absolute value of shutter to 20 ms. //Set the property. |
Spinnaker C API |
// Turn off auto exposure err = spinNodeMapGetNode(hNodeMap, "ExposureAuto", &hExposureAutoSelector); //Set exposure mode to "Timed" err = spinNodeMapGetNode(hNodeMap, "ExposureAuto", &hExposureModeSelector); //Set absolute value of shutter exposure time to 20000 microseconds |
Setting Gain
The following code snippet adjusts gain to 10.5 dB.
FlyCapture2 C API |
//Declare a Property struct. //Define the property to adjust. //Ensure auto-adjust mode is off. //Ensure the property is set up to use absolute value control. //Set the absolute value of shutter to 20 ms. //Set the property. |
Spinnaker C API |
//Turn auto gain off err = spinNodeMapGetNode(hNodeMap, "GainAuto", &hGainAutoSelector); //Set gain to 10.5 dB |
Setting Gamma
The following code snippet adjusts gamma to 1.5.
FlyCapture2 C API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is on. //Ensure the property is set up to use absolute value control. //Set the absolute value of gamma to 1.5. //Set the property. |
Spinnaker C API |
// Enable Gamma err = spinNodeMapGetNode(hNodeMap, "GammaEnable", &hGammaEnable); // Set the absolute value of gamma to 1.5 |
Setting White Balance
The following code snippet adjusts the white balance's red and blue channels.
FlyCapture2 C API |
//Declare a Property struct. //Define the property to adjust. //Ensure the property is on. //Ensure auto-adjust mode is off. //Set the white balance red channel to 500. //Set the white balance blue channel to 850. //Set the property. |
Spinnaker C API |
//Set auto white balance to off err = spinNodeMapGetNode(hNodeMap, "BalanceWhiteAuto", &hBalanceWhiteAutoSelector); //Select blue channel balance ratio err = spinNodeMapGetNode(hNodeMap, "BalanceRatioSelector", &hBalanceRatioSelector); //Set the white balance blue channel to 2 //Set the white balance red channel to 2 spinNodeHandle hRedRatio; |
Accessing Raw Bayer Data
Raw image data can be accessed programmatically via the getData method of the FlyCapture2 and Spinnaker Image class. In 8 bits per pixel modes such as BayerRG8, the first byte represents the pixel at [row 0, column 0], the second byte at [row 0, column 1], and so on. Image data always starts in the top left corner of the image.
FlyCapture2 C API |
// Read the BAYER_TILE_MAPPING register 0x1040 to determine the current Bayer output format (RGGB, GRBG, and so on). Using a Bayer format of RGGB, for example, the fc2GetImageData method returns the following: // Assuming image is 640 x 480 |
Spinnaker C API |
// Assuming image is 640 x 480 resolution. The current pixel format as well as PixelColorFilter indicate the Bayer Tile Mapping for the camera. For example, BayerRG8 is RGGB. err = spinCameraGetNextImage(hCam, &hResultImage); void **data; spinImageGetData(hResultImage, data); // Assuming image is 640 x 480 |
Setting Number of Software Buffers
The following code snippet adjusts the number of image buffers that the driver initializes for buffering images on your PC to 11 (default is 10).
FlyCapture2 C API |
FC2Config BufferFrame; |
Spinnaker C API |
spinNodeHandle hGenTLNode = NULL; |