Made the app more tolerant to inconsistencies on the feature data.

It ignores any data that seems wrong.
parent 0c7eff39
......@@ -68,7 +68,14 @@ public class EarFeature {
assert this._getFeatures().type() == feature2._getFeatures().type();
MatOfDMatch matches = new MatOfDMatch();
matcher.match(this._getFeatures(), feature2._getFeatures(), matches);
Mat features1 = this._getFeatures();
Mat features2 = feature2._getFeatures();
if (features1 == null || features2 == null) {
return Double.MAX_VALUE;
}
matcher.match(features1, features2, matches);
DMatch[] aMatches = matches.toArray();
double distance = 0;
......@@ -86,11 +93,18 @@ public class EarFeature {
features = gson.fromJson(featuresString, features.getClass());
Mat mFeatures = new Mat();
if (features == null || features.size() == 0) {
return null;
}
mFeatures.create(features.size(), kFeatureSize, CvType.CV_32F);
float buffer[] = new float[1];
for (int i=0;i<features.size();++i) {
ArrayList<Double> feature = features.get(i);
if (feature == null || feature.size() != kFeatureSize) {
return null;
}
for (int j=0;j<feature.size();++j) {
buffer[0] = feature.get(j).floatValue();
mFeatures.put(i, j, buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment