PXL_RETURN_CODE PxLSetEventCallback (

  HANDLE hCamera,
  U32    eventId,
  LPVOID pContext,
  U32 (PXL_APICALL* EventProcessFunction)(

      HANDLE             hCamera,
      U32                eventId,
      double             eventTimestamp,
      U32				 numDataBytes,
      LPVOID			 pData,
      LPVOID             pContext ) );


This function installs a user defined callback that will be called by the API whenever the specified event occurs in the specified camera.

  • hCamera is the camera handle. This value is returned by PxLInitialize

  • eventId identifies the specific event. The entire set of possible events can be found here: Event ID

  • pContext is a parameter that can be used to have additional information passed to your callback function. It is optional, and can be NULL.

  • EventProcessFunction is a function pointer to a user-defined callback function. This function will be called by the API with the following parameters:

    • hCamera is the camera handle. This value is returned by PxLInitialize.

    • eventId identifies the specific event.

    • eventTimestamp identifies the specific time within the camera, when the event occurred. The application can get the camera’s time via the function PxLGetCurrentTimestamp.

    • numDataBytes is the number of data bytes associated with the event (the number of bytes pointed to by pData). At present, this is always 0

    • pData is an array of numDataBytes bytes, representing event specific data. Currently, none of the defined events have any associated data (so this value will be NULL).

    • pContext is the value that was passed as the pContext parameter to PxLSetEventCallback.


U32 userData = 0x5AFECAFE;

rc = PxLSetEventCallback(
        EVENT_ANY, // We can specify a specific event, or all of them

if (!API_SUCCESS(rc)) {
     // Error handling here


PxLSetEventCallback (hCamera, EVENT_ANY, NULL, NULL); // Cancel the callback

Comments, Restrictions and Limitations

Similar to frame callbacks, event callbacks do not persist across camera power cycles – a camera reset effectively cancels all callback requests. Also, callbacks are not saved as part of the camera settings with PxLSave/LoadCameraSettings operations.