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

Error loading file at Matrix.matrix.detectObject #93

Closed
agustinhaller opened this issue Nov 28, 2013 · 11 comments
Closed

Error loading file at Matrix.matrix.detectObject #93

agustinhaller opened this issue Nov 28, 2013 · 11 comments

Comments

@agustinhaller
Copy link

Hi, i'm trying to run the examples, but i'm getting some errors when running the face_detection.js file.

Here's what i get:

MacBook-Pro-de-Agustin:examples agustinhaller$ node face_detection.js

/Users/agustinhaller/repos/nodecv.com/node_modules/opencv/lib/opencv.js:29
      var face_cascade = new cv.CascadeClassifier(classifier);
                         ^
TypeError: Error loading file
    at Matrix.matrix.detectObject (/Users/agustinhaller/repos/nodecv.com/node_modules/opencv/lib/opencv.js:29:23)
    at /Users/agustinhaller/repos/nodecv.com/node_modules/opencv/examples/face_detection.js:9:9
    at Object.<anonymous> (/Users/agustinhaller/repos/nodecv.com/node_modules/opencv/examples/face_detection.js:7:4)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3

I'm very new to this, so i don't have much idea which may be the problem. Any help is appreciated!

@agustinhaller
Copy link
Author

My bad, some reference error.

@gossamershadow
Copy link

I was wondering what the resolution to this problem was? I am having the same issue and haven't been able to figure it out.

@gossamershadow
Copy link

For others reference, the problem I had was using "~/" in my file names. I needed to explicitly say which folder the file was in by using "/home/username/" instead.

@dkniffin
Copy link

@agustinhaller I'm also seeing this error. The fix @gossamershadow gave didn't resolve the issue for me. Could you clarify what you did to fix your issue?

@dkniffin
Copy link

lol I guess I'll follow the trend. I fixed my issue on my own as well. Instead of doing this:

var cascade = new opencv.CascadeClassifier("./cascades/hogcascade_cars_sideview.xml");

I gave the filename directly to detectObject:

im.detectObject("./cascades/new_cascade.xml", {}, function(err, detections){

@AVVS
Copy link
Contributor

AVVS commented Apr 22, 2015

that works, or you can do path.resolve(__dirname, 'relative/path/to/classifier.xml')

@dkniffin
Copy link

hmm..will that allow me to load a cascade once, and use it in multiple detect statements?

@AVVS
Copy link
Contributor

AVVS commented Apr 22, 2015

cascades are cached once they are resolved, so it doesn't matter which way you use

@dkniffin
Copy link

Ok, so if I do something like this:

images.each(function(img){
   img.detectObject("../cascades/hogcascade_cars_sideview.xml", {}, function(err, detections){
   ...
   })
})

It'll only load that cascade once?

@AVVS
Copy link
Contributor

AVVS commented Apr 22, 2015

Yes, it will only read file once

https://github.com/peterbraden/node-opencv/blob/master/lib/opencv.js#L16-L28

However, note that after that operation is async, and if you want to track progress use bluebird or async or neo-async, or whatever you prefer for flow control

@dkniffin
Copy link

Ok. I'm still having issues, but I'm gonna open another issue, because at this point it's unrelated.

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

4 participants