### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- shape. Shape Distance and Matching »

# Cost Matrix for Histograms Common Interface

A common interface is defined to ease the implementation of some algorithms pipelines, such as the Shape Context Matching Algorithm. A common class is defined, so any object that implements a Cost Matrix builder inherits the `HistogramCostExtractor` interface.

## HistogramCostExtractor

class `HistogramCostExtractor` : public `Algorithm`

Abstract base class for histogram cost algorithms.

    class CV_EXPORTS_W HistogramCostExtractor : public Algorithm
    {
    public:
        CV_WRAP virtual void buildCostMatrix(InputArray descriptors1, InputArray descriptors2, OutputArray costMatrix) = 0;

        CV_WRAP virtual void setNDummies(int nDummies) = 0;
        CV_WRAP virtual int getNDummies() const = 0;

        CV_WRAP virtual void setDefaultCost(float defaultCost) = 0;
        CV_WRAP virtual float getDefaultCost() const = 0;
    };

## NormHistogramCostExtractor

class `NormHistogramCostExtractor` : public `HistogramCostExtractor`

A norm based cost extraction.

    class CV_EXPORTS_W NormHistogramCostExtractor : public HistogramCostExtractor
    {
    public:
        CV_WRAP virtual void setNormFlag(int flag) = 0;
        CV_WRAP virtual int getNormFlag() const = 0;
    };

    CV_EXPORTS_W Ptr<HistogramCostExtractor>
        createNormHistogramCostExtractor(int flag=cv::DIST_L2, int nDummies=25, float defaultCost=0.2);

## EMDHistogramCostExtractor

class `EMDHistogramCostExtractor` : public `HistogramCostExtractor`

An EMD based cost extraction.

    class CV_EXPORTS_W EMDHistogramCostExtractor : public HistogramCostExtractor
    {
    public:
        CV_WRAP virtual void setNormFlag(int flag) = 0;
        CV_WRAP virtual int getNormFlag() const = 0;
    };

    CV_EXPORTS_W Ptr<HistogramCostExtractor>
        createEMDHistogramCostExtractor(int flag=cv::DIST_L2, int nDummies=25, float defaultCost=0.2);

## ChiHistogramCostExtractor

class `ChiHistogramCostExtractor` : public `HistogramCostExtractor`

An Chi based cost extraction.

    class CV_EXPORTS_W ChiHistogramCostExtractor : public HistogramCostExtractor
    {};

    CV_EXPORTS_W Ptr<HistogramCostExtractor> createChiHistogramCostExtractor(int nDummies=25, float defaultCost=0.2);

## EMDL1HistogramCostExtractor

class `EMDL1HistogramCostExtractor` : public `HistogramCostExtractor`

An EMD-L1 based cost extraction.

    class CV_EXPORTS_W EMDL1HistogramCostExtractor : public HistogramCostExtractor
    {};

    CV_EXPORTS_W Ptr<HistogramCostExtractor>
        createEMDL1HistogramCostExtractor(int nDummies=25, float defaultCost=0.2);

## Help and Feedback

You did not find what you were looking for?

- Ask a question on the Q&A forum.
- If you think something is missing or wrong in the documentation, please file a bug report.

### Navigation

- index
- next |
- previous |
- OpenCV 3.0.0-dev documentation »
- OpenCV API Reference »
- shape. Shape Distance and Matching »