// 你的 APPID AK SK
$app_id = ' ';
$api_key = ' ';
$ssecret_key = ' ';
/*
*/
//引入图像识别类
import('identification.AipImageClassify', EXTEND_PATH);
$client = new \AipImageClassify($app_id, $api_key, $ssecret_key);
$request = \think\Request::instance();
$file = $request->root(true) . $image;
$image1 = file_get_contents($file);
// 调用动物识别
$client->animalDetect($image1);
// 如果有可选参数
$options = array();
$options["top_num"] = 3;
$options["baike_num"] = 5;
/**
* 动物识别接口
*
* @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式
* @param array $options - 可选参数对象,key: value都为string类型
* @description options列表:
* top_num 返回预测得分top结果数,默认为6
* baike_num 返回百科信息的结果数,默认不返回
* @return array
*/
// 带参数调用动物识别
$arr =$client->animalDetect($image1, $options);
if (isset($arr['error_code'])) {
return json($this->info('20000', $arr['error_code']));
}