- java.lang.Object
-
- com.uddernetworks.newocr.character.Character
-
- com.uddernetworks.newocr.character.CoordinateCharacter
-
- com.uddernetworks.newocr.character.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.
-
Method Summary
Modifier and Type Method Description voidcopyProperties(ImageLetter imageLetter)Copies the properties from the givenImageLetterto the current one.booleanequals(java.lang.Object obj)doublegetAverageHeight()Gets the average height of this character's trained data.doublegetAverageWidth()Gets the average width of this character's trained data.java.util.List<it.unimi.dsi.fastutil.objects.Object2DoubleMap.Entry<ImageLetter>>getClosestMatches()java.util.Optional<java.lang.Object>getData()Gets the raw data Object set to theImageLetterobject, useful for storing any needed data about the character to be used in the future.<T> java.util.Optional<T>getData(java.lang.Class<T> clazz)Gets any data set to theImageLetterobject, useful for storing any needed data about the character to be used in the future.doublegetMaxCenter()Gets the maximum relative center value from the top of the character found in the training set for this font size.doublegetMinCenter()Gets the minimum relative center value from the top of the character found in the training set for this font size.doublegetRatio()Gets the width/height ratio of this character.inthashCode()voidsetAverageHeight(double averageHeight)Sets the average height of this character's trained data.voidsetAverageWidth(double averageWidth)Sets the average width of this character's trained data.voidsetClosestMatches(java.util.List<it.unimi.dsi.fastutil.objects.Object2DoubleMap.Entry<ImageLetter>> closestMatches)voidsetData(java.lang.Object data)Sets any data to theImageLetterobject, useful for storing any needed data about the character to be used in the future.voidsetMaxCenter(double maxCenter)Sets the maximum relative center value from the top of the character found in the training set for this font size.voidsetMinCenter(double minCenter)Sets the minimum relative center value from the top of the character found in the training set for this font size.voidsetNextClosest()voidsetRatio(double ratio)Sets the width/height ratio of this character.java.lang.StringtoString()-
Methods inherited from class com.uddernetworks.newocr.character.CoordinateCharacter
getAmountOfMerges, getCoordinates, getMergedPieces, getValues, merge, setValues
-
Methods inherited from class com.uddernetworks.newocr.character.Character
compareTo, getHeight, getLetter, getModifier, getWidth, getX, getY, isInBounds, isInXBounds, isInYBounds, isOverlappingX, isOverlappingY, setHeight, setLetter, setModifier, setWidth, setX, setY
-
-
-
-
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 valuemodifier- The modifier of the letterx- The X coordinate of this charactery- The Y coordinate of this characterwidth- The width of this characterheight- The height of this characteraverageWidth- The average width of the characteraverageHeight- The average height of the characterratio- 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 valuemodifier- The modifier of the letterx- The X coordinate of this charactery- The Y coordinate of this characterwidth- The width of this characterheight- The height of this characteraverageWidth- The average width of the characteraverageHeight- The average height of the characterratio- The width/height ratio of this charactercoordinates- 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 theImageLetterobject, 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 theImageLetterobject, 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 theImageLetterobject, 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 givenImageLetterto the current one.- Parameters:
imageLetter- TheImageLetterto copy data from
-
hashCode
public int hashCode()
- Overrides:
hashCodein classCoordinateCharacter
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classCoordinateCharacter
-
-