Commit a5a758991de0036223c3f0d50e75815b9b85182e
1 parent
167eb072
Added other metrics
Showing
1 changed file
with
12 additions
and
1 deletions
openbr/plugins/distance/emd.cpp
| @@ -15,6 +15,17 @@ class EMDDistance : public UntrainableDistance | @@ -15,6 +15,17 @@ class EMDDistance : public UntrainableDistance | ||
| 15 | { | 15 | { |
| 16 | Q_OBJECT | 16 | Q_OBJECT |
| 17 | 17 | ||
| 18 | + Q_ENUMS(Metric) | ||
| 19 | + Q_PROPERTY(Metric metric READ get_metric WRITE set_metric RESET reset_metric STORED false) | ||
| 20 | + | ||
| 21 | +public: | ||
| 22 | + enum Metric { L1 = CV_DIST_L1, | ||
| 23 | + L2 = CV_DIST_L2, | ||
| 24 | + C = CV_DIST_C }; | ||
| 25 | + | ||
| 26 | +private: | ||
| 27 | + BR_PROPERTY(Metric, metric, L2) | ||
| 28 | + | ||
| 18 | float compare(const Template &a, const Template &b) const | 29 | float compare(const Template &a, const Template &b) const |
| 19 | { | 30 | { |
| 20 | const int dims_a = a.m().rows > 1 ? 3 : 2; | 31 | const int dims_a = a.m().rows > 1 ? 3 : 2; |
| @@ -39,7 +50,7 @@ class EMDDistance : public UntrainableDistance | @@ -39,7 +50,7 @@ class EMDDistance : public UntrainableDistance | ||
| 39 | } | 50 | } |
| 40 | } | 51 | } |
| 41 | 52 | ||
| 42 | - return EMD(sig_a,sig_b,CV_DIST_L2); | 53 | + return EMD(sig_a,sig_b,metric); |
| 43 | } | 54 | } |
| 44 | }; | 55 | }; |
| 45 | 56 |