node-opencv/README.md
2012-01-19 18:01:37 -08:00

1.7 KiB

node-opencv

Build Status

OpenCV bindings for Node.js

Install

You'll need OpenCV installed. I'm using v2.2 because I couldn't get 2.3 to compile, but it should theoretically work with 2.3

Then:

    npm install opencv

Or to build the repo:

    node-waf configure && node-waf build

Examples

Face Detection

    var im = new cv.Image("./examples/mona.jpg")
    , face_cascade = new cv.CascadeClassifier("./examples/haarcascade_frontalface_alt.xml")

    var faces = face_cascade.detectMultiScale(im, function(err, faces){
      
      for (var i=0;i<faces.length; i++){
        var x = faces[i]
        im.ellipse(x.x + x.width/2, x.y + x.height/2, x.width/2, x.height/2);
      }
      im.save('./out.jpg');   
             
    }, 1.1, 2, [30, 30]);

WIP

This is a WIP. I've never written C++ before so the code may be interesting - if I'm doing stuff wrong please feel free to correct me.