ImageProcessor is a helper class for preprocessing and postprocessing TensorImage. It
could transform a TensorImage to another by executing a chain of ImageOperator.
Example Usage:
ImageProcessor processor = new ImageProcessor.Builder()
.add(new ResizeOp(224, 224, ResizeMethod.NEAREST_NEIGHBOR)
.add(new Rot90Op())
.add(new NormalizeOp(127.5f, 127.5f))
.build();
TensorImage anotherTensorImage = processor.process(tensorImage);
WARNING: Instances of an ImageProcessor are not thread-safe with updateNumberOfRotations(int). Updating the number of rotations and then processing images (using
SequentialProcessor.process(T)) must be protected from concurrent access. It is recommended to create separate
ImageProcessor instances for each thread. If multiple threads access a ImageProcessor concurrently, it must be synchronized externally.
| class | ImageProcessor.Builder | The Builder to create an ImageProcessor, which could be executed later. | |
| RectF |
inverseTransform(RectF rect, int inputImageHeight, int inputImageWidth)
Transforms a rectangle from coordinates system of the result image back to the one of the input
image.
|
| PointF |
inverseTransform(PointF point, int inputImageHeight, int inputImageWidth)
Transforms a point from coordinates system of the result image back to the one of the input
image.
|
| TensorImage | |
| void |
updateNumberOfRotations(int k)
Updates the number of rotations for the first
Rot90Op in this ImageProcessor. |
| synchronized void |
updateNumberOfRotations(int k, int occurrence)
|
Transforms a rectangle from coordinates system of the result image back to the one of the input image.
| rect | the rectangle from the result coordinates system. |
|---|---|
| inputImageHeight | the height of input image. |
| inputImageWidth | the width of input image. |
Transforms a point from coordinates system of the result image back to the one of the input image.
| point | the point from the result coordinates system. |
|---|---|
| inputImageHeight | the height of input image. |
| inputImageWidth | the width of input image. |
Processes a TensorImage object with prepared TensorOperator.
| image |
|---|
| IllegalArgumentException | if the image is not supported by any op. |
|---|
Updates the number of rotations for the first Rot90Op in this ImageProcessor.
WARNING:this method is not thread-safe. Updating the number of rotations and
then processing images (using SequentialProcessor.process(T)) must be protected from concurrent access with
additional synchronization.
| k | the number of rotations |
|---|
| IllegalStateException | if Rot90Op has not been added to this ImageProcessor
|
|---|
Updates the number of rotations for the Rot90Op specified by occurrence in this
ImageProcessor.
WARNING:this method is not thread-safe. Updating the number of rotations and
then processing images (using SequentialProcessor.process(T)) must be protected from concurrent access with
additional synchronization.
| k | the number of rotations |
|---|---|
| occurrence | the index of perticular Rot90Op in this ImageProcessor. For
example, if the second Rot90Op needs to be updated, occurrence should be
set to 1. |
| IndexOutOfBoundsException | if occurrence is negative or is not less than the
number of Rot90Op in this ImageProcessor |
|---|---|
| IllegalStateException | if Rot90Op has not been added to this ImageProcessor
|