detectFace();は,顔検出APIを提供するWebサービスです.
フリーで使えるみたいです.
http://detectface.com/reference.html
APIの引数に画像のURLを指定すると顔のパーツの位置をxmlで返してくれます.
↓nodeで使ってみました.
sample.js
var url = require('url');
var request = require('request');
var che = require('cheerio');
var options1 = {
url: "http://detectface.com/api/detect?画像のURL",
json: true
};
request.get(options1, function (error, response, body1) {
if (!error && response.statusCode == 200) {
$ = che.load(body1);
$("point").each(function (i, el) {
//cheerioを使って,xmlの要素を取り出す
});
} else {
console.log('error: ' + response.statusCode);
}
});
↓ちなみにxmlはこんな感じでかえってきます.
kekka.xml
<?xml version='1.0'?>
<faces>
<face id='0'>
<bounds x='209' y='105' width='195' height='195'/>
<right-eye x='269' y='187'/>
<left-eye x='342' y='171'/>
<features s-avg='0.76' s-min='0.42' s-max='0.91'>
<point id='PR' x='271' y='186' s='0.83'/>
<point id='PL' x='339' y='170' s='0.84'/>
<point id='BR2' x='283' y='162' s='0.83'/>
<point id='BL2' x='321' y='155' s='0.74'/>
<point id='N1' x='302' y='175' s='0.89'/>
<point id='N5' x='316' y='224' s='0.77'/>
<point id='M1' x='326' y='251' s='0.56'/>
<point id='M5' x='331' y='264' s='0.75'/>
<point id='M3' x='304' y='260' s='0.42'/>
<point id='M7' x='354' y='245' s='0.81'/>
<point id='EL4' x='352' y='168' s='0.76'/>
<point id='EL1' x='327' y='179' s='0.89'/>
<point id='ER1' x='285' y='189' s='0.88'/>
<point id='ER4' x='256' y='188' s='0.80'/>
<point id='M2' x='314' y='249' s='0.51'/>
<point id='M8' x='336' y='244' s='0.67'/>
<point id='M4' x='317' y='265' s='0.57'/>
<point id='M6' x='345' y='259' s='0.80'/>
<point id='BR3' x='264' y='161' s='0.85'/>
<point id='BL3' x='334' y='147' s='0.71'/>
<point id='N2' x='292' y='233' s='0.44'/>
<point id='N4' x='335' y='221' s='0.49'/>
<point id='F1' x='291' y='95' s='0.81'/>
<point id='F2' x='237' y='130' s='0.81'/>
<point id='F10' x='345' y='114' s='0.61'/>
<point id='ER2' x='275' y='181' s='0.87'/>
<point id='ER3' x='262' y='184' s='0.79'/>
<point id='ER5' x='265' y='193' s='0.81'/>
<point id='ER6' x='278' y='192' s='0.84'/>
<point id='EL2' x='331' y='168' s='0.87'/>
<point id='EL3' x='346' y='165' s='0.79'/>
<point id='EL5' x='347' y='174' s='0.83'/>
<point id='EL6' x='337' y='178' s='0.87'/>
<point id='BR1' x='284' y='173' s='0.87'/>
<point id='BR4' x='251' y='165' s='0.85'/>
<point id='BR5' x='244' y='175' s='0.82'/>
<point id='BR6' x='257' y='169' s='0.86'/>
<point id='BL1' x='321' y='162' s='0.84'/>
<point id='BL4' x='343' y='146' s='0.78'/>
<point id='BL5' x='350' y='150' s='0.77'/>
<point id='BL6' x='338' y='150' s='0.75'/>
<point id='N3' x='319' y='237' s='0.61'/>
<point id='M9' x='328' y='255' s='0.67'/>
<point id='F3' x='234' y='202' s='0.87'/>
<point id='F9' x='373' y='167' s='0.83'/>
<point id='F4' x='253' y='241' s='0.78'/>
<point id='F8' x='389' y='217' s='0.91'/>
<point id='F6' x='333' y='297' s='0.77'/>
<point id='F5' x='280' y='272' s='0.51'/>
<point id='F7' x='381' y='251' s='0.88'/>
</features>
</face>
</faces>