TensorImage class

TensorImage is the wrapper class for Image object. When using image processing utils in Flutter Helper library, it's common to convert image objects in variant types to TensorImage at first.

IMPORTANT: Image always refers to Image from 'package:image/image.dart' and not those from 'dart:ui' or 'package:flutter/widgets.dart.

At present, only RGB images are supported, and the A channel is always ignored.

Details of data storage: a TensorImage object may have 2 potential sources of truth: a Image or a TensorBuffer. TensorImage maintains the state and only convert one to the other when needed.

IMPORTANT: The container doesn't own its data. Callers should not modify data objects those are passed to BaseImageContainer.bufferImage or BaseImageContainer.tensorBuffer.

See ImageProcessor which is often used for transforming a TensorImage.

Constructors

TensorImage([TfLiteType dataType = TfLiteType.uint8])
Initialize a TensorImage object.

Properties

buffer ByteBuffer
Returns a ByteBuffer representation of this TensorImage.
no setter
dataType → TfLiteType
Gets the current data type.
no setter
hashCode int
The hash code for this object.
no setterinherited
height int
Gets the image height.
no setter
image → Image
Returns the underlying Image representation of this TensorImage.
no setter
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
tensorBuffer TensorBuffer
Returns the underlying TensorBuffer representation for this TensorImage
no setter
tfLiteType → TfLiteType
Gets the current data type.
no setter
width int
Gets the image width.
no setter

Methods

getBuffer() ByteBuffer
Returns a ByteBuffer representation of this TensorImage.
getDataType() → TfLiteType
Gets the current data type.
getHeight() int
Gets the image height.
getTensorBuffer() TensorBuffer
Returns the underlying TensorBuffer representation for this TensorImage
getWidth() int
Gets the image width.
load(TensorBuffer buffer, ColorSpaceType colorSpaceType) → void
loadImage(Image image) → void
Load Image to this TensorImage
loadRgbPixels(List pixels, List<int> shape) → void
Load a list of RGB pixels into this TensorImage
loadTensorBuffer(TensorBuffer buffer) → void
Loads a TensorBuffer containing pixel values. The color layout should be RGB.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

fromFile(File imageFile) TensorImage
Initialize TensorImage from File
fromImage(Image image) TensorImage
Initialize TensorImage from Image
fromTensorBuffer(TensorBuffer buffer) TensorImage
Initialize TensorImage from TensorBuffer