public class OmrImage extends Object
Represents an image in a way that is suitable for marks recognition.
Modifier and Type | Field and Description |
---|---|
static int |
BUFFER_PIXEL_FORMAT
Pixel format of image data in the buffer
|
static int |
BYTES_PER_PIXEL
Number of bytes per pixel
|
Constructor and Description |
---|
OmrImage(int width,
int height,
double dpi,
byte[] pixelData)
Initializes a new instance of the
OmrImage class. |
Modifier and Type | Method and Description |
---|---|
BufferedImage |
asBitmap()
Copies pixel data into a
BufferedImage . |
OmrImage |
copy()
Creates a deep copy of the
OmrImage . |
byte[] |
getBuffer()
Gets the pixel data of the
OmrImage object. |
int |
getHeight()
Gets the height, in pixels, of this
OmrImage . |
double |
getResolution()
Gets image DPI resolution
|
int |
getWidth()
Gets the width, in pixels, of this
OmrImage . |
boolean |
isAutoDetectResolution()
Gets a value indicating whether the engine should attempt to detect actual resolution of
the image basing on dimensions of the template.
|
static OmrImage |
load(InputStream stream)
Loads an image from a stream.
|
static OmrImage |
load(String fileName)
Loads an image from the specified file name.
|
static OmrImage |
loadFromUrl(String url)
Loads an image from URL.
|
void |
setAutoDetectResolution(boolean autoDetectResolution)
Sets a value indicating whether the engine should attempt to detect actual resolution of
the image basing on dimensions of the template.
|
void |
setResolution(double value)
Sets image DPI resolution
|
public static final int BUFFER_PIXEL_FORMAT
Pixel format of image data in the buffer
OmrImage image = OmrImage.load("image.png"); // image path OmrTemplate template = OmrTemplate.load("template.amr"); // template path OmrEngine engine = new OmrEngine(template); OmrProcessingResult result = engine.extractData(new OmrImage[] { image });
public static final int BYTES_PER_PIXEL
Number of bytes per pixel
public OmrImage(int width, int height, double dpi, byte[] pixelData)
Initializes a new instance of the OmrImage
class.
width
- The width, in pixelsheight
- The height, in pixels.dpi
- The resolution of the image, dots per inch.pixelData
- The pixel data of the image.public BufferedImage asBitmap()
Copies pixel data into a BufferedImage
.
public OmrImage copy()
Creates a deep copy of the OmrImage
.
OmrImage
.public byte[] getBuffer()
Gets the pixel data of the OmrImage
object.
public int getHeight()
Gets the height, in pixels, of this OmrImage
.
public double getResolution()
Gets image DPI resolution
OmrImage omrImage = OmrImage.load("Path to image"); double resolution = omrImage.getResolution();
public int getWidth()
Gets the width, in pixels, of this OmrImage
.
public boolean isAutoDetectResolution()
public static OmrImage load(InputStream stream) throws IOException
Loads an image from a stream.
stream
- The stream to load fromOmrImage
that represents the image.
InputStream inputStream = new FileInputStream(fileName); OmrImage image = OmrImage.load(stream);
IOException
public static OmrImage load(String fileName) throws IOException
Loads an image from the specified file name.
fileName
- The file name.OmrImage
that represents the image.
Stream stream = File.openRead(fileName); OmrImage image = OmrImage.load(stream);
IOException
public static OmrImage loadFromUrl(String url) throws IOException
url
- The source URL.IOException
public void setAutoDetectResolution(boolean autoDetectResolution)
autoDetectResolution
- true if autodetection is enabled; otherwise, falsepublic void setResolution(double value)
Sets image DPI resolution
OmrImage omrImage = OmrImage.load("Path to image"); omrImage.setResolution(newResolution);
Copyright © 2017. All Rights Reserved.