嗨,我正试图在我的Node.js项目中使用opencv,所以我决定使用opencv4nodejs。我试图通过npm安装这个模块,并发现了一些与我的计算机上缺少cmake有关的错误。因此,我决定通过cmake安装brew。但是,在这个过程之后,当我试图安装这个模块时,会发生以下错误:
MacBook-Air-Micha:webcam-myidea michalkukielka$ npm install opencv4nodejs
> opencv-build@0.1.8 install /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build
> node ./install.js
info No package.json in folder.
info install if you want to use an own OpenCV installation set OPENCV4NODEJS_DISABLE_AUTOBUILD
info readAutoBuildFile file does not exists: /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/auto-build.json /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/auto-build.json
info install failed to find auto-build.json: /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/auto-build.json
info install
info install running install script...
info install
info install opencv version: 3.4.6
info install with opencv contrib: yes
info install custom build flags:
info install
info install executing: git --version
info install git --version: git version 2.20.1
info install
info install executing: cmake --version
info install cmake --version: cmake version 3.15.3
info install
info install CMake suite maintained and supported by Kitware (kitware.com/cmake).
info install
info install installing opencv version 3.4.6 into directory: /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv
Cloning into 'opencv_contrib'...
remote: Enumerating objects: 2160, done.
remote: Counting objects: 100% (2160/2160), done.
remote: Compressing objects: 100% (1916/1916), done.
remote: Total 2160 (delta 365), reused 1101 (delta 134), pack-reused 0
Receiving objects: 100% (2160/2160), 50.82 MiB | 1.57 MiB/s, done.
Resolving deltas: 100% (365/365), done.
Note: checking out 'f26c98365da6af93cb5e49397b571190fca7bb55'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Checking out files: 100% (1780/1780), done.
Cloning into 'opencv'...
remote: Enumerating objects: 7328, done.
remote: Counting objects: 100% (7328/7328), done.
remote: Compressing objects: 100% (6260/6260), done.
remote: Total 7328 (delta 1166), reused 3907 (delta 692), pack-reused 0
Receiving objects: 100% (7328/7328), 81.33 MiB | 1.62 MiB/s, done.
Resolving deltas: 100% (1166/1166), done.
Note: checking out '33b765d7979fd8a6038026aa44f6ff1a9c082b7b'.
You are in 'detached HEAD' state. You can look around, make experimental
changes and commit them, and you can discard any commits you make in this
state without impacting any branches by performing another checkout.
If you want to create a new branch to retain commits you create, you may
do so (now or later) by using -b with the checkout command again. Example:
git checkout -b <new-branch-name>
Checking out files: 100% (6080/6080), done.
info install running cmake /Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/opencv,-DCMAKE_INSTALL_PREFIX=/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/build,-DCMAKE_BUILD_TYPE=Release,-DBUILD_EXAMPLES=OFF,-DBUILD_DOCS=OFF,-DBUILD_TESTS=OFF,-DBUILD_PERF_TESTS=OFF,-DBUILD_JAVA=OFF,-DCUDA_NVCC_FLAGS=--expt-relaxed-constexpr,-DBUILD_opencv_apps=OFF,-DBUILD_opencv_aruco=OFF,-DBUILD_opencv_bgsegm=OFF,-DBUILD_opencv_bioinspired=OFF,-DBUILD_opencv_ccalib=OFF,-DBUILD_opencv_datasets=OFF,-DBUILD_opencv_dnn_objdetect=OFF,-DBUILD_opencv_dpm=OFF,-DBUILD_opencv_fuzzy=OFF,-DBUILD_opencv_hfs=OFF,-DBUILD_opencv_java_bindings_generator=OFF,-DBUILD_opencv_js=OFF,-DBUILD_opencv_img_hash=OFF,-DBUILD_opencv_line_descriptor=OFF,-DBUILD_opencv_optflow=OFF,-DBUILD_opencv_phase_unwrapping=OFF,-DBUILD_opencv_python3=OFF,-DBUILD_opencv_python_bindings_generator=OFF,-DBUILD_opencv_reg=OFF,-DBUILD_opencv_rgbd=OFF,-DBUILD_opencv_saliency=OFF,-DBUILD_opencv_shape=OFF,-DBUILD_opencv_stereo=OFF,-DBUILD_opencv_stitching=OFF,-DBUILD_opencv_structured_light=OFF,-DBUILD_opencv_superres=OFF,-DBUILD_opencv_surface_matching=OFF,-DBUILD_opencv_ts=OFF,-DBUILD_opencv_xobjdetect=OFF,-DBUILD_opencv_xphoto=OFF,-DWITH_VTK=OFF,-DOPENCV_ENABLE_NONFREE=ON,-DOPENCV_EXTRA_MODULES_PATH=/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/opencv_contrib/modules
-- The CXX compiler identification is unknown
-- The C compiler identification is unknown
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - failed
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
CMake Error at CMakeLists.txt:153 (message):
CMake fails to determine the bitness of the target platform.
Please check your CMake and compiler installation. If you are cross-compiling then ensure that your CMake toolchain file correctly sets the compiler details.
-- Configuring incomplete, errors occurred!
See also "/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/build/CMakeFiles/CMakeOutput.log".
See also "/Users/michalkukielka/Documents/webcam-myidea/node_modules/opencv-build/opencv/build/CMakeFiles/CMakeError.log".
ERR! child process exited with code 1 (for more info, set '--loglevel silly')
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! opencv-build@0.1.8 install: `node ./install.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the opencv-build@0.1.8 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/michalkukielka/.npm/_logs/2019-09-07T05_38_02_479Z-debug.log据我所知,cmake有一些新的问题,但我无法找到解决办法。
你能帮我完成安装opencv4nodejs的过程吗?
发布于 2019-09-07 06:40:16
首先,本机节点模块是通过node-gyp构建的,在默认情况下,该模块已经随npm一起出现了。但是,node-gyp需要安装python。如果您遇到的是特定于节点的问题,那么首先要了解一下node的已知问题。
重要注意事项: node-gyp无法正确处理空白空间,因此确保项目目录的路径不包含任何空白空间。在"C:\Program Files\some_dir“或类似项下安装Files\some_dir将无法工作,并且将失败:”致命错误C1083:无法打开包含文件:‘opencv2 2/core.hpp’“!**
在Windows上,您还需要Windows工具来编译OpenCV和opencv4nodejs。如果没有安装Visual或,则可以轻松安装VS2015生成工具:
npm install --global windows-build-tools第二步:您应该检查CMake和编译器的安装。如果您正在交叉编译,那么请确保您的CMake工具链文件正确设置编译器详细信息。
CMake不(总是)听CC和CXX。相反,请使用CMAKE_C_COMPILER和CMAKE_CXX_COMPILER:
cmake -DCMAKE_C_COMPILER=/usr/bin/gcc -DCMAKE_CXX_COMPILER=/usr/bin/g++ ...也见文档。
或者,您可以提供一个工具链文件,但在这种情况下,这可能是过分的。
最后:在OSX下,我们可以通过brew安装OpenCV:
brew update
brew install opencv@4
brew link --force opencv@4https://stackoverflow.com/questions/57831117
复制相似问题