• OPENCV with NodeJS

    Posted by Himanshu Goyal | Last Updated: 16-May-16

    Intro: OpenCV was introduce by intel corp,it provide the cpu intensive task and used in many application like:

    • 2D and 3D feature toolkits
    • Egomotion estimation
    • Facial recognition system
    • Gesture recognition
    • Human–computer interaction (HCI)
    • Mobile robotics
    • Motion understanding
    • Object identification
    • Segmentation and recognition
    • Stereopsis stereo vision: depth perception from 2 cameras
    • Structure from motion (SFM)
    • Motion tracking

    OpenCV with NodeJS:  opencv in npm module which is used in nodejs to connect with opencv.The nodejs fully support opencv v2.4.5 to v2.4.11. The latest version v.3.0.0 is not yet fully supported and if you install the this version you may get the error in installing node module. 

    • npm install opencv //to install the node module 

    Code for Counting faces and draw eclipse on faces of person:

    var express = require('express');
    var app = express();
    var multipart = require('connect-multiparty');
    var multipartMiddleware = multipart();
    var cv = require('opencv');
    var fs = require('fs');'/upload', multipartMiddleware, function (req, res) {
        console.log("Control in the upload the image", req.files.file.path);
        var filePath = req.files.file.path;
        var fileExtension ='.');
         cv.readImage(filePath, function (err, im) {
            console.log(err, "control in the cv", im);
            im.detectObject(cv.FACE_CASCADE, {}, function (err, faces) {
                console.log("Total number of faces", faces.length);
                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);
                var storeFileName = new Date().getTime();
                var destinationPath = './images/' + storeFileName + "." + fileExtension[fileExtension.length - 1];
                   object:"total number of faces : "+faces.length,
                   message:"See the image with face eclipise on images folder"
    app.listen(4000, function () {
        console.log('Example app listening on port 4000!');




Tags: OpenCV

View All Posts Leave a Comment
comments powered by Disqus

Mobile Applications

Video Content

Bigdata & NoSQL

SaaS Applications



Alexa Certified Site Stats for