@@ -500,44 +500,6 @@ - (void)analyzeLayout
500500 self.layoutAnalysed = YES ;
501501}
502502
503- - (NSArray *)characterBoxes
504- {
505- NSMutableArray *recognizedTextBoxes = [[NSMutableArray alloc ] init ];
506-
507- // Get box info
508- char *boxText = _tesseract->GetBoxText (0 );
509- if (boxText == NULL ) {
510- NSLog (@" No boxes recognized. Check that -[Tesseract setImage:] is passed an image bigger than 0x0." );
511- return nil ;
512- }
513-
514- NSString *stringBoxes = [NSString stringWithUTF8String: boxText];
515- delete[] boxText;
516-
517- NSArray *arrayOfStringBoxes = [stringBoxes componentsSeparatedByString: @" \n " ];
518- for (NSString *stringBox in arrayOfStringBoxes) {
519- // A stringBox is of the format "c L B R T p"
520- // (L, T) is the top left corner of the box, and (R, B) is the bottom right corner
521- // Tesseract has (0, 0) in the bottom left corner and UIKit has (0, 0) in the top left corner
522- // Need to flip to work with UIKit
523- // c is the recognized character and p is the page it is recognized on
524- NSArray *boxComponents = [stringBox componentsSeparatedByString: @" " ];
525- if (boxComponents.count >= 6 ) {
526- CGFloat x = [boxComponents[1 ] floatValue ];
527- CGFloat y = self.imageSize .height - [boxComponents[4 ] floatValue ];
528- CGFloat width = [boxComponents[3 ] floatValue ] - [boxComponents[1 ] floatValue ];
529- CGFloat height = [boxComponents[4 ] floatValue ] - [boxComponents[2 ] floatValue ];
530- CGRect box = [self normalizedRectForX: x y: y width: width height: height];
531-
532- G8RecognizedBlock *block = [[G8RecognizedBlock alloc ] initWithText: boxComponents[0 ]
533- boundingBox: box
534- confidence: 0 .0f
535- level: G8PageIteratorLevelBlock];
536- [recognizedTextBoxes addObject: block];
537- }
538- }
539- return [recognizedTextBoxes copy ];
540- }
541503
542504- (CGRect)normalizedRectForX : (CGFloat)x y : (CGFloat)y width : (CGFloat)width height : (CGFloat)height
543505{
@@ -557,8 +519,9 @@ - (G8RecognizedBlock *)blockFromIterator:(tesseract::ResultIterator *)iterator
557519 const char *word = iterator->GetUTF8Text (level);
558520 if (word != NULL ) {
559521 // BoundingBox parameters are (Left Top Right Bottom).
560- // See comment in characterBoxes() for information on the coordinate
561- // system, and changes being made.
522+ // (L, T) is the top left corner of the box, and (R, B) is the bottom right corner
523+ // Tesseract has (0, 0) in the bottom left corner and UIKit has (0, 0) in the top left corner
524+ // Need to flip to work with UIKit
562525 int x1, y1, x2, y2;
563526 iterator->BoundingBox (level, &x1, &y1, &x2, &y2);
564527
@@ -614,7 +577,7 @@ - (NSArray *)characterChoices
614577 return [array copy ];
615578}
616579
617- - (NSArray *)confidencesByIteratorLevel : (G8PageIteratorLevel)pageIteratorLevel
580+ - (NSArray *)recognizedBlocksByIteratorLevel : (G8PageIteratorLevel)pageIteratorLevel
618581{
619582 tesseract::PageIteratorLevel level = (tesseract::PageIteratorLevel)pageIteratorLevel;
620583
0 commit comments