Overview
The Aptina (formerly Micron) Imaging Device Library (midlib) provides a device independent API for seamless device control and transport. A transport is a protocol for moving data off and on an imaging sensor. The currently supported transports are USB2.0 bulk transport, video file and bitmap file. Additional transports will be added as needed. Users can add a new transport by creating a DLL that implements the camera structure (mi_camera_t) functions. See the MIDLib Transport DLL Development Guide document.
The library supports any number of imaging sensors through use of sensor data files. Known sensor files are included with the library and users may add additional sensor data files as needed. An application begins using the library by calling the routine mi_OpenCameras(). This function goes through all supported transport types and attempts to initialize all cameras. It returns an array of pointers to camera structures (mi_camera_t) for all successfully initialized cameras. This camera structure holds all of the pertinent information about a camera, including a transport specific context, a pointer to a sensor, and function pointers to routines used to interact with the transport mechanism. The most common device specific transport routines are:
startTransport - Starts a transport stream
stopTransport - Stops a transport stream
grabFrame - Returns an image frame
updateFrameSize - Allows the user to update the image sensor data size after initialization
Given the array of cameras, the application may then use any of the these cameras by calling the camera's startTransport() routine. Once the transport has been started, the application can grab image frames and read and write sensor registers. When a camera is no longer needed, its transport may be stopped using the stopTransport() routine. When the application finishes with all cameras, it must call mi_CloseCameras(). An application can start and stop the camera's transport as many times as needed.
The library will attempt to locate the sensor data file that corresponds to the attached sensor in the directory passed in by the user. Alternately, a specific sensor data file may be provided by the user. mi_updateFrameSize() should be called when the image size or format has changed due to changes to the sensor registers. If a sensor data file does not exist the application may call mi_OpenCameras() with a null string for the sensor data file. The user must call mi_initTransport() and mi_updateFrameSize() if they want to grab image data in this mode, please see initTransport() for more information about this functionality.