Configure the Acquisition
After opening the camera, configure the camera for acquisition by specifying the following parameters: whether the acquisition is one-shot or continuous, and the number of internal buffers to use.
While configuring the camera, the driver validates all the user-configurable attributes. If any attributes are invalid or out of range, the driver returns an error and does not configure the acquisition.
If you want to reconfigure the acquisition, call the Unconfigure Acquisition function before calling the Configure function again.
Note National Instruments recommends that you do not configure an acquisition in a loop because doing so is time-intensive. |
One-Shot Acquisition
Use a one-shot acquisition to start an acquisition, perform the acquisition, and stop the acquisition using a single function. The number of images acquired is equal to the number of images in the images collection.
With a one-shot acquisition, you specify a certain number of internal buffers. The camera transfers each image up to and including the specified number of buffers. The driver acquires every image during a one-shot acquisition. National Instruments recommends one-shot acquisition for applications that do not require real-time acquisition or processing.
Continuous Acquisition
Use a continuous acquisition to start an acquisition, continuously acquire images into the internal buffers, and explicitly stop the acquisition. With continuous acquisition, the driver acquires video data continuously from the camera and enables you to examine the most current buffer. National Instruments recommends continuous acquisition for real-time acquisition and processing.
Note If CPU activity increases during a continuous acquisition, the driver might miss subsequent images. Check the buffer number output to determine if you have missed any images. |
Number of Buffers
Another aspect of configuration is specifying the number of internal buffers into which you want to acquire image data. During configuration, buffers are allocated from system memory and page-locked. Once the acquisition starts, the camera transfers video data over the IEEE 1394 bus to the IEEE 1394 interface card FIFO. Then, video data is directly transferred to the internal buffer. This transfer requires negligible CPU resources. For the GigE Vision bus, CPU resources are used to pass network packets. For ethernet, ethernet packets are evaluated by software and copied into an internal buffer.
Each internal buffer you allocate is the exact size of the raw data being transmitted by the camera. For continuous acquisitions, allocate three or more buffers. Allocating a single buffer for a continuous acquisition may result in a high number of lost images. For one-shot acquisitions, specify the number of buffers that the application requires. For example, if the application runs for two seconds, and the camera acquires at 30 frames per second, allocate 60 buffers to capture each image.
Having more buffers available for the GigE Vision bus can increase the reliability of data transfer, especially when there are adverse network conditions.
Region of Interest
The region of interest (ROI) specifies a rectangular portion of the image to be captured. If the camera supports scalable video modes, the ROI defines the portion of the image to transfer from the camera to system memory.
If the camera does not support scalable video modes, the entire image is transferred from the camera to system memory. In all video modes, the ROI specifies the amount of data decoded by the driver while acquiring into a user buffer.
By default, the driver transfers the entire image. Specify a smaller ROI for the following reasons.
- To acquire only the necessary subset of data
- To increase the acquisition speed by reducing the amount of data transferred and/or decoded
- To allow for multiple simultaneous acquisitions by reducing bandwidth usage
Note Although you can specify an ROI of any size, the NI-IMAQdx software coerces the ROI into one that is more compatible for the given camera. Refer to the section Advanced Programming with NI-IMAQdx, for more information about defining an ROI for scalable images.
Pixel Format
The pixel format specifies the source type of the image format. Different pixel formats decode into different image types. Refer to the Acquisition section for more information on decoding.