尝试在mac mavericks上安装opencv节点时出现gyp错误

时间:2014-01-03 19:53:15

标签: macos opencv osx-mavericks gyp

我正在尝试安装节点opencv,我在mac上运行mavericks。我运行“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

2 个答案:

答案 0 :(得分: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版本与节点模块使用的版本不同。

createLBPHFaceRecognizer的第五个参数已添加in this opencv commit,因此看起来您至少需要OpenCV v2.4.3,而您错误提及v2.4.0

您应该通过运行brew然后brew update来确保您的brew upgrade opencv安装是最新的,以便从自制软件中提取最新的OpenCV,这看起来是{ {1}}。

答案 1 :(得分:0)

嗯,in my case was not the same,但您可以尝试以下操作。 以下是我在Mac OS X上修复OpenCV和npm opencv的方法:

  1. 安装自制程序brew install homebrew/science/opencv

  2. 安装opencv brew install pkg-config

  3. 安装pkg-config:mdfind -name opencv.pc

  4. 运行nano .bash_profile

  5. 查找名为 opencv.pc 的文件的位置
  6. 运行PKG_CONFIG_PATH=$PKG_CONFIG_PATH:/usr/local/Cellar/opencv/2.4.12_2/lib/pkgconfig export PKG_CONFIG_PATH 并将步骤4中找到的路径添加到Bash环境变量中。保存存档。关闭并重新启动终端。

  7. 我的Mac示例:

    env | grep PKG_CONFIG_PATH

    您可以通过在终端中运行'Variables '------------------------------------------------------------------------------- Private Shared VanServArray As Array 'Used to store "vanilla" list of NIST server IPs stored in My.Settings.VanillaServerIPList Private Shared ServArray As Array 'Used to store list of NIST server IPs stored in My.Settings.ServerIPList Private Shared Result As DateTime 'Stores DateTime retrieved from NIST Server Public Shared LastHost As String = "" Public Shared LastSysTime As DateTime 'Stores last available system DateTime 'Functions '------------------------------------------------------------------------------- Public Shared Function GetTime() As DateTime 'Returns UTC/GMT using an NIST server if possible, ' degrading to simply returning the system clock If My.Settings.ServerIPList Is Nothing Then 'If the user modifiable list of NIST server IP addresses IS null (null = TRUE) then 'Put pre-stored, read-only "vanilla" StringsCollection of IP Addresses into the Array ServArray = My.Settings.VanillaServerIPList.Cast(Of String)().ToArray Else 'If the user modifiable list of NIST server IP addresses IS NOT null (null = FALSE) then 'Put the user modifiable StringsCollection of IP Addresses into an Array ServArray = My.Settings.ServerIPList.Cast(Of String)().ToArray End If 'Assign null value to LastHost LastHost = "" 'Runs the "If Then" logic that pings all IPs in the array 'Ping each IP and try to retrieve results For Each IP As String In ServArray Try 'Shows each IP in Debug console Debug.WriteLine(IP, "IP Addresses") If My.Computer.Network.Ping(IP) Then LastHost = IP Result = GetNISTTime(IP) End If Catch ex As Exception 'Return "Sync Error 0x01" MsgBox("There was a sync error while retrieving the updated internet time. Please try again.", MsgBoxStyle.Critical, "Sync Error 0x01") Debug.WriteLine("There was a sync error while retrieving the updated internet time. Please try again.", "Sync Error 0x01") End Try Next 'No server in list was successful so use system time If LastHost = "" Then 'Return "Sync Error 0x02" MsgBox("No server in list returned the time. The sytem time has not been updated.", MsgBoxStyle.Critical, "Sync Error 0x02") Debug.WriteLine("No server in list returned the time. The sytem time has not been updated.", "Sync Error 0x02") Result = DateTime.UtcNow() End If Return Result End Function 来检查是否已配置。