Skip to content

C++ Examples

Ready-to-run examples shipped with the Spinnaker SDK. Source files are located under src/{ExampleName}/ in the SDK source tree.

Standard Examples

Example Description
Acquisition.cpp Acquisition.cpp shows how to acquire images. It relies on information provided in the Enumeration example. Also, check out the ExceptionHandling and NodeMapInfo examples if you haven't already. ExceptionHandling shows the handling of standard and Spinnaker exceptions while NodeMapInfo explores retrieving information from various node types.
AcquisitionMultipleCameraRecovery.cpp AcquisitionMultipleCameraRecovery.cpp shows how to continuously acquire images from multiple cameras using image events. It demonstrates the use of User Set Control to save persistent camera configurations, allowing for smooth camera recovery through interface events. This example relies on information provided in the ImageEvents, EnumerationEvents, ImageFormatControl, and Acquisition examples.
AcquisitionMultipleCamerasWriteToFile.cpp AcquisitionMultipleCamerasWriteToFile.cpp shows how to acquire images from one or more cameras and write the images to a binary file. Thereafter, the acquired images can be retrieved from the file and saved using a desired file format supported by the current Spinnaker SDK.
AcquisitionMultipleThread.cpp AcquisitionMultipleThread.cpp shows how to capture images from multiple cameras simultaneously using threads. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
AcquisitionUserBuffer.cpp AcquisitionUserBuffer.cpp shows how to use User Buffers for image acquisition. The acquisition engine uses a pool of memory buffers. The memory of a buffer can be allocated by the library (default) or the user. User Buffers refer to the latter. This example relies on information provided in the Acquisition example.
BufferHandling.cpp BufferHandling.cpp shows how the different buffer handling modes work. It relies on information provided in the Acquisition and Trigger examples.
ChunkData.cpp ChunkData.cpp shows how to get chunk data on an image, either from the nodemap or from the image itself. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
Compression.cpp Compression.cpp shows how to utilize the compression features on a supported camera and in the Spinnaker SDK. It relies on information provided in the Acquisition, Enumeration, ChunkData, and NodeMapInfo examples.
CounterAndTimer.cpp CounterAndTimer.cpp shows how to setup a Pulse Width Modulation (PWM) signal using counters and timers. The camera will output the PWM signal via strobe, and capture images at a rate defined by the PWM signal as well. Users should take care to use a PWM signal within the camera's max framerate (by default, the PWM signal is set to 50 Hz).
CPUAffinity.cpp CPUAffinity.cpp demonstrates CPU affinity node access checks and status inspection through GenTL nodes.
Enumeration.cpp Enumeration.cpp shows how to enumerate interfaces and cameras. Knowing this is mandatory for doing anything with the Spinnaker SDK, and is therefore the best place to start learning how to use the SDK.
EnumerationEvents.cpp EnumerationEvents.cpp explores arrival and removal events on interfaces and the system. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
ExceptionHandling.cpp ExceptionHandling.cpp shows the catching of an exception in Spinnaker. Following this, check out the Acquisition or NodeMapInfo examples if you haven't already. Acquisition demonstrates image acquisition while NodeMapInfo explores retrieving information from various node types.
Exposure.cpp Exposure.cpp shows how to set a custom exposure time on a device. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
GigEVisionPerformance.cpp GigEVisionPerformance.cpp measures GigE Vision performance. It is built on top of Acquisition example.
ImageEvents.cpp ImageEvents.cpp shows how to acquire images using the image event handler. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
ImageFormatControl.cpp ImageFormatControl.cpp shows how to apply custom image settings to the camera. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
ImageRelay.cpp ImageRelay.cpp shows how to setup relays for forwarding Spinnaker images from client PC to Host PC using the SpinnakerRelay library. It relies on information provided in the Enumeration, Acquisition, and ImageEvent examples.
Inference.cpp Inference.cpp shows how to perform the following: - Upload custom inference neural networks to the camera (DDR or Flash) - Inject sample test image - Enable/Configure chunk data - Enable/Configure trigger inference ready sync - Acquire images - Display inference data from acquired image chunk data - Disable previously configured camera configurations
Logging.cpp Logging.cpp shows how to create a handler to access logging events. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
LogicBlock.cpp LogicBlock.cpp shows how to use logic blocks to detect missing triggers and refire. It relies on information provided in the Acquisition and Trigger examples.
LookupTable.cpp LookupTable.cpp shows how to configure lookup tables on the camera. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
NodeMapCallback.cpp NodeMapCallback.cpp shows how to use nodemap callbacks. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples. As callbacks are very similar to events, it may be a good idea to explore this example prior to tackling the events examples.
NodeMapInfo.cpp NodeMapInfo.cpp shows how to retrieve node map information. It relies on information provided in the Enumeration example. Also, check out the Acquisition and ExceptionHandling examples if you haven't already. Acquisition demonstrates image acquisition while ExceptionHandling shows the handling of standard and Spinnaker exceptions.
Polarization.cpp Polarization.cpp shows how to extract and create images from a source image of Polarized8 or BayerRGPolarized8 pixel format using methods from the ImageUtilityPolarization, ImageUtility and ImageUtilityHeatmap classes. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
SaveToVideo.cpp SaveToVideo.cpp shows how to create a video from a vector of images. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
Sequencer.cpp Sequencer.cpp shows how to use the sequencer to grab images with various settings. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.
SerialRxTx.cpp SerialRxTx.cpp shows how to communicate using Serial ports. It sets serial port settings in Spinnaker, opens and operates on FileAccess nodes and creates COM Port handle. After the setup, it transmits and receives simple data. It verifies the communication by transmitting data and reading data to/from the COM Port. Basic understanding of serial communication and knowledge of the installation process for a serial port is required.
StereoAcquisition.cpp StereoAcquisition.cpp shows how to acquire image sets from a stereo camera. The image sets are then saved to file and/or used to compute 3D point cloud and saved as a PLY (Polygon File Format) file.
StereoGPIO.cpp StereoGPIO.cpp shows how to set the GPIO of the stereo camera.
Trigger.cpp Trigger.cpp shows how to trigger the camera. It relies on information provided in the Enumeration, Acquisition, and NodeMapInfo examples.

QuickSpin Examples

The QuickSpin API provides a simplified, type-safe interface to common camera properties without requiring direct GenICam node access.

Example Description
Enumeration_QuickSpin.cpp Enumeration_QuickSpin.cpp shows how to enumerate interfaces and cameras using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control. This is a great example to start learning about QuickSpin.
Exposure_QuickSpin.cpp Exposure_QuickSpin.cpp shows how to customize image exposure time using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control.
FileAccess_QuickSpin.cpp
ImageFormatControl_QuickSpin.cpp ImageFormatControl_QuickSpin.cpp shows how to apply custom image settings to the camera using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control.
NodeMapInfo_QuickSpin.cpp NodeMapInfo_QuickSpin.cpp shows how to interact with nodes using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control.
StereoAcquisition_QuickSpin.cpp StereoAcquisition_QuickSpin.cpp shows how to acquire image sets from a stereo camera using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control. The image sets are then saved to file and/or used to compute 3D point cloud and saved as a PLY (Polygon File Format) file.
Trigger_QuickSpin.cpp Trigger_QuickSpin.cpp shows how to capture images with the trigger using the QuickSpin API. QuickSpin is a subset of the Spinnaker library that allows for simpler node access and control.