晴川云百度小程序教程:swan.ai.carClassify

  • swan.ai.carClassify
    • 方法参数
      • object 参数说明
      • success 返回参数说明
      • result 返回值说明
      • location_result 返回值说明
    • 示例
      • 图片示例
      • 代码示例
      • 返回值示例

    swan.ai.carClassify

    解释 :用于检测一张车辆图片的具体车型,即对于输入的一张图片(可正常解码,且长宽比适宜),输出图片的车辆品牌及型号、颜色及年份、位置信息。
    Web 态说明:受宿主环境限制,Web 态暂不支持 AI 能力相关接口。在 Web 态会做 打开百度 App 对应小程序页面 的降级处理。

    方法参数

    Object object

    object 参数说明

    属性名 类型 必填 默认值 说明

    image

    String

    图像资源地址

    top_num

    Number

    5

    返回结果 top n,默认 5

    success

    Function

    接口调用成功的回调函数

    fail

    Function

    接口调用失败的回调函数

    complete

    Function

    接口调用结束的回调函数(调用成功、失败都会执行)

    success 返回参数说明

    参数 类型 说明

    log_id

    Number

    唯一的 log id ,用于问题定位

    color_result

    string

    颜色

    result

    Array

    车型识别结果数组

    location_result

    Object

    车在图片中的位置信息

    result 返回值说明

    参数名 参数类型 说明

    name

    String

    车型名称,示例:宝马 x6

    score

    Number

    置信度,示例:0.5321

    year

    String

    年份

    location_result 返回值说明

    参数名 参数类型 说明

    left

    Number

    左起像素位置

    top

    Number

    上起像素位置

    width

    Number

    像素宽

    height

    Number

    像素高

    示例

    跳转编辑工具

    在开发者工具中打开

    在 WEB IDE 中打开

    扫码体验

    代码示例

    请使用百度APP扫码

    图片示例

    代码示例

    • SWAN
    • JS
     
     
     
    1. <view class="wrap">
    2. <view class="card-area" style="height:2.1rem">
    3. <image mode="aspectFill" class="display-area-image" src="{{image}}"></image>
    4. </view>
    5. <view class="card-area" style="margin-bottom: 1.2rem;">
    6. <view s-if="!loading" class="top-description border-bottom">识别结果</view>
    7. <view s-if="result.length>0">
    8. <view s-if="!loading">
    9. <view s-for="item in result" class="list-area border-bottom">
    10. <view class="reasult-keyword">{{item.name}}</view>
    11. <view class="reasult-score">
    12. <view class="score-title">置信度</view>
    13. <view style="display:inline-block">
    14. <view class="score-info">{{item.score}}<text class="percent">%</text></view>
    15. <view class="score-percent">
    16. <view class="percent-front {{item.score===100?'percent-100':''}}" style="width:{{item.score}}%;"></view>
    17. </view>
    18. </view>
    19. </view>
    20. <view class="score-title">年份</view>
    21. <view class="root-info">{{item.year}}</view>
    22. </view>
    23. </view>
    24. </view>
    25. <view s-else>
    26. <view s-if="!loading">
    27. <view class="result-area">
    28. <view class="result-area-fail">未检测到车辆</view>
    29. <view class="result-area-tips">请上传包含车辆的清晰图片</view>
    30. </view>
    31. </view>
    32. </view>
    33. </view>
    34. <view class="swan-security-padding-bottom flex-button">
    35. <button type="primary" hover-class="button-hover" disabled="{{loading}}" bindtap="carClassify">上传车辆图片</button>
    36. </view>
    37. </view>

    返回值示例

    • JSON
     
     
     
    1. {
    2. "log_id": $log_id,
    3. "location_result": {
    4. "width": 434,
    5. "top": 119,
    6. "height": 246,
    7. "left": 110
    8. },
    9. "result": [
    10. {
    11. "score": 0.99993008375168,
    12. "name": "宝马X3",
    13. "year": "2016"
    14. },
    15. {
    16. "score": 0.00005255633732304,
    17. "name": "宝马X4",
    18. "year": "2015-2016"
    19. },
    20. {
    21. "score": 0.0000031432850846613,
    22. "name": "SWM斯威X7",
    23. "year": "2016-2017"
    24. },
    25. {
    26. "score": 0.0000012879694395451,
    27. "name": "宝马X5",
    28. "year": "2016-2017"
    29. },
    30. {
    31. "score": 5.6126202707674e-7,
    32. "name": "丰田汉兰达",
    33. "year": "2015-2017"
    34. },
    35. {
    36. "score": 4.4069730620322e-7,
    37. "name": "斯柯达速尊",
    38. "year": "2014-2016"
    39. },
    40. {
    41. "score": 4.0618823504701e-7,
    42. "name": "宝马X1",
    43. "year": "2017"
    44. }
    45. ],
    46. "color_result": "白色"
    47. }

    原创文章,作者:晴川运维,如若转载,请注明出处:https://baike.qcidc.com/10043.html

    (0)
    晴川运维晴川运维
    上一篇 2小时前
    下一篇 2小时前

    相关推荐

    发表回复

    您的邮箱地址不会被公开。 必填项已用 * 标注