Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
Linij committed May 6, 2019
1 parent ebacd4c commit 61166f2
Show file tree
Hide file tree
Showing 15 changed files with 4,406 additions and 0 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/vendor/
28 changes: 28 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
{
"name": "linij/baiduaip",
"description": "baidu ocr aip",
"type": "library",
"license": "MIT",
"keywords": [
"laravel",
"baidu",
"aip"
],
"authors": [
{
"name": "linji",
"email": "[email protected]"
}
],
"require": {
"php": ">=7.0.0"
},
"autoload": {
"classmap": [
"Lib/"
],
"psr-4": {
"Linij\\BaiduAip\\": "src/"
}
}
}
150 changes: 150 additions & 0 deletions src/AipBodyAnalysis.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
<?php
/*
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* Http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

require_once 'Lib/AipBase.php';
class AipBodyAnalysis extends AipBase {

/**
* 人体关键点识别 body_analysis api url
* @var string
*/
private $bodyAnalysisUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_analysis';

/**
* 人体属性识别 body_attr api url
* @var string
*/
private $bodyAttrUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_attr';

/**
* 人流量统计 body_num api url
* @var string
*/
private $bodyNumUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_num';

/**
* 手势识别 gesture api url
* @var string
*/
private $gestureUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/gesture';

/**
* 人像分割 body_seg api url
* @var string
*/
private $bodySegUrl = 'https://aip.baidubce.com/rest/2.0/image-classify/v1/body_seg';



/**
* 人体关键点识别接口
*
* @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
* @param array $options - 可选参数对象,key: value都为string类型
* @description options列表:
* @return array
*/
public function bodyAnalysis($image, $options=array()){

$data = array();

$data['image'] = base64_encode($image);

$data = array_merge($data, $options);

return $this->request($this->bodyAnalysisUrl, $data);
}

/**
* 人体属性识别接口
*
* @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
* @param array $options - 可选参数对象,key: value都为string类型
* @description options列表:
* type gender,<br>age,<br>lower_wear,<br>upper_wear,<br>headwear,<br>glasses,<br>upper_color,<br>lower_color,<br>cellphone,<br>upper_wear_fg,<br>upper_wear_texture,<br>lower_wear_texture,<br>orientation,<br>umbrella,<br>bag,<br>smoke,<br>vehicle,<br>carrying_item,<br>upper_cut,<br>lower_cut,<br>occlusion &#124; 1)可选值说明:<br>gender-性别,<br>age-年龄阶段,<br>lower_wear-下身服饰,<br>upper_wear-上身服饰,<br>headwear-是否戴帽子,<br>glasses-是否戴眼镜,<br>upper_color-上身服饰颜色,<br>lower_color-下身服饰颜色,<br>cellphone-是否使用手机,<br>upper_wear_fg-上身服饰细分类,<br>upper_wear_texture-上身服饰纹理,<br>orientation-身体朝向,<br>umbrella-是否撑伞;<br>bag-背包,<br>smoke-是否吸烟,<br>vehicle-交通工具,<br>carrying_item-是否有手提物,<br>upper_cut-上方截断,<br>lower_cut-下方截断,<br>occlusion-遮挡<br>2)type 参数值可以是可选值的组合,用逗号分隔;**如果无此参数默认输出全部20个属性**
* @return array
*/
public function bodyAttr($image, $options=array()){

$data = array();

$data['image'] = base64_encode($image);

$data = array_merge($data, $options);

return $this->request($this->bodyAttrUrl, $data);
}

/**
* 人流量统计接口
*
* @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
* @param array $options - 可选参数对象,key: value都为string类型
* @description options列表:
* area 特定框选区域坐标,逗号分隔,如‘x1,y1,x2,y2,x3,y3...xn,yn',默认尾点和首点相连做闭合,**此参数为空或无此参数默认识别整个图片的人数**
* show 是否输出渲染的图片,默认不返回,**选true时返回渲染后的图片(base64)**,其它无效值或为空则默认false
* @return array
*/
public function bodyNum($image, $options=array()){

$data = array();

$data['image'] = base64_encode($image);

$data = array_merge($data, $options);

return $this->request($this->bodyNumUrl, $data);
}

/**
* 手势识别接口
*
* @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
* @param array $options - 可选参数对象,key: value都为string类型
* @description options列表:
* @return array
*/
public function gesture($image, $options=array()){

$data = array();

$data['image'] = base64_encode($image);

$data = array_merge($data, $options);

return $this->request($this->gestureUrl, $data);
}

/**
* 人像分割接口
*
* @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
* @param array $options - 可选参数对象,key: value都为string类型
* @description options列表:
* @return array
*/
public function bodySeg($image, $options=array()){

$data = array();

$data['image'] = base64_encode($image);

$data = array_merge($data, $options);

return $this->request($this->bodySegUrl, $data);
}
}
25 changes: 25 additions & 0 deletions src/AipContentCensor.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?php
/*
* Copyright (c) 2017 Baidu.com, Inc. All Rights Reserved
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* Http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/

require_once 'AipImageCensor.php';

/**
* 内容审核
*/
class AipContentCensor extends AipImageCensor{

}
Loading

0 comments on commit 61166f2

Please sign in to comment.