Search code examples
ubuntutesseractcpu-usagepython-tesseract

pytesseract eats CPU too high


In Ubuntu 16.04 LTS, the pyteserract script eats too high, and it causes system reboot intermittenly.

The top command output is

    top - 21:23:31 up 27 min,  4 users,  load average: 3.27, 1.86, 1.28
Tasks: 290 total,   2 running, 216 sleeping,   0 stopped,   0 zombie
%Cpu(s): 87.5 us,  0.7 sy,  0.0 ni, 11.7 id,  0.0 wa,  0.0 hi,  0.1 si,  0.0 st
KiB Mem : 16295836 total, 10387872 free,  2990788 used,  2917176 buff/cache
KiB Swap: 16645116 total, 16645116 free,        0 used. 12155216 avail Mem 

  PID USER  PR  NI VIRT    RES     SHR   S %CPU   %MEM  TIME+   COMMAND    
 5391 myid  20   0 1393532 141324  39308 R 667.8  0.9   2:30.57 python     

the python script is

text_eng = pytesseract.image_to_string(Image.open(dst), lang='eng', config='--oem 1 --psm 1 -c preserve_interword_spaces=1')

My environment is

tesseract 4.1.0-rc1
 leptonica-1.77.0
  libjpeg 8d (libjpeg-turbo 1.4.2) : libpng 1.2.54 : libtiff 4.0.6 : zlib 1.2.8 : libopenjp2 2.1.2
 Found AVX2
 Found AVX
 Found SSE

What I have done are 1) removed oem option 2) remove psm option but no luck so far.

Any clue?


Solution

  • Answer by myself.

    I've removed leptonica-1.77.0 and compiled again, then the problem has been gone.