<?php/** * Info 图文识别 */namespace lib;use o;use fun;use file;use lib;use lib3\TesseractOCR\TesseractOCR;use lib3\TesseractOCR\Command;class ocr{ /** * @param mixed $k 参数,有需要才传 * @return object */ public static function I($k = ''){ return I(__CLASS__, $k); } /** * 测试方法 * 调用方法lib\ocr::I()->test(DATA_ROOT . 'zt/ocr/img/Image_00002.jpg'); * @param string $imgFile 需要识别的图片地址 * @return string */ public function test($imgFile){ if(!is_file($imgFile)) return $imgFile .'文件不存在'; $outputFile = DATA_ROOT . 'zt/ocr/temp/test'; $cmd = new Command($imgFile, $outputFile); $tess = new TesseractOCR($imgFile, $cmd); $ret = $tess->lang('chi_sim', 'eng')->run(); return $ret; }}