Removed the serialization from the EarIdentifier.

parent e077deba
...@@ -2,7 +2,7 @@ package com.aluxoft.earrecognition; ...@@ -2,7 +2,7 @@ package com.aluxoft.earrecognition;
import com.aluxoft.earrecognition.common.EarDatabase; import com.aluxoft.earrecognition.common.EarDatabase;
import com.aluxoft.earrecognition.common.EarFeature; import com.aluxoft.earrecognition.common.EarFeature;
import com.aluxoft.earrecognition.common.EarIdentifierResult; import com.aluxoft.earrecognition.common.EarIdList;
import com.aluxoft.earrecognition.utils.OpenCvUtils; import com.aluxoft.earrecognition.utils.OpenCvUtils;
import com.google.gson.Gson; import com.google.gson.Gson;
...@@ -34,12 +34,12 @@ public class EarIdentifier { ...@@ -34,12 +34,12 @@ public class EarIdentifier {
* @param feature The result of the identification. * @param feature The result of the identification.
* @return * @return
*/ */
public EarIdentifierResult identify(EarFeature feature) { public EarIdList identify(EarFeature feature) {
return null; return null;
} }
public String computeFeatures(String imagePath) { public EarFeature computeFeatures(String imagePath) {
Mat image, descriptors; Mat image, descriptors;
MatOfKeyPoint keypoints; MatOfKeyPoint keypoints;
...@@ -55,19 +55,10 @@ public class EarIdentifier { ...@@ -55,19 +55,10 @@ public class EarIdentifier {
detector.detect(image, keypoints); detector.detect(image, keypoints);
DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.SIFT); DescriptorExtractor extractor = DescriptorExtractor.create(DescriptorExtractor.SIFT);
extractor.compute(image, keypoints, descriptors); extractor.compute(image, keypoints, descriptors);
return new EarFeature(descriptors);
ArrayList<ArrayList<Integer>> features = new ArrayList<>();
for (int i=0;i<descriptors.rows();++i) {
ArrayList<Integer> feature = new ArrayList<>();
for (int j=0;j<descriptors.cols();++j) {
feature.add((int)descriptors.get(i, j)[0]);
}
features.add(feature);
}
Gson gson = new Gson();
return gson.toJson(features);
} }
static { static {
System.loadLibrary("opencv_java"); System.loadLibrary("opencv_java");
System.loadLibrary("nonfree"); System.loadLibrary("nonfree");
......
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