diff options
author | Manjunath Kudlur <keveman@gmail.com> | 2015-11-06 16:27:58 -0800 |
---|---|---|
committer | Manjunath Kudlur <keveman@gmail.com> | 2015-11-06 16:27:58 -0800 |
commit | f41959ccb2d9d4c722fe8fc3351401d53bcf4900 (patch) | |
tree | ef0ca22cb2a5ac4bdec9d080d8e0788a53ed496d /tensorflow/examples/android/src/org/tensorflow/demo/Classifier.java |
TensorFlow: Initial commit of TensorFlow library.
TensorFlow is an open source software library for numerical computation
using data flow graphs.
Base CL: 107276108
Diffstat (limited to 'tensorflow/examples/android/src/org/tensorflow/demo/Classifier.java')
-rw-r--r-- | tensorflow/examples/android/src/org/tensorflow/demo/Classifier.java | 87 |
1 files changed, 87 insertions, 0 deletions
diff --git a/tensorflow/examples/android/src/org/tensorflow/demo/Classifier.java b/tensorflow/examples/android/src/org/tensorflow/demo/Classifier.java new file mode 100644 index 0000000000..60b3037c7d --- /dev/null +++ b/tensorflow/examples/android/src/org/tensorflow/demo/Classifier.java @@ -0,0 +1,87 @@ +package org.tensorflow.demo; + +import android.graphics.Bitmap; +import android.graphics.RectF; + +import java.util.List; + +/** + * Generic interface for interacting with different recognition engines. + */ +public interface Classifier { + /** + * An immutable result returned by a Classifier describing what was recognized. + */ + public class Recognition { + /** + * A unique identifier for what has been recognized. Specific to the class, not the instance of + * the object. + */ + private final String id; + + /** + * Display name for the recognition. + */ + private final String title; + + /** + * A sortable score for how good the recognition is relative to others. Higher should be better. + */ + private final Float confidence; + + /** + * Optional location within the source image for the location of the recognized object. + */ + private final RectF location; + + public Recognition( + final String id, final String title, final Float confidence, final RectF location) { + this.id = id; + this.title = title; + this.confidence = confidence; + this.location = location; + } + + public String getId() { + return id; + } + + public String getTitle() { + return title; + } + + public Float getConfidence() { + return confidence; + } + + public RectF getLocation() { + return new RectF(location); + } + + @Override + public String toString() { + String resultString = ""; + if (id != null) { + resultString += "[" + id + "] "; + } + + if (title != null) { + resultString += title + " "; + } + + if (confidence != null) { + resultString += String.format("(%.1f%%) ", confidence * 100.0f); + } + + if (location != null) { + resultString += location + " "; + } + + return resultString.trim(); + } + } + + List<Recognition> recognizeImage(Bitmap bitmap); + + void close(); +} |