- java.lang.Object
-
- com.uddernetworks.newocr.character.Character
-
- com.uddernetworks.newocr.character.CoordinateCharacter
-
- com.uddernetworks.newocr.character.SearchCharacter
-
- All Implemented Interfaces:
java.lang.Comparable<Character>
public class SearchCharacter extends CoordinateCharacter
An object meant to store characters directly scanned from an image and that is being searched for/mutated.- Since:
- April 25, 2019
-
-
Constructor Summary
Constructors Constructor Description SearchCharacter(java.util.List<IntPair> coordinates)Creates a SearchCharacter from a list of coordinates used by the character.SearchCharacter(java.util.List<IntPair> coordinates, int xOffset, int yOffset)Creates a SearchCharacter from a list of coordinates used by the character.
-
Method Summary
Modifier and Type Method Description voidaddSegment(IntPair entry)Adds a data segment to be calculated in the future.voidanalyzeSlices()Performs calculations for the sections added byaddSegment(IntPair), getting their <= 1 percentages accessible fromgetSegmentPercentages().voidapplySections()Creates sections and invokesaddSegment(IntPair)for each one.booleanequals(java.lang.Object obj)doublegetCenterOffset()Gets the amount away a character is from the center of the line.double[]getSegmentPercentages()Gets the raw segment percentages all <= 1.java.util.List<IntPair>getSegments()Gets the raw segments added viaaddSegment(IntPair)where the Entry format is [total black, size of segment].java.util.OptionalDoublegetTrainingMeta(java.lang.String name)Gets the training meta with the given name.inthashCode()voidsetCenterOffset(double centerOffset)Sets the amount away a character is from the center of the line.voidsetTrainingMeta(java.lang.String name, double data)Sets the training data with a given name.-
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, toString
-
-
-
-
Constructor Detail
-
SearchCharacter
public SearchCharacter(java.util.List<IntPair> coordinates)
Creates a SearchCharacter from a list of coordinates used by the character.- Parameters:
coordinates- Coordinates used by the character
-
SearchCharacter
public SearchCharacter(java.util.List<IntPair> coordinates, int xOffset, int yOffset)
Creates a SearchCharacter from a list of coordinates used by the character.- Parameters:
coordinates- Coordinates used by the characterxOffset- The X offset of the coordinatesyOffset- The Y offset of the coordinates
-
-
Method Detail
-
applySections
public void applySections()
Creates sections and invokesaddSegment(IntPair)for each one. This is vital for the use of this object.
-
analyzeSlices
public void analyzeSlices()
Performs calculations for the sections added byaddSegment(IntPair), getting their <= 1 percentages accessible fromgetSegmentPercentages(). This must be invoked afterapplySections().
-
addSegment
public void addSegment(IntPair entry)
Adds a data segment to be calculated in the future. The segments may be fetched viagetSegments().- Parameters:
entry- The data segment in the format of [total black, size of segment]
-
getSegments
public java.util.List<IntPair> getSegments()
Gets the raw segments added viaaddSegment(IntPair)where the Entry format is [total black, size of segment].- Returns:
- The raw segments
-
getSegmentPercentages
public double[] getSegmentPercentages()
Gets the raw segment percentages all <= 1. This will return an empty array untilapplySections()andanalyzeSlices()have been invoked.- Returns:
- The raw array of segment percentages with a length of 17
-
getTrainingMeta
public java.util.OptionalDouble getTrainingMeta(java.lang.String name)
Gets the training meta with the given name. This contains data such as separation of the dots of an i, data on the holes of a %, etc.- Parameters:
name- The name of the training data- Returns:
- The value of the training data
-
setTrainingMeta
public void setTrainingMeta(java.lang.String name, double data)Sets the training data with a given name.- Parameters:
name- The name of the datadata- The data to set
-
getCenterOffset
public double getCenterOffset()
Gets the amount away a character is from the center of the line. This isn't useful for detecting single characters.- Returns:
- The offset of the character
-
setCenterOffset
public void setCenterOffset(double centerOffset)
Sets the amount away a character is from the center of the line. This isn't useful for detecting single characters.- Parameters:
centerOffset- The offset of the character to set
-
hashCode
public int hashCode()
- Overrides:
hashCodein classCoordinateCharacter
-
equals
public boolean equals(java.lang.Object obj)
- Overrides:
equalsin classCoordinateCharacter
-
-