| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  |  * Class OCR | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  |  * @link https://www.icy2003.com/ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  * @author icy2003 <[email protected]> | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  |  * @copyright Copyright (c) 2017, icy2003 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | namespace icy2003\php\iapis\baidu; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use icy2003\php\I; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use icy2003\php\ihelpers\Arrays; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use icy2003\php\ihelpers\Http; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use icy2003\php\ihelpers\Json; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  * 文字识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |  * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |  * @link https://ai.baidu.com/docs#/OCR-API/top | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | class OCR extends Base | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |      * 选项列表 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |      * @var array | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |     protected $_options = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |         'image' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         'language_type' => 'CHN_ENG', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         'detect_direction' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         'detect_language' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |         'probability' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         'recognize_granularity' => 'big', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |         'vertexes_location' => false, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |         'words_type' => null, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |     ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |      * 设置选项 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |      * @param array $options | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |      * - image:图片 base64 或本地文件路径 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |      * - language_type:识别语言类型,默认为CHN_ENG。可选值包括: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |      *      - CHN_ENG:中英文混合 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |      *      - ENG:英文 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |      *      - JAP:日语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |      *      - KOR:韩语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |      *      - FRE:法语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |      *      - SPA:西班牙语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |      *      - POR:葡萄牙语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |      *      - GER:德语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |      *      - ITA:意大利语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |      *      - RUS:俄语 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |      * - detect_direction:是否检测图像朝向,默认不检测,即:false。朝向是指输入图像是正常方向、逆时针旋转90/180/270度。可选值包括: | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |      *      - true,检测朝向 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |      *      - false,不检测朝向 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |      * - detect_language:是否检测语言,默认不检测。当前支持(中文、英语、日语、韩语) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |      * - paragraph:是否输出段落信息,默认 false。 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |      * - probability:是否返回识别结果中每一行的置信度 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |      * - recognize_granularity:是否定位单字符位置,big:不定位单字符位置,默认值;small:定位单字符位置 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |      * - vertexes_location:是否返回文字外接多边形顶点位置,不支持单字位置。默认为false | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |     public function setOptions($options) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |         return parent::setOptions($options); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |      * 通用文字识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |     const URL_GENERAL_BASIC = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |      * 通用文字识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |      * 用户向服务请求识别某张图中的所有文字 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/zk3h7xz52 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |     public function generalBasic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_GENERAL_BASIC, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             'language_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |             'detect_language', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |             'paragraph', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |             'probability', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |      * 通用文字识别(高精度版) API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |     const URL_ACCURATE_BASIC = 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |      * 通用文字识别(高精度版) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |      * 用户向服务请求识别某张图中的所有文字,相对于通用文字识别该产品精度更高,但是识别耗时会稍长 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/1k3h7y3db | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |     public function accurateBasic() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_ACCURATE_BASIC, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 121 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |             'language_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 123 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 124 |  |  |             'paragraph', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 125 |  |  |             'probability', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 126 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 127 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 128 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 129 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 130 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 131 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 132 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 133 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 134 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 135 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 136 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 137 |  |  |      * 通用文字识别(含位置信息版) API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 138 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 139 |  |  |     const URL_GENERAL = 'https://aip.baidubce.com/rest/2.0/ocr/v1/general'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 140 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 141 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 142 |  |  |      * 通用文字识别(含位置信息版) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 143 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 144 |  |  |      * 用户向服务请求识别某张图中的所有文字,并返回文字在图中的位置信息 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 145 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/vk3h7y58v | 
            
                                                                                                            
                            
            
                                    
            
            
                | 146 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 147 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 148 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 149 |  |  |     public function general() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 150 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 151 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 152 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_GENERAL, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 153 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 154 |  |  |             'recognize_granularity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 155 |  |  |             'language_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 156 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 157 |  |  |             'detect_language', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 158 |  |  |             'paragraph', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 159 |  |  |             'vertexes_location', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 160 |  |  |             'probability', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 161 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 162 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 163 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 164 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 165 |  |  |             return I::get($result, 'words_result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 166 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 167 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 168 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 169 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 170 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 171 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 172 |  |  |      * 通用文字识别(高精度含位置版) API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 173 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 174 |  |  |     const URL_ACCURATE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 175 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 176 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 177 |  |  |      * 通用文字识别(高精度含位置版) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 178 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 179 |  |  |      * 用户向服务请求识别某张图中的所有文字,并返回文字在图片中的坐标信息,相对于通用文字识别(含位置信息版)该产品精度更高,但是识别耗时会稍长 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 180 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/tk3h7y2aq | 
            
                                                                                                            
                            
            
                                    
            
            
                | 181 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 182 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 183 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 184 |  |  |     public function accurate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 185 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 186 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 187 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_ACCURATE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 188 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 189 |  |  |             'language_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 190 |  |  |             'recognize_granularity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 191 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 192 |  |  |             'vertexes_location', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 193 |  |  |             'paragraph', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 194 |  |  |             'probability', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 195 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 196 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 197 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 198 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 199 |  |  |             return I::get($result, 'words_result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 200 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 201 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 202 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 203 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 204 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 205 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 206 |  |  |      * 身份证识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 207 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 208 |  |  |     const URL_ID_CARD = 'https://aip.baidubce.com/rest/2.0/ocr/v1/idcard'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 209 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 210 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 211 |  |  |      * 身份证识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 212 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 213 |  |  |      * 支持对大陆居民二代身份证正反面的所有字段进行结构化识别,包括姓名、性别、民族、出生日期、住址、身份证号、签发机关、有效期限;同时,支持对用户上传的身份证图片进行图像风险和质量检测,可识别图片是否为复印件或临时身份证,是否被翻拍或编辑,是否存在正反颠倒、模糊、欠曝、过曝等质量问题 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 214 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/rk3h7xzck | 
            
                                                                                                            
                            
            
                                    
            
            
                | 215 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 216 |  |  |      * @param string $side front 或 back | 
            
                                                                                                            
                            
            
                                    
            
            
                | 217 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 218 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 219 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 220 |  |  |     public function idcard($side = 'front') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 221 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 222 |  |  |         parent::setOption('id_card_side', $side); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 223 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 224 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_ID_CARD, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 225 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 226 |  |  |             'id_card_side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 227 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 228 |  |  |             'detect_risk', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 229 |  |  |             'detect_photo', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 230 |  |  |             'detect_rectify', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 231 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 232 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 233 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 234 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 235 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 236 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 237 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 238 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 239 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 240 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 241 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 242 |  |  |      * 银行卡识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 243 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 244 |  |  |     const URL_BANK_CARD = 'https://aip.baidubce.com/rest/2.0/ocr/v1/bankcard'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 245 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 246 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 247 |  |  |      * 银行卡识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 248 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 249 |  |  |      * 识别银行卡并返回卡号、有效期、发卡行和卡片类型 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 250 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/ak3h7xxg3 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 251 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 252 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 253 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 254 |  |  |     public function bankcard() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 255 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 256 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 257 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_BANK_CARD, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 258 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 259 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 260 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 261 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 262 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 263 |  |  |             return I::get($result, 'result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 264 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 265 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 266 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 267 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 268 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 269 |  |  |      * 营业执照识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 270 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 271 |  |  |     const URL_BUSINESS_LICENSE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/business_license'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 272 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 273 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 274 |  |  |      * 营业执照识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 275 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 276 |  |  |      * 识别营业执照,并返回关键字段的值,包括单位名称、类型、法人、地址、有效期、证件编号、社会信用代码等 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 277 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/sk3h7y3zs | 
            
                                                                                                            
                            
            
                                    
            
            
                | 278 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 279 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 280 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 281 |  |  |     public function businessLicense() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 282 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 283 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 284 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_BUSINESS_LICENSE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 285 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 286 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 287 |  |  |             'accuracy', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 288 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 289 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 290 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 291 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 292 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 293 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 294 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 295 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 296 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 297 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 298 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 299 |  |  |      * 名片识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 300 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 301 |  |  |     const URL_BUSINESS_CARD = 'https://aip.baidubce.com/rest/2.0/ocr/v1/business_card'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 302 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 303 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 304 |  |  |      * 名片识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 305 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 306 |  |  |      * 提供对各类名片的结构化识别功能,提取姓名、邮编、邮箱、电话、网址、地址、手机号、公司、职位字段 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 307 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/5k3h7xyi2 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 308 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 309 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 310 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 311 |  |  |     public function businessCard() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 312 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 313 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 314 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_BUSINESS_CARD, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 315 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 316 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 317 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 318 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 319 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 320 |  |  |             return I::get($result, 'words_result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 321 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 322 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 323 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 324 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 325 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 326 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 327 |  |  |      * 护照识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 328 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 329 |  |  |     const URL_PASSPORT = 'https://aip.baidubce.com/rest/2.0/ocr/v1/passport'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 330 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 331 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 332 |  |  |      * 护照识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 333 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 334 |  |  |      * 支持对中国大陆居民护照的资料页进行结构化识别,包含国家码、姓名、姓名拼音、性别、护照号、出生日期、出生地点、签发日期、有效期至、签发地点 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 335 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Wk3h7y1gi | 
            
                                                                                                            
                            
            
                                    
            
            
                | 336 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 337 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 338 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 339 |  |  |     public function passport() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 340 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 341 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 342 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_PASSPORT, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 343 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 344 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 345 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 346 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 347 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 348 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 349 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 350 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 351 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 352 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 353 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 354 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 355 |  |  |      * 港澳通行证识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 356 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 357 |  |  |     const URL_HK_MACAU_EXITENTRYPERMIT = 'https://aip.baidubce.com/rest/2.0/ocr/v1/HK_Macau_exitentrypermit'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 358 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 359 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 360 |  |  |      * 港澳通行证识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 361 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 362 |  |  |      * 对港澳通行证证号、姓名、姓名拼音、性别、有效期限、签发地点、出生日期字段进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 363 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/4k3h7y0ly | 
            
                                                                                                            
                            
            
                                    
            
            
                | 364 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 365 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 366 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 367 |  |  |     public function hkMacauExitentrypermit() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 368 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 369 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 370 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_HK_MACAU_EXITENTRYPERMIT, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 371 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 372 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 373 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 374 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 375 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 376 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 377 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 378 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 379 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 380 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 381 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 382 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 383 |  |  |      * 台湾通行证识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 384 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 385 |  |  |     const URL_TAIWAN_EXITENTRYPERMIT = 'https://aip.baidubce.com/rest/2.0/ocr/v1/taiwan_exitentrypermit'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 386 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 387 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 388 |  |  |      * 台湾通行证识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 389 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 390 |  |  |      * 对台湾通行证证号、签发地、出生日期、姓名、姓名拼音、性别、有效期字段进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 391 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/kk3h7y2yc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 392 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 393 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 394 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 395 |  |  |     public function taiwanExitentrypermit() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 396 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 397 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 398 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_TAIWAN_EXITENTRYPERMIT, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 399 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 400 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 401 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 402 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 403 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 404 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 405 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 406 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 407 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 408 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 409 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 410 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 411 |  |  |      * 户口本识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 412 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 413 |  |  |     const URL_HOUSEHOLD_REGISTER = 'https://aip.baidubce.com/rest/2.0/ocr/v1/household_register'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 414 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 415 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 416 |  |  |      * 户口本识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 417 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 418 |  |  |      * 对出生地、出生日期、姓名、民族、与户主关系、性别、身份证号码字段进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 419 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/ak3h7xzk7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 420 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 421 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 422 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 423 |  |  |     public function householdRegister() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 424 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 425 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 426 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_HOUSEHOLD_REGISTER, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 427 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 428 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 429 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 430 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 431 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 432 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 433 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 434 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 435 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 436 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 437 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 438 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 439 |  |  |      * 出生医学证明识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 440 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 441 |  |  |     const URL_BIRTH_CERTIFICATE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/birth_certificate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 442 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 443 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 444 |  |  |      * 出生医学证明识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 445 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 446 |  |  |      * 对出生时间、姓名、性别、出生证编号、父亲姓名、母亲姓名字段进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 447 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/mk3h7y1o6 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 448 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 449 |  |  |      * @return static | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 450 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 451 |  |  |     public function birthCertificate() | 
            
                                                                        
                            
            
                                    
            
            
                | 452 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 453 |  |  |         $this->requestToken(); | 
            
                                                                        
                            
            
                                    
            
            
                | 454 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_BIRTH_CERTIFICATE, parent::filterOptions([ | 
            
                                                                        
                            
            
                                    
            
            
                | 455 |  |  |             'image', | 
            
                                                                        
                            
            
                                    
            
            
                | 456 |  |  |         ]), [ | 
            
                                                                        
                            
            
                                    
            
            
                | 457 |  |  |             'access_token' => $this->_token, | 
            
                                                                        
                            
            
                                    
            
            
                | 458 |  |  |         ])); | 
            
                                                                        
                            
            
                                    
            
            
                | 459 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                        
                            
            
                                    
            
            
                | 460 |  |  |             return Arrays::column((array) I::get($result, 'words_result', []), 'words'); | 
            
                                                                        
                            
            
                                    
            
            
                | 461 |  |  |         }; | 
            
                                                                        
                            
            
                                    
            
            
                | 462 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 463 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 464 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 465 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 466 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 467 |  |  |      * 增值税发票识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 468 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 469 |  |  |     const URL_VAT_INVOICE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/vat_invoice'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 470 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 471 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 472 |  |  |      * 增值税发票识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 473 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 474 |  |  |      * 支持对增值税普票、专票、电子发票的所有字段进行结构化识别,包括发票基本信息、销售方及购买方信息、商品信息、价税信息等,其中四要素识别准确率超过 99.9% | 
            
                                                                                                            
                            
            
                                    
            
            
                | 475 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 476 |  |  |      * 同时,支持对增值税卷票的 16 个关键字段进行识别,包括包括发票类型、发票代码、发票号码、机打号码、机器编号、销售方纳税人识别号、开票日期、购买方纳税人识别号、项目、单价、数量、金额、税额、合计金额(小写)、合计金额(大写)、校验码,四要素平均识别准确率可达95%以上 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 477 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/nk3h7xy2t | 
            
                                                                                                            
                            
            
                                    
            
            
                | 478 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 479 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 480 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 481 |  |  |     public function vatInvoice() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 482 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 483 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 484 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_VAT_INVOICE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 485 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 486 |  |  |             'accuracy', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 487 |  |  |             'type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 488 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 489 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 490 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 491 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 492 |  |  |             return I::get($result, 'words_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 493 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 494 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 495 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 496 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 497 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 498 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 499 |  |  |      * 定额发票识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 500 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 501 |  |  |     const URL_QUOTA_INVOICE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/quota_invoice'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 502 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 503 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 504 |  |  |      * 定额发票识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 505 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 506 |  |  |      * 对各类定额发票的代码、号码、金额进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 507 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/lk3h7y4ev | 
            
                                                                                                            
                            
            
                                    
            
            
                | 508 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 509 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 510 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 511 |  |  |     public function quotaInvoice() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 512 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 513 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 514 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_QUOTA_INVOICE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 515 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 516 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 517 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 518 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 519 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 520 |  |  |             return I::get($result, 'words_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 521 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 522 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 523 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 524 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 525 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 526 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 527 |  |  |      * 火车票识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 528 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 529 |  |  |     const URL_TRAIN_TICKET = 'https://aip.baidubce.com/rest/2.0/ocr/v1/train_ticket'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 530 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 531 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 532 |  |  |      * 火车票识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 533 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 534 |  |  |      * 支持对大陆火车票的车票号、始发站、目的站、车次、日期、票价、席别、姓名进行结构化识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 535 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Ok3h7y35u | 
            
                                                                                                            
                            
            
                                    
            
            
                | 536 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 537 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 538 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 539 |  |  |     public function trainTicket() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 540 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 541 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 542 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_TRAIN_TICKET, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 543 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 544 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 545 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 546 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 547 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 548 |  |  |             return I::get($result, '0', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 549 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 550 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 551 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 552 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 553 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 554 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 555 |  |  |      * 出租车票识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 556 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 557 |  |  |     const URL_TAXI_RECEIPT = 'https://aip.baidubce.com/rest/2.0/ocr/v1/taxi_receipt'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 558 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 559 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 560 |  |  |      * 出租车票识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 561 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 562 |  |  |      * 针对全国各大城市出租车票的发票号码、发票代码、车号、日期、时间、金额进行结构化识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 563 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Zk3h7xxnn | 
            
                                                                                                            
                            
            
                                    
            
            
                | 564 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 565 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 566 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 567 |  |  |     public function taxiReceipt() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 568 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 569 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 570 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_TAXI_RECEIPT, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 571 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 572 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 573 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 574 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 575 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 576 |  |  |             return I::get($result, 'words_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 577 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 578 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 579 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 580 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 581 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 582 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 583 |  |  |      * 通用票据识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 584 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 585 |  |  |     const URL_RECEIPT = 'https://aip.baidubce.com/rest/2.0/ocr/v1/receipt'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 586 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 587 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 588 |  |  |      * 通用票据识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 589 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 590 |  |  |      * 用户向服务请求识别医疗票据、发票、的士票、保险保单等票据类图片中的所有文字,并返回文字在图中的位置信息 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 591 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/6k3h7y11b | 
            
                                                                                                            
                            
            
                                    
            
            
                | 592 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 593 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 594 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 595 |  |  |     public function receipt() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 596 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 597 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 598 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_RECEIPT, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 599 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 600 |  |  |             'recognize_granularity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 601 |  |  |             'probability', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 602 |  |  |             'accuracy', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 603 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 604 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 605 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 606 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 607 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 608 |  |  |             return I::get($result, 'words_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 609 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 610 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 611 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 612 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 613 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 614 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 615 |  |  |      * 保单识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 616 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 617 |  |  |     const URL_INSURANCE_DOCUMENTS = 'https://aip.baidubce.com/rest/2.0/ocr/v1/insurance_documents'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 618 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 619 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 620 |  |  |      * 保单识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 621 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 622 |  |  |      * 对各类保单中投保人、受益人的各项信息、保费、保险名称等字段进行结构化识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 623 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Wk3h7y0eb | 
            
                                                                                                            
                            
            
                                    
            
            
                | 624 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 625 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 626 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 627 |  |  |     public function insuranceDocuments() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 628 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 629 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 630 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_INSURANCE_DOCUMENTS, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 631 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 632 |  |  |             'kv_business', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 633 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 634 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 635 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 636 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 637 |  |  |             return I::get($result, 'words_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 638 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 639 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 640 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 641 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 642 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 643 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 644 |  |  |      * 行驶证识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 645 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 646 |  |  |     const URL_VEHICLE_LICENSE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_license'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 647 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 648 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 649 |  |  |      * 行驶证识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 650 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 651 |  |  |      * 对机动车行驶证主页及副页所有21个字段进行结构化识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 652 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/yk3h7y3ks | 
            
                                                                                                            
                            
            
                                    
            
            
                | 653 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 654 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 655 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 656 |  |  |     public function vehicleLicense() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 657 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 658 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 659 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_VEHICLE_LICENSE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 660 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 661 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 662 |  |  |             'accuracy', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 663 |  |  |             'vehicle_license_side', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 664 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 665 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 666 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 667 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 668 |  |  |             return Arrays::column((array) I::get($result, 'data.words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 669 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 670 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 671 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 672 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 673 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 674 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 675 |  |  |      * 驾驶证识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 676 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 677 |  |  |     const URL_DRIVING_LICENSE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/driving_license'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 678 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 679 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 680 |  |  |      * 驾驶证识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 681 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 682 |  |  |      * 对机动车驾驶证所有关键字段进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 683 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Vk3h7xzz7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 684 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 685 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 686 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 687 |  |  |     public function drivingLicense() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 688 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 689 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 690 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_DRIVING_LICENSE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 691 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 692 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 693 |  |  |             'unified_valid_period', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 694 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 695 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 696 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 697 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 698 |  |  |             return Arrays::column((array) I::get($result, 'data.words_result', []), 'words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 699 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 700 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 701 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 702 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 703 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 704 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 705 |  |  |      * 车牌识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 706 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 707 |  |  |     const URL_LICENSE_PLATE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/license_plate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 708 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 709 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 710 |  |  |      * 车牌识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 711 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 712 |  |  |      * 对机动车蓝牌、绿牌、单/双行黄牌的地域编号和车牌号进行识别,并能同时识别图像中的多张车牌 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 713 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/ck3h7y191 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 714 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 715 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 716 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 717 |  |  |     public function licensePlate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 718 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 719 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 720 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_LICENSE_PLATE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 721 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 722 |  |  |             'multi_detect', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 723 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 724 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 725 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 726 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 727 |  |  |             return I::get($result, 'data.words_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 728 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 729 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 730 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 731 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 732 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 733 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 734 |  |  |      * VIN码识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 735 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 736 |  |  |     const URL_VIN_CODE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/vin_code'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 737 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 738 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 739 |  |  |      * VIN码识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 740 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 741 |  |  |      * 对车辆车架上、挡风玻璃上的VIN码进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 742 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/zk3h7y51e | 
            
                                                                                                            
                            
            
                                    
            
            
                | 743 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 744 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 745 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 746 |  |  |     public function vinCode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 747 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 748 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 749 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_VIN_CODE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 750 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 751 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 752 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 753 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 754 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 755 |  |  |             return I::get($result, 'words_result.0.words'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 756 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 757 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 758 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 759 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 760 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 761 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 762 |  |  |      * 车辆合格证识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 763 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 764 |  |  |     const URL_VEHICLE_CERTIFICATE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/vehicle_certificate'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 765 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 766 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 767 |  |  |      * 车辆合格证识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 768 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 769 |  |  |      * 识别车辆合格证编号、车架号、排放标准、发动机编号等12个字段 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 770 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/yk3h7y3sc | 
            
                                                                                                            
                            
            
                                    
            
            
                | 771 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 772 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 773 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 774 |  |  |     public function vehicleCertificate() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 775 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 776 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 777 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_VEHICLE_CERTIFICATE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 778 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 779 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 780 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 781 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 782 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 783 |  |  |             return I::get($result, 'words_result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 784 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 785 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 786 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 787 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 788 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 789 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 790 |  |  |      * 手写文字识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 791 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 792 |  |  |     const URL_HANDWRITING = 'https://aip.baidubce.com/rest/2.0/ocr/v1/handwriting'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 793 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 794 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 795 |  |  |      * 手写文字识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 796 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 797 |  |  |      * 对手写中文汉字、数字进行识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 798 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/hk3h7y2qq | 
            
                                                                                                            
                            
            
                                    
            
            
                | 799 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 800 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 801 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 802 |  |  |     public function handwriting() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 803 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 804 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 805 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_HANDWRITING, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 806 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 807 |  |  |             'recognize_granularity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 808 |  |  |             'words_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 809 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 810 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 811 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 812 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 813 |  |  |             return I::get($result, 'words_result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 814 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 815 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 816 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 817 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 818 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 819 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 820 |  |  |      * 网络图片文字识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 821 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 822 |  |  |     const URL_WEB_IMAGE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/webimage'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 823 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 824 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 825 |  |  |      * 网络图片文字识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 826 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 827 |  |  |      * 用户向服务请求识别一些网络上背景复杂,特殊字体的文字 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 828 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Sk3h7xyad | 
            
                                                                                                            
                            
            
                                    
            
            
                | 829 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 830 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 831 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 832 |  |  |     public function webImage() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 833 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 834 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 835 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_WEB_IMAGE, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 836 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 837 |  |  |             'detect_direction', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 838 |  |  |             'detect_language', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 839 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 840 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 841 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 842 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 843 |  |  |             return I::get($result, 'words_result'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 844 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 845 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 846 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 847 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 848 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 849 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 850 |  |  |      * 表格文字识别(异步接口)-请求 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 851 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 852 |  |  |     const URL_FORM_REQUEST = 'https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/request'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 853 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 854 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 855 |  |  |      * 表格文字识别(异步接口)-请求 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 856 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 857 |  |  |      * 对图片中的表格文字内容进行提取和识别,结构化输出表头、表尾及每个单元格的文字内容。支持识别常规表格及含合并单元格表格,并可选择以JSON或Excel形式进行返回。 本接口为异步接口,分为两个API:提交请求接口、获取结果接口。下面分别描述两个接口的使用方法 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 858 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Ik3h7y238 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 859 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 860 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 861 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 862 |  |  |     public function formRequest() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 863 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 864 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 865 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_FORM_REQUEST, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 866 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 867 |  |  |             'is_sync', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 868 |  |  |             'request_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 869 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 870 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 871 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 872 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 873 |  |  |             return I::get($result, 'result.0'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 874 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 875 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 876 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 877 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 878 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 879 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 880 |  |  |      * 表格文字识别(异步接口)-接收 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 881 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 882 |  |  |     const URL_FORM_RESULT = 'https://aip.baidubce.com/rest/2.0/solution/v1/form_ocr/get_request_result'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 883 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 884 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 885 |  |  |      * 表格文字识别(异步接口)-接收 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 886 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 887 |  |  |      * 对图片中的表格文字内容进行提取和识别,结构化输出表头、表尾及每个单元格的文字内容。支持识别常规表格及含合并单元格表格,并可选择以JSON或Excel形式进行返回。 本接口为异步接口,分为两个API:提交请求接口、获取结果接口。下面分别描述两个接口的使用方法 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 888 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Ik3h7y238 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 889 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 890 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 891 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 892 |  |  |     public function formResult() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 893 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 894 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 895 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_FORM_RESULT, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 896 |  |  |             'request_id', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 897 |  |  |             'request_type', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 898 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 899 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 900 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 901 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 902 |  |  |             return I::get($result, 'result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 903 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 904 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 905 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 906 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 907 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 908 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 909 |  |  |      * 数字识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 910 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 911 |  |  |     const URL_NUMBERS = 'https://aip.baidubce.com/rest/2.0/ocr/v1/numbers'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 912 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 913 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 914 |  |  |      * 数字识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 915 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 916 |  |  |      * 对图像中的阿拉伯数字进行识别提取,适用于快递单号、手机号、充值码提取等场景 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 917 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/Ok3h7y1vo | 
            
                                                                                                            
                            
            
                                    
            
            
                | 918 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 919 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 920 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 921 |  |  |     public function numbers() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 922 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 923 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 924 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_NUMBERS, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 925 |  |  |             'image', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 926 |  |  |             'recognize_granularity', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 927 |  |  |             'detect_direction' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 928 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 929 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 930 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 931 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 932 |  |  |             return I::get($result, 'words_result.0.words', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 933 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 934 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 935 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 936 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 937 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 938 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 939 |  |  |      * 二维码识别 API 地址 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 940 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 941 |  |  |     const URL_QRCODE = 'https://aip.baidubce.com/rest/2.0/ocr/v1/qrcode'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 942 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 943 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 944 |  |  |      * 二维码识别 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 945 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 946 |  |  |      * 识别条形码、二维码中包含的URL或其他信息内容 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 947 |  |  |      * @link https://ai.baidu.com/ai-doc/OCR/qk3h7y5o7 | 
            
                                                                                                            
                            
            
                                    
            
            
                | 948 |  |  |      * | 
            
                                                                                                            
                            
            
                                    
            
            
                | 949 |  |  |      * @return static | 
            
                                                                                                            
                            
            
                                    
            
            
                | 950 |  |  |      */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 951 |  |  |     public function qrcode() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 952 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 953 |  |  |         $this->requestToken(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 954 |  |  |         $this->_result = (array) Json::decode(Http::post(self::URL_NUMBERS, parent::filterOptions([ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 955 |  |  |             'image' | 
            
                                                                                                            
                            
            
                                    
            
            
                | 956 |  |  |         ]), [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 957 |  |  |             'access_token' => $this->_token, | 
            
                                                                                                            
                            
            
                                    
            
            
                | 958 |  |  |         ])); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 959 |  |  |         $this->_toArrayCall = function ($result) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 960 |  |  |             return I::get($result, 'codes_result', []); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 961 |  |  |         }; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 962 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 963 |  |  |         return $this; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 964 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 965 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 966 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 967 |  |  |  |