Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The diagram below illustrates the main modules in DevWare that have call-backs into the plug-in DLL.

Features of the

...

Plug-in API

Plug-ins can be used to create a UI for new sensor registers or third party or prototype hardware not supported by Sensor Control pages in DevWare, or for image processing or image data capture. The Plug-in API provides:

...

DevWare supports up to 24 plug-in dialogs simultaneously. If plug-ins are present, DevWare will add a “Plug-ins” menu to its main window. The user can activate and deactivate plug-in windows at will. If your plug-in does not need a UI then there is also a way to run it without a dialog window.


Dialog Plugin API Details

...

CloseDialogCloseDialog()
CloseDialog(void);

Called when DevWare is switching to another camera, or exiting. Destroy your window and free all allocated memory. If OpenDialog() returned 0, CloseDialog() will not be called.

__declspec(dllexport) void CALLBACK
ImageData(unsigned char * pImage,
mi_image_types imageType,
int nWidth,
int nHeight,
int nStride);

DevWare will pass all image data to your plug-in through this function. It will be called at least twice for every frame displayed by DevWare. Once with the data in sensor-dependent format, and again with the final RGB image that DevWare is going to display in its window. You do not need to export this function if your plug-in does not use the image data. image data . OpenDialog() and CloseDialog() are required
Function

Details

Calling Thread
OpenDialog

__declspec(dllexport) HWND CALLBACK
OpenDialog(DWORD dwApiVersion,
HWND hwndParent,
DEVW_Camera *pCamera,
DEVW_Callbacks *pCallbacks);

(Only on Windows, if your plug-in is creating a dialog, but not using the Qt GUI library.)

DevWare calls this function when it's starting up a camera or switching cameras. You should create your window but not show it. Return the Windows window handle for your window. DevWare will use the handle to show and hide your window. The title of your window will be used for the menu in DevWare. Do only basic initialization here. Do not access registers yet; you will have an opportunity to do that later.

Parameters:

  • dwApiVersion: Compare this against the constant PLUGIN_DLG_API to make sure you and DevWare are using the same version of the API.
  • hwndParent: The Windows window handle of the main DevWare window. Normally your window would be a WS_POPUP style window with DevWare as its parent (but this is not strictly necessary). Also you can use this handle to send messages to DevWare.
  • pCamera: Information about the sensor and camera. See the header files for details. The pointer does not remain valid after OpenDialog() returns, you must copy the contents of the structure into your own variable.
  • pCallbacks: Pointers to the callback functions in DevWare. See below. The pointer does not remain valid after OpenDialog() returns, you must copy the contents of the structure into your own variable. (The pointers to functions within the structure do remain valid.)

If something goes wrong return 0. If your plug-in should only work with certain devices you can examine the pCamera structure and return 0 if you plug-in is not designed for that device.

Otherwise DevWare will add your plug-in to the “Plug-Ins” menu, using the title bar text from your window for its menu item. The API supports only one window per DLL. (But that window could be a tabbed dialog with any number of tabs, or could have child windows. Also, DevWare can load up to 24 DLLs simultaneously.)

GUI
OpenQtDialog

__declspec(dllexport) QWidget * CALLBACK
OpenQtDialog(DWORD dwApiVersion,
QWidget * widgetParent,
DEVW_Camera *pCamera,
DEVW_Callbacks *pCallbacks);

(If your plug-in is creating a dialog window using the Qt GUI library. Any OS.)

Same as OpenDialog(), but using Qt widgets instead of Windows window handles.

  GUI
OpenHeadless

__declspec(dllexport) void * CALLBACK

GUIImageData

OpenHeadless(DWORD dwApiVersion,
DEVW_Camera *pCamera,
DEVW_Callbacks *pCallbacks);

(If your plug-in will run with no UI. Any OS.)

Same as OpenDialog(), but return any non-NULL pointer to indicate that the plug-in should be active. A headless plug-in can implement any of the image data functions, and can call DevWare through the callbacks.

GUI
CloseDialog

__declspec(dllexport) void CALLBACK
CloseDialog(void);

Called when DevWare is switching to another camera, or exiting. Destroy your window and free all allocated memory. If OpenDialog() returned 0, CloseDialog() will not be called.

GUI
CloseHeadless

__declspec(dllexport) void CALLBACK
CloseHeadless(void);

Like CloseDialog(), but used with OpenHeadless().

GUI
ImageData

__declspec(dllexport) void CALLBACK
ImageData(unsigned char * pImage,
mi_image_types imageType,
int nWidth,
int nHeight,
int nStride);

DevWare will pass all image data to your plug-in through this function. It will be called at least twice for every frame displayed by DevWare. Once with the data in sensor-dependent format, and again with the final RGB image that DevWare is going to display in its window. You do not need to export this function if your plug-in does not use the image data.

Parameters:

  • pImage: Pointer to upper left pixel of image.
  • imageType: See midlib.h. Tells you the image type, for example, MI_BAYER_S12, MI_YCBCR, MI_RGB32, etc.
  • nWidth: Width in pixels.
  • nHeight: Height in pixels.
  • nStride: Distance in bytes between rows in the image. To get the y?th row use pImage + y * nStride. Never depend on the nWidth parameter for this. DevWare may put pad bytes between rows.

This function can be used for analysis, image processing, or data capture. You can write to the image buffer and DevWare will use the new data. For example, you can write to the MI_RGB32 buffer to create indicator graphics in the image. You could also filter image data, etc.

This function is called every frame regardless of whether your window is visible or not. If you want your processing to stop when your window is hidden then you must explicitly check for that case and return immediately from the function.

You must be careful of what you do in this function because it is called from a different thread than the UI thread. You must not directly access your window controls from this function. If the UI needs to be updated use inter-thread communication such as PostMessage() or Qt signals to send a message to your window, or use some other communication mechanism such as common variables and critical sections.

You should not call DevWare callback functions, except that it is permissible to read and write sensor registers.

DevWare converts all Bayer data to MI_BAYER_S12 for processing. MI_BAYER_S12 uses a 16-bit signed 2s-complement integer for each pixel. The value 0 represents the Black Level, and the value 4095 represents the maximum brightness. Values outside this range are possible as a result of noise or image processing. The final image is always MI_RGB32, which is 32-bits per pixel, B-G-R-x byte order.The ImageDataper pixel, B-G-R-x byte order.

The ImageData() function is optional. If you do not need image data then you do not need to have this function.

Display
RawImageData

__declspec(dllexport) void CALLBACK
RawImageData(unsigned char * pImage,
mi_image_types imageType,
int nWidth,
int nHeight,
int nStride);

Like ImageData(), but called earlier in the color processing, before black subtraction and multiple exposure combining. The RawImageData() function is optional. If you do not need the notifications then you do not need to have this function.
Display
LinearImageData

__declspec(dllexport) void CALLBACK
LinearImageData(unsigned char * pImage,

mi_image_types imageType,
int nWidth,
int nHeight,
int nStride);
Like RawImageData(), but called right after multiple exposure combining. The LinearImageData() function is optional. If you do not need

the notifications then you do not need to have this function

.

Display
GrabFrame

__declspec(dllexport) void CALLBACK
GrabFrame(unsigned char * pBuffer, int nDataLength);

DevWare will call this function every time it gets a new frame from the camera. This is called before the ImageData() functions. The parameters are a pointer to the data and the data length. The data is just as it came from the camera. You do not need to export this function if your plug-in does not need this notification.

If you need to poll registers or update registers frequently, this function is the best place to do it. Register access here will have the least interference with the frame rate.

Parameters:

  • pBuffer: Pointer to the data from the camera.
  • nDataLength: Number of bytes of data received.

This function can be used for analysis, image processing, or data capture. You can write to the image buffer and DevWare will use the new data.

This function is called on every received frame regardless of whether your window is visible or not. If you want your processing to stop when your window is hidden then you must explicitly check for that case and return immediately from the function.

You must be careful of what you do in this function because it is called from a different thread than the UI thread. You must not directly access your window controls from this function.

You should not call DevWare callback functions, except that it is permissible to read and write sensor registers.The GrabFrame() function is optional. If you do not need the notifications then you do not need to have this function.

Camera
SaveImage

__declspec(dllexport) void CALLBACK
SaveImage(const char * szPath);

DevWare will call this function when it saves a captured image. The plug-in may save additional data files if desired.

Parameters:

  • szPath: A C style string that is the saved file path and name without an extension.

This function is called whenever the application saves a captured image, regardless of whether your window is visible or not.

This function is typically called from the main thread.

The SaveImage() function is optional. If you do not need the notifications then you do not need to have this function.

Display?
RegisterChanged

__declspec(dllexport) void CALLBACK
RegisterChanged(int nId, unsigned int nValue);

DevWare will call this function when a sensor register you are monitoring has been written. See MonitorRegister() below. Take any action needed. This function will be called even if your plug-in window is hidden.

This function is typically called from the UI thread.

The RegisterChanged() function is optional. If you do not need the notifications then you do not need to have this function.

 

...