# areaDetector Plugin NDPluginColorConvert

## January 30, 2009

## Mark Rivers

## University of Chicago

## Contents

- Overview
- Configuration
- Screen shots
- Restrictions

## Overview

This plugin is a tool for converting the color mode of NDArray data.

NDPluginColorConvert inherits from NDPluginDriver. NDPluginColorConvert receives an input NDArray with one color mode and outputs another NDArray with a (potentially) different color mode. All other attributes of the array are preserved. The NDPluginColorConvert public interface is defined in NDPluginColorConvert.h as follows:

    class NDPluginColorConvert : public NDPluginDriver {
    public:
        NDPluginColorConvert(const char *portName, int queueSize, int blockingCallbacks,
                             const char *NDArrayPort, int NDArrayAddr,
                             size_t maxMemory);

        /* These methods override the virtual methods in the base class */
        void processCallbacks(NDArray *pArray);
        asynStatus drvUserCreate(asynUser *pasynUser, const char *drvInfo,
                                 const char **pptypeName, size_t *psize);

        /* These methods are just for this class */
        template < typename epicstype > void convertColor(NDArray *pArray);
    };
    ...
    }

NDPluginColorConvert defines the following parameters. It also implements all of the standard plugin parameters from NDPluginDriver . The EPICS database NDColorConvert.template provides access to these parameters, listed in the following table.

Parameter Definitions in NDPluginColorConvert.h and EPICS Record Definitions in NDColorConvert.template
Enum name | asyn interface | Access | Description | drvUser string | EPICS record name | EPICS record type
--- | --- | --- | --- | --- | --- | ---
NDPluginColorConvertColorModeOut | asynInt32 | r/w | The output color mode (NDColorMode_t). | COLOR_MODE_OUT | $(P)$(R)ColorModeOut $(P)$(R)ColorModeOut_RBV | mbbo mbbi

NDPluginColorConvert currently supports the following conversions:

- Bayer to RGB1, RGB2, or RGB3
- RGB1 to RGB2 or RGB3
- RGB2 to RGB1 or RGB3
- RGB3 to RGB1 or RGB2

The Bayer color conversion supports the 4 Bayer formats (NDBayerRGGB, NDBayerGBRG, NDBayerGRBG, NDBayerBGGR) defined in NDArray.h. If the input color mode and output color mode are not one of these supported conversion combinations then the output array is simply a copy of the input array and no conversion is performed.

## Configuration

The NDPluginColorConvert plugin is created with the following command, either from C/C++ or from the EPICS IOC shell.

    int drvNDColorConvertConfigure(const char *portName, int queueSize, int blockingCallbacks,
                                   const char *NDArrayPort, int NDArrayAddr,
                                   int maxBuffers, size_t maxMemory);

Argument | Description
--- | ---
`portName` | The name of the asyn port for this plugin.
`queueSize` | The maximum number of NDArray objects that can be queued for processing. Passed to the NDPluginDriver base class constructor.
`blockingCallbacks` | Flag controlling whether callbacks block. Passed to the NDPluginDriver base class constructor.
`NDArrayPort` | The name of the asyn port of the driver that will provide the NDArray data. Passed to the NDPluginDriver base class constructor.
`NDArrayAddr` | The asyn addr of the asyn port of the driver that will provide the NDArray data. Passed to the NDPluginDriver base class constructor.
`maxBuffers` | Maximum number of NDArray buffers to be created for plugin callbacks, i.e. for plugins that will be getting called from this plugin. Passed to the constructor for the NDPluginDriver base class.
`maxMemory` | Maximum number of bytes of memory to be allocated from the NDArrayPool. Passed to the constructor for the NDPluginDriver base class.

## Screen shots

The following is the MEDM screen that provides access to the parameters in NDPluginDriver.h and NDPluginColorConvert.h through records in NDPluginBase.template and NDColorConvert.template.

### NDColorConvert.adl

## Restrictions

- The Bayer color conversion is done using a library function provided in the Prosilica library. The source code for this function is not provided, and the binaries are only available on Linux and Windows.
- YUV color conversion is not supported. This may be added in a future release.