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
Systemsingleton.
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.
PySpin.DeviceEventHandler¶
PySpin.DeviceRemovalEventHandler¶
- class DeviceRemovalEventHandler¶
An event handler for capturing the device removal event.
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
PySpin.ImageEventHandler¶
PySpin.ImageListEventHandler¶
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.
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¶
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