Shell commands work in Terminal but not in Automator service
Any executable that is not within the PATH passed to the Run Shell Script action, which is /usr/bin:/bin:/usr/sbin:/sbin, you must use the fully qualified pathname of the executable.
In this case, e.g. /path/to/tesseract
You should be able to get its path in Terminal using:
which tesseract

As tesseract is not a default of macOS, it may be in /usr/local/bin/, however which tesseract should report its fully qualified pathname.

Instead of using the fully qualified pathname, or in conjunction with, you can also add a PATH statement to the top of the Run Shell Script action, e.g. for a bash shell:
PATH=&quot;${PATH}:/usr/local/bin/&quot;

You could also just substitute everything to the right of the = sign for what the output in Terminal, e.g. echo $PATH is. Then the Run Shell Script action has the same PATH as Terminal.