45
45
import org .slf4j .Logger ;
46
46
import org .slf4j .LoggerFactory ;
47
47
48
+ import static org .junit .Assert .assertArrayEquals ;
49
+ import static org .junit .Assert .assertEquals ;
50
+ import static org .junit .Assert .assertTrue ;
48
51
import static org .junit .Assert .assertArrayEquals ;
49
52
import static org .junit .Assert .assertEquals ;
50
53
import static org .junit .Assert .assertTrue ;
@@ -233,7 +236,8 @@ public void testExtendingTesseract1() throws Exception {
233
236
int pageIteratorLevel = TessPageIteratorLevel .RIL_WORD ;
234
237
logger .info ("PageIteratorLevel: "
235
238
+ Utils .getConstantName (pageIteratorLevel , TessPageIteratorLevel .class ));
236
- List <Word > result = instance1 .getWords (imageFile , pageIteratorLevel );
239
+ BufferedImage bi = ImageIO .read (imageFile );
240
+ List <Word > result = instance1 .getWords (bi , pageIteratorLevel );
237
241
238
242
// print the complete result
239
243
for (Word word : result ) {
@@ -250,13 +254,12 @@ public void testExtendingTesseract1() throws Exception {
250
254
251
255
class Tess1Extension extends Tesseract1 {
252
256
253
- public List <Word > getWords (File file , int pageIteratorLevel ) {
257
+ public List <Word > getWords (BufferedImage bi , int pageIteratorLevel ) {
254
258
this .init ();
255
259
this .setTessVariables ();
256
260
257
261
List <Word > words = new ArrayList <Word >();
258
262
try {
259
- BufferedImage bi = ImageIO .read (file );
260
263
setImage (bi , null );
261
264
262
265
TessBaseAPIRecognize (this .getHandle (), null );
@@ -292,7 +295,7 @@ public List<Word> getWords(File file, int pageIteratorLevel) {
292
295
}
293
296
294
297
/**
295
- * Test of getRegions method, of class Tesseract1.
298
+ * Test of getSegmentedRegions method, of class Tesseract1.
296
299
*/
297
300
@ Test
298
301
public void testGetRegions () throws Exception {
@@ -301,7 +304,7 @@ public void testGetRegions() throws Exception {
301
304
BufferedImage bi = ImageIO .read (imageFile );
302
305
int level = TessPageIteratorLevel .RIL_SYMBOL ;
303
306
logger .info ("PageIteratorLevel: " + Utils .getConstantName (level , TessPageIteratorLevel .class ));
304
- List <Rectangle > result = instance .getRegions (bi , level );
307
+ List <Rectangle > result = instance .getSegmentedRegions (bi , level );
305
308
for (int i = 0 ; i < result .size (); i ++) {
306
309
Rectangle rect = result .get (i );
307
310
logger .info (String .format ("Box[%d]: x=%d, y=%d, w=%d, h=%d" , i , rect .x , rect .y , rect .width , rect .height ));
0 commit comments