Hello, I installed opencv4nodejs few weeks ago. But I don't know some reason I uninstalled and tried to reinstall same machine it failed. I scroll up terminal little bit and try to find reason why. There are bunch of error messages respect with tesseract. I was like what ?
Btw I have installed tesseract on my machine
tesseract 4.0.0
leptonica-1.78.0
libgif 5.1.4 : libjpeg 9c : libpng 1.6.36 : libtiff 4.0.10 : zlib 1.2.5 : libwebp 1.0.2 : libopenjp2 2.3.1
Found SSE
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:33:1: error: unknown type name 'constexpr'
constexpr int kPointsPerInch = 72;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:33:11: error: expected unqualified-id
constexpr int kPointsPerInch = 72;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:38:1: error: unknown type name 'constexpr'
constexpr int kMinCredibleResolution = 70;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:38:11: error: expected unqualified-id
constexpr int kMinCredibleResolution = 70;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:40:1: error: unknown type name 'constexpr'
constexpr int kMaxCredibleResolution = 2400;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:40:11: error: expected unqualified-id
constexpr int kMaxCredibleResolution = 2400;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:45:1: error: unknown type name 'constexpr'
constexpr int kResolutionEstimationFactor = 10;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:45:11: error: expected unqualified-id
constexpr int kResolutionEstimationFactor = 10;
^
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h:31:
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/resultiterator.h:103:63: error: a space is required between consecutive right angle
brackets (use '> >')
virtual std::vector<std::vector<std::pair<const char*, float>>>* GetBestLSTMSymbolChoices() const;
^
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/erfilter.cpp:43:
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h:32:
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:1: error: unknown type name 'constexpr'
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:17: error: expected ';' at end of declaration
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:18: error: C++ requires a type specifier for all declarations
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:26: error: use of undeclared identifier 'T'
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:41: error: expected ';' after top level declarator
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:56:40: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, char* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:57:41: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, float* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:58:42: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, int8_t* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:59:43: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, int16_t* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:60:43: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, int32_t* data, size_t n = 1);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_beamsearch_decoder.cpp:43:
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h:27:
In file included from /usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/apitypes.h:23:
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:33:1: error: unknown type name 'constexpr'
constexpr int kPointsPerInch = 72;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:33:11: error: expected unqualified-id
constexpr int kPointsPerInch = 72;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:38:1: error: unknown type name 'constexpr'
constexpr int kMinCredibleResolution = 70;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:38:11: error: expected unqualified-id
constexpr int kMinCredibleResolution = 70;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:40:1: error: unknown type name 'constexpr'
constexpr int kMaxCredibleResolution = 2400;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:40:11: error: expected unqualified-id
constexpr int kMaxCredibleResolution = 2400;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:45:1: error: unknown type name 'constexpr'
constexpr int kResolutionEstimationFactor = 10;
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/publictypes.h:45:11: error: expected unqualified-id
constexpr int kResolutionEstimationFactor = 10;
^
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_beamsearch_decoder.cpp:43:
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h:31:
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/resultiterator.h:103:63: error: a space is required between consecutive right angle
brackets (use '> >')
virtual std::vector<std::vector<std::pair<const char*, float>>>* GetBestLSTMSymbolChoices() const;
^
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/ocr_beamsearch_decoder.cpp:43:
In file included from /Users/jeefo/projects/face_recognition/node_modules/opencv-build/opencv/opencv_contrib/modules/text/src/precomp.hpp:54:
In file included from /usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/baseapi.h:32:
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:1: error: unknown type name 'constexpr'
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:17: error: expected ';' at end of declaration
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:18: error: C++ requires a type specifier for all declarations
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:26: error: use of undeclared identifier 'T'
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:43:41: error: expected ';' after top level declarator
constexpr size_t countof(T const (&)[N]) noexcept {
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:56:40: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, char* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:57:41: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, float* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:58:42: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, int8_t* data, size_t n = 1);
^
[ 83%] Building CXX object modules/calib3d/CMakeFiles/opencv_calib3d.dir/src/compat_stereo.cpp.o
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:59:43: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, int16_t* data, size_t n = 1);
^
/usr/local/Cellar/tesseract/4.0.0_1/include/tesseract/serialis.h:60:43: error: unknown type name 'size_t'
bool DeSerialize(FILE* fp, int32_t* data, size_t n = 1);
^
fatal error: too many errors emitted, stopping now [-ferror-limit=]
A hint to fix. I uninstalled tesseract and tried to reinstall it succeeded. I think there is some problem with compiler flags or build configuration.
@je3f0o I think the problem is in the opencv build rather than the opencv4nodejs build.
I'm on OSX, so I do ... brew unlink tesseract before the build and brew link tesseract after ... purely a work around until I find time to dive into the build code or the problem "just goes away" :)
unlinking or uninstalling tesseract system-wide is not a sustainable solution. we use openCV for lots of other purposes. there's at least three other issues where this is the recommended 'solution'. when can we expect a fix?
https://github.com/justadudewhohacks/opencv4nodejs/issues/503
https://github.com/justadudewhohacks/opencv4nodejs/issues/401
https://github.com/justadudewhohacks/opencv4nodejs/issues/179
Keep in mind that installing OpenCV via the autobuild script is optional. You can use your own OpenCV build. Furthermore you can circumvent these issues by setting the correspondings cmake flags for the autobuild script manually via an environment variable.
For everyone facing issues with the auto build script + tesseract:
I am not sure if it is possible to pass a cmake flag to OpenCV to prevent building OpenCV with tesseract. If so, providing the flags via OPENCV4NODEJS_AUTOBUILD_FLAGS should fix it.
Optionally you can build OpenCV without the text module at all: set OPENCV4NODEJS_AUTOBUILD_FLAGS=-DBUILD_opencv_text=OFF.
Otherwise I would say the approach described by @goulash1971 is the way to go.
Issue persists
Most helpful comment
@je3f0o I think the problem is in the opencv build rather than the opencv4nodejs build.
I'm on OSX, so I do ...
brew unlink tesseractbefore the build andbrew link tesseractafter ... purely a work around until I find time to dive into the build code or the problem "just goes away" :)