0

I am trying to install node opencv , i'm running mavericks on a mac. i run "npm install opencv" and have tried so many things to fix this problem but can't figure it out. here are my errors: there are also a bunch of warnings but this is the errors before it fails:

similar errors happen when i run node-gyp configure or node-gyp rebuild I tried to get help here: https://github.com/joyent/node/issues/3113 but it didn't help, I still get gyp errors

when running npm install opencv: here is the entire output

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
gabriella
  • 371
  • 1
  • 3
  • 8
  • Is this all of the output, or is there anything else saying what those 7 errors were? – loganfsmyth Jan 03 '14 at 21:49
  • I pasted in the entire output now above ... thanks – gabriella Jan 03 '14 at 22:26
  • Was your issue resolved? I have a similar issue (although I only get warnings instead of errors installing node-opencv). I tried installing old versions of opencv, but that didn't help because they fail the build process. – Gregir May 06 '14 at 16:26

2 Answers2

0

Your errors are things like this:

../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);

So the OpenCV version you are compiling against is different from the one that the node module works with.

The fifth argument to createLBPHFaceRecognizer was added in this opencv commit, so it looks like you will need at least OpenCV v2.4.3, whereas you errors mention v2.4.0.

You should make sure your brew install is full up-to-date by running brew update and then brew upgrade opencv to pull in the most recent OpenCV from homebrew, which looks to be v2.4.7.1.

loganfsmyth
  • 156,129
  • 30
  • 331
  • 251
  • Really? What is all the gyp Err about ? Ok i'll try with older OpenCV version – gabriella Jan 04 '14 at 01:36
  • @gabriella The `gyp` errors say `Error: 'make' failed with exit code: 2`. `make` is one of the tools that Node uses to compile modules from their source C++, so it is failing because of the C++ compilation errors. – loganfsmyth Jan 04 '14 at 01:51
  • ok thanks - i'm installing opencv 2.3.1 now. from the website , can i have two versions of opencv that you know of? – gabriella Jan 04 '14 at 03:24
  • or rather, do you know how i can install 2.3.1 even though i have 2.4 now – gabriella Jan 04 '14 at 03:26
  • I'm not sure what the best way is honestly. – loganfsmyth Jan 04 '14 at 03:45
  • 2.3.1 does not have face recognition – berak Jan 04 '14 at 14:32
  • ok - i'm confused then, because this guy uses node + opencv+ face recognition : https://github.com/paulhayes/copterface - so i am going to ask him, but i'm assuming he is using opencv 2.4 . so i'm still perplexed why i can't install opencv using npm install opencv is that error truly mean i have to downgrade to opencv 2.3.1 or can it be something else? – gabriella Jan 04 '14 at 18:36
  • @berak You are clearly right, sorry I've never used OpenCV. I was just going off the Node module README, which said `v2.3.1`. I've updated my answer with more steps. – loganfsmyth Jan 04 '14 at 19:13
  • Okay, looked into it even more. This is a bug in the Node module. It has a check for adding facial recognition when >2.4, but uses functions only available >2.4.3, so it fails if you are on 2.4.0,2.4.1 , or 2.4.2. Filed a bug: https://github.com/peterbraden/node-opencv/issues/96 – loganfsmyth Jan 04 '14 at 19:28
0

Hm, in my case was not the same, but you can try the following. Here is how I fixed OpenCV and npm opencv on Mac OS X:

  1. install homebrew ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)"

  2. install opencv brew install homebrew/science/opencv

  3. install pkg-config: brew install pkg-config

  4. Find location of file named opencv.pc by running mdfind -name opencv.pc

  5. Run nano .bash_profile and add path found in step 4. to your Bash environment variables. Save file. Close and relaunch Terminal.

Example from my Mac:

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

You can check if configured by running env | grep PKG_CONFIG_PATH in your terminal.

Erik Ušaj
  • 159
  • 6