Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

face_cascade = new cv.CascadeClassifier(classifier); #20

Closed
datomnurdin opened this issue Sep 4, 2016 · 1 comment
Closed

face_cascade = new cv.CascadeClassifier(classifier); #20

datomnurdin opened this issue Sep 4, 2016 · 1 comment

Comments

@datomnurdin
Copy link

I got this error message when execute node script

/Users/ZERO/node_modules/opencv/lib/opencv.js:22
    face_cascade = new cv.CascadeClassifier(classifier);
                   ^

TypeError: Error loading file
    at TypeError (native)
    at Matrix.detectObject (/Users/ZERO/node_modules/opencv/lib/opencv.js:22:20)
    at /Users/ZERO/RM1/index.js:14:8
    at /Users/ZERO/RM1/index.js:13:6
    at Array.forEach (native)
    at Object.<anonymous> (/Users/ZERO/RM1/index.js:12:12)
    at Module._compile (module.js:409:26)
    at Object.Module._extensions..js (module.js:416:10)
    at Module.load (module.js:343:32)
    at Function.Module._load (module.js:300:12)

My script

var cv = require('opencv');

var color       = [0, 255, 0];
var thickness   = 2;
var cascadeFile = '/Users/ZERO/RM1/classifier/cascade.xml';

var inputFiles = [
  '/Users/ZERO/RM1/recognize/recognize_this_1.jpg', 
  '/Users/ZERO/RM1/recognize/recognize_this_2.jpg', 
  '/Users/ZERO/RM1/recognize/recognize_this_3.jpg',
  '/Users/ZERO/RM1/recognize/recognize_this_4.jpg', 
  '/Users/ZERO/RM1/recognize/recognize_this_5.jpg', 
  '/Users/ZERO/RM1/recognize/recognize_this_6.jpg'
];

inputFiles.forEach(function(fileName) {
  cv.readImage(fileName, function(err, im) {
    im.detectObject(cascadeFile, {neighbors: 2, scale: 2}, function(err, objects) {
      console.log(objects);
      for(var k = 0; k < objects.length; k++) {
        var object = objects[k];
        im.rectangle(
          [object.x, object.y],
          [object.x + object.width, object.y + object.height],
          color,
          2
        );
      }
      im.save(fileName.replace(/\.jpg/, 'processed.jpg'));
    });
  });
});

Please advice. Thank you.

@mrnugget
Copy link
Owner

mrnugget commented Sep 4, 2016

That code is not really part of this repository/tutorial. It seems like the problem is node-opencv here. Check out the node-opencv repository and documentation. A quick search brought me to this issue which seems to be the exact same one you have.

@mrnugget mrnugget closed this as completed Sep 4, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants