PVCAM
3.9.x
Programmable Virtual Camera Access Method library
|
This sample application demonstrates acquisition of frames with multiple defined regions of interest. Callback acquisition is used and 5 frames are acquired in total. The example uses so called 'emulated' software trigger where sequence acquisition for a single frame is configured and the acquisition is then executed multiple times. The number of regions can be configured by the cRoiCount
constant, the ROIs are automatically arranged in a diagonal order.
Please note that multiple region acquisition is supported on modern cameras only. The acquisition with multiple regions stores additional metadata in user image buffer and requires this feature to be enabled with PARAM_METADATA_ENABLED parameter.
Initialize PVCAM and open the first available camera. Please, refer to the actual code sample in the SDK installation directory for more details about the common helper functions used in this documentation.
This code example uses the recommended callbacks acquisition (see Polling versus Callbacks). A part of the code omitted here defines a static callback function and registers the function with PVCAM. This approach is used in other code samples as well. The relevant code part is described in Frame Callback Handler section.
Ensure that the camera supports multiple region acquisition and obtain the maximum number of supported ROIs per frame.
The multiple-ROI feature requires frame metadata feature to be enabled, therefore, before starting the acquisition, the PARAM_METADATA_ENABLED needs to be set to TRUE
.
Set regions diagonally from the top-left corner to the bottom-right corner with serial and parallel binning set to 1. Regions must not overlap.
Prepare the sequence acquisition. The pl_exp_setup_seq function returns the size of the buffer required to store all images (unlike a size of just one frame as with the pl_exp_setup_cont function). In this case, we only require one image acquisition. For more details, please refer to Acquisition Configuration. section.
Now allocate the buffer memory to the size reported by pl_exp_setup_seq function.
In this example we will recompose all individual ROIs into full frame image, as they would appear on the sensor, thus we allocate memory for the full frame image. At the moment the pl_md_frame_recompose function works with uns16
type pixels only.
Allocate memory for the metadata structures. Do not access the structure members before the structure is filled with the pl_md_frame_decode function.
Acquire 5 images in a loop:
Start the acquisition. Since the pl_exp_setup_seq was configured to use the internal camera trigger, the acquisition is started immediately. In hardware triggering modes the camera would wait for an external trigger signal.
Here we need to wait for a frame readout notification signaled by eofEvent
in CameraContext which is raised in the callback handler we registered. If the frame does not arrive within 5 seconds, or if the user aborts the acquisition with ctrl+c shortcut, the main while
loop is interrupted and the acquisition is aborted.
Decode the frame and display ADU values of first several pixels for each region:
Optionally, recompose all ROIs into a full-frame image. The whole frame is already filled with black pixels, here we only overwrite the ROI pixels with the new data because the region positions do not change in between the acquisitions.
When acquiring single frames with callback notifications, call the pl_exp_finish_seq after every frame before a new acquisition is started with pl_exp_start_seq.
Clean up before exiting the program. Please, refer to the Closing Camera and Uninitializing PVCAM section for more details.