├── .idea ├── ai.iml ├── inspectionProfiles │ └── profiles_settings.xml ├── modules.xml └── workspace.xml ├── README.md ├── ai_use.sql ├── config ├── AipFace.php ├── AipImageCensor.php ├── AipImageClassify.php ├── AipImageSearch.php ├── AipKg.php ├── AipNlp.php ├── AipOcr.php ├── AipSpeech.php ├── database.php ├── image.php ├── lib │ ├── 15e8cea06b1af4cfaea634b6415014ca │ ├── 185b48c05443ec47c61cb4e8db299fa8 │ ├── 72a0202dfc3207b84f0ac644bce32fd4 │ ├── 7ec61eb54e899ef423189e85c0666216 │ ├── AipBCEUtil.php │ ├── AipBase.php │ ├── AipHttpClient.php │ ├── AipImageUtil.php │ └── d74c87a631288137ae7fc2f0d5460477 └── rain_function.php ├── face_compare.php ├── face_detect.php ├── header.php ├── image_identification.php ├── ocr_all.php ├── public ├── assets │ ├── css │ │ ├── admin.css │ │ ├── amazeui.flat.min.css │ │ ├── amazeui.min.css │ │ └── app.css │ ├── fonts │ │ ├── FontAwesome.otf │ │ ├── fontawesome-webfont.eot │ │ ├── fontawesome-webfont.ttf │ │ ├── fontawesome-webfont.woff │ │ └── fontawesome-webfont.woff2 │ ├── i │ │ ├── app-icon72x72@2x.png │ │ ├── examples │ │ │ ├── admin-chrome.png │ │ │ ├── admin-firefox.png │ │ │ ├── admin-ie.png │ │ │ ├── admin-opera.png │ │ │ ├── admin-safari.png │ │ │ ├── adminPage.png │ │ │ ├── blogPage.png │ │ │ ├── landing.png │ │ │ ├── landingPage.png │ │ │ ├── loginPage.png │ │ │ └── sidebarPage.png │ │ ├── favicon.png │ │ └── startup-640x1096.png │ └── js │ │ ├── amazeui.ie8polyfill.min.js │ │ ├── amazeui.min.js │ │ ├── amazeui.widgets.helper.min.js │ │ ├── app.js │ │ └── handlebars.min.js ├── css │ ├── reset.css │ └── style.css ├── face2.jpg ├── face3.jpg ├── js │ ├── jquery-1.11.0.min.js │ ├── main.js │ └── modernizr-custom.js └── logo.ico ├── rain_ai.sql ├── sound.php ├── text_affections.php └── text_similarity.php /.idea/ai.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 5 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/workspace.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 1513329261654 21 | 25 | 26 | 27 | 28 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Rain-AI系统基于百度人工智能接口二次开发 2 | ## 有需要做毕设或购买其他成品的可以加QQ联系:641351484 3 | 4 | # 突然发现忘记放测试地址,[ai.rain1024.com](http://ai.rain1024.com) 5 | # 说明:这个代码是原生PHP开发的,在6个月前我为了效率和安全性能使用框架进行重写,测试站里的是框架版本 6 | ## 百度云免费开放了大量的人工智能接口,并且配置了详尽的说明文档和SDK,我用PHP将其中大部分接口封装好,只要在config里的rain_function.php中添加自己的密钥就可以使用,我还添加了使用记录功能,用户每次使用都会在数据库中记录IP等各种信息,还有对每日使用次数也进行了限制,你可以自由更改所需要限制的次数,根据这两个数据库请自行开发后台程序,就可以监测用户使用情况,界面UI也修改了很多遍,可以完美使用。 7 | ## 里面已经包含的功能有人脸检测,人脸对比,语音合成,文字识别,动物识别,植物识别,车辆识别,Logo识别,自然语言处理的情感分析,词法分析,文本对比,评论观点抽取,DNN模型等八个功能。 8 | ## 这个项目是使用原生PHP写的,效率让人担忧,所以今后不再维护,我最近在用thinkphp进行重写,到时候全面采用ajax请求,会提高很多效率,敬请期待。 9 | ## 下面是使用效果图 10 | 11 | ![](http://cos.rain1024.com/blog/php/php45.jpg) 12 | 13 | ![](http://cos.rain1024.com/blog/php/php46.jpg) 14 | 15 | ![](http://cos.rain1024.com/blog/php/php47.jpg) 16 | 17 | ![](http://cos.rain1024.com/blog/php/php48.jpg) 18 | 19 | ![](http://cos.rain1024.com/blog/php/php49.jpg) 20 | 21 | ![](http://cos.rain1024.com/blog/php/php50.jpg) 22 | 23 | ![](http://cos.rain1024.com/blog/php/php51.jpg) 24 | 25 | ![](http://cos.rain1024.com/blog/php/php52.jpg) 26 | 27 | ![](http://cos.rain1024.com/blog/php/php53.jpg) 28 | 29 | ![](http://cos.rain1024.com/blog/php/php54.jpg) 30 | 31 | ![](http://cos.rain1024.com/blog/php/php55.jpg) 32 | 33 | ![](http://cos.rain1024.com/blog/php/php56.jpg) 34 | 35 | ![](http://cos.rain1024.com/blog/php/php57.jpg) 36 | 37 | ![](http://cos.rain1024.com/blog/php/php58.jpg) 38 | 39 | ![](http://cos.rain1024.com/blog/php/php59.jpg) 40 | 41 | ![](http://cos.rain1024.com/blog/php/php60.jpg) 42 | -------------------------------------------------------------------------------- /ai_use.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : 本地数据库 5 | Source Server Version : 50547 6 | Source Host : localhost:3306 7 | Source Database : rain 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50547 11 | File Encoding : 65001 12 | 13 | Date: 2018-04-23 13:29:45 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for `ai_use` 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `ai_use`; 22 | CREATE TABLE `ai_use` ( 23 | `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '人工智能识别数据表', 24 | `add_time` char(255) DEFAULT NULL, 25 | `ip` char(255) DEFAULT NULL, 26 | `address` char(255) DEFAULT NULL, 27 | `status` char(255) DEFAULT NULL, 28 | `image1` char(255) DEFAULT NULL, 29 | `image2` char(255) DEFAULT NULL, 30 | `state` int(11) DEFAULT NULL, 31 | PRIMARY KEY (`id`) 32 | ) ENGINE=MyISAM DEFAULT CHARSET=utf8; 33 | 34 | -- ---------------------------- 35 | -- Records of ai_use 36 | -- ---------------------------- 37 | -------------------------------------------------------------------------------- /config/AipFace.php: -------------------------------------------------------------------------------- 1 | request($this->detectUrl, $data); 111 | } 112 | 113 | /** 114 | * 图片 array base64 encode 115 | * @param array $images 116 | * @return string 117 | */ 118 | private function getEncodeImages($images){ 119 | if(is_string($images)){ 120 | return base64_encode(trim($images)); 121 | } 122 | 123 | $result = array(); 124 | foreach($images as $image){ 125 | if(!empty($image)){ 126 | $result[] = base64_encode($image); 127 | } 128 | } 129 | 130 | return $result; 131 | } 132 | 133 | /** 134 | * 两两比对 135 | * @param array $images 136 | * @param array $options 137 | * @return array 138 | */ 139 | public function match($images, $options=array()){ 140 | $data = array(); 141 | $data['images'] = $images; 142 | 143 | $data = array_merge($data, $options); 144 | 145 | return $this->request($this->matchUrl, $data); 146 | } 147 | 148 | /** 149 | * 格式检查 150 | * @param string $url 151 | * @param array $data 152 | * @return array 153 | */ 154 | protected function validate($url, &$data){ 155 | 156 | // user_info参数 不超过256B 157 | if(isset($data['user_info'])){ 158 | 159 | if(strlen($data['user_info']) > 256){ 160 | return array( 161 | 'error_code' => 'SDK103', 162 | 'error_msg' => 'user_info size error', 163 | ); 164 | } 165 | } 166 | 167 | // group_id参数 组成为字母/数字/下划线,且不超过48B 168 | if(isset($data['group_id'])){ 169 | 170 | if(is_array($data['group_id'])){ 171 | $groupIds = $data['group_id']; 172 | }else{ 173 | $groupIds = array( 174 | $data['group_id'], 175 | ); 176 | } 177 | 178 | foreach($groupIds as $groupId){ 179 | if(!preg_match('/^\w+$/', $groupId)){ 180 | return array( 181 | 'error_code' => 'SDK104', 182 | 'error_msg' => 'group_id format error', 183 | ); 184 | } 185 | 186 | if(strlen($groupId) > 48){ 187 | return array( 188 | 'error_code' => 'SDK105', 189 | 'error_msg' => 'group_id size error', 190 | ); 191 | } 192 | } 193 | 194 | $data['group_id'] = implode(',', $groupIds); 195 | } 196 | 197 | // uid参数 组成为字母/数字/下划线,且不超过128B 198 | if(isset($data['uid'])){ 199 | if(!preg_match('/^\w+$/', $data['uid'])){ 200 | return array( 201 | 'error_code' => 'SDK106', 202 | 'error_msg' => 'uid format error', 203 | ); 204 | } 205 | 206 | if(strlen($data['uid']) > 128){ 207 | return array( 208 | 'error_code' => 'SDK107', 209 | 'error_msg' => 'uid size error', 210 | ); 211 | } 212 | } 213 | 214 | if(isset($data['image'])){ 215 | $data['image'] = $this->getEncodeImages($data['image']); 216 | 217 | //编码后小于10m 218 | if(empty($data['image']) || strlen($data['image']) >= 10 * 1024 * 1024){ 219 | return array( 220 | 'error_code' => 'SDK100', 221 | 'error_msg' => 'image size error', 222 | ); 223 | } 224 | }elseif(isset($data['images'])){ 225 | $images = $this->getEncodeImages($data['images']); 226 | $data['images'] = implode(',', $images); 227 | 228 | // 人脸比对 编码后小于20m 其他 10m 229 | if($url == $this->matchUrl){ 230 | if(count($images) < 2 || strlen($data['images']) >= 20 * 1024 * 1024){ 231 | return array( 232 | 'error_code' => 'SDK100', 233 | 'error_msg' => 'image size error', 234 | ); 235 | } 236 | }else{ 237 | if(count($images) < 1 || strlen($data['images']) >= 10 * 1024 * 1024){ 238 | return array( 239 | 'error_code' => 'SDK100', 240 | 'error_msg' => 'image size error', 241 | ); 242 | } 243 | } 244 | } 245 | 246 | return true; 247 | } 248 | 249 | /** 250 | * 添加用户 251 | * @param string $uid 252 | * @param string $userInfo 253 | * @param string $groupId 254 | * @param array $image 255 | * @param array $options 256 | * @return array 257 | */ 258 | public function addUser($uid, $userInfo, $groupId, $image, $options=array()){ 259 | 260 | $data = array(); 261 | $data['uid'] = $uid; 262 | $data['user_info'] = $userInfo; 263 | $data['group_id'] = $groupId; 264 | $data['image'] = $image; 265 | 266 | $data = array_merge($data, $options); 267 | 268 | return $this->request($this->addUserUrl, $data); 269 | } 270 | 271 | /** 272 | * 更新用户 273 | * @param string $uid 274 | * @param string $userInfo 275 | * @param string $groupId 276 | * @param array $images 277 | * @return array 278 | */ 279 | public function updateUser($uid, $userInfo, $groupId, $image){ 280 | 281 | $data = array(); 282 | $data['uid'] = $uid; 283 | $data['user_info'] = $userInfo; 284 | $data['group_id'] = $groupId; 285 | $data['image'] = $image; 286 | 287 | return $this->request($this->updateUserUrl, $data); 288 | } 289 | 290 | /** 291 | * 删除用户 292 | * @param string $uid 293 | * @param string $groupId 294 | * @return array 295 | */ 296 | public function deleteUser($uid, $options=array()){ 297 | 298 | $data = array(); 299 | $data['uid'] = $uid; 300 | 301 | $data = array_merge($data, $options); 302 | 303 | return $this->request($this->deleteUserUrl, $data); 304 | } 305 | 306 | /** 307 | * 认证用户 308 | * @param string $uid 309 | * @param array $images 310 | * @param array $options 311 | * @return array 312 | */ 313 | public function verifyUser($uid, $groupId, $image, $options=array()){ 314 | 315 | $data = array(); 316 | $data['uid'] = $uid; 317 | $data['group_id'] = $groupId; 318 | $data['image'] = $image; 319 | 320 | $data = array_merge($data, $options); 321 | 322 | return $this->request($this->verifyUserUrl, $data); 323 | } 324 | 325 | /** 326 | * 识别用户 327 | * @param string $groupId 328 | * @param array $image 329 | * @param array $options 330 | * @return array 331 | */ 332 | public function identifyUser($groupId, $image, $options=array()){ 333 | $data = array(); 334 | $data['group_id'] = $groupId; 335 | $data['image'] = $image; 336 | 337 | $data = array_merge($data, $options); 338 | 339 | return $this->request($this->identifyUserUrl, $data); 340 | } 341 | 342 | /** 343 | * 用户信息查询 344 | * @param string $uid 345 | * @param array $options 346 | * @return array 347 | */ 348 | public function getUser($uid, $options=array()){ 349 | 350 | $data = array(); 351 | $data['uid'] = $uid; 352 | 353 | $data = array_merge($data, $options); 354 | 355 | return $this->request($this->getUserUrl, $data); 356 | } 357 | 358 | /** 359 | * APP下组列表查询 360 | * @param array $options 361 | * @return array 362 | */ 363 | public function getGroupList($options=array()){ 364 | 365 | $data = array(); 366 | 367 | $data = array_merge($data, $options); 368 | 369 | return $this->request($this->getGroupListUrl, $data); 370 | } 371 | 372 | /** 373 | * 组内用户列表查询 374 | * @param string $groupId 375 | * @param array $options 376 | * @return array 377 | */ 378 | public function getGroupUsers($groupId, $options=array()){ 379 | 380 | $data = array(); 381 | $data['group_id'] = $groupId; 382 | 383 | $data = array_merge($data, $options); 384 | 385 | return $this->request($this->getGroupUsersUrl, $data); 386 | } 387 | 388 | /** 389 | * 组内添加用户 390 | * @param string $srcGroupId 391 | * @param string $dstGroupId 392 | * @param string $uid 393 | * @return array 394 | */ 395 | public function addGroupUser($srcGroupId, $dstGroupId, $uid){ 396 | 397 | $data = array(); 398 | $data['src_group_id'] = $srcGroupId; 399 | $data['group_id'] = $dstGroupId; 400 | $data['uid'] = $uid; 401 | 402 | return $this->request($this->addGroupUserUrl, $data); 403 | } 404 | 405 | /** 406 | * 组内删除用户 407 | * @param string $groupId 408 | * @param string $uid 409 | * @return array 410 | */ 411 | public function deleteGroupUser($groupId, $uid){ 412 | 413 | $data = array(); 414 | $data['group_id'] = $groupId; 415 | $data['uid'] = $uid; 416 | 417 | return $this->request($this->deleteGroupUserUrl, $data); 418 | } 419 | 420 | } 421 | -------------------------------------------------------------------------------- /config/AipImageCensor.php: -------------------------------------------------------------------------------- 1 | request($this->antiPornUrl, $data); 63 | } 64 | 65 | /** 66 | * @param string $image 图像读取 67 | * @return array 68 | */ 69 | public function multi_antiporn($images){ 70 | 71 | $data = array(); 72 | foreach($images as $image){ 73 | $data[] = array( 74 | 'image' => base64_encode($image), 75 | ); 76 | } 77 | 78 | return $this->multi_request($this->antiPornUrl, $data); 79 | } 80 | 81 | /** 82 | * 格式检查 83 | * @param string $url 84 | * @param array $data 85 | * @return array 86 | */ 87 | protected function validate($url, &$data){ 88 | 89 | if(!is_array($data)){ 90 | return true; 91 | } 92 | 93 | if(isset($data['images'])){ 94 | $imageB64s = array(); 95 | foreach($data['images'] as $image){ 96 | $imageInfo = AipImageUtil::getImageInfo($image); 97 | 98 | //图片格式检查 99 | if(!in_array($imageInfo['mime'], array('image/jpeg', 'image/png', 'image/bmp', 'image/gif'))){ 100 | return array( 101 | 'error_code' => 'SDK109', 102 | 'error_msg' => 'unsupported image format', 103 | ); 104 | } 105 | 106 | //编码后小于4m 107 | $imageB64 = base64_encode($image); 108 | if(strlen($imageB64) >= 4 * 1024 * 1024){ 109 | return array( 110 | 'error_code' => 'SDK100', 111 | 'error_msg' => 'image size error', 112 | ); 113 | } 114 | 115 | $imageB64s[] = $imageB64; 116 | } 117 | 118 | $data['images'] = implode(',', $imageB64s); 119 | }else if(isset($data['image'])){ 120 | $imageInfo = AipImageUtil::getImageInfo($data['image']); 121 | $data['image'] = base64_encode($data['image']); 122 | 123 | //Gif 格式校验 124 | if($url == $this->antiPornGifUrl){ 125 | 126 | if($imageInfo['mime'] != 'image/gif'){ 127 | return array( 128 | 'error_code' => 'SDK109', 129 | 'error_msg' => 'unsupported image format', 130 | ); 131 | } 132 | 133 | return true; 134 | } 135 | 136 | //图片格式检查 137 | if(!in_array($imageInfo['mime'], array('image/jpeg', 'image/png', 'image/bmp', 'image/gif'))){ 138 | return array( 139 | 'error_code' => 'SDK109', 140 | 'error_msg' => 'unsupported image format', 141 | ); 142 | } 143 | 144 | //编码后小于4m 145 | if(strlen($data['image']) >= 4 * 1024 * 1024){ 146 | return array( 147 | 'error_code' => 'SDK100', 148 | 'error_msg' => 'image size error', 149 | ); 150 | } 151 | 152 | } 153 | 154 | return true; 155 | } 156 | 157 | /** 158 | * @param string $image 图像读取 159 | * @return array 160 | */ 161 | public function antiPornGif($image){ 162 | 163 | $data = array(); 164 | $data['image'] = $image; 165 | 166 | return $this->request($this->antiPornGifUrl, $data); 167 | } 168 | 169 | /** 170 | * @param string $image 图像读取 171 | * @return array 172 | */ 173 | public function antiTerror($image){ 174 | 175 | $data = array(); 176 | $data['image'] = $image; 177 | 178 | return $this->request($this->antiTerrorUrl, $data); 179 | } 180 | 181 | /** 182 | * @param string $images 图像读取 183 | * @return array 184 | */ 185 | public function faceAudit($images, $configId=''){ 186 | 187 | // 非数组则处理为数组 188 | if(!is_array($images)){ 189 | $images = array( 190 | $images, 191 | ); 192 | } 193 | 194 | $data = array( 195 | 'configId' => $configId, 196 | ); 197 | 198 | $isUrl = substr(trim($images[0]), 0, 4) === 'http'; 199 | if(!$isUrl){ 200 | $data['images'] = $images; 201 | }else{ 202 | $urls = array(); 203 | 204 | foreach($images as $url){ 205 | $urls[] = urlencode($url); 206 | } 207 | 208 | $data['imgUrls'] = implode(',', $urls); 209 | } 210 | 211 | return $this->request($this->faceAuditUrl, $data); 212 | } 213 | 214 | /** 215 | * @param string $image 图像读取 216 | * @return array 217 | */ 218 | public function imageCensorComb($image, $scenes='antiporn', $options=array()){ 219 | 220 | $scenes = !is_array($scenes) ? explode(',', $scenes) : $scenes; 221 | 222 | $data = array( 223 | 'scenes' => $scenes, 224 | ); 225 | 226 | $isUrl = substr(trim($image), 0, 4) === 'http'; 227 | if(!$isUrl){ 228 | $data['image'] = base64_encode($image); 229 | }else{ 230 | $data['imgUrl'] = $image; 231 | } 232 | 233 | $data = array_merge($data, $options); 234 | 235 | return $this->request($this->imageCensorCombUrl, json_encode($data), array( 236 | 'Content-Type' => 'application/json', 237 | )); 238 | } 239 | } 240 | -------------------------------------------------------------------------------- /config/AipImageClassify.php: -------------------------------------------------------------------------------- 1 | request($this->dishDetectUrl, $data); 92 | } 93 | 94 | /** 95 | * 车辆识别接口 96 | * 该请求用于检测一张车辆图片的具体车型。即对于输入的一张图片(可正常解码,且长宽比适宜),输出图片的车辆品牌及型号。 97 | * 98 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 99 | * @param array $options - 可选参数对象,key: value都为string类型 100 | * @description options列表: 101 | * top_num 返回预测得分top结果数,默认为5 102 | * @return array 103 | */ 104 | public function carDetect($image, $options=array()) { 105 | $data = array(); 106 | 107 | $data['image'] = base64_encode($image); 108 | 109 | $data = array_merge($data, $options); 110 | 111 | return $this->request($this->carDetectUrl, $data); 112 | } 113 | 114 | /** 115 | * logo商标识别接口 116 | * 该请求用于检测和识别图片中的品牌LOGO信息。即对于输入的一张图片(可正常解码,且长宽比适宜),输出图片中LOGO的名称、位置和置信度。 当效果欠佳时,可以建立子库(请加入QQ群:649285136 联系工作人员申请建库)并自定义logo入库,提高识别效果。 117 | * 118 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 119 | * @param array $options - 可选参数对象,key: value都为string类型 120 | * @description options列表: 121 | * custom_lib 是否只使用自定义logo库的结果,默认false:返回自定义库+默认库的识别结果 122 | * @return array 123 | */ 124 | public function logoSearch($image, $options=array()) { 125 | $data = array(); 126 | 127 | $data['image'] = base64_encode($image); 128 | 129 | $data = array_merge($data, $options); 130 | 131 | return $this->request($this->logoSearchUrl, $data); 132 | } 133 | 134 | /** 135 | * logo商标识别—添加接口 136 | * 该接口尚在邀测阶段,使用该接口之前需要线下联系工作人员完成建库方可使用,请加入QQ群:649285136 联系相关人员。 137 | * 138 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式* 139 | * @param string $brief - brief,检索时带回。此处要传对应的name与code字段,name长度小于100B,code长度小于150B 140 | * @param array $options - 可选参数对象,key: value都为string类型 141 | * @description options列表: 142 | * @return array 143 | */ 144 | public function logoAdd($image, $brief, $options=array()) { 145 | $data = array(); 146 | 147 | $data['image'] = base64_encode($image); 148 | $data['brief'] = $brief; 149 | 150 | $data = array_merge($data, $options); 151 | 152 | return $this->request($this->logoAddUrl, $data); 153 | } 154 | 155 | /** 156 | * logo商标识别—删除接口 157 | * 该接口尚在邀测阶段,使用该接口之前需要线下联系工作人员完成建库方可使用,请加入QQ群:649285136 联系相关人员。 158 | * 159 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 160 | * @param array $options - 可选参数对象,key: value都为string类型 161 | * @description options列表: 162 | * @return array 163 | */ 164 | public function logoDeleteByImage($image, $options=array()) { 165 | $data = array(); 166 | 167 | $data['image'] = base64_encode($image); 168 | 169 | $data = array_merge($data, $options); 170 | 171 | return $this->request($this->logoDeleteUrl, $data); 172 | } 173 | 174 | /** 175 | * logo商标识别—删除接口 176 | * 该接口尚在邀测阶段,使用该接口之前需要线下联系工作人员完成建库方可使用,请加入QQ群:649285136 联系相关人员。 177 | * 178 | * @param string $contSign - 图片签名(和image二选一,image优先级更高) 179 | * @param array $options - 可选参数对象,key: value都为string类型 180 | * @description options列表: 181 | * @return array 182 | */ 183 | public function logoDeleteBySign($contSign, $options=array()) { 184 | $data = array(); 185 | 186 | $data['cont_sign'] = $contSign; 187 | 188 | $data = array_merge($data, $options); 189 | 190 | return $this->request($this->logoDeleteUrl, $data); 191 | } 192 | 193 | /** 194 | * 动物识别接口 195 | * 该请求用于识别一张图片。即对于输入的一张图片(可正常解码,且长宽比适宜),输出动物识别结果 196 | * 197 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 198 | * @param array $options - 可选参数对象,key: value都为string类型 199 | * @description options列表: 200 | * top_num 返回预测得分top结果数,默认为6 201 | * @return array 202 | */ 203 | public function animalDetect($image, $options=array()) { 204 | $data = array(); 205 | 206 | $data['image'] = base64_encode($image); 207 | 208 | $data = array_merge($data, $options); 209 | 210 | return $this->request($this->animalDetectUrl, $data); 211 | } 212 | 213 | /** 214 | * 植物识别接口 215 | * 该请求用于识别一张图片。即对于输入的一张图片(可正常解码,且长宽比适宜),输出植物识别结果。 216 | * 217 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 218 | * @param array $options - 可选参数对象,key: value都为string类型 219 | * @description options列表: 220 | * @return array 221 | */ 222 | public function plantDetect($image, $options=array()) { 223 | $data = array(); 224 | 225 | $data['image'] = base64_encode($image); 226 | 227 | $data = array_merge($data, $options); 228 | 229 | return $this->request($this->plantDetectUrl, $data); 230 | } 231 | 232 | /** 233 | * 图像主体检测接口 234 | * 用户向服务请求检测图像中的主体位置。 235 | * 236 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 237 | * @param array $options - 可选参数对象,key: value都为string类型 238 | * @description options列表: 239 | * with_face 如果检测主体是人,主体区域是否带上人脸部分,0-不带人脸区域,其他-带人脸区域,裁剪类需求推荐带人脸,检索/识别类需求推荐不带人脸。默认取1,带人脸。 240 | * @return array 241 | */ 242 | public function objectDetect($image, $options=array()) { 243 | $data = array(); 244 | 245 | $data['image'] = base64_encode($image); 246 | 247 | $data = array_merge($data, $options); 248 | 249 | return $this->request($this->objectDetectUrl, $data); 250 | } 251 | 252 | } -------------------------------------------------------------------------------- /config/AipImageSearch.php: -------------------------------------------------------------------------------- 1 | request($this->sameHqAddUrl, $data); 80 | } 81 | 82 | /** 83 | * 相同图检索—检索接口 84 | * 使用该接口前,请加入QQ群:649285136 ,联系工作人员完成建库。 85 | * 86 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 87 | * @param array $options - 可选参数对象,key: value都为string类型 88 | * @description options列表: 89 | * @return array 90 | */ 91 | public function sameHqSearch($image, $options=array()) { 92 | $data = array(); 93 | 94 | $data['image'] = base64_encode($image); 95 | 96 | $data = array_merge($data, $options); 97 | 98 | return $this->request($this->sameHqSearchUrl, $data); 99 | } 100 | 101 | /** 102 | * 相同图检索—删除接口 103 | * 删除相同图 104 | * 105 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 106 | * @param array $options - 可选参数对象,key: value都为string类型 107 | * @description options列表: 108 | * @return array 109 | */ 110 | public function sameHqDeleteByImage($image, $options=array()) { 111 | $data = array(); 112 | 113 | $data['image'] = base64_encode($image); 114 | 115 | $data = array_merge($data, $options); 116 | 117 | return $this->request($this->sameHqDeleteUrl, $data); 118 | } 119 | 120 | /** 121 | * 相同图检索—删除接口 122 | * 删除相同图 123 | * 124 | * @param string $contSign - 图片签名(和image二选一,image优先级更高) 125 | * @param array $options - 可选参数对象,key: value都为string类型 126 | * @description options列表: 127 | * @return array 128 | */ 129 | public function sameHqDeleteBySign($contSign, $options=array()) { 130 | $data = array(); 131 | 132 | $data['cont_sign'] = $contSign; 133 | 134 | $data = array_merge($data, $options); 135 | 136 | return $this->request($this->sameHqDeleteUrl, $data); 137 | } 138 | 139 | /** 140 | * 相似图检索—入库接口 141 | * 该请求用于实时检索相似图片集合。即对于输入的一张图片(可正常解码,且长宽比适宜),返回自建图库中相似的图片集合。相似图检索包含入库、检索、删除三个子接口;**在正式使用之前请加入QQ群:649285136 联系工作人员完成建库并调用入库接口完成图片入库**。 142 | * 143 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 144 | * @param array $options - 可选参数对象,key: value都为string类型 145 | * @description options列表: 146 | * brief 检索时原样带回,最长256B。 147 | * @return array 148 | */ 149 | public function similarAdd($image, $options=array()) { 150 | $data = array(); 151 | 152 | $data['image'] = base64_encode($image); 153 | 154 | $data = array_merge($data, $options); 155 | 156 | return $this->request($this->similarAddUrl, $data); 157 | } 158 | 159 | /** 160 | * 相似图检索—检索接口 161 | * 使用该接口前,请加入QQ群:649285136 ,联系工作人员完成建库。 162 | * 163 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 164 | * @param array $options - 可选参数对象,key: value都为string类型 165 | * @description options列表: 166 | * @return array 167 | */ 168 | public function similarSearch($image, $options=array()) { 169 | $data = array(); 170 | 171 | $data['image'] = base64_encode($image); 172 | 173 | $data = array_merge($data, $options); 174 | 175 | return $this->request($this->similarSearchUrl, $data); 176 | } 177 | 178 | /** 179 | * 相似图检索—删除接口 180 | * 删除相似图 181 | * 182 | * @param string $image - 图像数据,base64编码,要求base64编码后大小不超过4M,最短边至少15px,最长边最大4096px,支持jpg/png/bmp格式 183 | * @param array $options - 可选参数对象,key: value都为string类型 184 | * @description options列表: 185 | * @return array 186 | */ 187 | public function similarDeleteByImage($image, $options=array()) { 188 | $data = array(); 189 | 190 | $data['image'] = base64_encode($image); 191 | 192 | $data = array_merge($data, $options); 193 | 194 | return $this->request($this->similarDeleteUrl, $data); 195 | } 196 | 197 | /** 198 | * 相似图检索—删除接口 199 | * 删除相似图 200 | * 201 | * @param string $contSign - 图片签名(和image二选一,image优先级更高) 202 | * @param array $options - 可选参数对象,key: value都为string类型 203 | * @description options列表: 204 | * @return array 205 | */ 206 | public function similarDeleteBySign($contSign, $options=array()) { 207 | $data = array(); 208 | 209 | $data['cont_sign'] = $contSign; 210 | 211 | $data = array_merge($data, $options); 212 | 213 | return $this->request($this->similarDeleteUrl, $data); 214 | } 215 | 216 | } -------------------------------------------------------------------------------- /config/AipKg.php: -------------------------------------------------------------------------------- 1 | request($this->getUserTasksUrl, $data); 72 | } 73 | 74 | /** 75 | * @param int $taskId 任务ID 76 | * @return array 77 | */ 78 | public function getTaskInfo($taskId){ 79 | 80 | $data = array(); 81 | $data['id'] = $taskId; 82 | 83 | return $this->request($this->getTaskInfoUrl, $data); 84 | } 85 | 86 | /** 87 | * @param string $name 88 | * @param string $tplStr 89 | * @param string $inputMapping 90 | * @param string $outputFile 91 | * @param string $urlPattern 92 | * @param array $options 可选参数 93 | * @return array 94 | */ 95 | public function createTask( 96 | $name, 97 | $tplStr, 98 | $inputMapping, 99 | $outputFile, 100 | $urlPattern, 101 | $options=array() 102 | ){ 103 | 104 | $data = array(); 105 | $data['name'] = $name; 106 | $data['template_content'] = $tplStr; 107 | $data['input_mapping_file'] = $inputMapping; 108 | $data['url_pattern'] = $urlPattern; 109 | $data['output_file'] = $outputFile; 110 | 111 | $data = array_merge($data, $options); 112 | 113 | return $this->request($this->createTaskUrl, $data); 114 | } 115 | 116 | /** 117 | * @param int $taskId 任务ID 118 | * @param array $options 可选参数 119 | * @return array 120 | */ 121 | public function updateTask($taskId, $options=array()){ 122 | 123 | $data = array(); 124 | $data['id'] = $taskId; 125 | 126 | $data = array_merge($data, $options); 127 | 128 | return $this->request($this->updateTaskUrl, $data); 129 | } 130 | 131 | /** 132 | * @param int $taskId 任务ID 133 | * @return array 134 | */ 135 | public function startTask($taskId){ 136 | 137 | $data = array(); 138 | $data['id'] = $taskId; 139 | 140 | return $this->request($this->startTaskUrl, $data); 141 | } 142 | 143 | /** 144 | * @param int $taskId 任务ID 145 | * @return array 146 | */ 147 | public function getTaskStatus($taskId){ 148 | 149 | $data = array(); 150 | $data['id'] = $taskId; 151 | 152 | return $this->request($this->getTaskStatusUrl, $data); 153 | } 154 | } 155 | -------------------------------------------------------------------------------- /config/AipNlp.php: -------------------------------------------------------------------------------- 1 | request($this->wordsegUrl, urldecode(json_encode($data))); 107 | } 108 | 109 | /** 110 | * 词性标注 111 | * @param string $query 自然语言 112 | * @param array $options 可选参数 113 | * @return array 114 | */ 115 | public function wordpos($query, $options=array()){ 116 | 117 | $data = array(); 118 | $data['query'] = urlencode(mb_convert_encoding($query, 'GBK', 'UTF8')); 119 | 120 | return $this->request($this->wordposUrl, urldecode(json_encode($data))); 121 | } 122 | 123 | /** 124 | * 词向量 125 | * @param string $word 自然语言 126 | * @return array 127 | */ 128 | public function wordEmbedding($word, $options=array()){ 129 | 130 | $data = array(); 131 | $data['word'] = urlencode(mb_convert_encoding($word, 'GBK', 'UTF8')); 132 | 133 | $data = array_merge($data, $options); 134 | 135 | return $this->request($this->wordEmbeddingUrl, urldecode(json_encode($data))); 136 | } 137 | 138 | /** 139 | * 词相似度 140 | * @param string $word1 自然语言1 141 | * @param string $word2 自然语言2 142 | * @return array 143 | */ 144 | public function wordSimEmbedding($word1, $word2, $options=array()){ 145 | 146 | $data = array(); 147 | $data['word_1'] = urlencode(mb_convert_encoding($word1, 'GBK', 'UTF8')); 148 | $data['word_2'] = urlencode(mb_convert_encoding($word2, 'GBK', 'UTF8')); 149 | 150 | $data = array_merge($data, $options); 151 | 152 | return $this->request($this->wordSimEmbeddingUrl, urldecode(json_encode($data))); 153 | } 154 | 155 | /** 156 | * 中文DNN语言模型 157 | * @param string $text 自然语言 158 | * @param array $options 可选参数 159 | * @return array 160 | */ 161 | public function dnnlm($text, $options=array()){ 162 | 163 | $data = array(); 164 | $data['text'] = urlencode(mb_convert_encoding($text, 'GBK', 'UTF8')); 165 | 166 | $data = array_merge($data, $options); 167 | 168 | return $this->request($this->dnnlmUrl, urldecode(json_encode($data))); 169 | } 170 | 171 | /** 172 | * 短文本相似度 173 | * @param string $text1 自然语言1 174 | * @param string $text2 自然语言2 175 | * @param array $options 可选参数 176 | * @return array 177 | */ 178 | public function simnet($text1, $text2, $options=array()){ 179 | 180 | $data = array(); 181 | $data['text_1'] = urlencode(mb_convert_encoding($text1, 'GBK', 'UTF8')); 182 | $data['text_2'] = urlencode(mb_convert_encoding($text2, 'GBK', 'UTF8')); 183 | 184 | $data = array_merge($data, $options); 185 | 186 | return $this->request($this->simnetUrl, urldecode(json_encode($data))); 187 | } 188 | 189 | /** 190 | * 情感观点挖掘 191 | * @param string $text 自然语言 192 | * @param array $options 可选参数 193 | * @return array 194 | */ 195 | public function commentTag($text, $options=array()){ 196 | 197 | $data = array(); 198 | $data['text'] = urlencode(mb_convert_encoding($text, 'GBK', 'UTF8')); 199 | 200 | $data = array_merge($data, $options); 201 | 202 | return $this->request($this->commentTagUrl, urldecode(json_encode($data))); 203 | } 204 | 205 | /** 206 | * 词法分析 207 | * @param string $text 文本 208 | * @return array 209 | */ 210 | public function lexer($text){ 211 | 212 | $data = array(); 213 | $data['text'] = urlencode(mb_convert_encoding($text, 'GBK', 'UTF8')); 214 | 215 | return $this->request($this->lexerUrl, urldecode(json_encode($data))); 216 | } 217 | 218 | /** 219 | * 情感分析 220 | * @param string $text 自然语言 221 | * @param array $options 可选参数 222 | * @return array 223 | */ 224 | public function sentimentClassify($text, $options=array()){ 225 | 226 | $data = array(); 227 | $data['text'] = urlencode(mb_convert_encoding($text, 'GBK', 'UTF8')); 228 | 229 | $data = array_merge($data, $options); 230 | 231 | return $this->request($this->sentimentClassifyUrl, urldecode(json_encode($data))); 232 | } 233 | 234 | /** 235 | * 依存分析 236 | * @param string $text 自然语言 237 | * @param array $options 可选参数 238 | * @return array 239 | */ 240 | public function depParser($text, $options=array()){ 241 | 242 | $data = array(); 243 | $data['text'] = urlencode(mb_convert_encoding($text, 'GBK', 'UTF8')); 244 | 245 | $data = array_merge($data, $options); 246 | 247 | return $this->request($this->depParserUrl, urldecode(json_encode($data))); 248 | } 249 | 250 | } 251 | -------------------------------------------------------------------------------- /config/AipOcr.php: -------------------------------------------------------------------------------- 1 | request($this->idcardUrl, $data); 121 | } 122 | 123 | /** 124 | * @param string $image 图像读取 125 | * @return array 126 | */ 127 | public function bankcard($image){ 128 | 129 | $data = array(); 130 | $data['image'] = $image; 131 | 132 | return $this->request($this->bankcardUrl, $data); 133 | } 134 | 135 | /** 136 | * @param string $image 图像读取 137 | * @param array $options 可选参数 138 | * @return array 139 | */ 140 | public function general($image, $options=array()){ 141 | 142 | $data = array(); 143 | $data['image'] = $image; 144 | 145 | $data = array_merge($data, $options); 146 | 147 | return $this->request($this->generalUrl, $data); 148 | } 149 | 150 | /** 151 | * @param string $image 图像读取 152 | * @param array $options 可选参数 153 | * @return array 154 | */ 155 | public function basicGeneral($image, $options=array()){ 156 | 157 | $data = array(); 158 | $data['image'] = $image; 159 | 160 | $data = array_merge($data, $options); 161 | 162 | return $this->request($this->basicGeneralUrl, $data); 163 | } 164 | 165 | /** 166 | * @param string $image 图像读取 167 | * @param options 接口可选参数 168 | * detect_direction : true/false 169 | * language_type : 170 | *

识别语言类型,若不传则默认为CHN_ENG。 171 | * 可选值包括:CHN_ENG - 中英文混合; 172 | * ENG - 英文; 173 | * POR - 葡萄牙语; 174 | * FRE - 法语; 175 | * GER - 德语; 176 | * ITA - 意大利语; 177 | * SPA - 西班牙语; 178 | * RUS - 俄语; 179 | * JAP - 日语

180 | * mask : 表示mask区域的黑白灰度图片,白色代表选中, base64编码 181 | * detect_language: true/false 182 | * @return array 183 | */ 184 | public function webImage($image, $options=array()){ 185 | 186 | $data = array(); 187 | $data['image'] = $image; 188 | 189 | $data = array_merge($data, $options); 190 | 191 | return $this->request($this->webImageUrl, $data); 192 | } 193 | 194 | /** 195 | * @param string $image 图像读取 196 | * @param options 接口可选参数 197 | * detect_direction : true/false 198 | * language_type : 199 | *

识别语言类型,若不传则默认为CHN_ENG。 200 | * 可选值包括:CHN_ENG - 中英文混合; 201 | * ENG - 英文; 202 | * POR - 葡萄牙语; 203 | * FRE - 法语; 204 | * GER - 德语; 205 | * ITA - 意大利语; 206 | * SPA - 西班牙语; 207 | * RUS - 俄语; 208 | * JAP - 日语

209 | * mask : 表示mask区域的黑白灰度图片,白色代表选中, base64编码 210 | * detect_language: true/false 211 | * @return array 212 | */ 213 | public function enhancedGeneral($image, $options=array()){ 214 | 215 | $data = array(); 216 | $data['image'] = $image; 217 | 218 | $data = array_merge($data, $options); 219 | 220 | return $this->request($this->enhancedGeneralUrl, $data); 221 | } 222 | 223 | /** 224 | * 行驶证 225 | * @param string $image 图像读取 226 | * @param options 接口可选参数 227 | * @return array 228 | */ 229 | public function vehicleLicense($image, $options=array()){ 230 | 231 | $data = array(); 232 | $data['image'] = $image; 233 | 234 | $data = array_merge($data, $options); 235 | 236 | return $this->request($this->vehicleLicenseUrl, $data); 237 | } 238 | 239 | /** 240 | * 驾驶证 241 | * @param string $image 图像读取 242 | * @param options 接口可选参数 243 | * @return array 244 | */ 245 | public function drivingLicense($image, $options=array()){ 246 | 247 | $data = array(); 248 | $data['image'] = $image; 249 | 250 | $data = array_merge($data, $options); 251 | 252 | return $this->request($this->drivingLicenseUrl, $data); 253 | } 254 | 255 | /** 256 | * 格式检查 257 | * @param string $url 258 | * @param array $data 259 | * @return array 260 | */ 261 | protected function validate($url, &$data){ 262 | if($url === $this->tableResultUrl){ 263 | return true; 264 | } 265 | 266 | // 支持url 267 | if(preg_match('/^\w{1,128}:\/\//', $data['image'])){ 268 | $data['url'] = $data['image']; 269 | unset($data['image']); 270 | return true; 271 | } 272 | 273 | $imageInfo = AipImageUtil::getImageInfo($data['image']); 274 | 275 | //图片格式检查 276 | if(!in_array($imageInfo['mime'], array('image/jpeg', 'image/png', 'image/bmp'))){ 277 | return array( 278 | 'error_code' => 'SDK109', 279 | 'error_msg' => 'unsupported image format', 280 | ); 281 | } 282 | 283 | //图片大小检查 284 | if($imageInfo['width'] < 15 || $imageInfo['width'] > 4096 || $imageInfo['height'] < 15 || $imageInfo['height'] > 4096){ 285 | return array( 286 | 'error_code' => 'SDK101', 287 | 'error_msg' => 'image length error', 288 | ); 289 | } 290 | 291 | $data['image'] = base64_encode($data['image']); 292 | 293 | //编码后小于4m 294 | if(strlen($data['image']) >= 4 * 1024 * 1024){ 295 | return array( 296 | 'error_code' => 'SDK100', 297 | 'error_msg' => 'image size error', 298 | ); 299 | } 300 | 301 | return true; 302 | } 303 | 304 | /** 305 | * 异步请求 306 | * @param string $image 图像读取 307 | * @param options 接口可选参数 308 | * @return array 309 | */ 310 | public function tableRecognitionAsync($image, $options=array()){ 311 | 312 | $data = array(); 313 | $data['image'] = $image; 314 | 315 | $data = array_merge($data, $options); 316 | 317 | return $this->request($this->tableRequestUrl, $data); 318 | } 319 | 320 | /** 321 | * 获取结果 322 | * @param string $requestId 图像读取 323 | * @param options 接口可选参数 324 | * @return array 325 | */ 326 | public function getTableRecognitionResult($requestId, $options=array()){ 327 | 328 | $data = array(); 329 | $data['request_id'] = $requestId; 330 | 331 | $data = array_merge($data, $options); 332 | 333 | return $this->request($this->tableResultUrl, $data); 334 | } 335 | 336 | /** 337 | * 同步请求 338 | * @param string $image 图像读取 339 | * @param options 接口可选参数 340 | * @return array 341 | */ 342 | public function tableRecognition($image, $options=array(), $timeout=10000){ 343 | $result = $this->tableRecognitionAsync($image); 344 | 345 | if(isset($result['error_code'])){ 346 | return $result; 347 | } 348 | 349 | $requestId = $result['result'][0]['request_id']; 350 | $count = ceil($timeout / 1000); 351 | for($i=0; $i<$count; $i++){ 352 | 353 | $result = $this->getTableRecognitionResult($requestId, $options); 354 | 355 | // 完成 356 | if($result['result']['ret_code'] == 3){ 357 | break; 358 | } 359 | 360 | sleep(1); 361 | } 362 | 363 | return $result; 364 | } 365 | 366 | /** 367 | * 车牌 368 | * @param string $image 图像读取 369 | * @param options 接口可选参数 370 | * @return array 371 | */ 372 | public function licensePlate($image, $options=array()){ 373 | 374 | $data = array(); 375 | $data['image'] = $image; 376 | 377 | $data = array_merge($data, $options); 378 | 379 | return $this->request($this->licensePlateUrl, $data); 380 | } 381 | 382 | /** 383 | * @param string $image 图像读取 384 | * @param array $options 可选参数 385 | * @return array 386 | */ 387 | public function accurate($image, $options=array()){ 388 | 389 | $data = array(); 390 | $data['image'] = $image; 391 | 392 | $data = array_merge($data, $options); 393 | 394 | return $this->request($this->accurateUrl, $data); 395 | } 396 | 397 | /** 398 | * @param string $image 图像读取 399 | * @param array $options 可选参数 400 | * @return array 401 | */ 402 | public function basicAccurate($image, $options=array()){ 403 | 404 | $data = array(); 405 | $data['image'] = $image; 406 | 407 | $data = array_merge($data, $options); 408 | 409 | return $this->request($this->basicAccurateUrl, $data); 410 | } 411 | 412 | /** 413 | * @param string $image 图像读取 414 | * @param array $options 可选参数 415 | * @return array 416 | */ 417 | public function receipt($image, $options=array()){ 418 | 419 | $data = array(); 420 | $data['image'] = $image; 421 | 422 | $data = array_merge($data, $options); 423 | 424 | return $this->request($this->receiptUrl, $data); 425 | } 426 | 427 | /** 428 | * @param string $image 图像读取 429 | * @param array $options 可选参数 430 | * @return array 431 | */ 432 | public function businessLicense($image, $options=array()){ 433 | 434 | $data = array(); 435 | $data['image'] = $image; 436 | 437 | $data = array_merge($data, $options); 438 | 439 | return $this->request($this->businessLicenseUrl, $data); 440 | } 441 | 442 | } 443 | -------------------------------------------------------------------------------- /config/AipSpeech.php: -------------------------------------------------------------------------------- 1 | asrUrl){ 63 | $data['token'] = $token; 64 | $data = json_encode($data); 65 | }else{ 66 | $data['tok'] = $token; 67 | } 68 | 69 | unset($params['access_token']); 70 | } 71 | 72 | /** 73 | * 格式化结果 74 | * @param $content string 75 | * @return mixed 76 | */ 77 | protected function proccessResult($content){ 78 | $obj = json_decode($content, true); 79 | 80 | if($obj === null){ 81 | $obj = array( 82 | '__json_decode_error' => $content 83 | ); 84 | } 85 | 86 | return $obj; 87 | } 88 | 89 | /** 90 | * @param string $speech 91 | * @param string $format 92 | * @param int $rate 93 | * @param array $options 94 | * @return array 95 | */ 96 | public function asr($speech, $format, $rate, $options=array()){ 97 | $data = array(); 98 | 99 | if(!empty($speech)){ 100 | $data['speech'] = base64_encode($speech); 101 | $data['len'] = strlen($speech); 102 | } 103 | 104 | $data['format'] = $format; 105 | $data['rate'] = $rate; 106 | $data['channel'] = 1; 107 | 108 | $data = array_merge($data, $options); 109 | 110 | return $this->request($this->asrUrl, $data, array()); 111 | } 112 | 113 | /** 114 | * @param string $text 115 | * @param string $lang 116 | * @param int $ctp 117 | * @param array $options 118 | * @return array 119 | */ 120 | public function synthesis($text, $lang='zh', $ctp=1, $options=array()){ 121 | $data = array(); 122 | 123 | $data['tex'] = $text; 124 | $data['lan'] = $lang; 125 | $data['ctp'] = $ctp; 126 | 127 | $data = array_merge($data, $options); 128 | 129 | $result = $this->request($this->ttsUrl, $data, array()); 130 | 131 | if(isset($result['__json_decode_error'])){ 132 | return $result['__json_decode_error']; 133 | } 134 | 135 | return $result; 136 | } 137 | 138 | } 139 | -------------------------------------------------------------------------------- /config/database.php: -------------------------------------------------------------------------------- 1 | conn_mysql(); //连接mysql 23 | $result = mysqli_query($con,'SELECT * FROM rain_ai WHERE id="'.$id.'"'); 24 | $this->close_mysql($con); //释放连接 25 | return mysqli_fetch_array($result); 26 | } 27 | public function get_AllPageNum($page_num){ 28 | $con = $this->conn_mysql(); //连接mysql 29 | $result = mysqli_query($con,'SELECT * FROM rain_ai '); //进行查询操作 30 | $all_num = $result->num_rows; 31 | if ($all_num%$page_num==0){ 32 | $all_page = $all_num/$page_num; 33 | }else{ 34 | /** 35 | * 这时候分页就会出现两种情况,总数大于,或者小于时,余数都不为0 36 | */ 37 | $all_page = (intval($all_num/$page_num)) ; 38 | if ($all_num>$all_page*$page_num){ 39 | $all_page = $all_page +1; 40 | } 41 | } 42 | $this->close_mysql($con); //释放连接 43 | return ($all_page); 44 | } 45 | /** 后台显示数据的获取 46 | * @return bool|mysqli_result 47 | */ 48 | public function ListInfo($page_num, $page){ 49 | $con = $this->conn_mysql(); //连接mysql 50 | $result = mysqli_query($con,'SELECT * FROM rain_ai '); //进行查询操作 51 | $all_num = $result->num_rows; 52 | if ($all_num%$page_num==0){ 53 | $all_page = $all_num/$page_num; 54 | }else{ 55 | /** 56 | * 这时候分页就会出现两种情况,总数大于,或者小于时,余数都不为0 57 | */ 58 | $all_page = (intval($all_num/$page_num)) ; 59 | if ($all_num>$all_page*$page_num){ 60 | $all_page = $all_page +1; 61 | } 62 | } 63 | if ($page>$all_page||$page==-1){$page = $all_page;} 64 | if ($page<1){$page = 1;} 65 | $now_page_num = $page*$page_num-$page_num; 66 | $result = mysqli_query($con,'SELECT * FROM rain_ai LIMIT '.$now_page_num.','.$page_num); 67 | $this->close_mysql($con); //释放连接 68 | return ($result); 69 | } 70 | private function ip_database_select($ip){ 71 | $con = $this->conn_mysql(); //连接mysql 72 | $result = mysqli_query($con,'SELECT address FROM rain_ai WHERE ip="'.$ip.'"'); //进行查询操作 73 | $row = mysqli_fetch_array($result); //获取查询到的数组 74 | $this->close_mysql($con); //释放连接 75 | if (empty($row['address'])){ 76 | return $this->ip_select($ip); 77 | }else{ 78 | return $row['address']; 79 | } 80 | } 81 | public function ai_InsertInfo($data){ 82 | $data['add_time'] = date('Y-m-d:h:i:sa'); 83 | $data['address'] = $this->ip_database_select($data['ip']);; 84 | $con = $this->conn_mysql(); //连接mysql 85 | $return = mysqli_query($con,"INSERT INTO rain_ai VALUES(null,'{$data['add_time']}','{$data['ip']}','{$data['address']}','{$data['status']}','{$data['image1']}','{$data['image2']}','{$data['state']}')"); 86 | // $return = mysql_query("INSERT INTO student(s_id,s_card,s_username,s_phone,s_addtime,s_grade,s_class,s_lastleave,s_state,s_c_id,s_g_id) VALUES(null,'1','1','1','1','1','1','','1','1','1')",$con); 87 | // var_dump(mysql_error());die(); 88 | $this->close_mysql($con); //释放连接 89 | } 90 | public function delete($s_id){ 91 | $data = $this->get_Info($s_id); 92 | if ($data['state']!=2){ 93 | if (($data['image1']!='.')&&($data['state']==1)){ 94 | unlink($data['image1']); 95 | } 96 | if ($data['image2']!='.'){ 97 | unlink($data['image2']); 98 | } 99 | } 100 | $con = $this->conn_mysql(); //连接mysql 101 | $result = mysqli_query($con,'DELETE FROM rain_ai WHERE id="'.$s_id.'"'); 102 | $this->close_mysql($con); //释放连接 103 | } 104 | 105 | /** 106 | * 用于建立新的使用次数记录 107 | */ 108 | public function create_UseNum(){ 109 | $date = date('Y-m-d'); 110 | $state = 1; 111 | $con = $this->conn_mysql(); //连接mysql 112 | $return = mysqli_query($con,"INSERT INTO ai_use VALUES(null,'{$state}','{$date}','{$this->face}','{$this->face}', 113 | '{$this->sound}','{$this->ocr}','{$this->image}','{$this->image}','{$this->image}','{$this->image}','{$this->text}' 114 | ,'{$this->text}','{$this->text}','{$this->text}','{$this->text}','{$this->text}','{$this->text}','{$this->text}')"); 115 | $this->close_mysql($con); //释放连接 116 | } 117 | /** 用于查询每个功能所剩余的次数 118 | * @param $field 119 | * @return array|int|null 120 | */ 121 | public function get_UseNum($field){ 122 | $date = date('Y-m-d'); 123 | $con = $this->conn_mysql(); //连接mysql 124 | $result = mysqli_query($con,'SELECT '.$field.' FROM ai_use WHERE date="'.$date.'"'); 125 | $row = mysqli_fetch_array($result); 126 | if (empty($row[0])){ 127 | $this->create_UseNum(); 128 | $result = mysqli_query($con,'SELECT '.$field.' FROM ai_use WHERE date="'.$date.'"'); 129 | $row = mysqli_fetch_array($result); 130 | } 131 | $this->close_mysql($con); //释放连接 132 | return $row[0]; 133 | } 134 | public function reduce_UseNum($field){ 135 | $date = date('Y-m-d'); 136 | $con = $this->conn_mysql(); //连接mysql 137 | $result = mysqli_query($con,'SELECT '.$field.' FROM ai_use WHERE date="'.$date.'"'); 138 | $row = mysqli_fetch_array($result); 139 | $row = $row[0] - 1; 140 | // var_dump($row); 141 | $result = mysqli_query($con,'update ai_use set '.$field.'="'.$row.'" where date="'.$date.'"'); 142 | $this->close_mysql($con); //释放连接 143 | // var_dump($result); 144 | } 145 | public function close_mysql($con){ //释放连接的函数 146 | mysqli_close($con); 147 | } 148 | /** IP地址查询接口函数 149 | * @param $ip IP地址 150 | */ 151 | private function ip_select($ip){ 152 | 153 | } 154 | } -------------------------------------------------------------------------------- /config/image.php: -------------------------------------------------------------------------------- 1 | src = $src; 22 | 23 | } 24 | /** 25 | 打开图片 26 | */ 27 | public function openImage(){ 28 | 29 | list($width, $height, $type, $attr) = getimagesize($this->src); 30 | $this->imageinfo = array( 31 | 32 | 'width'=>$width, 33 | 'height'=>$height, 34 | 'type'=>image_type_to_extension($type,false), 35 | 'attr'=>$attr 36 | ); 37 | $fun = "imagecreatefrom".$this->imageinfo['type']; 38 | $this->image = $fun($this->src); 39 | } 40 | /** 41 | 操作图片 42 | */ 43 | public function thumpImage(){ 44 | 45 | $new_width = $this->imageinfo['width'] * $this->percent; 46 | $new_height = $this->imageinfo['height'] * $this->percent; 47 | $image_thump = imagecreatetruecolor($new_width,$new_height); 48 | //将原图复制带图片载体上面,并且按照一定比例压缩,极大的保持了清晰度 49 | imagecopyresampled($image_thump,$this->image,0,0,0,0,$new_width,$new_height,$this->imageinfo['width'],$this->imageinfo['height']); 50 | imagedestroy($this->image); 51 | $this->image = $image_thump; 52 | } 53 | /** 54 | 输出图片 55 | */ 56 | public function showImage(){ 57 | 58 | // header('Content-Type: image/'.$this->imageinfo['type']); 59 | $funcs = "image".$this->imageinfo['type']; 60 | $funcs($this->image); 61 | 62 | } 63 | /** 64 | 保存图片到硬盘 65 | */ 66 | public function saveImage($name){ 67 | 68 | $funcs = "image".$this->imageinfo['type']; 69 | $funcs($this->image,$name.'.'.$this->imageinfo['type']); 70 | 71 | } 72 | /** 73 | * desription 压缩图片 74 | * @param sting $imgsrc 图片路径 75 | * @param string $imgdst 压缩后保存路径 76 | */ 77 | function image_png_size_add($imgsrc,$imgdst){ 78 | list($width,$height,$type)=getimagesize($imgsrc); 79 | $new_width = ($width)*0.7; 80 | $new_height =($height)*0.7; 81 | // $new_width = ($width>600?600:$width)*0.9; 82 | // $new_height =($height>600?600:$height)*0.9; 83 | switch($type){ 84 | case 1: 85 | $giftype=check_gifcartoon($imgsrc); 86 | if($giftype){ 87 | // header('Content-Type:image/gif'); 88 | $image_wp=imagecreatetruecolor($new_width, $new_height); 89 | $image = imagecreatefromgif($imgsrc); 90 | imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 91 | imagejpeg($image_wp, $imgdst,75); 92 | imagedestroy($image_wp); 93 | } 94 | break; 95 | case 2: 96 | // header('Content-Type:image/jpg'); 97 | $image_wp=imagecreatetruecolor($new_width, $new_height); 98 | $image = imagecreatefromjpeg($imgsrc); 99 | imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 100 | imagejpeg($image_wp, $imgdst,75); 101 | imagedestroy($image_wp); 102 | break; 103 | case 3: 104 | // header('Content-Type:image/png'); 105 | $image_wp=imagecreatetruecolor($new_width, $new_height); 106 | $image = imagecreatefrompng($imgsrc); 107 | imagecopyresampled($image_wp, $image, 0, 0, 0, 0, $new_width, $new_height, $width, $height); 108 | imagejpeg($image_wp, $imgdst,75); 109 | imagedestroy($image_wp); 110 | break; 111 | } 112 | } 113 | /** 114 | 销毁图片 115 | */ 116 | // public function __destruct(){ 117 | // 118 | // imagedestroy($this->image); 119 | // } 120 | 121 | } -------------------------------------------------------------------------------- /config/lib/15e8cea06b1af4cfaea634b6415014ca: -------------------------------------------------------------------------------- 1 | {"access_token":"24.0dd8fb64539b226c7d885c3bee08efce.2592000.1515656452.282335-10498320","session_key":"9mzdC3w0xlcH1V37R1ZpVEQrVgjO6Y9v97MSdsvbW7u9WntwBSvaDAQebzgtGcXxBs3QipW4i4vJQJzilIIvs4zb5LJIIg==","scope":"vis-faceverify_faceverify_v2 public vis-faceverify_faceverify vis-faceattribute_faceattribute vis-faceverify_faceverify_match_v2 brain_all_scope vis-faceverify_vis-faceverify-detect wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower bnstest_fasf lpq_\u5f00\u653e","refresh_token":"25.9412dbaebe3fdf4ec71e8a1395fb2c3a.315360000.1828424452.282335-10498320","session_secret":"e4830a6e0923440472b44430648fe227","expires_in":2592000,"time":1513064453,"is_cloud_user":false} -------------------------------------------------------------------------------- /config/lib/185b48c05443ec47c61cb4e8db299fa8: -------------------------------------------------------------------------------- 1 | {"access_token":"24.1775324591ca64454e526d8d193e126d.2592000.1518534827.282335-10495881","session_key":"9mzdCrPnblns2IMoyp2zbmGjMV9ZV0Tfhby\/WD1uppmKeFinrv5bzn7EtLl0s4fQx5v\/kXhuCJGKduh77dZQXZI8EY2I\/A==","scope":"public brain_all_scope audio_voice_assistant_get audio_tts_post wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower bnstest_fasf lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission","refresh_token":"25.eb922fc99ee49d444ce6d4431236e5aa.315360000.1831302827.282335-10495881","session_secret":"f27e8f769e13943e683d377835a288ad","expires_in":2592000,"time":1515942827,"is_cloud_user":false} -------------------------------------------------------------------------------- /config/lib/72a0202dfc3207b84f0ac644bce32fd4: -------------------------------------------------------------------------------- 1 | {"access_token":"24.9bab548050e2c6faa1fa3d98c5fcd5a4.2592000.1518601608.282335-10523702","session_key":"9mzdAqBLW\/jxIQ4+LGbobp6o0LeKXr8tDVf5UWwnpknRD04DfypBAiSxrTEWIyKOPnEJ0Wbv0p1KfxpKB5bgvs83CUlcvQ==","scope":"public vis-classify_dishes vis-classify_car brain_all_scope vis-classify_animal vis-classify_plant brain_object_detect brain_realtime_logo brain_dish_detect brain_car_detect brain_animal_classify brain_plant_classify wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower bnstest_fasf lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission","refresh_token":"25.51930260f010cf63097041262796077e.315360000.1831369608.282335-10523702","session_secret":"f9dc16f7d99e1f5b9fb6872bcf73a7ae","expires_in":2592000,"time":1516009609,"is_cloud_user":false} -------------------------------------------------------------------------------- /config/lib/7ec61eb54e899ef423189e85c0666216: -------------------------------------------------------------------------------- 1 | {"access_token":"24.f11edfbf9e6eab242fbadffe5085cf44.2592000.1518601763.282335-10498297","session_key":"9mzdXUXMSAFWpdxcaLGZPHwh8NXs22p\/vck5LnsspEWvPFvwaMlp8lI37totH+lhnrzCxFZxmwGrLI+Jl4Jnjw+UMRqmTg==","scope":"brain_nlp_keyword public nlp_simnet nlp_wordemb nlp_comtag nlp_dnnlm_cn brain_nlp_lexer brain_all_scope brain_nlp_comment_tag brain_nlp_dnnlm_cn brain_nlp_word_emb_vec brain_nlp_word_emb_sim brain_nlp_sentiment_classify brain_nlp_simnet brain_nlp_depparser brain_nlp_wordembedding brain_nlp_dnnlm_cn_legacy brain_nlp_simnet_legacy brain_nlp_comment_tag_legacy brain_nlp_lexer_custom wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower bnstest_fasf lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission","refresh_token":"25.39e1ada4c072e873e3a463b940ad54aa.315360000.1831369763.282335-10498297","session_secret":"7d4dbd4a71f5c152d11eb307e6a0d66f","expires_in":2592000,"time":1516009762,"is_cloud_user":false} -------------------------------------------------------------------------------- /config/lib/AipBCEUtil.php: -------------------------------------------------------------------------------- 1 | $v) { 98 | //跳过Authorization字段 99 | if (strcasecmp('Authorization', $k) == 0) { 100 | continue; 101 | } 102 | if (!isset($k)) { 103 | throw new \InvalidArgumentException( 104 | "parameter key should not be null" 105 | ); 106 | } 107 | if (isset($v)) { 108 | //对于有值的,编码后放在=号两边 109 | $parameterStrings[] = AipHttpUtil::urlEncode($k) 110 | . '=' . AipHttpUtil::urlEncode((string) $v); 111 | } else { 112 | //对于没有值的,只将key编码后放在=号的左边,右边留空 113 | $parameterStrings[] = AipHttpUtil::urlEncode($k) . '='; 114 | } 115 | } 116 | //按照字典序排序 117 | sort($parameterStrings); 118 | 119 | //使用'&'符号连接它们 120 | return implode('&', $parameterStrings); 121 | } 122 | 123 | /** 124 | * 生成标准化uri 125 | * @param string $path 126 | * @return string 127 | */ 128 | public static function getCanonicalURIPath($path) 129 | { 130 | //空路径设置为'/' 131 | if (empty($path)) { 132 | return '/'; 133 | } else { 134 | //所有的uri必须以'/'开头 135 | if ($path[0] == '/') { 136 | return AipHttpUtil::urlEncodeExceptSlash($path); 137 | } else { 138 | return '/' . AipHttpUtil::urlEncodeExceptSlash($path); 139 | } 140 | } 141 | } 142 | 143 | /** 144 | * 生成标准化http请求头串 145 | * @param array $headers 146 | * @return array 147 | */ 148 | public static function getCanonicalHeaders($headers) 149 | { 150 | //如果没有headers,则返回空串 151 | if (count($headers) == 0) { 152 | return ''; 153 | } 154 | 155 | $headerStrings = array(); 156 | foreach ($headers as $k => $v) { 157 | //跳过key为null的 158 | if ($k === null) { 159 | continue; 160 | } 161 | //如果value为null,则赋值为空串 162 | if ($v === null) { 163 | $v = ''; 164 | } 165 | //trim后再encode,之后使用':'号连接起来 166 | $headerStrings[] = AipHttpUtil::urlEncode(strtolower(trim($k))) . ':' . AipHttpUtil::urlEncode(trim($v)); 167 | } 168 | //字典序排序 169 | sort($headerStrings); 170 | 171 | //用'\n'把它们连接起来 172 | return implode("\n", $headerStrings); 173 | } 174 | } 175 | AipHttpUtil::__init(); 176 | 177 | 178 | class AipSignOption 179 | { 180 | const EXPIRATION_IN_SECONDS = 'expirationInSeconds'; 181 | 182 | const HEADERS_TO_SIGN = 'headersToSign'; 183 | 184 | const TIMESTAMP = 'timestamp'; 185 | 186 | const DEFAULT_EXPIRATION_IN_SECONDS = 1800; 187 | 188 | const MIN_EXPIRATION_IN_SECONDS = 300; 189 | 190 | const MAX_EXPIRATION_IN_SECONDS = 129600; 191 | } 192 | 193 | 194 | class AipSampleSigner 195 | { 196 | 197 | const BCE_AUTH_VERSION = "bce-auth-v1"; 198 | const BCE_PREFIX = 'x-bce-'; 199 | 200 | //不指定headersToSign情况下,默认签名http头,包括: 201 | // 1.host 202 | // 2.content-length 203 | // 3.content-type 204 | // 4.content-md5 205 | public static $defaultHeadersToSign; 206 | 207 | public static function __init() 208 | { 209 | AipSampleSigner::$defaultHeadersToSign = array( 210 | "host", 211 | "content-length", 212 | "content-type", 213 | "content-md5", 214 | ); 215 | } 216 | 217 | /** 218 | * 签名 219 | * @param array $credentials 220 | * @param string $httpMethod 221 | * @param string $path 222 | * @param array $headers 223 | * @param string $params 224 | * @param array $options 225 | * @return string 226 | */ 227 | public static function sign( 228 | array $credentials, 229 | $httpMethod, 230 | $path, 231 | $headers, 232 | $params, 233 | $options = array() 234 | ) { 235 | //设定签名有效时间 236 | if (!isset($options[AipSignOption::EXPIRATION_IN_SECONDS])) { 237 | //默认值1800秒 238 | $expirationInSeconds = AipSignOption::DEFAULT_EXPIRATION_IN_SECONDS; 239 | } else { 240 | $expirationInSeconds = $options[AipSignOption::EXPIRATION_IN_SECONDS]; 241 | } 242 | 243 | //解析ak sk 244 | $accessKeyId = $credentials['ak']; 245 | $secretAccessKey = $credentials['sk']; 246 | 247 | //设定时间戳,注意:如果自行指定时间戳需要为UTC时间 248 | if (!isset($options[AipSignOption::TIMESTAMP])) { 249 | //默认值当前时间 250 | $timestamp = gmdate('Y-m-d\TH:i:s\Z'); 251 | } else { 252 | $timestamp = $options[AipSignOption::TIMESTAMP]; 253 | } 254 | 255 | //生成authString 256 | $authString = AipSampleSigner::BCE_AUTH_VERSION . '/' . $accessKeyId . '/' 257 | . $timestamp . '/' . $expirationInSeconds; 258 | 259 | //使用sk和authString生成signKey 260 | $signingKey = hash_hmac('sha256', $authString, $secretAccessKey); 261 | 262 | //生成标准化URI 263 | $canonicalURI = AipHttpUtil::getCanonicalURIPath($path); 264 | 265 | //生成标准化QueryString 266 | $canonicalQueryString = AipHttpUtil::getCanonicalQueryString($params); 267 | 268 | //填充headersToSign,也就是指明哪些header参与签名 269 | $headersToSign = null; 270 | if (isset($options[AipSignOption::HEADERS_TO_SIGN])) { 271 | $headersToSign = $options[AipSignOption::HEADERS_TO_SIGN]; 272 | } 273 | 274 | //生成标准化header 275 | $canonicalHeader = AipHttpUtil::getCanonicalHeaders( 276 | AipSampleSigner::getHeadersToSign($headers, $headersToSign) 277 | ); 278 | 279 | //整理headersToSign,以';'号连接 280 | $signedHeaders = ''; 281 | if ($headersToSign !== null) { 282 | $signedHeaders = strtolower( 283 | trim(implode(";", $headersToSign)) 284 | ); 285 | } 286 | 287 | //组成标准请求串 288 | $canonicalRequest = "$httpMethod\n$canonicalURI\n" 289 | . "$canonicalQueryString\n$canonicalHeader"; 290 | 291 | //使用signKey和标准请求串完成签名 292 | $signature = hash_hmac('sha256', $canonicalRequest, $signingKey); 293 | 294 | //组成最终签名串 295 | $authorizationHeader = "$authString/$signedHeaders/$signature"; 296 | 297 | return $authorizationHeader; 298 | } 299 | 300 | /** 301 | * 根据headsToSign过滤应该参与签名的header 302 | * @param array $headers 303 | * @param array $headersToSign 304 | * @return array 305 | */ 306 | public static function getHeadersToSign($headers, $headersToSign) 307 | { 308 | 309 | //value被trim后为空串的header不参与签名 310 | $filter_empty = function($v) { 311 | return trim((string) $v) !== ''; 312 | }; 313 | $headers = array_filter($headers, $filter_empty); 314 | 315 | //处理headers的key:去掉前后的空白并转化成小写 316 | $trim_and_lower = function($str){ 317 | return strtolower(trim($str)); 318 | }; 319 | $temp = array(); 320 | $process_keys = function($k, $v) use(&$temp, $trim_and_lower) { 321 | $temp[$trim_and_lower($k)] = $v; 322 | }; 323 | array_map($process_keys, array_keys($headers), $headers); 324 | $headers = $temp; 325 | 326 | //取出headers的key以备用 327 | $header_keys = array_keys($headers); 328 | 329 | $filtered_keys = null; 330 | if ($headersToSign !== null) { 331 | //如果有headersToSign,则根据headersToSign过滤 332 | 333 | //预处理headersToSign:去掉前后的空白并转化成小写 334 | $headersToSign = array_map($trim_and_lower, $headersToSign); 335 | 336 | //只选取在headersToSign里面的header 337 | $filtered_keys = array_intersect_key($header_keys, $headersToSign); 338 | 339 | } else { 340 | //如果没有headersToSign,则根据默认规则来选取headers 341 | $filter_by_default = function($k) { 342 | return AipSampleSigner::isDefaultHeaderToSign($k); 343 | }; 344 | $filtered_keys = array_filter($header_keys, $filter_by_default); 345 | } 346 | 347 | //返回需要参与签名的header 348 | return array_intersect_key($headers, array_flip($filtered_keys)); 349 | } 350 | 351 | /** 352 | * 检查header是不是默认参加签名的: 353 | * 1.是host、content-type、content-md5、content-length之一 354 | * 2.以x-bce开头 355 | * @param array $header 356 | * @return boolean 357 | */ 358 | public static function isDefaultHeaderToSign($header) 359 | { 360 | $header = strtolower(trim($header)); 361 | if (in_array($header, AipSampleSigner::$defaultHeadersToSign)) { 362 | return true; 363 | } 364 | return substr_compare($header, AipSampleSigner::BCE_PREFIX, 0, strlen(AipSampleSigner::BCE_PREFIX)) == 0; 365 | } 366 | } 367 | AipSampleSigner::__init(); 368 | -------------------------------------------------------------------------------- /config/lib/AipBase.php: -------------------------------------------------------------------------------- 1 | appId = trim($appId); 64 | $this->apiKey = trim($apiKey); 65 | $this->secretKey = trim($secretKey); 66 | $this->isCloudUser = null; 67 | $this->client = new AipHttpClient(); 68 | $this->version = '1_6_8'; 69 | $this->proxies = array(); 70 | } 71 | 72 | /** 73 | * 查看版本 74 | * @return string 75 | * 76 | */ 77 | public function getVersion(){ 78 | return $this->version; 79 | } 80 | 81 | /** 82 | * 连接超时 83 | * @param int $ms 毫秒 84 | */ 85 | public function setConnectionTimeoutInMillis($ms){ 86 | $this->client->setConnectionTimeoutInMillis($ms); 87 | } 88 | 89 | /** 90 | * 响应超时 91 | * @param int $ms 毫秒 92 | */ 93 | public function setSocketTimeoutInMillis($ms){ 94 | $this->client->setSocketTimeoutInMillis($ms); 95 | } 96 | 97 | /** 98 | * 代理 99 | * @param array $proxy 100 | * @return string 101 | * 102 | */ 103 | public function setProxies($proxies){ 104 | $this->client->setConf($proxies); 105 | } 106 | 107 | /** 108 | * 处理请求参数 109 | * @param string $url 110 | * @param array $params 111 | * @param array $data 112 | * @param array $headers 113 | */ 114 | protected function proccessRequest($url, &$params, &$data, $headers){ 115 | $params['aipSdk'] = 'php'; 116 | $params['aipSdkVersion'] = $this->version; 117 | } 118 | 119 | /** 120 | * Api 请求 121 | * @param string $url 122 | * @param mixed $data 123 | * @return mixed 124 | */ 125 | protected function request($url, $data, $headers=array()){ 126 | try{ 127 | $result = $this->validate($url, $data); 128 | if($result !== true){ 129 | return $result; 130 | } 131 | 132 | $params = array(); 133 | $authObj = $this->auth(); 134 | 135 | if($this->isCloudUser === false){ 136 | $params['access_token'] = $authObj['access_token']; 137 | } 138 | 139 | // 特殊处理 140 | $this->proccessRequest($url, $params, $data, $headers); 141 | 142 | $headers = $this->getAuthHeaders('POST', $url, $params, $headers); 143 | $response = $this->client->post($url, $data, $params, $headers); 144 | 145 | $obj = $this->proccessResult($response['content']); 146 | 147 | if(!$this->isCloudUser && isset($obj['error_code']) && $obj['error_code'] == 110){ 148 | $authObj = $this->auth(true); 149 | $params['access_token'] = $authObj['access_token']; 150 | $response = $this->client->post($url, $data, $params, $headers); 151 | $obj = $this->proccessResult($response['content']); 152 | } 153 | 154 | if(empty($obj) || !isset($obj['error_code'])){ 155 | $this->writeAuthObj($authObj); 156 | } 157 | }catch(Exception $e){ 158 | return array( 159 | 'error_code' => 'SDK108', 160 | 'error_msg' => 'connection or read data timeout', 161 | ); 162 | } 163 | 164 | return $obj; 165 | } 166 | 167 | /** 168 | * Api 多个并发请求 169 | * @param string $url 170 | * @param mixed $data 171 | * @return mixed 172 | */ 173 | protected function multi_request($url, $data){ 174 | try{ 175 | $params = array(); 176 | $authObj = $this->auth(); 177 | $headers = $this->getAuthHeaders('POST', $url); 178 | 179 | if($this->isCloudUser === false){ 180 | $params['access_token'] = $authObj['access_token']; 181 | } 182 | 183 | $responses = $this->client->multi_post($url, $data, $params, $headers); 184 | 185 | $is_success = false; 186 | foreach($responses as $response){ 187 | $obj = $this->proccessResult($response['content']); 188 | 189 | if(empty($obj) || !isset($obj['error_code'])){ 190 | $is_success = true; 191 | } 192 | 193 | if(!$this->isCloudUser && isset($obj['error_code']) && $obj['error_code'] == 110){ 194 | $authObj = $this->auth(true); 195 | $params['access_token'] = $authObj['access_token']; 196 | $responses = $this->client->post($url, $data, $params, $headers); 197 | break; 198 | } 199 | } 200 | 201 | if($is_success){ 202 | $this->writeAuthObj($authObj); 203 | } 204 | 205 | $objs = array(); 206 | foreach($responses as $response){ 207 | $objs[] = $this->proccessResult($response['content']); 208 | } 209 | 210 | }catch(Exception $e){ 211 | return array( 212 | 'error_code' => 'SDK108', 213 | 'error_msg' => 'connection or read data timeout', 214 | ); 215 | } 216 | 217 | return $objs; 218 | } 219 | 220 | /** 221 | * 格式检查 222 | * @param string $url 223 | * @param array $data 224 | * @return mix 225 | */ 226 | protected function validate($url, &$data){ 227 | return true; 228 | } 229 | 230 | /** 231 | * 格式化结果 232 | * @param $content string 233 | * @return mixed 234 | */ 235 | protected function proccessResult($content){ 236 | return json_decode($content, true); 237 | } 238 | 239 | /** 240 | * 返回 access token 路径 241 | * @return string 242 | */ 243 | private function getAuthFilePath(){ 244 | return dirname(__FILE__) . DIRECTORY_SEPARATOR . md5($this->apiKey); 245 | } 246 | 247 | /** 248 | * 写入本地文件 249 | * @param array $obj 250 | * @return void 251 | */ 252 | private function writeAuthObj($obj){ 253 | if($obj === null || (isset($obj['is_read']) && $obj['is_read'] === true)){ 254 | return; 255 | } 256 | 257 | $obj['time'] = time(); 258 | $obj['is_cloud_user'] = $this->isCloudUser; 259 | @file_put_contents($this->getAuthFilePath(), json_encode($obj)); 260 | } 261 | 262 | /** 263 | * 读取本地缓存 264 | * @return array 265 | */ 266 | private function readAuthObj(){ 267 | $content = @file_get_contents($this->getAuthFilePath()); 268 | if($content !== false){ 269 | $obj = json_decode($content, true); 270 | $this->isCloudUser = $obj['is_cloud_user']; 271 | $obj['is_read'] = true; 272 | if($this->isCloudUser || $obj['time'] + $obj['expires_in'] - 30 > time()){ 273 | return $obj; 274 | } 275 | } 276 | 277 | return null; 278 | } 279 | 280 | /** 281 | * 认证 282 | * @param bool $refresh 是否刷新 283 | * @return array 284 | */ 285 | private function auth($refresh=false){ 286 | 287 | //非过期刷新 288 | if(!$refresh){ 289 | $obj = $this->readAuthObj(); 290 | if(!empty($obj)){ 291 | return $obj; 292 | } 293 | } 294 | 295 | $response = $this->client->get($this->accessTokenUrl, array( 296 | 'grant_type' => 'client_credentials', 297 | 'client_id' => $this->apiKey, 298 | 'client_secret' => $this->secretKey, 299 | )); 300 | 301 | $obj = json_decode($response['content'], true); 302 | 303 | $this->isCloudUser = !$this->isPermission($obj); 304 | return $obj; 305 | } 306 | 307 | /** 308 | * 判断认证是否有权限 309 | * @param array $authObj 310 | * @return boolean 311 | */ 312 | protected function isPermission($authObj) 313 | { 314 | if(empty($authObj) || !isset($authObj['scope'])){ 315 | return false; 316 | } 317 | 318 | $scopes = explode(' ', $authObj['scope']); 319 | 320 | return in_array($this->scope, $scopes); 321 | } 322 | 323 | /** 324 | * @param string $method HTTP method 325 | * @param string $url 326 | * @param array $param 参数 327 | * @return array 328 | */ 329 | private function getAuthHeaders($method, $url, $params=array(), $headers=array()){ 330 | 331 | //不是云的老用户则不用在header中签名 认证 332 | if($this->isCloudUser === false){ 333 | return $headers; 334 | } 335 | 336 | $obj = parse_url($url); 337 | if(!empty($obj['query'])){ 338 | foreach(explode('&', $obj['query']) as $kv){ 339 | if(!empty($kv)){ 340 | list($k, $v) = explode('=', $kv, 2); 341 | $params[$k] = $v; 342 | } 343 | } 344 | } 345 | 346 | //UTC 时间戳 347 | $timestamp = gmdate('Y-m-d\TH:i:s\Z'); 348 | $headers['Host'] = isset($obj['port']) ? sprintf('%s:%s', $obj['host'], $obj['port']) : $obj['host']; 349 | $headers['x-bce-date'] = $timestamp; 350 | 351 | //签名 352 | $headers['authorization'] = AipSampleSigner::sign(array( 353 | 'ak' => $this->apiKey, 354 | 'sk' => $this->secretKey, 355 | ), $method, $obj['path'], $headers, $params, array( 356 | 'timestamp' => $timestamp, 357 | 'headersToSign' => array_keys($headers), 358 | )); 359 | 360 | return $headers; 361 | } 362 | 363 | } 364 | -------------------------------------------------------------------------------- /config/lib/AipHttpClient.php: -------------------------------------------------------------------------------- 1 | headers = $this->buildHeaders($headers); 29 | $this->connectTimeout = 60000; 30 | $this->socketTimeout = 60000; 31 | $this->conf = array(); 32 | } 33 | 34 | /** 35 | * 连接超时 36 | * @param int $ms 毫秒 37 | */ 38 | public function setConnectionTimeoutInMillis($ms){ 39 | $this->connectTimeout = $ms; 40 | } 41 | 42 | /** 43 | * 响应超时 44 | * @param int $ms 毫秒 45 | */ 46 | public function setSocketTimeoutInMillis($ms){ 47 | $this->socketTimeout = $ms; 48 | } 49 | 50 | /** 51 | * 配置 52 | * @param array $conf 53 | */ 54 | public function setConf($conf){ 55 | $this->conf = $conf; 56 | } 57 | 58 | /** 59 | * 请求预处理 60 | * @param resource $ch 61 | */ 62 | public function prepare($ch){ 63 | foreach($this->conf as $key => $value){ 64 | curl_setopt($ch, $key, $value); 65 | } 66 | } 67 | 68 | /** 69 | * @param string $url 70 | * @param array $data HTTP POST BODY 71 | * @param array $param HTTP URL 72 | * @param array $headers HTTP header 73 | * @return array 74 | */ 75 | public function post($url, $data=array(), $params=array(), $headers=array()){ 76 | $url = $this->buildUrl($url, $params); 77 | $headers = array_merge($this->headers, $this->buildHeaders($headers)); 78 | 79 | $ch = curl_init(); 80 | $this->prepare($ch); 81 | curl_setopt($ch, CURLOPT_URL, $url); 82 | curl_setopt($ch, CURLOPT_POST, 1); 83 | curl_setopt($ch, CURLOPT_HEADER, false); 84 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 85 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 86 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 87 | curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data); 88 | curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout); 89 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout); 90 | $content = curl_exec($ch); 91 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 92 | 93 | if($code === 0){ 94 | throw new Exception(curl_error($ch)); 95 | } 96 | 97 | curl_close($ch); 98 | return array( 99 | 'code' => $code, 100 | 'content' => $content, 101 | ); 102 | } 103 | 104 | /** 105 | * @param string $url 106 | * @param array $datas HTTP POST BODY 107 | * @param array $param HTTP URL 108 | * @param array $headers HTTP header 109 | * @return array 110 | */ 111 | public function multi_post($url, $datas=array(), $params=array(), $headers=array()){ 112 | $url = $this->buildUrl($url, $params); 113 | $headers = array_merge($this->headers, $this->buildHeaders($headers)); 114 | 115 | $chs = array(); 116 | $result = array(); 117 | $mh = curl_multi_init(); 118 | foreach($datas as $data){ 119 | $ch = curl_init(); 120 | $chs[] = $ch; 121 | $this->prepare($ch); 122 | curl_setopt($ch, CURLOPT_URL, $url); 123 | curl_setopt($ch, CURLOPT_POST, 1); 124 | curl_setopt($ch, CURLOPT_HEADER, false); 125 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 126 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 127 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 128 | curl_setopt($ch, CURLOPT_POSTFIELDS, is_array($data) ? http_build_query($data) : $data); 129 | curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout); 130 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout); 131 | curl_multi_add_handle($mh, $ch); 132 | } 133 | 134 | $running = null; 135 | do{ 136 | curl_multi_exec($mh, $running); 137 | usleep(100); 138 | }while($running); 139 | 140 | foreach($chs as $ch){ 141 | $content = curl_multi_getcontent($ch); 142 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 143 | $result[] = array( 144 | 'code' => $code, 145 | 'content' => $content, 146 | ); 147 | curl_multi_remove_handle($mh, $ch); 148 | } 149 | curl_multi_close($mh); 150 | 151 | return $result; 152 | } 153 | 154 | /** 155 | * @param string $url 156 | * @param array $param HTTP URL 157 | * @param array $headers HTTP header 158 | * @return array 159 | */ 160 | public function get($url, $params=array(), $headers=array()){ 161 | $url = $this->buildUrl($url, $params); 162 | $headers = array_merge($this->headers, $this->buildHeaders($headers)); 163 | 164 | $ch = curl_init(); 165 | $this->prepare($ch); 166 | curl_setopt($ch, CURLOPT_URL, $url); 167 | curl_setopt($ch, CURLOPT_HEADER, false); 168 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 169 | curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 170 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 171 | curl_setopt($ch, CURLOPT_TIMEOUT_MS, $this->socketTimeout); 172 | curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, $this->connectTimeout); 173 | $content = curl_exec($ch); 174 | $code = curl_getinfo($ch, CURLINFO_HTTP_CODE); 175 | 176 | if($code === 0){ 177 | throw new Exception(curl_error($ch)); 178 | } 179 | 180 | curl_close($ch); 181 | return array( 182 | 'code' => $code, 183 | 'content' => $content, 184 | ); 185 | } 186 | 187 | /** 188 | * 构造 header 189 | * @param array $headers 190 | * @return array 191 | */ 192 | private function buildHeaders($headers){ 193 | $result = array(); 194 | foreach($headers as $k => $v){ 195 | $result[] = sprintf('%s:%s', $k, $v); 196 | } 197 | return $result; 198 | } 199 | 200 | /** 201 | * 202 | * @param string $url 203 | * @param array $params 参数 204 | * @return string 205 | */ 206 | private function buildUrl($url, $params){ 207 | if(!empty($params)){ 208 | $str = http_build_query($params); 209 | return $url . (strpos($url, '?') === false ? '?' : '&') . $str; 210 | }else{ 211 | return $url; 212 | } 213 | } 214 | } 215 | -------------------------------------------------------------------------------- /config/lib/AipImageUtil.php: -------------------------------------------------------------------------------- 1 | $info['mime'], 30 | 'width' => $info[0], 31 | 'height' => $info[1], 32 | ); 33 | } 34 | } 35 | 36 | // var_dump(AipUtil::getImageInfo(file_get_contents('../test/general.png'))); 37 | -------------------------------------------------------------------------------- /config/lib/d74c87a631288137ae7fc2f0d5460477: -------------------------------------------------------------------------------- 1 | {"access_token":"24.09556534800f4695cd02b82578352545.2592000.1518529255.282335-9855248","session_key":"9mzdCyF1FXmmG\/N+LmWW6QDsAypnXl6UwU2ddElv1I0oD6Xf44LZasYiX4JnjWegseoqdEr++2tVVYyAq+8cCBOpttdq","scope":"vis-faceattribute_faceattribute vis-faceverify_vis-faceverify-detect vis-faceverify_faceverify vis-faceverify_faceverify_match_v2 vis-ocr_business_license brain_ocr_business_license public vis-ocr_ocr brain_ocr_scope vis-faceverify_faceverify_v2 brain_ocr_general brain_ocr_general_basic brain_ocr_general_enhanced brain_ocr_webimage brain_all_scope brain_ocr_idcard brain_ocr_driving_license brain_ocr_vehicle_license vis-ocr_plate_number brain_solution brain_ocr_plate_number brain_ocr_accurate brain_ocr_accurate_basic brain_ocr_receipt wise_adapt lebo_resource_base lightservice_public hetu_basic lightcms_map_poi kaidian_kaidian ApsMisTest_Test\u6743\u9650 vis-classify_flower bnstest_fasf lpq_\u5f00\u653e cop_helloScope ApsMis_fangdi_permission","refresh_token":"25.e82c1524c568a952d5cd2590d5941ca3.315360000.1831297255.282335-9855248","session_secret":"0aabc41a8d1631bf9048f0c07dd6a63e","expires_in":2592000,"time":1515937264,"is_cloud_user":false} -------------------------------------------------------------------------------- /config/rain_function.php: -------------------------------------------------------------------------------- 1 | get_UseNum('face1'); 45 | }elseif ($type==2){ 46 | $num = $database->get_UseNum('face2'); 47 | }elseif ($type==3){ 48 | $num = $database->get_UseNum('sound'); 49 | }elseif ($type==4){ 50 | $num = $database->get_UseNum('ocr'); 51 | }elseif ($type==51){ 52 | $num = $database->get_UseNum('image1'); 53 | }elseif ($type==52){ 54 | $num = $database->get_UseNum('image2'); 55 | }elseif ($type==53){ 56 | $num = $database->get_UseNum('image3'); 57 | }elseif ($type==54){ 58 | $num = $database->get_UseNum('image4'); 59 | }elseif ($type==61){ 60 | $num = $database->get_UseNum('text1'); 61 | }elseif ($type==62){ 62 | $num = $database->get_UseNum('text2'); 63 | }elseif ($type==63){ 64 | $num = $database->get_UseNum('text3'); 65 | }elseif ($type==64){ 66 | $num = $database->get_UseNum('text4'); 67 | }elseif ($type==66){ 68 | $num = $database->get_UseNum('text6'); 69 | }elseif ($type==67){ 70 | $num = $database->get_UseNum('text7'); 71 | }else{ 72 | $num = 0; 73 | } 74 | return $num; 75 | } 76 | /** 77 | * file_get_contens函数,用作所有图片的处理,应该是返回图片内容,还有URL的请求发起 78 | */ 79 | function file_get_contents($filename, $incpath = false, $resource_context = null) { 80 | if (false === $fh = fopen($filename, 'rb', $incpath)) { 81 | user_error('file_get_contents() failed to open stream: No such file or directory', 82 | E_USER_WARNING); 83 | return false; 84 | } 85 | clearstatcache(); 86 | if ($fsize = @filesize($filename)) { 87 | $data = fread($fh, $fsize); 88 | } 89 | else { 90 | $data = ''; 91 | while (!feof($fh)) { 92 | $data .= fread($fh, 8192); 93 | } 94 | } 95 | fclose($fh); 96 | return $data; 97 | } 98 | /** 99 | * 人脸识别函数 100 | */ 101 | function face($image_src,$image_src2=null,$type){ 102 | $client = new AipFace($this->Face_APP_ID, $this->Face_API_KEY, $this->Face_SECRET_KEY); 103 | $database = new database(); 104 | if ($type==1){ 105 | // 调用人脸两两比对接口 106 | $result = $client->match(array( 107 | file_get_contents($image_src), 108 | file_get_contents($image_src2), 109 | )); 110 | $log = '人脸对比'; 111 | $database->reduce_UseNum('face2'); 112 | }else{ 113 | // 调用人脸检测 114 | $option = array( 115 | 'max_face_num' => 20, 116 | 'face_fields' => 'expression,beauty,faceshape,gender,glasses,age,race,qualities' 117 | 118 | ); 119 | $result = $client->detect($this->file_get_contents($image_src),$option); 120 | $log = '人脸检测'; 121 | $database->reduce_UseNum('face1'); 122 | } 123 | $data['ip'] = $_SERVER['REMOTE_ADDR']; 124 | $data['image1'] = '.'.$image_src; 125 | $data['image2'] = '.'.$image_src2; 126 | $data['status'] = $log; 127 | $data['state'] = 1; 128 | $database->ai_InsertInfo($data); 129 | return $result; 130 | } 131 | /** 132 | * 文字识别函数 133 | */ 134 | function ocr_recognition($image_src,$type){ 135 | $client = new AipOcr($this->Ocr_APP_ID, $this->Ocr_API_KEY, $this->Ocr_SECRET_KEY); 136 | $database = new database(); 137 | // 调用通用文字识别接口 138 | if ($type==2){ 139 | $result = $client->vehicleLicense($this->file_get_contents($image_src)); 140 | $log = '驾驶证识别'; 141 | // $database->reduce_UseNum('ocr'); 142 | }else{ 143 | $result = $client->basicGeneral($this->file_get_contents($image_src)); 144 | $log = '通用文字识别'; 145 | $database->reduce_UseNum('ocr'); 146 | } 147 | $data['ip'] = $_SERVER['REMOTE_ADDR']; 148 | $data['image1'] = '.'.$image_src; 149 | $data['image2'] = '.'; 150 | $data['status'] = $log; 151 | $data['state'] = 1; 152 | $database->ai_InsertInfo($data); 153 | return $result; 154 | // 如果图片是url 调用示例如下 155 | // $result = $client->basicGeneral('http://www.xxxxxx.com/img.jpg'); 156 | } 157 | /** 158 | * 图像识别函数 159 | */ 160 | function image_identification($image_src,$type){ 161 | $client = new AipImageClassify($this->Image_APP_ID, $this->Image_API_KEY, $this->Image_SECRET_KEY); 162 | $database = new database(); 163 | if ($type==2){ 164 | // 图像识别函数--植物识别 165 | $result = $client->plantDetect($this->file_get_contents($image_src)); 166 | $log = '植物识别'; 167 | $database->reduce_UseNum('image2'); 168 | }elseif ($type==3){ 169 | // 图像识别函数--车辆识别 170 | $result = $client->carDetect($this->file_get_contents($image_src)); 171 | $log = '车辆识别'; 172 | $database->reduce_UseNum('image3'); 173 | }elseif ($type==4){ 174 | // 图像识别函数--Logo识别 175 | $result = $client->logoSearch($this->file_get_contents($image_src)); 176 | $log = 'Logo识别'; 177 | $database->reduce_UseNum('image4'); 178 | }else{ 179 | // 图像识别函数--动物识别 180 | $result = $client->animalDetect($this->file_get_contents($image_src)); 181 | $log = '动物识别'; 182 | $database->reduce_UseNum('image1'); 183 | } 184 | $data['ip'] = $_SERVER['REMOTE_ADDR']; 185 | $data['image1'] = '.'.$image_src; 186 | $data['image2'] = '.'; 187 | $data['status'] = $log; 188 | $data['state'] = 1; 189 | $database->ai_InsertInfo($data); 190 | return $result; 191 | // 如果图片是url 调用示例如下 192 | // $result = $client->basicGeneral('http://www.xxxxxx.com/img.jpg'); 193 | } 194 | 195 | function str_handling($text){ 196 | $text = str_replace(" ", "", $text); 197 | $text = str_replace("\n", "", $text); 198 | $text = str_replace("\r", "", $text); 199 | $text = htmlspecialchars( $text); 200 | return $text; 201 | } 202 | /** 203 | * 自然语言处理 204 | */ 205 | function language($text1, $text2,$type){ 206 | $client = new AipNlp($this->Text_APP_ID, $this->Text_API_KEY, $this->Text_SECRET_KEY); 207 | $database = new database(); 208 | if ($type==3){ 209 | // 调用短文本相似度对比接口 210 | $result = $client->simnet($text1,$text2); 211 | $log = '短文本相似度对比'; 212 | $database->reduce_UseNum('text3'); 213 | }else if ($type==4){ 214 | // 调用 词义相似度对比接口 215 | $result = $client->wordSimEmbedding($text1,$text2); 216 | $log = '词义相似度对比'; 217 | $database->reduce_UseNum('text4'); 218 | }else if ($type==2){ 219 | // 调用 词法分析接口 220 | $result = $client->lexer($text1); 221 | $log = '词法分析'; 222 | $database->reduce_UseNum('text2'); 223 | }else if ($type==7){ 224 | // 调用中文DNN语言模型接口 225 | $result = $client->dnnlm($text1); 226 | $log = '中文DNN语言模型'; 227 | $database->reduce_UseNum('text7'); 228 | }else if ($type==6){ 229 | /** 因为参数有13个,所以需要一一遍历出来 $option */ 230 | for($i=1;$i<=13;$i++){ 231 | // 定义参数变量 232 | $option = array('type' => $i); // 汽车分类 233 | // 调用 评论观点抽取接口 234 | $result = $client->commentTag($text1,$option); 235 | if (empty($result['error_code'])){ 236 | break; 237 | } 238 | } 239 | $log = '评论观点抽取'; 240 | $database->reduce_UseNum('text6'); 241 | }else{ 242 | // type = 1 243 | // 调用情感倾向分析接口 244 | $result = $client->sentimentClassify($text1); 245 | $log = '情感倾向分析'; 246 | $database->reduce_UseNum('text1'); 247 | } 248 | $data['ip'] = $_SERVER['REMOTE_ADDR']; 249 | $data['image1'] = $text1; 250 | $data['image2'] = $text2; 251 | $data['status'] = $log; 252 | $data['state'] = 2; 253 | $database->ai_InsertInfo($data); 254 | return $result; 255 | } 256 | /** 257 | * 语音合成与识别处理 258 | */ 259 | function sound($text,$per,$spd,$pit){ 260 | $client = new AipSpeech($this->Sound_APP_ID, $this->Sound_API_KEY, $this->Sound_SECRET_KEY); 261 | $database = new database(); 262 | // 调用语音合成接口 263 | $result = $client->synthesis($text, 'zh', 1, array( 264 | 'vol' => 5,'per' => $per,'spd' => $spd,'pit' => $pit, 265 | )); 266 | 267 | // 识别正确返回语音二进制 错误则返回json 参照下面错误码 268 | //采用时间戳命名 269 | $fname = rand() . time(); 270 | $file = './public/sound/'.$fname.'.mp3'; 271 | if(!is_array($result)){ 272 | file_put_contents($file, $result); 273 | } 274 | $log = '语音合成'; 275 | $database->reduce_UseNum('sound'); 276 | $data['ip'] = $_SERVER['REMOTE_ADDR']; 277 | $data['image1'] = $text; 278 | $data['image2'] = '.'.$file; 279 | $data['status'] = $log; 280 | $data['state'] = 3; 281 | $database->ai_InsertInfo($data); 282 | return $file; 283 | // 如果图片是url 调用示例如下 284 | // $result = $client->basicGeneral('http://www.xxxxxx.com/img.jpg'); 285 | } 286 | /** 287 | * 图片上传函数 288 | */ 289 | function upload_file($file) 290 | { 291 | //全局变量 292 | $arrType = array('image/jpg', 'image/png', 'image/jpeg'); 293 | $max_size = '500000'; // 最大文件限制(单位:byte) 294 | $upfile = './public/uploads'; //图片目录路径 295 | if ($_SERVER['REQUEST_METHOD'] == 'POST') { //判断提交方式是否为POST 296 | if (!is_uploaded_file($file['tmp_name'])) { //判断上传文件是否存在 297 | // return '文件不存在!'; 298 | return '0'; 299 | } 300 | // if ($file['size'] > $max_size) { //判断文件大小是否大于500000字节 301 | // return '上传文件太大!'; 302 | // } 303 | if (!in_array($file['type'], $arrType)) { //判断图片文件的格式 304 | return '0'; 305 | } 306 | if (!file_exists($upfile)) { // 判断存放文件目录是否存在 307 | mkdir($upfile, 0777, true); 308 | } 309 | $imageSize = getimagesize($file['tmp_name']); 310 | $img = $imageSize[0] . '*' . $imageSize[1]; 311 | //采用时间戳命名 312 | $fname = rand() . time(); 313 | $ftype = explode('.', $fname); 314 | $fileinfo = pathinfo($file['name']); 315 | // var_dump($fileinfo['extension']); 316 | // exit(); 317 | $picName = $upfile . "/rain" . $fname . '.' . $fileinfo['extension']; 318 | if (file_exists($picName)) { 319 | // return '同文件名已存在!'; 320 | return '0'; 321 | } 322 | if (!move_uploaded_file($file['tmp_name'], $picName)) { 323 | // return '移动文件出错!'; 324 | return '0'; 325 | } else { 326 | // echo $picName."
"; 327 | // echo "图片文件上传成功!
"; 328 | // echo "图片大小:$img
"; 329 | // echo "图片预览:
330 | // ".$fname."
"; 331 | $image = new Image($picName); 332 | // $image->percent = 0.5; 333 | // $image->openImage(); 334 | // $image->thumpImage(); 335 | // $image->showImage(); 336 | // $picName = './public/image' . "/rain" . $fname . '.' . $file['type']; 337 | // $image->saveImage($fname); 338 | $image->image_png_size_add($picName,$picName); 339 | return $picName; 340 | 341 | } 342 | } 343 | } 344 | } 345 | 346 | ?> -------------------------------------------------------------------------------- /face_compare.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 人脸对比 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | use_num('2');?> 33 |
34 | 35 | 36 | 37 |

人脸识别---人脸对比功能
38 | 对比两张人脸的相似度,并给出相似度评分,从而判断是否同一个人
39 | (今日剩余使用次数

40 | 41 |

今日次数以及使用完毕,请明日再来

42 | 43 |
44 |
45 | 46 |
47 | 49 | 50 |    51 |
52 |
53 | 55 | 56 |    57 |
58 |
59 | 60 |
61 |
62 |
63 | 64 | upload_file($file1); 73 | $image_src2 = $function->upload_file($file2); 74 | if ($image_src1=='0'||$image_src2=='0'){?>

上传文件格式不对!

75 | face($image_src1,$image_src2,1); 77 | $use_num = $function->use_num('2'); 78 | // var_dump($result); 79 | ?> 80 | 81 |
82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
相似指数
90 |
91 |
92 | 93 |
94 | 95 |
96 |
97 | 98 |
99 |
100 | 101 | 106 |
107 | 108 | 109 | 110 | 111 | -------------------------------------------------------------------------------- /face_detect.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 人脸检测 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | use_num('1'); 36 | ?> 37 |
38 |

人脸识别---人脸检测功能
39 | 精准定位图中人脸,获得眼、口、鼻等72个关键点位置,分析性别、年龄、表情等多种人脸属性
40 | (今日剩余使用次数 41 |

42 | 43 |

今日次数以及使用完毕,请明日再来

44 | 45 |
46 |
47 |
48 | 49 | 51 | 52 |    53 | 54 | 55 | 56 |
57 | 58 |
59 |
60 |
61 | 62 | upload_file($file); 70 | if ($image_src=='0'){?>

上传文件格式不对!

71 | face($image_src,'',2); 73 | $use_num = $function->use_num('1'); 74 | // var_dump($result); 75 | ?> 76 | 77 |
78 |
79 | 80 |
81 |
82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 |
人脸数
90 | 91 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 |
人脸属性
颜值分数
面部表情
人物性别
眼镜类型
人种肤色
人物年龄
人物脸型方形脸概率:
三角形脸概率:
椭圆脸概率:
心型脸概率:
圆形脸概率:
真人/卡通真实人脸置信度:
卡通人脸置信度:
153 | 154 | 155 | 156 |
157 |
158 | 159 | 164 | 165 |
166 | 167 | 168 | 169 | 170 | -------------------------------------------------------------------------------- /header.php: -------------------------------------------------------------------------------- 1 |
2 | Open Nav 3 | 4 | 26 | 27 |
28 | 184 |
185 |
-------------------------------------------------------------------------------- /image_identification.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 图像识别 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 34 |
35 | 36 | 37 | 38 |

图像识别--- 39 | 4||$type<2){$type=1;} 47 | $use_num = $function->use_num('5'.$type); 48 | ?>识别功能
49 | (今日剩余使用次数 50 |

51 | 52 |

今日次数以及使用完毕,请明日再来

53 | 54 |
55 |
56 |
57 | 59 | 60 |    61 | 62 | 63 | 64 |
65 | 66 |
67 |
68 |
69 | 70 | upload_file($file); 78 | if ($image_src=='0'){?>

上传文件格式不对!

79 | image_identification($image_src,$type); 81 | $use_num = $function->use_num('5'.$type); 82 | // var_dump($result); 83 | ?> 84 | 85 |
86 |
87 | 88 |
89 | 90 |
91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 |
识别数
99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 109 | 110 | 111 | 114 | 115 | 116 |
商标名称置信度
112 | 113 |
117 | 118 |
119 | 120 |
121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 131 | 132 | 133 | 136 | 137 | 138 |
动物名称置信度
134 | 135 |
139 | 140 |
141 | 142 | 143 |
144 | 145 | 150 |
151 | 152 | 153 | 154 | 155 | -------------------------------------------------------------------------------- /ocr_all.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 文字识别 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | use_num('4');?> 33 |
34 | 35 | 36 | 37 |

文字识别---通用文字识别功能
38 | 基于深度学习技术,提供多场景、多语种、高精度的整图文字检测和识别服务
39 | (今日剩余使用次数

40 | 41 |

今日次数以及使用完毕,请明日再来

42 | 43 |
44 |
45 |
46 | 47 | 49 | 50 |    51 | 52 | 53 | 54 |
55 | 56 |
57 | 58 |
59 | 60 | upload_file($file); 68 | // echo $image_src;exit(); 69 | if ($image_src=='0'){?>

上传文件格式不对!

70 | ocr_recognition($image_src,1); 72 | $use_num = $function->use_num('4'); 73 | // var_dump($result); 74 | ?> 75 | 76 |
77 |
78 | 79 |
80 |
81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 |
识别行数
89 | 90 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 |

105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 |
114 |
115 | 116 | 121 |
122 | 123 | 124 | 125 | 126 | -------------------------------------------------------------------------------- /public/assets/css/admin.css: -------------------------------------------------------------------------------- 1 | /** 2 | * admin.css 3 | */ 4 | 5 | 6 | /* 7 | fixed-layout 固定头部和边栏布局 8 | */ 9 | 10 | html, 11 | body { 12 | height: 100%; 13 | overflow: hidden; 14 | } 15 | 16 | ul { 17 | margin-top: 0; 18 | } 19 | 20 | .admin-icon-yellow { 21 | color: #ffbe40; 22 | } 23 | 24 | .admin-header { 25 | position: fixed; 26 | top: 0; 27 | left: 0; 28 | right: 0; 29 | z-index: 1500; 30 | font-size: 1.4rem; 31 | margin-bottom: 0; 32 | } 33 | 34 | .admin-header-list a:hover :after { 35 | content: none; 36 | } 37 | 38 | .admin-main { 39 | position: relative; 40 | height: 100%; 41 | padding-top: 51px; 42 | background: #f3f3f3; 43 | } 44 | 45 | .admin-menu { 46 | position: fixed; 47 | z-index: 10; 48 | bottom: 30px; 49 | right: 20px; 50 | } 51 | 52 | .admin-sidebar { 53 | width: 260px; 54 | min-height: 100%; 55 | float: left; 56 | border-right: 1px solid #cecece; 57 | } 58 | 59 | .admin-sidebar.am-active { 60 | z-index: 1600; 61 | } 62 | 63 | .admin-sidebar-list { 64 | margin-bottom: 0; 65 | } 66 | 67 | .admin-sidebar-list li a { 68 | color: #5c5c5c; 69 | padding-left: 24px; 70 | } 71 | 72 | .admin-sidebar-list li:first-child { 73 | border-top: none; 74 | } 75 | 76 | .admin-sidebar-sub { 77 | margin-top: 0; 78 | margin-bottom: 0; 79 | box-shadow: 0 16px 8px -15px #e2e2e2 inset; 80 | background: #ececec; 81 | padding-left: 24px; 82 | } 83 | 84 | .admin-sidebar-sub li:first-child { 85 | border-top: 1px solid #dedede; 86 | } 87 | 88 | .admin-sidebar-panel { 89 | margin: 10px; 90 | } 91 | 92 | .admin-content { 93 | display: -webkit-box; 94 | display: -webkit-flex; 95 | display: -ms-flexbox; 96 | display: flex; 97 | -webkit-box-orient: vertical; 98 | -webkit-box-direction: normal; 99 | -webkit-flex-direction: column; 100 | -ms-flex-direction: column; 101 | flex-direction: column; 102 | background: #fff; 103 | } 104 | 105 | .admin-content, 106 | .admin-sidebar { 107 | height: 100%; 108 | overflow-x: hidden; 109 | overflow-y: scroll; 110 | -webkit-overflow-scrolling: touch; 111 | } 112 | 113 | .admin-content-body { 114 | -webkit-box-flex: 1; 115 | -webkit-flex: 1 0 auto; 116 | -ms-flex: 1 0 auto; 117 | flex: 1 0 auto; 118 | } 119 | 120 | .admin-content-footer { 121 | font-size: 85%; 122 | color: #777; 123 | } 124 | 125 | .admin-content-list { 126 | border: 1px solid #e9ecf1; 127 | margin-top: 0; 128 | } 129 | 130 | .admin-content-list li { 131 | border: 1px solid #e9ecf1; 132 | border-width: 0 1px; 133 | margin-left: -1px; 134 | } 135 | 136 | .admin-content-list li:first-child { 137 | border-left: none; 138 | } 139 | 140 | .admin-content-list li:last-child { 141 | border-right: none; 142 | } 143 | 144 | .admin-content-table a { 145 | color: #535353; 146 | } 147 | .admin-content-file { 148 | margin-bottom: 0; 149 | color: #666; 150 | } 151 | 152 | .admin-content-file p { 153 | margin: 0 0 5px 0; 154 | font-size: 1.4rem; 155 | } 156 | 157 | .admin-content-file li { 158 | padding: 10px 0; 159 | } 160 | 161 | .admin-content-file li:first-child { 162 | border-top: none; 163 | } 164 | 165 | .admin-content-file li:last-child { 166 | border-bottom: none; 167 | } 168 | 169 | .admin-content-file li .am-progress { 170 | margin-bottom: 4px; 171 | } 172 | 173 | .admin-content-file li .am-progress-bar { 174 | line-height: 14px; 175 | } 176 | 177 | .admin-content-task { 178 | margin-bottom: 0; 179 | } 180 | 181 | .admin-content-task li { 182 | padding: 5px 0; 183 | border-color: #eee; 184 | } 185 | 186 | .admin-content-task li:first-child { 187 | border-top: none; 188 | } 189 | 190 | .admin-content-task li:last-child { 191 | border-bottom: none; 192 | } 193 | 194 | .admin-task-meta { 195 | font-size: 1.2rem; 196 | color: #999; 197 | } 198 | 199 | .admin-task-bd { 200 | font-size: 1.4rem; 201 | margin-bottom: 5px; 202 | } 203 | 204 | .admin-content-comment { 205 | margin-bottom: 0; 206 | } 207 | 208 | .admin-content-comment .am-comment-bd { 209 | font-size: 1.4rem; 210 | } 211 | 212 | .admin-content-pagination { 213 | margin-bottom: 0; 214 | } 215 | .admin-content-pagination li a { 216 | padding: 4px 8px; 217 | } 218 | 219 | @media only screen and (min-width: 641px) { 220 | .admin-sidebar { 221 | display: block; 222 | position: static; 223 | background: none; 224 | } 225 | 226 | .admin-offcanvas-bar { 227 | position: static; 228 | width: auto; 229 | background: none; 230 | -webkit-transform: translate3d(0, 0, 0); 231 | -ms-transform: translate3d(0, 0, 0); 232 | transform: translate3d(0, 0, 0); 233 | overflow-y: visible; 234 | min-height: 100%; 235 | } 236 | .admin-offcanvas-bar:after { 237 | content: none; 238 | } 239 | } 240 | 241 | @media only screen and (max-width: 640px) { 242 | .admin-sidebar { 243 | width: inherit; 244 | } 245 | 246 | .admin-offcanvas-bar { 247 | background: #f3f3f3; 248 | } 249 | 250 | .admin-offcanvas-bar:after { 251 | background: #BABABA; 252 | } 253 | 254 | .admin-sidebar-list a:hover, .admin-sidebar-list a:active{ 255 | -webkit-transition: background-color .3s ease; 256 | -moz-transition: background-color .3s ease; 257 | -ms-transition: background-color .3s ease; 258 | -o-transition: background-color .3s ease; 259 | transition: background-color .3s ease; 260 | background: #E4E4E4; 261 | } 262 | 263 | .admin-content-list li { 264 | padding: 10px; 265 | border-width: 1px 0; 266 | margin-top: -1px; 267 | } 268 | 269 | .admin-content-list li:first-child { 270 | border-top: none; 271 | } 272 | 273 | .admin-content-list li:last-child { 274 | border-bottom: none; 275 | } 276 | 277 | .admin-form-text { 278 | text-align: left !important; 279 | } 280 | 281 | } 282 | 283 | /* 284 | * user.html css 285 | */ 286 | .user-info { 287 | margin-bottom: 15px; 288 | } 289 | 290 | .user-info .am-progress { 291 | margin-bottom: 4px; 292 | } 293 | 294 | .user-info p { 295 | margin: 5px; 296 | } 297 | 298 | .user-info-order { 299 | font-size: 1.4rem; 300 | } 301 | 302 | /* 303 | * errorLog.html css 304 | */ 305 | 306 | .error-log .am-pre-scrollable { 307 | max-height: 40rem; 308 | } 309 | 310 | /* 311 | * table.html css 312 | */ 313 | 314 | .table-main { 315 | font-size: 1.4rem; 316 | padding: .5rem; 317 | } 318 | 319 | .table-main button { 320 | background: #fff; 321 | } 322 | 323 | .table-check { 324 | width: 30px; 325 | } 326 | 327 | .table-id { 328 | width: 50px; 329 | } 330 | 331 | @media only screen and (max-width: 640px) { 332 | .table-select { 333 | margin-top: 10px; 334 | margin-left: 5px; 335 | } 336 | } 337 | 338 | /* 339 | gallery.html css 340 | */ 341 | 342 | .gallery-list li { 343 | padding: 10px; 344 | } 345 | 346 | .gallery-list a { 347 | color: #666; 348 | } 349 | 350 | .gallery-list a:hover { 351 | color: #3bb4f2; 352 | } 353 | 354 | .gallery-title { 355 | margin-top: 6px; 356 | font-size: 1.4rem; 357 | } 358 | 359 | .gallery-desc { 360 | font-size: 1.2rem; 361 | margin-top: 4px; 362 | } 363 | 364 | /* 365 | 404.html css 366 | */ 367 | 368 | .page-404 { 369 | background: #fff; 370 | border: none; 371 | width: 200px; 372 | margin: 0 auto; 373 | } 374 | -------------------------------------------------------------------------------- /public/assets/css/app.css: -------------------------------------------------------------------------------- 1 | /* Write your styles */ -------------------------------------------------------------------------------- /public/assets/fonts/FontAwesome.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/fonts/FontAwesome.otf -------------------------------------------------------------------------------- /public/assets/fonts/fontawesome-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/fonts/fontawesome-webfont.eot -------------------------------------------------------------------------------- /public/assets/fonts/fontawesome-webfont.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/fonts/fontawesome-webfont.ttf -------------------------------------------------------------------------------- /public/assets/fonts/fontawesome-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/fonts/fontawesome-webfont.woff -------------------------------------------------------------------------------- /public/assets/fonts/fontawesome-webfont.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/fonts/fontawesome-webfont.woff2 -------------------------------------------------------------------------------- /public/assets/i/app-icon72x72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/app-icon72x72@2x.png -------------------------------------------------------------------------------- /public/assets/i/examples/admin-chrome.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/admin-chrome.png -------------------------------------------------------------------------------- /public/assets/i/examples/admin-firefox.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/admin-firefox.png -------------------------------------------------------------------------------- /public/assets/i/examples/admin-ie.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/admin-ie.png -------------------------------------------------------------------------------- /public/assets/i/examples/admin-opera.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/admin-opera.png -------------------------------------------------------------------------------- /public/assets/i/examples/admin-safari.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/admin-safari.png -------------------------------------------------------------------------------- /public/assets/i/examples/adminPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/adminPage.png -------------------------------------------------------------------------------- /public/assets/i/examples/blogPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/blogPage.png -------------------------------------------------------------------------------- /public/assets/i/examples/landing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/landing.png -------------------------------------------------------------------------------- /public/assets/i/examples/landingPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/landingPage.png -------------------------------------------------------------------------------- /public/assets/i/examples/loginPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/loginPage.png -------------------------------------------------------------------------------- /public/assets/i/examples/sidebarPage.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/examples/sidebarPage.png -------------------------------------------------------------------------------- /public/assets/i/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/favicon.png -------------------------------------------------------------------------------- /public/assets/i/startup-640x1096.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/assets/i/startup-640x1096.png -------------------------------------------------------------------------------- /public/assets/js/app.js: -------------------------------------------------------------------------------- 1 | (function($) { 2 | 'use strict'; 3 | 4 | $(function() { 5 | var $fullText = $('.admin-fullText'); 6 | $('#admin-fullscreen').on('click', function() { 7 | $.AMUI.fullscreen.toggle(); 8 | }); 9 | 10 | $(document).on($.AMUI.fullscreen.raw.fullscreenchange, function() { 11 | $fullText.text($.AMUI.fullscreen.isFullscreen ? '退出全屏' : '开启全屏'); 12 | }); 13 | }); 14 | })(jQuery); 15 | -------------------------------------------------------------------------------- /public/css/reset.css: -------------------------------------------------------------------------------- 1 | /* http://meyerweb.com/eric/tools/css/reset/ 2 | v2.0 | 20110126 3 | License: none (public domain) 4 | */ 5 | 6 | html, body, div, span, applet, object, iframe, 7 | h1, h2, h3, h4, h5, h6, p, blockquote, pre, 8 | a, abbr, acronym, address, big, cite, code, 9 | del, dfn, em, img, ins, kbd, q, s, samp, 10 | small, strike, strong, sub, sup, tt, var, 11 | b, u, i, center, 12 | dl, dt, dd, ol, ul, li, 13 | fieldset, form, label, legend, 14 | table, caption, tbody, tfoot, thead, tr, th, td, 15 | article, aside, canvas, details, embed, 16 | figure, figcaption, footer, header, hgroup, 17 | menu, nav, output, ruby, section, summary, 18 | time, mark, audio, video { 19 | margin: 0; 20 | padding: 0; 21 | border: 0; 22 | font-size: 100%; 23 | font: inherit; 24 | vertical-align: baseline; 25 | } 26 | /* HTML5 display-role reset for older browsers */ 27 | article, aside, details, figcaption, figure, 28 | footer, header, hgroup, menu, nav, section, main { 29 | display: block; 30 | } 31 | body { 32 | line-height: 1; 33 | } 34 | ol, ul { 35 | list-style: none; 36 | } 37 | blockquote, q { 38 | quotes: none; 39 | } 40 | blockquote:before, blockquote:after, 41 | q:before, q:after { 42 | content: ''; 43 | content: none; 44 | } 45 | table { 46 | border-collapse: collapse; 47 | border-spacing: 0; 48 | } -------------------------------------------------------------------------------- /public/css/style.css: -------------------------------------------------------------------------------- 1 | /* -------------------------------- 2 | 3 | Primary style 4 | 5 | -------------------------------- */ 6 | *, *::after, *::before { 7 | box-sizing: border-box; 8 | } 9 | 10 | html { 11 | font-size: 62.5%; 12 | } 13 | 14 | body { 15 | font-size: 1.6rem; 16 | font-family: "Lato", sans-serif; 17 | color: #1A1A1A; 18 | background-color: #FFFFFF; 19 | } 20 | 21 | a { 22 | color: #DB6356; 23 | text-decoration: none; 24 | } 25 | 26 | /* -------------------------------- 27 | 28 | Header 29 | 30 | -------------------------------- */ 31 | .cd-morph-dropdown { 32 | position: relative; 33 | height: 60px; 34 | background-color: #FFFFFF; 35 | } 36 | .cd-morph-dropdown::before { 37 | /* never visible - used in JS to check mq */ 38 | content: 'mobile'; 39 | display: none; 40 | } 41 | .cd-morph-dropdown .nav-trigger { 42 | /* menu icon - visible on small screens only */ 43 | position: absolute; 44 | top: 0; 45 | right: 0; 46 | height: 60px; 47 | width: 60px; 48 | /* replace text with icon */ 49 | overflow: hidden; 50 | text-indent: 100%; 51 | white-space: nowrap; 52 | color: transparent; 53 | } 54 | .cd-morph-dropdown .nav-trigger span, .cd-morph-dropdown .nav-trigger span::after, .cd-morph-dropdown .nav-trigger span::before { 55 | /* these are the 3 lines of the menu icon */ 56 | position: absolute; 57 | background-color: #1A1A1A; 58 | height: 3px; 59 | width: 26px; 60 | } 61 | .cd-morph-dropdown .nav-trigger span { 62 | left: 50%; 63 | top: 50%; 64 | bottom: auto; 65 | right: auto; 66 | -webkit-transform: translateX(-50%) translateY(-50%); 67 | -ms-transform: translateX(-50%) translateY(-50%); 68 | transform: translateX(-50%) translateY(-50%); 69 | -webkit-transition: background-color .3s; 70 | transition: background-color .3s; 71 | } 72 | .cd-morph-dropdown .nav-trigger span::after, .cd-morph-dropdown .nav-trigger span::before { 73 | content: ''; 74 | left: 0; 75 | -webkit-transition: -webkit-transform .3s; 76 | transition: -webkit-transform .3s; 77 | transition: transform .3s; 78 | transition: transform .3s, -webkit-transform .3s; 79 | } 80 | .cd-morph-dropdown .nav-trigger span::before { 81 | -webkit-transform: translateY(-9px); 82 | -ms-transform: translateY(-9px); 83 | transform: translateY(-9px); 84 | } 85 | .cd-morph-dropdown .nav-trigger span::after { 86 | -webkit-transform: translateY(9px); 87 | -ms-transform: translateY(9px); 88 | transform: translateY(9px); 89 | } 90 | .cd-morph-dropdown.nav-open .nav-trigger span { 91 | background-color: transparent; 92 | } 93 | .cd-morph-dropdown.nav-open .nav-trigger span::before { 94 | -webkit-transform: rotate(45deg); 95 | -ms-transform: rotate(45deg); 96 | transform: rotate(45deg); 97 | } 98 | .cd-morph-dropdown.nav-open .nav-trigger span::after { 99 | -webkit-transform: rotate(-45deg); 100 | -ms-transform: rotate(-45deg); 101 | transform: rotate(-45deg); 102 | } 103 | .cd-morph-dropdown .main-nav { 104 | display: none; 105 | } 106 | .cd-morph-dropdown .morph-dropdown-wrapper { 107 | display: none; 108 | position: absolute; 109 | top: 60px; 110 | left: 0; 111 | width: 100%; 112 | padding: 1.2em 5%; 113 | box-shadow: inset 0 1px 0 #e6e6e6; 114 | background-color: #FFFFFF; 115 | } 116 | .cd-morph-dropdown.nav-open .morph-dropdown-wrapper { 117 | display: block; 118 | } 119 | .cd-morph-dropdown .dropdown-list > ul > li { 120 | margin-bottom: 3.3em; 121 | } 122 | .cd-morph-dropdown .label { 123 | display: block; 124 | font-size: 2.2rem; 125 | color: #1A1A1A; 126 | margin-bottom: .8em; 127 | } 128 | .cd-morph-dropdown .content li::after { 129 | clear: both; 130 | content: ""; 131 | display: block; 132 | } 133 | .cd-morph-dropdown .gallery .content li { 134 | margin-bottom: 1.4em; 135 | } 136 | .cd-morph-dropdown .gallery .content a { 137 | display: block; 138 | } 139 | .cd-morph-dropdown .gallery .content a::before { 140 | /* icon on the left */ 141 | content: ''; 142 | display: inline-block; 143 | float: left; 144 | height: 54px; 145 | width: 54px; 146 | margin-right: .6em; 147 | background: red; 148 | border-radius: 50%; 149 | -webkit-transition: background .2s; 150 | transition: background .2s; 151 | } 152 | .cd-morph-dropdown .gallery .content a span, .cd-morph-dropdown .gallery .content a em { 153 | display: block; 154 | line-height: 1.2; 155 | } 156 | .cd-morph-dropdown .gallery .content a em { 157 | font-size: 1.8rem; 158 | padding: .4em 0 .2em; 159 | color: #1A1A1A; 160 | } 161 | .cd-morph-dropdown .gallery .content a span { 162 | font-size: 1.4rem; 163 | color: #a6a6a6; 164 | } 165 | .cd-morph-dropdown .gallery .content a:hover::before { 166 | background-color: #1A1A1A; 167 | } 168 | .cd-morph-dropdown .gallery li:nth-of-type(1) a::before { 169 | background: #f4e58a url(../img/cd-gallery-icons.svg) no-repeat 0 0; 170 | } 171 | .cd-morph-dropdown .gallery li:nth-of-type(2) a::before { 172 | background: #F4AF6D url(../img/cd-gallery-icons.svg) no-repeat -54px 0; 173 | } 174 | .cd-morph-dropdown .gallery li:nth-of-type(3) a::before { 175 | background: #DB6356 url(../img/cd-gallery-icons.svg) no-repeat -108px 0; 176 | } 177 | .cd-morph-dropdown .gallery li:nth-of-type(4) a::before { 178 | background: #8D4645 url(../img/cd-gallery-icons.svg) no-repeat -162px 0; 179 | } 180 | .cd-morph-dropdown .links .content > ul > li { 181 | margin-top: 1em; 182 | } 183 | .cd-morph-dropdown .links-list a, 184 | .cd-morph-dropdown .btn { 185 | display: block; 186 | margin-left: 14px; 187 | font-size: 2.2rem; 188 | line-height: 1.6; 189 | } 190 | .cd-morph-dropdown .links-list a:hover, 191 | .cd-morph-dropdown .btn:hover { 192 | color: #1A1A1A; 193 | } 194 | .cd-morph-dropdown .content h2 { 195 | color: #ffff; 196 | text-transform: uppercase; 197 | font-weight: bold; 198 | font-size: 1.3rem; 199 | margin: 20px 0 10px 14px; 200 | } 201 | @media only screen and (min-width: 1000px) { 202 | .cd-morph-dropdown { 203 | position: absolute; 204 | height: 80px; 205 | left: 0; 206 | top: 0; 207 | width: 100%; 208 | padding: 0; 209 | text-align: center; 210 | background-color: transparent; 211 | } 212 | .cd-morph-dropdown::before { 213 | content: 'desktop'; 214 | } 215 | .cd-morph-dropdown .nav-trigger { 216 | display: none; 217 | } 218 | .cd-morph-dropdown .main-nav { 219 | display: inline-block; 220 | } 221 | .cd-morph-dropdown .main-nav > ul > li { 222 | display: inline-block; 223 | float: left; 224 | } 225 | .cd-morph-dropdown .main-nav > ul > li > a { 226 | display: block; 227 | padding: 0 1.8em; 228 | height: 70px; 229 | line-height: 70px; 230 | color: #393D49; 231 | font-size: 1.8rem; 232 | -webkit-font-smoothing: antialiased; 233 | -moz-osx-font-smoothing: grayscale; 234 | -webkit-transition: opacity .2s; 235 | transition: opacity .2s; 236 | } 237 | .cd-morph-dropdown.is-dropdown-visible .main-nav > ul > li > a { 238 | /* main navigation hover effect - on hover, reduce opacity of elements not hovered over */ 239 | opacity: .6; 240 | } 241 | .cd-morph-dropdown.is-dropdown-visible .main-nav > ul > li.active > a { 242 | opacity: 1; 243 | } 244 | .cd-morph-dropdown .morph-dropdown-wrapper { 245 | /* dropdown wrapper - used to create the slide up/slide down effect when dropdown is revealed/hidden */ 246 | display: block; 247 | top: 58px; 248 | /* overwrite mobile style */ 249 | width: auto; 250 | padding: 0; 251 | box-shadow: none; 252 | background-color: transparent; 253 | /* Force Hardware acceleration */ 254 | -webkit-transform: translateZ(0); 255 | transform: translateZ(0); 256 | will-change: transform; 257 | -webkit-transform: translateY(20px); 258 | -ms-transform: translateY(20px); 259 | transform: translateY(20px); 260 | -webkit-transition: -webkit-transform .3s; 261 | transition: -webkit-transform .3s; 262 | transition: transform .3s; 263 | transition: transform .3s, -webkit-transform .3s; 264 | } 265 | .cd-morph-dropdown.is-dropdown-visible .morph-dropdown-wrapper { 266 | -webkit-transform: translateY(0); 267 | -ms-transform: translateY(0); 268 | transform: translateY(0); 269 | } 270 | .cd-morph-dropdown .dropdown-list { 271 | position: absolute; 272 | top: 0; 273 | left: 0; 274 | visibility: hidden; 275 | -webkit-transform: translateZ(0); 276 | transform: translateZ(0); 277 | will-change: transform, width, height; 278 | -webkit-transition: visibility .3s; 279 | transition: visibility .3s; 280 | box-shadow: 0 10px 20px rgba(0, 0, 0, 0.08); 281 | } 282 | .no-csstransitions .cd-morph-dropdown .dropdown-list { 283 | display: none; 284 | } 285 | .cd-morph-dropdown .dropdown-list::before { 286 | /* dropdown top triangle */ 287 | content: ''; 288 | position: absolute; 289 | bottom: 100%; 290 | left: 50%; 291 | right: auto; 292 | -webkit-transform: translateX(-50%); 293 | -ms-transform: translateX(-50%); 294 | transform: translateX(-50%); 295 | height: 0; 296 | width: 0; 297 | border: 8px solid transparent; 298 | border-bottom-color: #FFFFFF; 299 | opacity: 0; 300 | -webkit-transition: opacity .3s; 301 | transition: opacity .3s; 302 | } 303 | .cd-morph-dropdown .dropdown-list > ul { 304 | position: relative; 305 | z-index: 1; 306 | height: 100%; 307 | width: 100%; 308 | overflow: hidden; 309 | } 310 | .cd-morph-dropdown.is-dropdown-visible .dropdown-list { 311 | visibility: visible; 312 | -webkit-transition: width .3s, height .3s, -webkit-transform .3s; 313 | transition: width .3s, height .3s, -webkit-transform .3s; 314 | transition: transform .3s, width .3s, height .3s; 315 | transition: transform .3s, width .3s, height .3s, -webkit-transform .3s; 316 | } 317 | .cd-morph-dropdown.is-dropdown-visible .dropdown-list::before { 318 | opacity: 1; 319 | } 320 | .cd-morph-dropdown .dropdown { 321 | position: absolute; 322 | left: 0; 323 | top: 0; 324 | opacity: 0; 325 | visibility: hidden; 326 | width: 100%; 327 | -webkit-transition: opacity .3s, visibility .3s; 328 | transition: opacity .3s, visibility .3s; 329 | } 330 | .cd-morph-dropdown .dropdown.active { 331 | opacity: 1; 332 | visibility: visible; 333 | } 334 | .cd-morph-dropdown .dropdown.move-left .content { 335 | -webkit-transform: translateX(-100px); 336 | -ms-transform: translateX(-100px); 337 | transform: translateX(-100px); 338 | } 339 | .cd-morph-dropdown .dropdown.move-right .content { 340 | -webkit-transform: translateX(100px); 341 | -ms-transform: translateX(100px); 342 | transform: translateX(100px); 343 | } 344 | .cd-morph-dropdown .label { 345 | /* hide the label on bigger devices */ 346 | display: none; 347 | } 348 | .cd-morph-dropdown .content { 349 | padding: 2.2em 1.8em; 350 | -webkit-transition: -webkit-transform .3s; 351 | transition: -webkit-transform .3s; 352 | transition: transform .3s; 353 | transition: transform .3s, -webkit-transform .3s; 354 | text-align: left; 355 | } 356 | .cd-morph-dropdown .content > ul::after { 357 | clear: both; 358 | content: ""; 359 | display: block; 360 | } 361 | .cd-morph-dropdown .content > ul > li { 362 | width: 48%; 363 | float: left; 364 | margin-right: 4%; 365 | margin-top: 0; 366 | } 367 | .cd-morph-dropdown .content > ul > li:nth-of-type(2n) { 368 | margin-right: 0; 369 | } 370 | .cd-morph-dropdown .gallery .content { 371 | /* you need to set a width for the .content elements because they have a position absolute */ 372 | width: 510px; 373 | padding-bottom: .8em; 374 | } 375 | .cd-morph-dropdown .gallery .content li { 376 | margin-bottom: 1.8em; 377 | } 378 | .cd-morph-dropdown .links .content > ul > li { 379 | margin-top: 0; 380 | } 381 | .cd-morph-dropdown .links .content, 382 | .cd-morph-dropdown .button .content { 383 | width: 390px; 384 | } 385 | .cd-morph-dropdown .links-list a { 386 | font-size: 1.6rem; 387 | margin-left: 0; 388 | } 389 | .cd-morph-dropdown .btn { 390 | display: block; 391 | width: 100%; 392 | height: 60px; 393 | margin: 1.5em 0 0; 394 | font-size: 1.8rem; 395 | text-align: center; 396 | color: #FFFFFF; 397 | line-height: 60px; 398 | background: #DB6356; 399 | -webkit-font-smoothing: antialiased; 400 | -moz-osx-font-smoothing: grayscale; 401 | } 402 | .cd-morph-dropdown .btn:hover { 403 | background: #1A1A1A; 404 | color: #FFFFFF; 405 | } 406 | .cd-morph-dropdown .content h2 { 407 | font-size: 1.8rem; 408 | text-transform: none; 409 | font-weight: normal; 410 | color: #1A1A1A; 411 | margin: 0 0 .6em; 412 | } 413 | .cd-morph-dropdown .bg-layer { 414 | /* morph dropdown background */ 415 | position: absolute; 416 | top: 0; 417 | left: 0; 418 | height: 1px; 419 | width: 1px; 420 | background: #FFFFFF; 421 | opacity: 0; 422 | -webkit-transition: opacity .3s; 423 | transition: opacity .3s; 424 | -webkit-transform-origin: top left; 425 | -ms-transform-origin: top left; 426 | transform-origin: top left; 427 | -webkit-transform: translateZ(0); 428 | transform: translateZ(0); 429 | will-change: transform; 430 | -webkit-backface-visibility: hidden; 431 | backface-visibility: hidden; 432 | } 433 | .cd-morph-dropdown.is-dropdown-visible .bg-layer { 434 | opacity: 1; 435 | -webkit-transition: opacity .3s, -webkit-transform .3s; 436 | transition: opacity .3s, -webkit-transform .3s; 437 | transition: transform .3s, opacity .3s; 438 | transition: transform .3s, opacity .3s, -webkit-transform .3s; 439 | } 440 | } 441 | 442 | /* -------------------------------- 443 | 444 | Main site content 445 | 446 | -------------------------------- */ 447 | .cd-main-content { 448 | min-height: 100vh; 449 | background-color: #F0F0F0; 450 | } 451 | @media only screen and (min-width: 1000px) { 452 | .cd-main-content { 453 | padding-top: 80px; 454 | } 455 | } 456 | -------------------------------------------------------------------------------- /public/face2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/face2.jpg -------------------------------------------------------------------------------- /public/face3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/rainweb521/AI-Face-Sound-OCR-Image/5f9904302d6920103250c31465758e476e45cf6a/public/face3.jpg -------------------------------------------------------------------------------- /public/js/main.js: -------------------------------------------------------------------------------- 1 | jQuery(document).ready(function($){ 2 | function morphDropdown( element ) { 3 | this.element = element; 4 | this.mainNavigation = this.element.find('.main-nav'); 5 | this.mainNavigationItems = this.mainNavigation.find('.has-dropdown'); 6 | this.dropdownList = this.element.find('.dropdown-list'); 7 | this.dropdownWrappers = this.dropdownList.find('.dropdown'); 8 | this.dropdownItems = this.dropdownList.find('.content'); 9 | this.dropdownBg = this.dropdownList.find('.bg-layer'); 10 | this.mq = this.checkMq(); 11 | this.bindEvents(); 12 | } 13 | 14 | morphDropdown.prototype.checkMq = function() { 15 | //check screen size 16 | var self = this; 17 | return window.getComputedStyle(self.element.get(0), '::before').getPropertyValue('content').replace(/'/g, "").replace(/"/g, "").split(', '); 18 | }; 19 | 20 | morphDropdown.prototype.bindEvents = function() { 21 | var self = this; 22 | //hover over an item in the main navigation 23 | this.mainNavigationItems.mouseenter(function(event){ 24 | //hover over one of the nav items -> show dropdown 25 | self.showDropdown($(this)); 26 | }).mouseleave(function(){ 27 | setTimeout(function(){ 28 | //if not hovering over a nav item or a dropdown -> hide dropdown 29 | if( self.mainNavigation.find('.has-dropdown:hover').length == 0 && self.element.find('.dropdown-list:hover').length == 0 ) self.hideDropdown(); 30 | }, 50); 31 | }); 32 | 33 | //hover over the dropdown 34 | this.dropdownList.mouseleave(function(){ 35 | setTimeout(function(){ 36 | //if not hovering over a dropdown or a nav item -> hide dropdown 37 | (self.mainNavigation.find('.has-dropdown:hover').length == 0 && self.element.find('.dropdown-list:hover').length == 0 ) && self.hideDropdown(); 38 | }, 50); 39 | }); 40 | 41 | //click on an item in the main navigation -> open a dropdown on a touch device 42 | this.mainNavigationItems.on('touchstart', function(event){ 43 | var selectedDropdown = self.dropdownList.find('#'+$(this).data('content')); 44 | if( !self.element.hasClass('is-dropdown-visible') || !selectedDropdown.hasClass('active') ) { 45 | event.preventDefault(); 46 | self.showDropdown($(this)); 47 | } 48 | }); 49 | 50 | //on small screens, open navigation clicking on the menu icon 51 | this.element.on('click', '.nav-trigger', function(event){ 52 | event.preventDefault(); 53 | self.element.toggleClass('nav-open'); 54 | }); 55 | }; 56 | 57 | morphDropdown.prototype.showDropdown = function(item) { 58 | this.mq = this.checkMq(); 59 | if( this.mq == 'desktop') { 60 | var self = this; 61 | var selectedDropdown = this.dropdownList.find('#'+item.data('content')), 62 | selectedDropdownHeight = selectedDropdown.innerHeight(), 63 | selectedDropdownWidth = selectedDropdown.children('.content').innerWidth(), 64 | selectedDropdownLeft = item.offset().left + item.innerWidth()/2 - selectedDropdownWidth/2; 65 | 66 | //update dropdown position and size 67 | this.updateDropdown(selectedDropdown, parseInt(selectedDropdownHeight), selectedDropdownWidth, parseInt(selectedDropdownLeft)); 68 | //add active class to the proper dropdown item 69 | this.element.find('.active').removeClass('active'); 70 | selectedDropdown.addClass('active').removeClass('move-left move-right').prevAll().addClass('move-left').end().nextAll().addClass('move-right'); 71 | item.addClass('active'); 72 | //show the dropdown wrapper if not visible yet 73 | if( !this.element.hasClass('is-dropdown-visible') ) { 74 | setTimeout(function(){ 75 | self.element.addClass('is-dropdown-visible'); 76 | }, 10); 77 | } 78 | } 79 | }; 80 | 81 | morphDropdown.prototype.updateDropdown = function(dropdownItem, height, width, left) { 82 | this.dropdownList.css({ 83 | '-moz-transform': 'translateX(' + left + 'px)', 84 | '-webkit-transform': 'translateX(' + left + 'px)', 85 | '-ms-transform': 'translateX(' + left + 'px)', 86 | '-o-transform': 'translateX(' + left + 'px)', 87 | 'transform': 'translateX(' + left + 'px)', 88 | 'width': width+'px', 89 | 'height': height+'px' 90 | }); 91 | 92 | this.dropdownBg.css({ 93 | '-moz-transform': 'scaleX(' + width + ') scaleY(' + height + ')', 94 | '-webkit-transform': 'scaleX(' + width + ') scaleY(' + height + ')', 95 | '-ms-transform': 'scaleX(' + width + ') scaleY(' + height + ')', 96 | '-o-transform': 'scaleX(' + width + ') scaleY(' + height + ')', 97 | 'transform': 'scaleX(' + width + ') scaleY(' + height + ')' 98 | }); 99 | }; 100 | 101 | morphDropdown.prototype.hideDropdown = function() { 102 | this.mq = this.checkMq(); 103 | if( this.mq == 'desktop') { 104 | this.element.removeClass('is-dropdown-visible').find('.active').removeClass('active').end().find('.move-left').removeClass('move-left').end().find('.move-right').removeClass('move-right'); 105 | } 106 | }; 107 | 108 | morphDropdown.prototype.resetDropdown = function() { 109 | this.mq = this.checkMq(); 110 | if( this.mq == 'mobile') { 111 | this.dropdownList.removeAttr('style'); 112 | } 113 | }; 114 | 115 | var morphDropdowns = []; 116 | if( $('.cd-morph-dropdown').length > 0 ) { 117 | $('.cd-morph-dropdown').each(function(){ 118 | //create a morphDropdown object for each .cd-morph-dropdown 119 | morphDropdowns.push(new morphDropdown($(this))); 120 | }); 121 | 122 | var resizing = false; 123 | 124 | //on resize, reset dropdown style property 125 | updateDropdownPosition(); 126 | $(window).on('resize', function(){ 127 | if( !resizing ) { 128 | resizing = true; 129 | (!window.requestAnimationFrame) ? setTimeout(updateDropdownPosition, 300) : window.requestAnimationFrame(updateDropdownPosition); 130 | } 131 | }); 132 | 133 | function updateDropdownPosition() { 134 | morphDropdowns.forEach(function(element){ 135 | element.resetDropdown(); 136 | }); 137 | 138 | resizing = false; 139 | }; 140 | } 141 | }); -------------------------------------------------------------------------------- /public/js/modernizr-custom.js: -------------------------------------------------------------------------------- 1 | /*! modernizr 3.3.1 (Custom Build) | MIT * 2 | * https://modernizr.com/download/?-csstransitions-setclasses !*/ 3 | !function(e,n,t){function r(e,n){return typeof e===n}function s(){var e,n,t,s,o,i,a;for(var l in C)if(C.hasOwnProperty(l)){if(e=[],n=C[l],n.name&&(e.push(n.name.toLowerCase()),n.options&&n.options.aliases&&n.options.aliases.length))for(t=0;tp;p++)if(h=e[p],v=z.style[h],a(h,"-")&&(h=l(h)),z.style[h]!==t){if(o||r(s,"undefined"))return f(),"pfx"==n?h:!0;try{z.style[h]=s}catch(g){}if(z.style[h]!=v)return f(),"pfx"==n?h:!0}return f(),!1}function v(e,n,t,s,o){var i=e.charAt(0).toUpperCase()+e.slice(1),a=(e+" "+b.join(i+" ")+i).split(" ");return r(n,"string")||r(n,"undefined")?h(a,n,s,o):(a=(e+" "+E.join(i+" ")+i).split(" "),u(a,n,t))}function y(e,n,r){return v(e,t,t,n,r)}var g=[],C=[],w={_version:"3.3.1",_config:{classPrefix:"",enableClasses:!0,enableJSClass:!0,usePrefixes:!0},_q:[],on:function(e,n){var t=this;setTimeout(function(){n(t[e])},0)},addTest:function(e,n,t){C.push({name:e,fn:n,options:t})},addAsyncTest:function(e){C.push({name:null,fn:e})}},Modernizr=function(){};Modernizr.prototype=w,Modernizr=new Modernizr;var _=n.documentElement,S="svg"===_.nodeName.toLowerCase(),x="Moz O ms Webkit",b=w._config.usePrefixes?x.split(" "):[];w._cssomPrefixes=b;var E=w._config.usePrefixes?x.toLowerCase().split(" "):[];w._domPrefixes=E;var P={elem:i("modernizr")};Modernizr._q.push(function(){delete P.elem});var z={style:P.elem.style};Modernizr._q.unshift(function(){delete z.style}),w.testAllProps=v,w.testAllProps=y,Modernizr.addTest("csstransitions",y("transition","all",!0)),s(),o(g),delete w.addTest,delete w.addAsyncTest;for(var N=0;N 2 | 3 | 4 | 5 | 语音合成 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | use_num('3');?> 36 |
37 |

语音合成功能
38 | 语音合成技术能将用户输入的文字,转换成流畅自然的语音输出,并且可以支持语速、 39 | 音调、音量设置
40 | (今日剩余使用次数

41 | 42 |

今日次数以及使用完毕,请明日再来

43 | 44 |
45 |
46 |
47 | 48 | 49 | 50 |
51 | 52 |
53 |
54 |
55 |
56 |
57 |
58 |
59 |
60 | 61 |
62 |
63 | 68 |
69 |
70 | 78 |
79 |
80 | 88 |
89 |


90 |
91 | 92 |
93 |

94 |
95 |
96 |
97 | 98 | str_handling($text); 110 | $result = $function->sound($text,$per,$spd,$pit); 111 | $use_num = $function->use_num('3'); 112 | // var_dump($result); 113 | ?> 114 | 115 | 121 |
122 | 123 | 127 | 128 |
129 | 130 | 131 | 136 |
137 |
138 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /text_similarity.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 短文本相似度 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 27 | 28 | 29 | 30 | 31 | 32 | use_num('1'); 36 | ?> 37 |
38 |

自然语言处理--- 39 | 功能 47 |
48 | use_num('6'.$type); 53 | ?> 54 |
55 | (今日剩余使用次数 56 |

57 | 58 |

今日次数以及使用完毕,请明日再来

59 | 60 |
61 |
62 |
63 | 64 |
65 | 66 |
67 |
68 | str_handling($text1); 77 | $text2 = $function->str_handling($text2); 78 | $result = $function->language($text1,$text2,$type); 79 | $use_num = $function->use_num('6'.$type); 80 | // var_dump($result); 81 | ?> 82 | 83 |
84 | 85 | 86 |
相似指数
87 |
88 | 93 |
94 | 95 | 98 |
99 |
100 | 101 |
102 |
103 | 104 |
105 |
108 |
109 | 110 |
111 |
112 | 113 |
114 | 117 | 118 |
119 |
120 |

121 |
122 |
123 | 124 | 125 |
126 | 127 | 128 | 129 | 130 | --------------------------------------------------------------------------------