Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
8
Help us understand the problem. What is going on with this article?
@nowmura

Amazon Rekognition をPHPで使って顔のパーツの位置を取得する手順

More than 1 year has passed since last update.

Amazon Rekognition
https://aws.amazon.com/jp/rekognition/

IAM作成

http://docs.aws.amazon.com/ja_jp/rekognition/latest/dg/setting-up.html
上記を参考にIAMを作る。


1.png

2.png

3.png

5.png

PHP7 + AWS SDK for PHP 3(aws.phar) + base64画像

S3上のファイルを指定することもできるようです。

$image = $_POST['image']; //base64エンコードされた画像
$image = explode(',', $image);
$image = $image[ count($image)-1 ];
$image = base64_decode($image);

require('aws.phar');

$o_awsRekognition = new Aws\Rekognition\RekognitionClient([
    'credentials' => array(
        'key'   => '{IAM作成時に取得したAccess key ID}',
        'secret'=> '{IAM作成時に取得したSecret access key}'
    ),
    'region'    => 'us-east-1', //北バージニア。アジアリージョン未対応
    'version'   => 'latest'
]);

$result = $o_awsRekognition->detectFaces([
    'Attributes'=> ['DEFAULT'],  //ALL|DEFAULT。ALLだと重い
    'Image'     => [
        'Bytes' => $image
    ]
]);
$result = (array)$result;

foreach ($result as $line) {
    $result = $line;
    break;
}

$result = json_encode($result);
print $result;

結果

http://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html
Response Syntax参照。

送信した画像はamazon側で保存されるの?

https://aws.amazon.com/jp/rekognition/faqs/
データプライバシーを見る限りされなさそう。

参考URL

http://docs.aws.amazon.com/rekognition/latest/dg/what-is.html
http://docs.aws.amazon.com/rekognition/latest/dg/rekognition-dg.pdf
http://docs.aws.amazon.com/rekognition/latest/dg/API_DetectFaces.html
http://docs.aws.amazon.com/aws-sdk-php/v3/api/api-rekognition-2016-06-27.html#detectfaces
http://docs.aws.amazon.com/ja_jp/rekognition/latest/dg/setting-up.html
http://docs.aws.amazon.com/aws-sdk-php/v3/api/class-Aws.Result.html

8
Help us understand the problem. What is going on with this article?
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
nowmura
自称スーパープログラマー

Comments

No comments
Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account Login
8
Help us understand the problem. What is going on with this article?