Package ai.djl.modality.cv
Class ImageFactory
- java.lang.Object
-
- ai.djl.modality.cv.ImageFactory
-
- Direct Known Subclasses:
BufferedImageFactory
public abstract class ImageFactory extends java.lang.Object
ImageFactory
contains image creation mechanism on top of different platforms like PC and Android. System will choose appropriate Factory based on the supported image type.
-
-
Constructor Summary
Constructors Constructor Description ImageFactory()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description abstract Image
fromFile(java.nio.file.Path path)
GetsImage
from file.abstract Image
fromImage(java.lang.Object image)
GetsImage
from varies Java image types.abstract Image
fromInputStream(java.io.InputStream is)
GetsImage
fromInputStream
.abstract Image
fromNDArray(NDArray array)
abstract Image
fromPixels(int[] pixels, int width, int height)
GetsImage
from array.Image
fromUrl(java.lang.String url)
GetsImage
from URL.Image
fromUrl(java.net.URL url)
GetsImage
from URL.static ImageFactory
getInstance()
Gets new instance of Image factory from the provided factory implementation.static void
setImageFactory(ImageFactory factory)
Sets a custom instance ofImageFactory
.
-
-
-
Method Detail
-
getInstance
public static ImageFactory getInstance()
Gets new instance of Image factory from the provided factory implementation.- Returns:
ImageFactory
-
setImageFactory
public static void setImageFactory(ImageFactory factory)
Sets a custom instance ofImageFactory
.- Parameters:
factory
- a custom instance ofImageFactory
-
fromFile
public abstract Image fromFile(java.nio.file.Path path) throws java.io.IOException
GetsImage
from file.- Parameters:
path
- the path to the image- Returns:
Image
- Throws:
java.io.IOException
- Image not found or not readable
-
fromUrl
public Image fromUrl(java.net.URL url) throws java.io.IOException
GetsImage
from URL.- Parameters:
url
- the URL to load from- Returns:
Image
- Throws:
java.io.IOException
- URL is not valid.
-
fromUrl
public Image fromUrl(java.lang.String url) throws java.io.IOException
GetsImage
from URL.- Parameters:
url
- the String represent URL to load from- Returns:
Image
- Throws:
java.io.IOException
- URL is not valid.
-
fromInputStream
public abstract Image fromInputStream(java.io.InputStream is) throws java.io.IOException
GetsImage
fromInputStream
.- Parameters:
is
-InputStream
- Returns:
Image
- Throws:
java.io.IOException
- image cannot be read from input stream.
-
fromImage
public abstract Image fromImage(java.lang.Object image)
GetsImage
from varies Java image types.Image can be BufferedImage or BitMap depends on platform
- Parameters:
image
- the image object.- Returns:
Image
-
fromNDArray
public abstract Image fromNDArray(NDArray array)
- Parameters:
array
- the NDArray with CHW format- Returns:
Image
-
-