我验证了下文字识别的sample,得到的错误代码不在文档里
xinshouke · xinshouke 发布于2017-07-13 17:00 浏览:3598 回复:0

请问文字识别验证sample(java)以下错误,怎么修改啊?

{
  "error_msg": "image length error",
  "error_code": "SDK101"
}
{
  "error_msg": "image length error",
  "error_code": "SDK101"
}
{
  "error_msg": "image length error",
  "error_code": "SDK101"
}

-----------我的代码----------------------------

import java.util.HashMap;
import org.json.JSONObject;
import com.baidu.aip.ocr.AipOcr;
public class ADIdentify {
    //设置APPID/AK/SK
    public static final String APP_ID = "xxx";
    public static final String API_KEY = "fffff";
    public static final String SECRET_KEY = wwwwww";
    public static void main(String[] args) {
        // 初始化一个OcrClient
        AipOcr client = new AipOcr(APP_ID, API_KEY, SECRET_KEY);
        // 可选:设置网络连接参数
        client.setConnectionTimeoutInMillis(2000);
        client.setSocketTimeoutInMillis(60000);
        // 调用身份证识别接口
        String idFilePath = "D:\\SCZHWorkSpace\\OCRPro\\src\\test.jpg";
        JSONObject idcardRes=client.idcard(idFilePath,true, new HashMap<String,String>());
        System.out.println(idcardRes.toString(2));
        // 调用银行卡识别接口
        String bankFilePath = "D:\\SCZHWorkSpace\\OCRPro\\src\\test_bank.jpg";
        JSONObject bankRes = client.bankcard(bankFilePath);
        System.out.println(bankRes.toString(2));
        // 调用通用识别接口
        String genFilePath = "D:\\SCZHWorkSpace\\OCRPro\\src\\test_basic_general.jpg";
        JSONObject genRes = client.basicGeneral(genFilePath, new HashMap<String, String>());
        System.out.println(genRes.toString(2));
        // 调用通用识别(含位置信息)接口
//        String genFilePath = "test_general.jpg";
//        JSONObject genRes = client.general(genFilePath, new HashMap<String, String>());
//        System.out.println(genRes.toString(2));
    }
}


点赞  ( 0 )
收藏
评论(0)
TOP