Rで写真に映っている人の年齢を取得する
マイクロソフトの顔認識+性年齢推定サービスが微妙に流行っている。
まあワイワイやるだけならブラウザからで十分なのだが俺にはちょっとやってみたいことがある。
で、どうせweb APIとかあるんだろ???ちょっと叩かせてくれよゲヘヘ???とか探してたらあるにはあったがAzureのmarket placeで該当サービスの登録が必要であり、しかも「お住まいの地域からは登録できません」とか言われて脱力。
仕方ないので類似サービスを探したらFACE++というのを見つけた。
簡単なdeveloper登録を済ませればAPI KEYとSECRETが発行されるので、それを使ってweb APIを叩けば性年齢笑顔と色々な推定結果が得られる。
たとえば新垣結衣さん(女性・26歳)の結果は以下の通り。
> devtools::install_github("dichika/faceplusplus") > library("faceplusplus") > getDetect("http://www.lespros.co.jp/files/talent/4/profile.jpg", secret=YOUR_SECRET, key=YOUR_KEY) attribute.age.range attribute.age.value attribute.gender.confidence attribute.gender.value 1 5 26 99.9999 Female attribute.glass.confidence attribute.glass.value attribute.pose.value attribute.pose.value 1 99.938 None 0 12.819 attribute.pose.value attribute.race.confidence attribute.race.value attribute.value 1 -21.48294 99.5921 Asian 86.1597 face_id position.center.x position.center.y position.eye_left.x 1 fd06a0b4b5840bd31c57439fb0a21c79 40.9375 29.44444 35.44812 position.eye_left.y position.eye_right.x position.eye_right.y position.height 1 22.51881 49.48938 25.35881 27.77778 position.mouth_left.x position.mouth_left.y position.mouth_right.x position.mouth_right.y 1 32.8175 35.45083 46.05812 38.77333 position.nose.x position.nose.y position.width tag 1 38.7525 30.33278 31.25
性年齢の他にメガネ判定とか人種判定とかありますね。
詳細はAPIリファレンスを参照されたし。
http://www.faceplusplus.com/detection_detect/
enjoy!!!