Acquire an Image

NI IMAQ

Acquire an Image

Use the CWIMAQ control to acquire images with a National Instruments image acquisition device. You can use NI Vision for Visual Basic to perform one-shot and continuous acquisitions. You can choose the acquisition type during design time by setting the value of the Acquisition Type combo box to One-Shot or Continuous. The Acquisition Type combo box is located on the Acquisition property page of the CWIMAQ control. You can set the value at run-time by setting the CWIMAQ.AcquisitionType property to cwimaqAcquisitionOneShot or cwimaqAcquisitionContinuous.

One-Shot Acquisition

Use a one-shot acquisition to start an acquisition, perform the acquisition, and stop the acquisition using a single method. The number of frames acquired is equal to the number of images in the images collection. Use the CWIMAQ.AcquireImage method to perform this operation synchronously. Use the CWIMAQ.Start method to perform this operation asynchronously.

If you want to acquire a single field or frame into a buffer, set the image count to 1. This operation is also referred to as a snap. Use a snap for low-speed or single capture applications. The following code illustrates a synchronous snap:

Private Sub Start_Click()

CWIMAQ1.AcquisitionType = cwimaqAcquisitionOneShot

CWIMAQ1.AcquireImage

End Sub

If you want to acquire multiple frames, set the image count to the number of frames you want to acquire. This operation is called a sequence. Use a sequence for applications that process multiple images. The following code illustrates an asynchronous sequence when numberOfImages is the number of images that you want to process:

Private Sub Start_Click()

CWIMAQ1.AcquisitionType = cwimaqAcquisitionOneShot

CWIMAQ1.Images.RemoveAll

CWIMAQ1.Images.Add numberOfImages

CWIMAQ1.Start

End Sub

Continuous Acquisition

Use a continuous acquisition to start an acquisition and continuously acquire frames into the image buffers, and then explicitly stop the acquisition. Use the CWIMAQ.Start method to start the acquisition. Use the CWIMAQ.Stop method to stop the acquisition. If you use a single buffer for the acquisition, this operation is called a grab. The following code illustrates a grab:

Private Sub Start_Click()

CWIMAQ1.AcquisitionType = cwimaqAcquisitionContinuous

CWIMAQ1.Start

End Sub

Private Sub Stop_Click()

CWIMAQ1.Stop

End Sub

A ring operation uses multiple buffers for the acquisition. Use a ring for high-speed applications that require processing on every image. The following code illustrates a ring, where numberOfImages is the number of images that you want to process:

Private Sub Start_Click()

CWIMAQ1.AcquisitionType = cwimaqAcquisitionContinuous

CWIMAQ1.Images.RemoveAll

CWIMAQ1.Images.Add numberOfImages

CWIMAQ1.Start

End Sub

Private Sub Stop_Click()

CWIMAQ1.Stop

End Sub