Skip to content

Commit

Permalink
Source code
Browse files Browse the repository at this point in the history
  • Loading branch information
sakarika committed Dec 15, 2019
1 parent 65a1d43 commit 433f6c4
Show file tree
Hide file tree
Showing 81 changed files with 14,914 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/net/kanjitomo/CharacterColor.java
@@ -0,0 +1,22 @@
package net.kanjitomo;

/**
* Character and background color.
*/
public enum CharacterColor {

/**
* Character color is detected automatically. (default)
*/
AUTOMATIC,

/**
* Black characters over white background
*/
BLACK_ON_WHITE,

/**
* White characters over black background
*/
WHITE_ON_BLACK;
}
55 changes: 55 additions & 0 deletions src/net/kanjitomo/Column.java
@@ -0,0 +1,55 @@
package net.kanjitomo;

import java.awt.Rectangle;
import java.util.ArrayList;
import java.util.List;

/**
* List of areas inside a single column (or row in horizontal orientation)
*/
public class Column {

// this is a simplified version of net.kanjitomo.area.Column intended to be used
// as a result object from KanjiTomo class

/**
* Rectangles around characters in this column.
* Ordered in reading direction (top-down or left-right).
*/
public List<Rectangle> areas;

/**
* Bounding box around areas
*/
public Rectangle rect;

/**
* Next column in reading direction
*/
public Column nextColumn;

/**
* Previous column in reading direction
*/
public Column previousColumn;

/**
* If true, this column has vertical reading direction. If false, horizontal.
*/
public boolean vertical;

/**
* If true, this column contains furigana characters
*/
public boolean furigana;

/**
* Furigana columns next to this column
*/
public List<Column> furiganaColumns = new ArrayList<Column>();

@Override
public String toString() {
return "rect:"+rect+" areas:"+areas.size()+" vertical:"+vertical+" furigana:"+furigana;
}
}
22 changes: 22 additions & 0 deletions src/net/kanjitomo/DictionaryType.java
@@ -0,0 +1,22 @@
package net.kanjitomo;

/**
* Type of dictionary used for searching and refining OCR results
*/
public enum DictionaryType {

/**
* Normal Japanese dictionary
*/
JAPANESE_DEFAULT,

/**
* Japanese names dictionary
*/
JAPANESE_NAMES,

/**
* Chinese dictionary
*/
CHINESE
}
38 changes: 38 additions & 0 deletions src/net/kanjitomo/IdentifiedCharacter.java
@@ -0,0 +1,38 @@
package net.kanjitomo;

import java.awt.Rectangle;
import java.util.List;

/**
* OCR results for a single target character
*/
public class IdentifiedCharacter {

/**
* List of reference characters that match the target character best,
* ordered by OCR score (first character is the closest match).
*/
public final String referenceCharacters;

/**
* OCR scores for each reference character. Same order as in referenceCharacters.
* Higher score is better but reference characters might have been re-ordered if
* first match didn't result in a valid dictionary word.
*/
public final List<Integer> scores;

// TODO normalized scores

/**
* Location of the character in target image's coordinates
*/
public final Rectangle location;

public IdentifiedCharacter(String matchedCharacters, Rectangle location,
List<Integer> scores) {

this.referenceCharacters = matchedCharacters;
this.location = location;
this.scores = scores;
}
}

0 comments on commit 433f6c4

Please sign in to comment.