0

我正在尝试安装 node opencv ,我在 Mac 上运行小牛。我运行“npm install opencv”并尝试了很多方法来解决这个问题,但无法弄清楚。这是我的错误:还有一堆警告,但这是失败之前的错误:

当我运行 node-gyp configure 或 node-gyp rebuild 时发生类似的错误我试图在这里获得帮助:https ://github.com/joyent/node/issues/3113 但它没有帮助,我仍然得到 gyp 错误

运行 npm install opencv 时:这是整个输出

npm WARN package.json make@0.0.0 No repository field.
npm http GET https://registry.npmjs.org/opencv
npm http 304 https://registry.npmjs.org/opencv

> opencv@0.4.0 preinstall /Users/gabriellalevine/ardrone-webflight/node_modules/opencv
> node-gyp clean rebuild

  CXX(target) Release/obj.target/opencv/src/init.o
  CXX(target) Release/obj.target/opencv/src/Matrix.o
../src/Matrix.cc:110:13: warning: variable 'mat' is used uninitialized whenever
      'if' condition is false [-Wsometimes-uninitialized]
        } else if (args.Length() == 5) {
                   ^~~~~~~~~~~~~~~~~~
../src/Matrix.cc:119:2: note: uninitialized use occurs here
        mat->Wrap(args.Holder());
        ^~~
../src/Matrix.cc:110:9: note: remove the 'if' if its condition is always true
        } else if (args.Length() == 5) {
               ^~~~~~~~~~~~~~~~~~~~~~~~
../src/Matrix.cc:104:13: note: initialize the variable 'mat' to silence this
      warning
        Matrix *mat;
                   ^
                    = nullptr
1 warning generated.
  CXX(target) Release/obj.target/opencv/src/OpenCV.o
  CXX(target) Release/obj.target/opencv/src/CascadeClassifierWrap.o
  CXX(target) Release/obj.target/opencv/src/Contours.o
  CXX(target) Release/obj.target/opencv/src/Point.o
  CXX(target) Release/obj.target/opencv/src/VideoCaptureWrap.o
  CXX(target) Release/obj.target/opencv/src/CamShift.o
  CXX(target) Release/obj.target/opencv/src/HighGUI.o
../src/HighGUI.cc:38:13: warning: variable 'win' is used uninitialized whenever
      'if' condition is false [-Wsometimes-uninitialized]
        } else if (args.Length() == 2){
                   ^~~~~~~~~~~~~~~~~~
../src/HighGUI.cc:42:2: note: uninitialized use occurs here
        win->Wrap(args.Holder());
        ^~~
../src/HighGUI.cc:38:9: note: remove the 'if' if its condition is always true
        } else if (args.Length() == 2){
               ^~~~~~~~~~~~~~~~~~~~~~~
../src/HighGUI.cc:35:19: note: initialize the variable 'win' to silence this
      warning
  NamedWindow* win;
                  ^
                   = nullptr
1 warning generated.
  CXX(target) Release/obj.target/opencv/src/FaceRecognizer.o
../src/FaceRecognizer.cc:64:76: error: too many arguments to function call,
      expected at most 4, have 5
  ...f = cv::createLBPHFaceRecognizer(1, 8, 8, 8, 80.0);
         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~             ^~~~
/usr/local/Cellar/opencv/2.4.0/include/opencv2/contrib/contrib.hpp:951:16: note: 
      'createLBPHFaceRecognizer' declared here
    CV_EXPORTS Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1...
               ^
../src/FaceRecognizer.cc:90:42: error: too many arguments to function call,
      expected at most 4, have 5
      radius, neighbors, grid_x, grid_y, threshold
                                         ^~~~~~~~~
/usr/local/Cellar/opencv/2.4.0/include/opencv2/contrib/contrib.hpp:951:16: note: 
      'createLBPHFaceRecognizer' declared here
    CV_EXPORTS Ptr<FaceRecognizer> createLBPHFaceRecognizer(int radius=1...
               ^
../src/FaceRecognizer.cc:111:19: error: too many arguments to function call,
      expected at most single argument 'num_components', have 2 arguments
      components, threshold
                  ^~~~~~~~~
/usr/local/Cellar/opencv/2.4.0/include/opencv2/contrib/contrib.hpp:949:16: note: 
      'createEigenFaceRecognizer' declared here
    CV_EXPORTS Ptr<FaceRecognizer> createEigenFaceRecognizer(int num_com...
               ^
../src/FaceRecognizer.cc:132:19: error: too many arguments to function call,
      expected at most single argument 'num_components', have 2 arguments
      components, threshold
                  ^~~~~~~~~
/usr/local/Cellar/opencv/2.4.0/include/opencv2/contrib/contrib.hpp:950:16: note: 
      'createFisherFaceRecognizer' declared here
    CV_EXPORTS Ptr<FaceRecognizer> createFisherFaceRecognizer(int num_co...
               ^
../src/FaceRecognizer.cc:218:14: error: no member named 'update' in
      'cv::FaceRecognizer'
  self->rec->update(images, labels);
  ~~~~~~~~~  ^
../src/FaceRecognizer.cc:234:26: error: too many arguments to function call,
      expected single argument 'src', have 3 arguments
  self->rec->predict(im, predictedLabel, confidence);
  ~~~~~~~~~~~~~~~~~~     ^~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/Cellar/opencv/2.4.0/include/opencv2/contrib/contrib.hpp:931:9: note: 
      'predict' declared here
        virtual int predict(InputArray src) const = 0;
        ^
../src/FaceRecognizer.cc:273:26: error: no member named 'getMat' in
      'cv::FaceRecognizer'
  cv::Mat m = self->rec->getMat(key);
              ~~~~~~~~~  ^
7 errors generated.
make: *** [Release/obj.target/opencv/src/FaceRecognizer.o] Error 1
gyp ERR! build error 
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack     at ChildProcess.onExit (/usr/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:267:23)
gyp ERR! stack     at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "clean" "rebuild"
gyp ERR! cwd /Users/gabriellalevine/ardrone-webflight/node_modules/opencv
gyp ERR! node -v v0.10.20
gyp ERR! node-gyp -v v0.10.10
gyp ERR! not ok 
npm ERR! weird error 1
npm ERR! not ok code 0
4

2 回答 2

0

你的错误是这样的:

../src/FaceRecognizer.cc:64:76: error: too many arguments to function call,
      expected at most 4, have 5
  ...f = cv::createLBPHFaceRecognizer(1, 8, 8, 8, 80.0);

因此,您正在编译的 OpenCV 版本与节点模块使用的版本不同。

在这个 opencv 提交createLBPHFaceRecognizer中添加了第五个参数,所以看起来你至少需要 OpenCV ,而你错误提到。v2.4.3v2.4.0

您应该通过运行确保您的brew安装是最新的brew update,然后brew upgrade opencv从 homebrew 中提取最新的 OpenCV,它看起来是v2.4.7.1.

于 2014-01-03T22:50:56.893 回答
0

嗯,在我的情况下是不一样的,但你可以尝试以下。这是我在 Mac OS X 上修复 OpenCV 和 npm opencv 的方法:

  1. 安装自制软件ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. 安装opencvbrew install homebrew/science/opencv

  3. 安装 pkg 配置:brew install pkg-config

  4. 通过运行查找名为opencv.pc的文件的位置mdfind -name opencv.pc

  5. 运行nano .bash_profile并将第 4 步中找到的路径添加到您的 Bash 环境变量中。保存存档。关闭并重新启动终端。

我的 Mac 中的示例:

PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/Cellar/opencv/2.4.12_2/lib/pkgconfig
export PKG_CONFIG_PATH

env | grep PKG_CONFIG_PATH您可以通过在终端中运行来检查是否已配置。

于 2016-05-22T21:51:53.040 回答