Skip to content

Commit

Permalink
Fixed a NPE with character segmentation
Browse files Browse the repository at this point in the history
  • Loading branch information
RubbaBoy committed Nov 12, 2018
1 parent 628eff6 commit 19effcb
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/main/java/com/uddernetworks/newocr/OCRUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/
public class OCRUtils {

public static final AbstractMap.SimpleEntry<Integer, Integer> ZERO_PLACEHOLDER = new AbstractMap.SimpleEntry<>(0, 0);

/*
* Advanced/Convenient Comparisons
*/
Expand Down Expand Up @@ -371,7 +373,7 @@ public static Stream<boolean[][]> getVerticalHalf(boolean[][] values) {
* @return A stream of 3 thirds: left, middle, and right
*/
public static Stream<AbstractMap.SimpleEntry<Integer, Integer>> getVerticalThird(boolean[][] values) {
if (values.length == 0) return Stream.of(null, null, null);
if (values.length == 0) return Stream.of(ZERO_PLACEHOLDER, ZERO_PLACEHOLDER, ZERO_PLACEHOLDER);
int leftHeight = values[0].length / 3;
int middleHeight = values[0].length - leftHeight * 2;

Expand Down

0 comments on commit 19effcb

Please sign in to comment.