Event Classes

PySpin provides an event-driven interface for responding to camera and system notifications asynchronously. Rather than polling for state changes, you register a handler subclass with the relevant camera or system object and override the appropriate callback method. The SDK will invoke your handler on a dedicated internal thread whenever the corresponding event fires.

The available handler categories are:

  • Device events – camera-level hardware notifications (arrival, removal, and device-specific GenICam events).

  • Image events – called each time a new image or image list is ready for processing without calling GetNextImage().

  • Interface events – fired when a network or USB interface appears or disappears on the host.

  • Logging events – route Spinnaker’s internal log messages to your own handler for diagnostics or structured logging.

  • System events – top-level notifications dispatched by the System singleton.

Usage pattern:

import PySpin

class MyImageHandler(PySpin.ImageEventHandler):
    def OnImageEvent(self, image):
        print(f"Received image {image.GetFrameID()}")

system = PySpin.System.GetInstance()
cam_list = system.GetCameras()
cam = cam_list[0]
cam.Init()

handler = MyImageHandler()
cam.RegisterEventHandler(handler)

cam.BeginAcquisition()
# ... handler fires automatically for each new image ...
cam.EndAcquisition()

cam.UnregisterEventHandler(handler)
cam.DeInit()
cam_list.Clear()
system.ReleaseInstance()

Note

Always call UnregisterEventHandler() before DeInit() to avoid callbacks firing on a partially torn-down camera object.

PySpin.DeviceArrivalEventHandler

class DeviceArrivalEventHandler

An event handler for capturing the device arrival event.

OnDeviceArrival(self, pCamera)

Parameters

pCamera: Spinnaker::CameraPtr

Spinnaker::DeviceArrivalEventHandler::OnDeviceArrival Callback to the device arrival event.

param pCamera:

Reference tracked CameraPtr object of the camera attached to the system

PySpin.DeviceEventHandler

class DeviceEventHandler

Proxy of C++ Spinnaker::DeviceEventHandler class.

GetDeviceEventId(self) uint64_t

Spinnaker::IDeviceEventHandler::GetDeviceEventId

GetDeviceEventName(self) gcstring

Spinnaker::IDeviceEventHandler::GetDeviceEventName

OnDeviceEvent(self, eventName)

Parameters

eventName: Spinnaker::GenICam::gcstring

Spinnaker::IDeviceEventHandler::OnDeviceEvent

PySpin.DeviceRemovalEventHandler

class DeviceRemovalEventHandler

An event handler for capturing the device removal event.

OnDeviceRemoval(self, pCamera)

Parameters

pCamera: Spinnaker::CameraPtr

Spinnaker::DeviceRemovalEventHandler::OnDeviceRemoval Device removal event callback.

param pCamera:

Reference tracked CameraPtr object of the camera removed from the system

PySpin.EventHandler

class EventHandler(*args, **kwargs)

The base class for all event handler types.

GetEventPayloadData(self) PyObject *

Spinnaker::EventHandler::GetEventPayloadData Gets the event payload data

The event payload data

GetEventPayloadDataSize(self) size_t const

Spinnaker::EventHandler::GetEventPayloadDataSize Gets the event payload data size

The event payload data size

GetEventType(self) Spinnaker::EventType

Spinnaker::EventHandler::GetEventType Gets the event type

The event type

SetEventType(self, eventType)

Parameters

eventType: enum Spinnaker::EventType

Spinnaker::EventHandler::SetEventType Sets the event type

param eventType:

The event type

PySpin.ImageEventHandler

class ImageEventHandler

A handler for capturing image arrival events.

OnImageEvent(self, image)

Parameters

image: Spinnaker::ImagePtr

PySpin.ImageListEventHandler

class ImageListEventHandler

A handler for capturing image list arrival events.

OnImageListEvent(self, imageList)

Parameters

imageList: Spinnaker::ImageList

PySpin.InterfaceArrivalEventHandler

class InterfaceArrivalEventHandler

An event handler for capturing the interface arrival event. Note that only GEV interface arrivals are currently handled.

OnInterfaceArrival(self, pInterface)

Parameters

pInterface: Spinnaker::InterfacePtr

Spinnaker::InterfaceArrivalEventHandler::OnInterfaceArrival

Interface arrival event callback. Note that only GEV interface arrivals are

currently handled.

param pInterface:

Reference tracked pointer to Interface object of the adapter attached to the system

PySpin.InterfaceEventHandler

class InterfaceEventHandler

A handler to device arrival and removal events on all interfaces.

OnDeviceArrival(self, pCamera)

Parameters

pCamera: Spinnaker::CameraPtr

Spinnaker::InterfaceEventHandler::OnDeviceArrival Device arrival event callback.

param pCamera:

Reference tracked pointer to Camera object of the device attached to the system

OnDeviceRemoval(self, pCamera)

Parameters

pCamera: Spinnaker::CameraPtr

Spinnaker::InterfaceEventHandler::OnDeviceRemoval Callback to the device removal event.

param pCamera:

Reference tracked pointer to Camera object of the device removed from the system

PySpin.InterfaceRemovalEventHandler

class InterfaceRemovalEventHandler

An event handler for capturing the interface removal event. Note that only GEV interface removals are currently handled.

OnInterfaceRemoval(self, pInterface)

Parameters

pInterface: Spinnaker::InterfacePtr

Spinnaker::InterfaceRemovalEventHandler::OnInterfaceRemoval

Interface removal event callback. Note that only GEV interface removals are

currently handled.

param pInterface:

Reference tracked pointer to Interface object of the adapter removed from the system

PySpin.LoggingEventHandler

class LoggingEventHandler

An event handler for capturing the device logging event.

OnLogEvent(self, eventPtr)

Parameters

eventPtr: Spinnaker::LoggingEventDataPtr

Spinnaker::LoggingEventHandler::OnLogEvent The callback for the log event.

param eventPtr:

The logging event pointer

PySpin.LoggingEventDataPtr

class LoggingEventDataPtr(*args)

A reference tracked pointer to the LoggingEvent object.

PySpin.SystemEventHandler

class SystemEventHandler

A handler to interface arrival and removal events on the system. Note that only GEV interface arrivals and removals are currently handled.

OnInterfaceArrival(self, pInterface)

Parameters

pInterface: Spinnaker::InterfacePtr

Spinnaker::SystemEventHandler::OnInterfaceArrival

Interface arrival event callback. Note that only GEV interface arrivals are

currently handled.

param pInterface:

Reference tracked pointer to Interface object of the adapter attached to the system

OnInterfaceRemoval(self, pInterface)

Parameters

pInterface: Spinnaker::InterfacePtr

Spinnaker::SystemEventHandler::OnInterfaceRemoval

Interface removal event callback. Note that only GEV interface removals are

currently handled.

param pInterface:

Reference tracked pointer to Interface object of the adapter removed from the system