Module NewOCR

Class ImageLetter

  • All Implemented Interfaces:
    java.lang.Comparable<Character>

    public class ImageLetter
    extends CoordinateCharacter
    An object to contain data from characters directly scanned from an image.
    Since:
    April 25, 2019
    • Constructor Summary

      Constructors 
      Constructor Description
      ImageLetter​(char letter, int modifier, int x, int y, int width, int height, double averageWidth, double averageHeight, double ratio)
      Creates an ImageLetter from collected data.
      ImageLetter​(char letter, int modifier, int x, int y, int width, int height, double averageWidth, double averageHeight, double ratio, java.util.List<IntPair> coordinates)
      Creates an ImageLetter from collected data.
    • Constructor Detail

      • ImageLetter

        public ImageLetter​(char letter,
                           int modifier,
                           int x,
                           int y,
                           int width,
                           int height,
                           double averageWidth,
                           double averageHeight,
                           double ratio)
        Creates an ImageLetter from collected data.
        Parameters:
        letter - The letter value
        modifier - The modifier of the letter
        x - The X coordinate of this character
        y - The Y coordinate of this character
        width - The width of this character
        height - The height of this character
        averageWidth - The average width of the character
        averageHeight - The average height of the character
        ratio - The width/height ratio of this character
      • ImageLetter

        public ImageLetter​(char letter,
                           int modifier,
                           int x,
                           int y,
                           int width,
                           int height,
                           double averageWidth,
                           double averageHeight,
                           double ratio,
                           java.util.List<IntPair> coordinates)
        Creates an ImageLetter from collected data.
        Parameters:
        letter - The letter value
        modifier - The modifier of the letter
        x - The X coordinate of this character
        y - The Y coordinate of this character
        width - The width of this character
        height - The height of this character
        averageWidth - The average width of the character
        averageHeight - The average height of the character
        ratio - The width/height ratio of this character
        coordinates - The data coordinates of this character (In form of [Black, Total])
    • Method Detail

      • getAverageWidth

        public double getAverageWidth()
        Gets the average width of this character's trained data.
        Returns:
        The average width of the character
      • setAverageWidth

        public void setAverageWidth​(double averageWidth)
        Sets the average width of this character's trained data.
        Parameters:
        averageWidth - The average width of the character
      • getAverageHeight

        public double getAverageHeight()
        Gets the average height of this character's trained data.
        Returns:
        The average height of the character
      • setAverageHeight

        public void setAverageHeight​(double averageHeight)
        Sets the average height of this character's trained data.
        Parameters:
        averageHeight - The average height of the character
      • getRatio

        public double getRatio()
        Gets the width/height ratio of this character.
        Returns:
        The width/height ratio of this character
      • setRatio

        public void setRatio​(double ratio)
        Sets the width/height ratio of this character.
        Parameters:
        ratio - The width/height ratio of this character
      • getData

        public <T> java.util.Optional<T> getData​(java.lang.Class<T> clazz)
        Gets any data set to the ImageLetter object, useful for storing any needed data about the character to be used in the future.
        Type Parameters:
        T - The type of the data
        Parameters:
        clazz - The class type of the data, only used for getting the returning type
        Returns:
        Data set to the character
      • getData

        public java.util.Optional<java.lang.Object> getData()
        Gets the raw data Object set to the ImageLetter object, useful for storing any needed data about the character to be used in the future.
        Returns:
        Data set to the character
      • setData

        public void setData​(java.lang.Object data)
        Sets any data to the ImageLetter object, useful for storing any needed data about the character to be used in the future.
        Parameters:
        data - The data to be set
      • getMinCenter

        public double getMinCenter()
        Gets the minimum relative center value from the top of the character found in the training set for this font size.
        Returns:
        The minimum relative center value from the top of the character found in the training set for this font size
      • setMinCenter

        public void setMinCenter​(double minCenter)
        Sets the minimum relative center value from the top of the character found in the training set for this font size.
        Parameters:
        minCenter - The minimum relative center value from the top of the character found in the training set for this font size
      • getMaxCenter

        public double getMaxCenter()
        Gets the maximum relative center value from the top of the character found in the training set for this font size.
        Returns:
        The maximum relative center value from the top of the character found in the training set for this font size
      • setMaxCenter

        public void setMaxCenter​(double maxCenter)
        Sets the maximum relative center value from the top of the character found in the training set for this font size.
        Parameters:
        maxCenter - The maximum relative center value from the top of the character found in the training set for this font size
      • getClosestMatches

        public java.util.List<it.unimi.dsi.fastutil.objects.Object2DoubleMap.Entry<ImageLetter>> getClosestMatches()
      • setClosestMatches

        public void setClosestMatches​(java.util.List<it.unimi.dsi.fastutil.objects.Object2DoubleMap.Entry<ImageLetter>> closestMatches)
      • setNextClosest

        public void setNextClosest()
      • copyProperties

        public void copyProperties​(ImageLetter imageLetter)
        Copies the properties from the given ImageLetter to the current one.
        Parameters:
        imageLetter - The ImageLetter to copy data from
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class Character