|
基于人工智能的通用图片识别平台
开发文档
JAVA

base64

        
import com.alibaba.fastjson.JSONObject;
import org.jsoup.Jsoup;
import java.util.Map;

public class Test {
    /**
     *  图像识别
     * @throws IOException
     * 注意: maven依赖
     *           < dependency>
     *             < groupId>org.jsoup< /groupId>
     *             < artifactId>jsoup< /artifactId>
     *             < version>1.11.3< /version>
     *         < /dependency>
     *
     */
    public static void main(String[] args) throws IOException {

        //用户名
        String username= "用户名";
        //密码
        String password= "密码";
        //备注字段: 可以不写
        String remark="输出计算结果";

        Map< String, String> data = new HashMap<>();
        data.put("username",username);
        data.put("password", password);
        //一、图片文字类型(默认 3 数英混合):
        //1 : 纯数字
        //1001:纯数字2
        //2 : 纯英文
        //1002:纯英文2
        //3 : 数英混合
        //1003:数英混合2
        //4 : 闪动GIF
        //7 : 无感学习(独家)
        //11 : 计算题
        //1005:  快速计算题
        //16 : 汉字
        //32 : 通用文字识别(证件、单据)
        //66:  问答题
        //49 :recaptcha图片识别
        //二、图片旋转角度类型:
        //29 :  旋转类型

        //三、图片坐标点选类型:
        //19 :  1个坐标
        //20 :  3个坐标
        //21 :  3 ~ 5个坐标
        //22 :  5 ~ 8个坐标
        //27 :  1 ~ 4个坐标
        //48 : 轨迹类型
        //四、缺口识别
        //18:缺口识别
        //五、拼图识别
        //53:拼图识别
        data.put("typeid", "3");
        data.put("remark", remark);
        data.put("image", "/9j/4AAQSkZJRgABAgAAAQABAAD/2wBDAAgGBgcGBQgHBwcJCQgKDBQNDAsLDBkSEw8UHRofHh0aHBwgJC4nICIsIxwcKDcpLDAxNDQ0Hyc5PTgyPC4zNDL/2wBDAQkJCQwLDBgNDRgyIRwhMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjIyMjL/wAARCAAgAFoDASIAAhEBAxEB/8QAHwAAAQUBAQEBAQEAAAAAAAAAAAECAwQFBgcICQoL/8QAtRAAAgEDAwIEAwUFBAQAAAF9AQIDAAQRBRIh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SXMKfM8ePmb5+uf4V9K7K68N+OrnxBqU1l4/WyZpAUtzo8MgS3LuYwHJy2AXHIBJHPGGrY0bxJ4H0+3gttJu9EsILotJst5IIk8zITB2nBYlSARndsOCQKkvfGXhKZUlg8WaCtzEcxsdRiGRkbkJ3dGAx0OODjIFAGHc+G/iBaxiWX4nN5WcO40C3xGP7zfN09T2zk4AJHdW9nIdIt7PUbj7ZOsSLNcbPLMsgAzIAv3CWG4Y6Hp0rn73xr4flytn438OW6lMZe5ikYH1B8wD04INQ6R4z8OW1rElz4r8OhWjDNEmoRDyH/ALi/Ocr+PGOOCAoB1FtDc28hjaZZbYD5C+fMT2J539+eDwM7iSa+KvHf/JQ/Ev8A2Fbr/wBGtX17J438GSxtHJ4o0F0cFWVtQhIIPUEbq+SvFmvXn/CZa5/Z2rT/AGH+0Lj7P9nuD5fl+Y23Zg424xjHGKAP/9k=");
        //base64 例子
        String resultString = Jsoup.connect("http://api.zhunkuai.cn/predict")
                .requestBody(JSON.toJSONString(data))
                .header("Content-Type", "application/json")
                .ignoreContentType(true).timeout(120000).post().text();
         //文件流 例子
         File file = new File("/path/to/file.ext");
         String resultString=Jsoup.connect("http://api.ttshitu.com/predict")
                .data("username", "user")
                .data("password", "12345")
                .data("typeid", "7")
                .data("remark", remark)
                .data("image", file.getName(), new FileInputStream(file)).ignoreContentType(true).timeout(120000).post().text();

        JSONObject jsonObject = JSONObject.parseObject(resultString);
        if (jsonObject.getBoolean("success")) {
           String result=jsonObject.getJSONObject("data").getString("result");
            System.out.println("识别成功结果为:"+result);
        }else {
            System.out.println("识别失败原因为:"+jsonObject.getString("message"));
        }
    }
}
        
    
 
您好,有什么需要帮助的吗?