inspirit / jsfeat

JavaScript Computer Vision library.
MIT License
2.74k stars 372 forks source link

node js and jsfeat/cascades #45

Open cybertim opened 9 years ago

cybertim commented 9 years ago

I'm currently using jsfeat in the backend of my project with nodejs. This is working great except for the loading of the cascades modules. Could these modules also be made compatible, like jsfeat.js, with nodejs? (with module.exports)

Nateowami commented 7 years ago

I had trouble with cascades too. jsfeat.bbf.face_cascade is undefined in jsfeat version 0.0.8 from npm. From what I read, the HTML5 canvas dependency was removed, so I'm not sure what the problem is.

However, I was able to get it working by copying node_modules/jsfeat/cascades/bbf_face.js, changing jsfeat.bbf on the third line (which is the last line) to module.exports, and then manually injecting it into jsfeat like so:

jsfeat.bbf.face_cascade = require('./bbf_face.js').face_cascade;

After that you can set it up like normal:

jsfeat.bbf.prepare_cascade(jsfeat.bbf.face_cascade);

I didn't try the HAAR detector, but presumably that's what all the other cascade files are for, and I imagine the same workaround would probably work.