我是靠谱客的博主 平常皮带,最近开发中收集的这篇文章主要介绍百度云图片识别(ImageRecognition) 针对 各种图片识别的例子,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

上一篇我们将javaAipImageClassify 继承了文档提供的一个操作类,并且设置基本的 什么超时时间,socek超时时间什么的.接下来我们看看文档上说到的几种图片识别功能

1,

 * 对象物体的识别
 * @param file
 * @return
 */
public static JSONObject  objectDetect(String file) {
   AipImageClassifyJava imageClassifyJava = new AipImageClassifyJava();
    byte[] bytes = null ;
    try {
         bytes = FileCopyUtils.copyToByteArray(new FileInputStream(file)); //"D:\baidutest.jpg"
    } catch (IOException e) {
        e.printStackTrace();
    }
    JSONObject jsonObject = imageClassifyJava.objectDetect(bytes, new HashMap<>());
    return jsonObject;
}
2,植物识别

/**
 * 植物识别
 * @param file
 * @return
 */

public static JSONObject  plantDetect(String file) {
    AipImageClassifyJava imageClassifyJava = new AipImageClassifyJava();
    byte[] bytes = null ;
    try {
        bytes = FileCopyUtils.copyToByteArray(new FileInputStream(file)); //"D:\baidutest.jpg"
    } catch (IOException e) {
        e.printStackTrace();
    }
    JSONObject jsonObject = imageClassifyJava.plantDetect(bytes, new HashMap<>(2));

    return jsonObject;
}

看到没有,有一个score 分数,置信度 (0-1),其实根据不同的业务场景返回的参数还略微不同,比如通用物体识别会返回 root  keyword 

 
// JSONObject jsonObject = plantDetect("D:\BaiDuYun\plantTest.jpg");
 //{"result":[{"score":0.92756402492523,"name":"月季花"},
 // {"score":0.049489587545395,"name":"山茶"},
 // {"score":0.01824583299458,"name":"香水月季"},
 // {"score":0.0024183592759073,"name":"小月季"},
 // {"score":0.001113455160521,"name":"丰花月季"}],
 // "log_id":603785892560534409}

3,汽车识别,是对车的型号,品牌,年份等等的识别,代码基本上和以上是一一样的除了调用的方法不一样而已,我就不抄了, 就给出测试结果吧,

//  JSONObject jsonObject = carDetect("D:\BaiDuYun\carTest.jpg");
  //{"result":[{"score":0.97644132375717,"year":"2017","name":"奥迪A4L"},
  // {"score":0.0072891912423074,"year":"无年份信息","name":"奥迪RS4"},
  // {"score":0.0051027676090598,"year":"2015-2017","name":"奥迪_A4"},
  // {"score":0.0043309261091053,"year":"2011-2017","name":"奥迪RS5"},
  // {"score":0.0019853969570249,"year":"无年份信息","name":"奥迪RS3"}],
  // "log_id":1695071238818986546,"color_result":"颜色无法识别","location_result":{"top":49,"left":16,"width":282,"height":144}}

4,logo识别

 

// JSONObject jsonObject = logoSearch("D:\BaiDuYun\logoTest.jpg"); // logoDetect
  //{"result":[{"probability":0.99948889017105,"name":"伊利","location":{"top":49,"left":30,"width":221,"height":118},"type":0}],"log_id":25141494171746141,"result_num":1}

5,菜品识别

置信度,0-1
其中 probablity 是每一行的置信度
 //JSONObject jsonObject = dishDetect("D:\BaiDuYun\caipinTest.jpg");
//  {"result":[{"probability":"0.757867","has_calorie":true,"calorie":"283","name":"东坡肘子"},
  // {"probability":"0.208655","has_calorie":true,"calorie":"81","name":"五香肘"},
  // {"probability":"0.0051988","has_calorie":true,"calorie":"66","name":"坛子肉"},
  // {"probability":"0.00483344","has_calorie":true,"calorie":"396","name":"樱桃肉"},
  // {"probability":"0.00363789","has_calorie":true,"calorie":"383","name":"同安封肉"}],"log_id":1631580523156268405,"result_num":5}

 

6,动物识别

置信度,0-1

 //   JSONObject jsonObject = animalDetect("D:\BaiDuYun\annimalTest.jpg");
//{"result":[{"score":"0.987378","name":"树袋熊"},
    // {"score":"0.0039235","name":"袋熊"},
    // {"score":"0.000478705","name":"袋鼠"},
    // {"score":"0.000140966","name":"树懒"},
    // {"score":"0.000109027","name":"棕熊"},
    // {"score":"9.40623e-05","name":"大灰熊"}],"log_id":5977852367650097823}

7,图片更多信息的识别

置信度,0-1

JSONObject jsonObject = advancedGeneral("D:\BaiDuYun\shuibei.jpg");
//{"result":[{"score":0.832369,"root":"商品-日用品","keyword":"杯具"},
// {"score":0.596167,"root":"商品-容器","keyword":"杯子"},
// {"score":0.424282,"root":"商品-厨具/餐具","keyword":"陶瓷/马克杯"},
// {"score":0.205376,"root":"商品-日用品","keyword":"陶瓷杯"},
// {"score":0.008621,"root":"商品-容器","keyword":"茶杯"}],"log_id":2186322515240317251,"result_num":5}

置信度,0-1

最后

以上就是平常皮带为你收集整理的百度云图片识别(ImageRecognition) 针对 各种图片识别的例子的全部内容,希望文章能够帮你解决百度云图片识别(ImageRecognition) 针对 各种图片识别的例子所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(40)

评论列表共有 0 条评论

立即
投稿
返回
顶部