LabVIEW is good at instrument control, but to talk to a Matrox frame grabber you have to use the Matrox Imaging Library (MIL) from C. I wrote milInterface to sit in between, as a thin C++ DLL. LabVIEW calls a handful of plain C functions, and the DLL does all of the MIL work.
The interface#
| Function | What it does |
|---|---|
initialize(dcf_path, max_frames) | Starts MIL, opens the frame grabber with a camera configuration file (DCF) and allocates a ring of image buffers |
start(n) | Starts an asynchronous grab of n frames |
is_grabbing(), get_num_grabbed() | Let LabVIEW poll the progress without blocking |
get_frame_size() | Size of one frame in bytes, so LabVIEW can allocate its array |
get(frame, buffer, size) | Copies one grabbed frame into a LabVIEW array (8- or 16-bit pixels) |
destroy() | Frees everything |
The grab runs asynchronously (MdigGrab and MdigGrabWait into the buffer ring), which keeps LabVIEW responsive while frames arrive, and frames get copied into LabVIEW memory only when LabVIEW asks for them. I gave every MIL allocation step a separate error code, so problems with a misconfigured camera are easy to diagnose from the LabVIEW side.
To check the camera and the configuration outside LabVIEW, the repository also has LabVIEW test VIs and Python scripts that use the MIL Python bindings.