3131 * <p>At present, only RGB images are supported, and the A channel is always ignored.
3232 *
3333 * <p>Details of data storage: a {@link TensorImage} object may have 2 potential sources of truth: a
34- * {@link Bitmap} or a {@link TensorBuffer}. {@link TensorImage} maintains the state and only
35- * converts one to the other when needed. A typical use case of {@link TensorImage} is to first load
36- * a {@link Bitmap} image, then process it using {@link ImageProcessor}, and finally get the
37- * underlying {@link ByteBuffer} of the {@link TensorBuffer} and feed it into the TFLite
38- * interpreter.
34+ * {@link android.graphics. Bitmap} or a {@link TensorBuffer}. {@link TensorImage} maintains the
35+ * state and only converts one to the other when needed. A typical use case of {@link TensorImage}
36+ * is to first load a {@link android.graphics. Bitmap} image, then process it using {@link
37+ * ImageProcessor}, and finally get the underlying {@link ByteBuffer} of the {@link TensorBuffer}
38+ * and feed it into the TFLite interpreter.
3939 *
4040 * <p>IMPORTANT: to achieve the best performance, {@link TensorImage} avoids copying data whenever
4141 * it's possible. Therefore, it doesn't own its data. Callers should not modify data objects those
42- * are passed to {@link TensorImage#load(Bitmap)} or {@link TensorImage#load(TensorBuffer)}.
42+ * are passed to {@link TensorImage#load(Bitmap)} or {@link TensorImage#load(TensorBuffer,
43+ * ColorSpaceType)}.
4344 *
4445 * <p>IMPORTANT: all methods are not proved thread-safe.
4546 *
@@ -87,10 +88,11 @@ public TensorImage(DataType dataType) {
8788 }
8889
8990 /**
90- * Initializes a {@link TensorImage} object of {@link DataType#UINT8} with a {@link Bitmap} .
91+ * Initializes a {@link TensorImage} object of {@link DataType#UINT8} with a {@link
92+ * android.graphics.Bitmap} .
9193 *
92- * @see TensorImage #load(Bitmap) for reusing the object when it's expensive to create objects
93- * frequently, because every call of {@code fromBitmap} creates a new {@link TensorImage}.
94+ * @see #load(Bitmap) for reusing the object when it's expensive to create objects frequently,
95+ * because every call of {@code fromBitmap} creates a new {@link TensorImage}.
9496 */
9597 public static TensorImage fromBitmap (Bitmap bitmap ) {
9698 TensorImage image = new TensorImage ();
@@ -113,11 +115,12 @@ public static TensorImage createFrom(TensorImage src, DataType dataType) {
113115 }
114116
115117 /**
116- * Loads a {@link Bitmap} image object into this {@link TensorImage}.
118+ * Loads a {@link android.graphics. Bitmap} image object into this {@link TensorImage}.
117119 *
118120 * <p>Note: if the {@link TensorImage} has data type other than {@link DataType#UINT8}, numeric
119121 * casting and clamping will be applied when calling {@link #getTensorBuffer} and {@link
120- * #getBuffer}, where the {@link Bitmap} will be converted into a {@link TensorBuffer}.
122+ * #getBuffer}, where the {@link android.graphics.Bitmap} will be converted into a {@link
123+ * TensorBuffer}.
121124 *
122125 * <p>Important: when loading a bitmap, DO NOT MODIFY the bitmap from the caller side anymore. The
123126 * {@link TensorImage} object will rely on the bitmap. It will probably modify the bitmap as well.
@@ -183,9 +186,9 @@ public void load(TensorBuffer buffer) {
183186 }
184187
185188 /**
186- * Loads a {@link TensorBuffer} containing pixel values with the specific {@link ColorSapceType }.
189+ * Loads a {@link TensorBuffer} containing pixel values with the specific {@link ColorSpaceType }.
187190 *
188- * <p>Only supports {@link ColorSapceType #RGB} and {@link ColorSpaceType#GRAYSCALE}. Use {@link
191+ * <p>Only supports {@link ColorSpaceType #RGB} and {@link ColorSpaceType#GRAYSCALE}. Use {@link
189192 * #load(TensorBuffer, ImageProperties)} for other color space types.
190193 *
191194 * <p>Note: if the data type of {@code buffer} does not match that of this {@link TensorImage},
@@ -196,7 +199,6 @@ public void load(TensorBuffer buffer) {
196199 * (1, h, w, 3) for RGB images, and either (h, w) or (1, h, w) for GRAYSCALE images
197200 * @throws IllegalArgumentException if the shape of buffer does not match the color space type, or
198201 * if the color space type is not supported
199- * @see ColorSpaceType#assertShape
200202 */
201203 public void load (TensorBuffer buffer , ColorSpaceType colorSpaceType ) {
202204 checkArgument (
@@ -241,22 +243,23 @@ public void load(ByteBuffer buffer, ImageProperties imageProperties) {
241243 }
242244
243245 /**
244- * Loads an {@link Image} object into this {@link TensorImage}.
246+ * Loads an {@link android.media. Image} object into this {@link TensorImage}.
245247 *
246- * <p>The main usage of this method is to load an {@link Image} object as model input to the <a
247- * href="TFLite Task
248+ * <p>The main usage of this method is to load an {@link android.media. Image} object as model
249+ * input to the <a href="TFLite Task
248250 * Library">https://www.tensorflow.org/lite/inference_with_metadata/task_library/overview</a>.
249- * {@link TensorImage} backed by {@link Image} is not supported by {#link ImageProcessor}.
251+ * {@link TensorImage} backed by {@link android.media.Image} is not supported by {#link
252+ * ImageProcessor}.
250253 *
251- * <p>* @throws IllegalArgumentException if the {@link ImageFormat} of {@code image} is not
252- * YUV_420_888
254+ * <p>* @throws IllegalArgumentException if the {@link android.graphics. ImageFormat} of {@code
255+ * image} is not YUV_420_888
253256 */
254257 public void load (Image image ) {
255258 container = MediaImageContainer .create (image );
256259 }
257260
258261 /**
259- * Returns a {@link Bitmap} representation of this {@link TensorImage}.
262+ * Returns a {@link android.graphics. Bitmap} representation of this {@link TensorImage}.
260263 *
261264 * <p>Numeric casting and clamping will be applied if the stored data is not uint8.
262265 *
@@ -266,9 +269,9 @@ public void load(Image image) {
266269 * <p>Important: it's only a reference. DO NOT MODIFY. We don't create a copy here for performance
267270 * concern, but if modification is necessary, please make a copy.
268271 *
269- * @return a reference to a {@link Bitmap} in {@code ARGB_8888} config ("A" channel is always
270- * opaque) or in {@code ALPHA_8}, depending on the {@link ColorSpaceType} of this {@link
271- * TensorBuffer}.
272+ * @return a reference to a {@link android.graphics. Bitmap} in {@code ARGB_8888} config ("A"
273+ * channel is always opaque) or in {@code ALPHA_8}, depending on the {@link ColorSpaceType} of
274+ * this {@link TensorBuffer}.
272275 * @throws IllegalStateException if the {@link TensorImage} never loads data
273276 */
274277 public Bitmap getBitmap () {
@@ -320,17 +323,18 @@ public TensorBuffer getTensorBuffer() {
320323 }
321324
322325 /**
323- * Returns an {@link Image} representation of this {@link TensorImage}.
326+ * Returns an {@link android.media. Image} representation of this {@link TensorImage}.
324327 *
325- * <p>This method only works when the {@link TensorImage} is backed by an {@link Image}, meaning
326- * you need to first load an {@link Image} through {@link TensorImage#load(Image)}.
328+ * <p>This method only works when the {@link TensorImage} is backed by an {@link
329+ * android.media.Image}, meaning you need to first load an {@link android.media.Image} through
330+ * {@link #load(Image)}.
327331 *
328332 * <p>Important: it's only a reference. DO NOT MODIFY. We don't create a copy here for performance
329333 * concern, but if modification is necessary, please make a copy.
330334 *
331- * @return a reference to a {@link Bitmap} in {@code ARGB_8888} config ("A" channel is always
332- * opaque) or in {@code ALPHA_8}, depending on the {@link ColorSpaceType} of this {@link
333- * TensorBuffer}.
335+ * @return a reference to a {@link android.graphics. Bitmap} in {@code ARGB_8888} config ("A"
336+ * channel is always opaque) or in {@code ALPHA_8}, depending on the {@link ColorSpaceType} of
337+ * this {@link TensorBuffer}.
334338 * @throws IllegalStateException if the {@link TensorImage} never loads data
335339 */
336340 public Image getMediaImage () {
0 commit comments