↓ Skip to main content
  1. Home projects/

milInterface: a Matrox frame grabber in LabVIEW

··Index: 3·
Table of Contents

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
#

FunctionWhat 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.

milInterface: LabVIEW calls the DLL, which grabs frames from the camera into a ring of buffers through MIL and copies them out on requestLabVIEWmilInterfaceC++ DLLplain C functionsMILMatroxframe grabbercameracallsring of image bufferspolls progress,then get(frame)grab runs asynchronously; frames are copied to LabVIEW only on request
Asynchronous grab into a ring of buffers, copied out on request

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.

Source on GitHub.

Related