GetComponentImages with tesseract::RIL_PARA returns the same results as tesseract::RIL_BLOCK

38 views
Skip to first unread message

Nils André

unread,
Jan 3, 2020, 11:13:10 AM1/3/20
to tesseract-ocr
I'm trying to extract paragraphs from an image so I tried GetComponentImages using tesseract::RIL_PARA but I just get the whole image.

Zdenko Podobny

unread,
Jan 3, 2020, 11:18:02 AM1/3/20
to tesser...@googlegroups.com
seems like you forget to attach you code, image, tesseract version details....

Zdenko


pi 3. 1. 2020 o 17:13 Nils André <nils.and...@gmail.com> napísal(a):
I'm trying to extract paragraphs from an image so I tried GetComponentImages using tesseract::RIL_PARA but I just get the whole image.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesseract-oc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tesseract-ocr/f6ca7c70-17c0-4ba3-aeba-e4a508e88fde%40googlegroups.com.

Nils André

unread,
Jan 3, 2020, 11:44:51 AM1/3/20
to tesseract-ocr

Here is my code with tesseract4:

#include
#include

int main() {
 
Pix *image = pixRead("image-001.ppm");
  tesseract
::TessBaseAPI *api = new tesseract::TessBaseAPI();
  api
->Init(NULL, "spa");
  api
->SetImage(image);
 
Boxa* boxes = api->GetComponentImages(tesseract::RIL_PARA, true, NULL, NULL);
  printf
("Found %d para image components.\n", boxes->n);
 
for (int i = 0; i < boxes->n; i++) {
    BOX
* box = boxaGetBox(boxes, i, L_CLONE);
    api
->SetRectangle(box->x, box->y, box->w, box->h);
   
char* ocrResult = api->GetUTF8Text();
   
int conf = api->MeanTextConf();
    fprintf
(stdout, "Box[%d]: x=%d, y=%d, w=%d, h=%d, confidence: %d, text: %s",
                    i
, box->x, box->y, box->w, box->h, conf, ocrResult);
    boxDestroy
(&box);
 
}
  boxaDestroy
(&boxes);
  pixDestroy
(&image);
}



On Friday, 3 January 2020 16:18:02 UTC, zdenop wrote:
seems like you forget to attach you code, image, tesseract version details....

Zdenko


pi 3. 1. 2020 o 17:13 Nils André <nils.an...@gmail.com> napísal(a):
I'm trying to extract paragraphs from an image so I tried GetComponentImages using tesseract::RIL_PARA but I just get the whole image.

--
You received this message because you are subscribed to the Google Groups "tesseract-ocr" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tesser...@googlegroups.com.

Nils André

unread,
Jan 3, 2020, 11:55:13 AM1/3/20
to tesseract-ocr
The problem is that instead of having paragraphs, I get one big chunk of text:

here is the output:

Warning: Invalid resolution 0 dpi. Using 70 instead.
Found 1 para image components.
Box[0]: x=64, y=40, w=1217, h=1529, confidence: 79, text: O. Indicar cuál de las siguientes 1gualdades entre expresiones regulares es verdadera:
(a) a(a+ba)* (a +ab)*a
(b)  a(a+ba) aa*b*a
(c) a(a+ba)* aa*(bay*
7. Dado el alfabeto » = (0, 1), se define £ como el lenguaje formado por las cadenas que cumplen que N(0) =
N
(1) +1 donde N(0) es el número de apariciones del símbolo 0 y N(1) es el número de apariciones del símbolo
1. Indicar cuál de las siguientes gramáticas independientes del contexto genera ,
(a)
S
CB|BC|0C1 | 1C0/0
C
> oc |1Coj0
B
OBLILBOJOL|LO
(6)
S
OAILJO
A
DAlJoBJO
B
0BI0
(e)
S
CB|IBCIOCI |1C0]0]E
E
- 0E1/1C0/0
B
0B1|1Bojo1|10
8. Sca / cl lenguaje gencrado por la siguiente gramática:
S
—-+A1B
A
0A|e
B_
.0OB|IBlc
Indicar cuál de las siguientes afirmaciones es verdadera:
(a) Lesindependiente del contexto no regular
(b) Z conticene la cadena vacía
(c) Sea w la cadena de menor longitud de 7, entonces |w| =2
(d) 7esregular y puede expresarse mediante la expresión regular 0*1(0+1)*
9. A la hora de trasladar la cabeza de la máquina de Turing en cada paso de ejecución de la máquina, ¿Cuál de las
siguientes afirmaciones es verdadera
?
(a) Las máquinas de Turing sólo pueden moverse una posición a la derecha.
(b) Las máquinas de Turing sólo pueden moverse una posición a la izquierda.
(c) Las máquinas de Turing sólo pueden moverse una posición a la derecha o a la izquierda.
(d) Las máquinas de Turing pueden moverse cualquier número de posiciones a la derecha o a la izquierda.
Enter code here...


Reply all
Reply to author
Forward
0 new messages