Hi tomosa,

On Friday, 3 June 2011 04:42:51 UTC+2, tomosa wrote:
>
> Hello. 
>
> I use the Tesseract V3.01 code "tesseract-ocr-read-only". 
> According to its ReleaseNotes, it seems to be able to use "Thread- 
> safety". 
>
> I want to mount the multithread processing at the page level. 
> That is, I want to make each thread work for each page at the same 
> time. 
>
> Now I mount it with OpenMP, but it doesn't operate well. 
> Segmentation fault is always generated. 
> Where is the place of "Thread-safety" in the source code? 
> How can I use "Thread-safety"? 
>
> Will you show me your idea if you can use "Thread-safety"? 
>
> Thanks. 
>
> tomosa


I have exactly the same questions, but I'm using tesseract 3.03 rc1.
I'm trying to use openmp to process one page per thread; so far, I just 
modified the ProcessPages code like this:

if (npages > 0) {

    pixDestroy(&pix);

//francesco

//modified to use omp:

//define lpage = local page variable to initialize the loop;

//modify branch logic to exclude break statement

#pragma omp parallel for private(pix) 

    for (int lpage = page; lpage < npages; ++lpage) {

      // only use opencl if compiled w/ OpenCL and selected device is opencl

#ifdef USE_OPENCL

      if ( od.selectedDeviceIsOpenCL() ) {

        pix = od.pixReadTiffCl(filename, lpage);

      } else {

#endif

        pix = pixReadTiff(filename, lpage);

#ifdef USE_OPENCL

      }

#endif


      if (pix == NULL) //was break. Now it keeps cycling doing nothing 
useful

        bool dummy_var = true;

      else{

        if ((lpage >= 0) && (npages > 1))

          tprintf("Page %d of %d\n", lpage + 1, npages);

        char page_str[kMaxIntSize];

        snprintf(page_str, kMaxIntSize - 1, "%d", lpage);

        SetVariable("applybox_page", page_str);

        success &= ProcessPage(pix, lpage, filename, retry_config,

                             timeout_millisec, renderer);

        pixDestroy(&pix);

      }

      //commented out

     /* if (tesseract_->tessedit_page_number >= 0 || npages == 1) {

        break;

      }*/
    } 

I got segfault too, and debugging via gdb I found the problem here - a 
short backtrace follows:

#0  0x00007ffff7829779 in ELIST_ITERATOR::forward (this=0x7fffffffb4d0) at 
elst.cpp:237

#1  0x00007ffff7640648 in C_BLOB_IT::forward (this=0x7fffffffb4d0) at 
../ccstruct/stepblob.h:28

#2  0x00007ffff776356a in assign_blobs_to_blocks2 (pix=0x83f530, 
blocks=0x7fffdc000960, 

    port_blocks=0x7fffffffb950) at tordmain.cpp:173

Moreover, I tried to run the code under valgrind with the drd tool, and I 
got a ton of conflicts.
It seems it really can't be the correct approach, we really need the help 
of a staff member here!


f.

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tesseract-ocr.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/tesseract-ocr/ab0d270a-cb89-4288-8280-ecfad3692c31%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to