Detecting a baby's face using OpenCV

1k views Asked by At

I was trying to write a program which would take pictures from the baby monitor and then detect face using OpenCV. I wanted to add other functionalities based on that. The problem is that it is not able to detect a face very often. The problem may be because in the pictures I ma using, the baby is something eating his hand :P. I wanted to write a program which could find out if the baby had rolled over or had a blanket over his head. Any suggestions for tackling this problem? Will training OpenCV with multiple pictures help my case. Here is the sample program. Although written in nodejs, logic should be the same. Is there some other library/algorithm/approach that can help me achieve this?

var request = require('request');
var cv = require('opencv');

var user =  'admin';
var pass = 'password';
var options = {
    url : 'http://192.168.86.114/cgi-bin/snapshot.cgi',
    method : 'GET',
    port: 80,
    encoding: 'binary',
    headers: { 'Authorization': 'Basic ' + new Buffer(user + ':' + pass).toString('base64') }
}

request( options, function(err, res, html){

    if(err){
        console.log(err)
        return
    }

    require("fs").writeFile("./pictures/out.jpeg", res.body,'binary', function(err) {
      console.log(err);
      cv.readImage("./pictures/out.jpeg", function(err, im){
          im.detectObject(cv.FACE_CASCADE, {}, 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

There are 1 answers

0
Rudy Chp On

Try MTCNN. It is fast and robust.

@ARTICLE{7553523, 
author={K. Zhang and Z. Zhang and Z. Li and Y. Qiao}, 
journal={IEEE Signal Processing Letters}, 
title={Joint Face Detection and Alignment Using Multitask Cascaded Convolutional Networks}, 
year={2016}, 
volume={23}, 
number={10}, 
pages={1499-1503}, 
keywords={Benchmark testing;Computer architecture;Convolution;Detectors;Face;Face detection;Training;Cascaded convolutional neural network (CNN);face alignment;face detection}, 
doi={10.1109/LSP.2016.2603342}, 
ISSN={1070-9908}, 
month={Oct},}