#ifndef NDPluginDynamicROI_H #define NDPluginDynamicROI_H #include #include "NDPluginDriver.h" typedef enum { profAverage, profThreshold, profCentroid, profCursor } NDStatProfileType; #define MAX_PROFILE_TYPES profCursor+1 typedef struct NDStats { size_t nElements; double centroidThreshold; double centroidTotal; double centroidX; double centroidY; double sigmaX; double sigmaY; double sigmaXY; double skewX; double skewY; double kurtosisX; double kurtosisY; double eccentricity; double orientation; double *profileX[MAX_PROFILE_TYPES]; double *profileY[MAX_PROFILE_TYPES]; size_t profileSizeX; size_t profileSizeY; size_t cursorX; size_t cursorY; } NDStats_t; /* Centroid */ #define NDPluginDynamicROIComputeCentroidString "COMPUTE_CENTROID" /* (asynInt32, r/w) Compute centroid? */ #define NDPluginDynamicROICentroidThresholdString "CENTROID_THRESHOLD" /* (asynFloat64, r/w) Threshold when computing centroids */ #define NDPluginDynamicROICentroidTotalString "CENTROID_TOTAL" /* (asynFloat64, r/o) Total centroid */ #define NDPluginDynamicROICentroidXString "CENTROIDX_VALUE" /* (asynFloat64, r/o) X centroid */ #define NDPluginDynamicROICentroidYString "CENTROIDY_VALUE" /* (asynFloat64, r/o) Y centroid */ #define NDPluginDynamicROISigmaXString "SIGMAX_VALUE" /* (asynFloat64, r/o) Sigma X */ #define NDPluginDynamicROISigmaYString "SIGMAY_VALUE" /* (asynFloat64, r/o) Sigma Y */ #define NDPluginDynamicROISigmaXYString "SIGMAXY_VALUE" /* (asynFloat64, r/o) Sigma XY */ /* Profiles*/ #define NDPluginDynamicROIComputeProfilesString "COMPUTE_PROFILES" /* (asynInt32, r/w) Compute profiles? */ #define NDPluginDynamicROIProfileSizeXString "PROFILE_SIZE_X" /* (asynInt32, r/o) X profile size */ #define NDPluginDynamicROIProfileSizeYString "PROFILE_SIZE_Y" /* (asynInt32, r/o) Y profile size */ #define NDPluginDynamicROICursorXString "CURSOR_X" /* (asynInt32, r/w) X cursor position */ #define NDPluginDynamicROICursorYString "CURSOR_Y" /* (asynInt32, r/w) Y cursor position */ #define NDPluginDynamicROIProfileAverageXString "PROFILE_AVERAGE_X" /* (asynFloat64Array, r/o) X average profile array */ #define NDPluginDynamicROIProfileAverageYString "PROFILE_AVERAGE_Y" /* (asynFloat64Array, r/o) Y average profile array */ #define NDPluginDynamicROIProfileThresholdXString "PROFILE_THRESHOLD_X" /* (asynFloat64Array, r/o) X average profile array after threshold */ #define NDPluginDynamicROIProfileThresholdYString "PROFILE_THRESHOLD_Y" /* (asynFloat64Array, r/o) Y average profile array after threshold */ #define NDPluginDynamicROIProfileCentroidXString "PROFILE_CENTROID_X" /* (asynFloat64Array, r/o) X centroid profile array */ #define NDPluginDynamicROIProfileCentroidYString "PROFILE_CENTROID_Y" /* (asynFloat64Array, r/o) Y centroid profile array */ #define NDPluginDynamicROIProfileCursorXString "PROFILE_CURSOR_X" /* (asynFloat64Array, r/o) X cursor profile array */ #define NDPluginDynamicROIProfileCursorYString "PROFILE_CURSOR_Y" /* (asynFloat64Array, r/o) Y cursor profile array */ /* Arrays of total and net counts for MCA or waveform record */ #define NDPluginDynamicROICallbackPeriodString "CALLBACK_PERIOD" /* (asynFloat64, r/w) Callback period */ /* ROI general parameters */ #define NDPluginDynamicROINameString "NAME" /* (asynOctet, r/w) Name of this ROI */ /* ROI definition */ #define NDPluginDynamicROIDim0MinString "DIM0_MIN" /* (asynInt32, r/w) Starting element of ROI in each dimension */ #define NDPluginDynamicROIDim1MinString "DIM1_MIN" /* (asynInt32, r/w) Starting element of ROI in each dimension */ #define NDPluginDynamicROIDim0SizeString "DIM0_SIZE" /* (asynInt32, r/w) Size of ROI in each dimension */ #define NDPluginDynamicROIDim1SizeString "DIM1_SIZE" /* (asynInt32, r/w) Size of ROI in each dimension */ #define NDPluginDynamicROIDim0MaxSizeString "DIM0_MAX_SIZE" /* (asynInt32, r/o) Maximum size of ROI in each dimension */ #define NDPluginDynamicROIDim1MaxSizeString "DIM1_MAX_SIZE" /* (asynInt32, r/o) Maximum size of ROI in each dimension */ #define NDPluginDynamicROIDataTypeString "ROI_DATA_TYPE" /* (asynInt32, r/w) Data type for ROI. -1 means automatic. */ #define NDPluginDynamicROIDim0EnableString "DIM0_ENABLE" /* (asynInt32, r/w) If set then do ROI in this dimension */ #define NDPluginDynamicROIDim1EnableString "DIM1_ENABLE" /* (asynInt32, r/w) If set then do ROI in this dimension */ #define NDPluginDynamicROIDim0BinString "DIM0_BIN" /* (asynInt32, r/w) Binning of ROI in each dimension */ #define NDPluginDynamicROIDim1BinString "DIM1_BIN" /* (asynInt32, r/w) Binning of ROI in each dimension */ /** Does image statistics. These include * X and Y centroid and sigma */ class epicsShareClass NDPluginDynamicROI : public NDPluginDriver { public: NDPluginDynamicROI(const char *portName, int queueSize, int blockingCallbacks, const char *NDArrayPort, int NDArrayAddr, int maxBuffers, size_t maxMemory, int priority, int stackSize, int maxThreads=1); /* These methods override the virtual methods in the base class */ void processCallbacks(NDArray *pArray); asynStatus writeInt32(asynUser *pasynUser, epicsInt32 value); asynStatus writeFloat64(asynUser *pasynUser, epicsFloat64 value); template asynStatus doComputeCentroidT(NDArray *pArray, NDStats_t *pStats); asynStatus doComputeCentroid(NDArray *pArray, NDStats_t *pStats); template asynStatus doComputeProfilesT(NDArray *pArray, NDStats_t *pStats); asynStatus doComputeProfiles(NDArray *pArray, NDStats_t *pStats); protected: int NDPluginDynamicROIComputeStatistics; #define FIRST_NDPLUGIN_STATS_PARAM NDPluginDynamicROIComputeStatistics /* Centroid */ int NDPluginDynamicROIComputeCentroid; int NDPluginDynamicROICentroidThreshold; int NDPluginDynamicROICentroidTotal; int NDPluginDynamicROICentroidX; int NDPluginDynamicROICentroidY; int NDPluginDynamicROISigmaX; int NDPluginDynamicROISigmaY; int NDPluginDynamicROISigmaXY; int NDPluginDynamicROISkewX; int NDPluginDynamicROISkewY; int NDPluginDynamicROIKurtosisX; int NDPluginDynamicROIKurtosisY; int NDPluginDynamicROIEccentricity; int NDPluginDynamicROIOrientation; /* Profiles */ int NDPluginDynamicROIComputeProfiles; int NDPluginDynamicROIProfileSizeX; int NDPluginDynamicROIProfileSizeY; int NDPluginDynamicROICursorX; int NDPluginDynamicROICursorY; int NDPluginDynamicROIProfileAverageX; int NDPluginDynamicROIProfileAverageY; int NDPluginDynamicROIProfileThresholdX; int NDPluginDynamicROIProfileThresholdY; int NDPluginDynamicROIProfileCentroidX; int NDPluginDynamicROIProfileCentroidY; int NDPluginDynamicROIProfileCursorX; int NDPluginDynamicROIProfileCursorY; /* ROI general parameters */ int NDPluginDynamicROIName; #define FIRST_NDPLUGIN_DynamicROI_PARAM NDPluginDynamicROIName /* ROI definition */ int NDPluginDynamicROIDim0Min; int NDPluginDynamicROIDim1Min; int NDPluginDynamicROIDim0Size; int NDPluginDynamicROIDim1Size; int NDPluginDynamicROIDim0MaxSize; int NDPluginDynamicROIDim1MaxSize; int NDPluginDynamicROIDataType; int NDPluginDynamicROIDim0Enable; int NDPluginDynamicROIDim1Enable; int NDPluginDynamicROIBin; int NDPluginDynamicROIDim2Bin; private: int requestedSize_[3]; int requestedOffset_[3]; }; #endif