Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fatal error: 'tesseract/baseapi.h' file not found #179

Closed
fakob opened this issue Feb 25, 2018 · 18 comments
Closed

fatal error: 'tesseract/baseapi.h' file not found #179

fakob opened this issue Feb 25, 2018 · 18 comments

Comments

@fakob
Copy link

fakob commented Feb 25, 2018

Hi,

I have seen that with the new version @justadudewhohacks has made it possible to build opencv within node. That is fantastic, thank you so much! With my hobby skills I could have never achieved that :-)

I have now tried to run your opencv-electron example using this new version 3.0.3. First I had to update electron and electron-rebuild, but then when running npm install I keep receiving

fatal error: 'tesseract/baseapi.h' file not found.

Here is the whole output:

[ 75%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/ap3p.cpp.o
In file included from /Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_holistic.cpp:5:
/Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error:
'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>
^~~~~~~~~~~~~~~~~~~~~
In file included from /Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_beamsearch_decoder.cpp:43:
/Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error:
'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>
^~~~~~~~~~~~~~~~~~~~~
In file included from /Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_tesseract.cpp:43:
/Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error:
'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>
^~~~~~~~~~~~~~~~~~~~~
In file included from /Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_hmm_decoder.cpp:43:
/Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error:
'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>
^~~~~~~~~~~~~~~~~~~~~
In file included from /Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
/Users/fakob/opencv-electron-3.0.3/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error:
'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>
^~~~~~~~~~~~~~~~~~~~~
1 error generated.
make[2]: *** [modules/text/CMakeFiles/opencv_text.dir/src/ocr_holistic.cpp.o] Error 1
make[2]: *** Waiting for unfinished jobs....
1 error generated.
make[2]: *** [modules/text/CMakeFiles/opencv_text.dir/src/ocr_tesseract.cpp.o] Error 1
[ 75%] Building CXX object modules/line_descriptor/CMakeFiles/opencv_line_descriptor.dir/src/binary_descriptor.cpp.o
1 error generated.
[ 75%] Building CXX object modules/saliency/CMakeFiles/opencv_saliency.dir/src/BING/CmShow.cpp.o
make[2]: *** [modules/text/CMakeFiles/opencv_text.dir/src/ocr_beamsearch_decoder.cpp.o] Error 1
1 error generated.
[ 75%] Building CXX object modules/line_descriptor/CMakeFiles/opencv_line_descriptor.dir/src/binary_descriptor_matcher.cpp.o
make[2]: *** [modules/text/CMakeFiles/opencv_text.dir/src/ocr_hmm_decoder.cpp.o] Error 1
[ 75%] Building CXX object modules/saliency/CMakeFiles/opencv_saliency.dir/src/BING/FilterTIG.cpp.o
1 error generated.
make[2]: *** [modules/text/CMakeFiles/opencv_text.dir/src/erfilter.cpp.o] Error 1
make[1]: *** [modules/text/CMakeFiles/opencv_text.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
[ 75%] Building CXX object modules/line_descriptor/CMakeFiles/opencv_line_descriptor.dir/src/draw.cpp.o

@fakob
Copy link
Author

fakob commented Feb 25, 2018

Strange. I have now run the same test on my other machine and it worked fine. Any idea what could be wrong with the first setup?
They are both macOS 10.13.3 using the latest cmake brew (3.10.2)

@justadudewhohacks
Copy link
Owner

Strange, it tries to include tesseract, although it shouldn't be enabled. On the system with the failing build, do you have any version of tesseract installed, maybe this is the reason why it is included in the build?

Could you also post the cmake output from the log?

@fakob
Copy link
Author

fakob commented Feb 25, 2018

If I remember correctly was a line naming tesseract

modules/text/CMakeFiles/opencv_text.dir/src/ocr_tesseract.cpp.o

also included on the machine where it had worked, but I will double check.

I am actually not sure if tesseract was installed globally. I had experimented with an app, which had it included, if I am not mistaken. Though this I think I did also on both machines.

The machines have different npm and node versions I noticed. Could that be responsible for this error?

Error machine: npm@5.5.1 | node@v8.4.0
Working machine: npm@5.6.0 | node@v8.9.1

Here is the log
2018-02-25T10_55_32_848Z-debug.log

@fakob
Copy link
Author

fakob commented Feb 25, 2018

I have now brew uninstalled tesseract and also updated npm and node to the latest version npm@5.6.0 | node@v9.6.1. Now it seems to build fine, but when running the opencv-electron example the image does not show and the console output says

Uncaught Error: dlopen(/Users/fakob/opencv-electron-3.0.3/node_modules/opencv4nodejs/build/Release/opencv4nodejs.node, 1): Library not loaded: /opt/local/lib/libX11.6.dylib
Referenced from: /usr/local/lib/libavcodec.56.dylib
Reason: image not found
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:172:20)
at Object.Module._extensions..node (module.js:598:18)
at Object.module.(anonymous function) [as .node] (ELECTRON_ASAR.js:172:20)
at Module.load (module.js:503:32)
at tryModuleLoad (module.js:466:12)
at Function.Module._load (module.js:458:3)
at Module.require (module.js:513:17)
at require (internal/module.js:11:18)
at Object. (/Users/fakob/opencv-electron-3.0.3/node_modules/opencv4nodejs/lib/opencv4nodejs.js:13:8)
at Object. (/Users/fakob/opencv-electron-3.0.3/node_modules/opencv4nodejs/lib/opencv4nodejs.js:31:3)

Your guess regarding uninstalling tesseract, seems to have worked. Not sure if the next error is somehow related though.

@justadudewhohacks
Copy link
Owner

Yeah I think it was due to having tesseract installed.

I guess your error is due to missing codecs. The example images are encoded with h.264 (avc), Updating libav should make it. Maybe also updating ffmpeg does the job for you: Homebrew/legacy-homebrew#40001

@fakob
Copy link
Author

fakob commented Feb 25, 2018

Thanks for the link, but the steps described with reinstalling libav and ffmpeg did not solve the issue.

I am confused as I thought that with packaging opencv into node, one would not have any external dependencies anymore. Is that not the case?

@justadudewhohacks
Copy link
Owner

justadudewhohacks commented Feb 26, 2018

You don't need any external dependencies that OpenCV does not need as well. The Referenced from: /usr/local/lib/libavcodec.56.dylib just made me think there is something wrong with libavc and codecs are integral parts of your system to decode images and video in general.

Anyway just noticed Library not loaded: /opt/local/lib/libX11.6.dylib ... . For OpenCV GUI related stuff non windows systems usually need either libgtk(linux) or libX11 (MacOSX). The error message is kind of strange, since I thought you should only get these kind of exceptions when calling cv.imshow or other functions from highgui and these should not be used with electron anyways.

Long story short since libX11 could not be loaded I suspect you either don't have it or it is not linked correctly. If you do have it installed you could try sudo ln -s /opt/X11 /usr/X11, related to this issue: https://tex.stackexchange.com/questions/208001/cant-compile-image-after-upgrading-to-os-x-yosemite.

Are you using OpenCV on the system with this issue the first time or is this issue just apparent in the electron example?

@fakob
Copy link
Author

fakob commented Feb 26, 2018

Thanks for pointing me into the right direction. I have to admit that my setup was kind of messed up. Probably due to an old MacPort install, osx upgrading and naive experimenting some time ago.
Had to completely remove MacPort and clean up the all Homebrew installations.
Here brew doctor came in quite handy.

@justadudewhohacks sorry that I took up your time. I really appreciate the work you put into into this!

@fakob fakob closed this as completed Feb 26, 2018
@justadudewhohacks
Copy link
Owner

Great, always glad if I can help somehow.

@vBoykoGit
Copy link

brew uninstall tesseract
This worked for me

@HyDDc
Copy link

HyDDc commented Mar 6, 2019

I passed the direct location from tesseract/baseapi.h file.
for me: "/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h"

Afterwards I was able to compile and install opencv.

@GiulioPettenuzzo
Copy link

@superhuy how did you passed the direct location from tesseract/baseapi.h file???

@awill1988
Copy link

@GiulioPettenuzzo
Let's say you receive output like this from your shell:

In file included from ~/opencv_contrib/modules/text/src/erfilter.cpp:43:
~/opencv_contrib/modules/text/src/precomp.hpp:54:10: fatal error: 
      'tesseract/baseapi.h' file not found
#include <tesseract/baseapi.h>
         ^~~~~~~~~~~~~~~~~~~~~

The non-ideal, but definitely workable solution is to:

  1. Find your favorite text editor
  2. Use text editor to open for modification the header file ~/opencv_contrib/modules/text/src/precomp.hpp
  3. Change lines like #include <tesseract/baseapi.h> to an absolute location (e.g. #include "/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h")

This assumes of course that's where base directory of tesseract is, but that's how you can "pass indicate the direct location"

@robie2011
Copy link

robie2011 commented Apr 17, 2019

in my case cpp command was not aware of tesseract headers.
You can see cpp-includes with command cpp -v.

Solution for me was to make tesseract-includes availble by defining export CPATH="/usr/local/Cellar/tesseract/4.0.0_1/include" and then run the build command.

About headers: https://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art026

@javadba
Copy link

javadba commented May 25, 2019

The suggestion from @robie2011 for adding tesseract to the headers worked for me. Would this be considered a weakness in the homebrew installation of tesseract since its header is not added to the system accessible C++ headers path?

@robie2011
Copy link

@javadba happy to hear that :)
I'm not so deep into homebrew. Can't answer that. Usually hombrew works well for me.

For me compiling OpenCV C++ Library seems to be a challange in general.

@zobeirraisi
Copy link

in my case cpp command was not aware of tesseract headers.
You can see cpp-includes with command cpp -v.

Solution for me was to make tesseract-includes availble by defining export CPATH="/usr/local/Cellar/tesseract/4.0.0_1/include" and then run the build command.

About headers: https://commandlinefanatic.com/cgi-bin/showarticle.cgi?article=art026

It worked for me, Thanks

@whatboxapp
Copy link

export CPATH="/usr/local/Cellar/tesseract/4.1.0/include"

It works, Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants