ImageCensor.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace app\service\api;
  3. use app\service\ConfServiceFacade;
  4. use laytp\traits\Error;
  5. use think\facade\Cache;
  6. use think\facade\Config;
  7. use think\facade\Request;
  8. require_once IA_ROOT_WK.'/extend/baiduai/AipImageCensor.php';
  9. class ImageCensor
  10. {
  11. use Error;
  12. /**
  13. * phpmailer对象
  14. */
  15. protected $client;
  16. protected $conf;
  17. /**
  18. * 构造函数
  19. */
  20. public function __construct()
  21. {
  22. $this->conf = ConfServiceFacade::groupGet('system.ai');
  23. $this->client = new \AipImageCensor($this->conf['app_id'],$this->conf['api_key'],$this->conf['secret_key']);
  24. }
  25. /**
  26. * 人脸检测
  27. * @param $image //图片链接
  28. */
  29. public function imageCensorUserDefined($image) {
  30. return $this->client->imageCensorUserDefined($image);
  31. }
  32. /**
  33. * 营业执照识别接口
  34. * @param $image //图片链接
  35. */
  36. public function textCensorUserDefined($image) {
  37. if(empty($this->conf['app_id'])){
  38. return true;
  39. }
  40. return $this->client->textCensorUserDefined($image);
  41. }
  42. }