PVCAM  3.9.x
Programmable Virtual Camera Access Method library
Polling versus Callbacks

This page explains difference between callbacks and polling.

Warning
Use of polling in production code is not recommended anymore and it will become an unmaintained feature in the upcoming PVCAM releases.

Polling is a periodic call reading the camera status.

If polling is used, PVCAM translates the BOF and EOF events as follows:

  • Application starts the acquisition -> PVCAM reports the camera in EXPOSURE_IN_PROGRESS state.
  • Camera sends BOF event -> PVCAM reports the camera in READOUT_IN_PROGRESS state -> the frame is being transferred from the camera to the host computer.
  • Camera sends EOF event -> PVCAM reports the camera has completed transfer via READOUT_COMPLETE/FRAME_AVAILABLE flag and sends this state to application if requested before the state is switched to EXPOSURE_IN_PROGRESS again (unless another BOF arrives). Even though the READOUT_COMPLETE and FRAME_AVAILABLE states are defined with the same value, each of them is reported in a different mode:
  • Camera sends BOF event -> PVCAM reports the camera in READOUT_IN_PROGRESS state again. Afterwards, the state loop as described above repeats.

Callback is an executable function registered by the application. Once a specified event occurs in PVCAM, it calls the handler function directly to handle the event.

Callbacks are the preferred approach because with modern cameras the change between READOUT_COMPLETE and EXPOSURE_IN_PROGRESS states may happen too fast to be reliably captured using the polling method.

Due to on-camera frame buffering, the EXPOSURE_IN_PROGRESS and READOUT_IN_PROGRESS states do not always match the camera state. It can be interpreted as the n-th frame transfer has completed, but additional frames could have been read out and buffered in the meantime with another frame being currently exposed.

For these reasons the use of EOF callbacks for new frame notifications and camera hardware signals for the synchronization with other devices are recommended.

Polling method may be considered an option when using CCD cameras or when acquiring at low frame rates.

Callbacks approach is more robust and handles high-speed imaging with better reliability.

Note
See examples for reference: Single Image Callbacks, Single Image Polling, Live Image Callbacks, Live Image Polling.