Example Code

IMAQ Automatic Focus Example

Code and Documents

Attachment

Download All
This example illustrates two methods for determining the best focus for your imaging system. One approach uses frequency content to determine edge sharpness. The other method uses an edge detector and measures the average intensity of the edges. Both methods return a relative score that you can use to automate focusing. The concept is similar for both, but the approaches are different. Experiment with both methods to find which works best for you.

To use these methods, you need a way to automatically control the focus of your imaging system. For example, you need a lens that supports programmatic focus adjustment or you need a way to programmatically move the camera relative to the object under inspection.


Related Links:
System Setup

Example code from the Example Code Exchange in the NI Community is licensed with the MIT license.

Contributors