Skip to content

Commit

Permalink
Add test coverage for HOCR and bounding box
Browse files Browse the repository at this point in the history
  • Loading branch information
rmtheis committed Feb 17, 2014
1 parent b1235fd commit 65c979e
Showing 1 changed file with 7 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public void testGetUTF8Text() {
final String outputText = baseApi.getUTF8Text();
assertEquals("\"" + outputText + "\" != \"" + inputText + "\"", inputText, outputText);

// Ensure that getHOCRText() produced a result.
final String hOcr = baseApi.getHOCRText(0);
assertNotNull("HOCR result found", hOcr);

// Ensure getRegions() works.
final Pixa regions = baseApi.getRegions();
assertEquals("Found one region", regions.size(), 1);
Expand All @@ -119,17 +123,20 @@ public void testGetUTF8Text() {
final ResultIterator iterator = baseApi.getResultIterator();
String lastUTF8Text;
float lastConfidence;
int[] lastBoundingBox;
int count = 0;
iterator.begin();
do {
lastUTF8Text = iterator.getUTF8Text(PageIteratorLevel.RIL_WORD);
lastConfidence = iterator.confidence(PageIteratorLevel.RIL_WORD);
lastBoundingBox = iterator.getBoundingBox(PageIteratorLevel.RIL_WORD);
count++;
} while (iterator.next(PageIteratorLevel.RIL_WORD));

assertEquals("Found only one result", count, 1);
assertEquals("Found the correct result", lastUTF8Text, outputText);
assertTrue("Result was high-confidence", lastConfidence > 80);
assertTrue("Result has a bounding box", lastBoundingBox[2] > 0 && lastBoundingBox[3] > 0);

// Attempt to shut down the API.
baseApi.end();
Expand Down

0 comments on commit 65c979e

Please sign in to comment.