javascripthtmleye-detection

Eye Detection using javascript and html5


Does anyone have any ideas or steps or algorithms for performing Eye Detection on 2d images using javascript and HTML5?

I have already done converting RGB to YCbCr color space

Now I need some help on eye extraction

function hellow(e)
{
    var r,g,b,a,gray;
    var imageData = ctxBg.createImageData(gameWidth,gameHeight);
    var das =imageData.data;

    for(var i=0;i<=800;i++)
    {
        for(var j=0;j<=640;j++)
        {
            var d = (j*imageData.width+i)*4;
            var helow = ctxBg.getImageData(i,j,1,1);
            r=helow.data[0];
            g=helow.data[1];
            b=helow.data[2];
            a=helow.data[3];
            das[d]=Math.round((0.299 *r) - (0.168935*g) + (0.499813*b));
            das[d+1]=Math.round((0.587 *r) - (0.331665*g) + (0.418531*b));
            das[d+2]=Math.round((0.114 *r) - (0.50059*g) + (0.081282*b));
            das[d+3]=a;
            console.log(das[d]+":"+das[d+1]+":"+das[d+2]);
        }
    }
    ctxBg.putImageData(imageData,0,0);
    //console.log('c');
    e.preventDefault(); 
}

That's my code for converting the rgb to YCbCr color space.

Please help me also improve the code for faster execution.


Solution

  • What i did recently trying to solve same problem was:

    1. Scale down processed image to achieve decent performance (I downscaled everything to 320px width)

    2. Detect face in image using Core Computer Vision Library - https://github.com/liuliu/ccv

    3. Based on the detected face rectangle information detect eyes using HAAR object detector (it has cascade for eyes only detection - https://github.com/inspirit/jsfeat

    For step 2 i also used "grayscale" and "equalize_histogram" from JSFEAT library.

    Also if step 3 fails you can try to guess eyes position (depends on how high accuracy you're going for).

    This workflow gave me satisfying results and performance. It tested it both on desktop (~500ms on iMac) and mobile devices (~3000ms on iphone 4 using image from webcam). Unfortunately I cannot post a link to working example at this point, but i'll post a link to github once i have something there.