com.aspose.omr

Class OmrImage



  • public class OmrImage
    extends Object

    Represents an image in a way that is suitable for marks recognition.

    • Field Detail

      • BUFFER_PIXEL_FORMAT

        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 });
         

        See Also:
        Constant Field Values
      • BYTES_PER_PIXEL

        public static final int BYTES_PER_PIXEL

        Number of bytes per pixel

        See Also:
        Constant Field Values
    • Constructor Detail

      • OmrImage

        public OmrImage(int width,
                int height,
                double dpi,
                byte[] pixelData)

        Initializes a new instance of the OmrImage class.

        Parameters:
        width - The width, in pixels
        height - The height, in pixels.
        dpi - The resolution of the image, dots per inch.
        pixelData - The pixel data of the image.
    • Method Detail

      • getBuffer

        public byte[] getBuffer()

        Gets the pixel data of the OmrImage object.

      • getHeight

        public int getHeight()

        Gets the height, in pixels, of this OmrImage.

      • getResolution

        public double getResolution()

        Gets image DPI resolution


         
         OmrImage omrImage = OmrImage.load("Path to image");
         double resolution = omrImage.getResolution();
         

      • getWidth

        public int getWidth()

        Gets the width, in pixels, of this OmrImage.

      • isAutoDetectResolution

        public boolean isAutoDetectResolution()
        Gets a value indicating whether the engine should attempt to detect actual resolution of the image basing on dimensions of the template.
        Returns:
        true if autodetection is enabled; otherwise, false
      • load

        public static OmrImage load(InputStream stream)
                             throws IOException

        Loads an image from a stream.

        Parameters:
        stream - The stream to load from
        Returns:
        An instance of OmrImage that represents the image.


         
         InputStream inputStream = new FileInputStream(fileName);
         OmrImage image = OmrImage.load(stream);
         

        Throws:
        IOException
      • load

        public static OmrImage load(String fileName)
                             throws IOException

        Loads an image from the specified file name.

        Parameters:
        fileName - The file name.
        Returns:
        An instance of OmrImage that represents the image.


         
         Stream stream = File.openRead(fileName);
         OmrImage image = OmrImage.load(stream);
         

        Throws:
        IOException
      • loadFromUrl

        public static OmrImage loadFromUrl(String url)
                                    throws IOException
        Loads an image from URL.
        Parameters:
        url - The source URL.
        Returns:
        An instance of that represents the image.
        Throws:
        IOException
      • setAutoDetectResolution

        public 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.
        Parameters:
        autoDetectResolution - true if autodetection is enabled; otherwise, false
      • setResolution

        public void setResolution(double value)

        Sets image DPI resolution


         
         OmrImage omrImage = OmrImage.load("Path to image");
         omrImage.setResolution(newResolution);