zoukankan      html  css  js  c++  java
  • 完成植物识别,自行拍摄植物图片进行上传并查看结果

    向日葵:

    苹果树

    import com.baidu.aip.imageclassify.AipImageClassify;
    import org.json.JSONObject;

    import java.util.HashMap;

    public class Sample {
        //设置APPID/AK/SK
        public static final String APP_ID = "25053576";
        public static final String API_KEY = "LVy72lb9RiKdixRaG06iUBnz";
        public static final String SECRET_KEY = "Mcw9Ad11m4BKCM9lHI776fgmIpnA4fdv";

        public static void main(String[] args) {
            // 初始化一个AipImageClassify
            AipImageClassify client = new AipImageClassify(APP_ID, API_KEY, SECRET_KEY);

            // 可选:设置网络连接参数
            client.setConnectionTimeoutInMillis(2000);
            client.setSocketTimeoutInMillis(60000);

            // 传入可选参数调用接口
            HashMap<String, String> options = new HashMap<String, String>();
            options.put("baike_num", "5");


            // 参数为本地路径
            /*
            String image = "C:\\Users\\杜子轩\\Desktop\\安妮海瑟薇.JPG";
            JSONObject res = client.advancedGeneral(image, options);
            System.out.println(res.toString(2));*/

            //动物识别
            /*
            String image = "C:\\Users\\杜子轩\\Desktop\\狐狸.png";
            JSONObject res = client.animalDetect(image, options);
            System.out.println(res.toString(2));*/

            // 植物识别

            String image = "C:\\Users\\杜子轩\\Desktop\\苹果.png";
            JSONObject res = client.plantDetect(image, options);
            System.out.println(res.toString(2));

        }
    }

     

    三、实验总结

    最开始做的时候感觉很难,但其实做到后面发现比较简单,难得是能够一步一步按照教程来写代码,通过不断练习,慢慢更加熟练的掌握怎么更迅速的读懂教程,并为自己所用,是一种很重要的能力,这次试验收获很多,也发现了代码的乐趣所在,简单的几十行代码,就能完成一项很重要的功能,使我更加明白,熟练的实用工具也是一项很重要的基本功

  • 相关阅读:
    HTML Strip Char Filter
    Creating a custom analyzer in ElasticSearch Nest client
    elasticsearch-analysis-pinyin
    ElasticSearch安装拼音插件 elasticsearch-analysis-pinyin
    Elasticsearch5.4 删除type
    Performs the analysis process on a text and return the tokens breakdown of the text
    Elasticsearch 5 Ik+pinyin分词配置详解
    线性可分支持向量机--SVM(1)
    感知机分类(perceptron classification)
    创建DateFrame的常用四种方式
  • 原文地址:https://www.cnblogs.com/D10304/p/15650071.html
Copyright © 2011-2022 走看看