文档

物体检测

本文介绍目标检测(objectdet)类目下的物体检测DetectObject的语法及示例。

功能描述

物体检测能力可以检测输入图像中的物体。

关于该接口功能的示例图如下:

说明
  • 您可以进入在线咨询获取在线人工帮助。
  • 当前能力可在视觉智能开放平台有完整的免费产品体验,您可以单击立即试用对该能力进行更直观试用以及在线购买。
  • 阿里云视觉智能开放平台视觉AI能力API接入、接口使用或问题咨询等,请通过钉钉群(23109592)加入阿里云视觉智能开放平台咨询群联系我们。

接入指引

1. 注册阿里云账号:打开阿里云官网,在阿里云官网右上角,单击立即注册,按照操作提示完成账号注册。

2. 开通能力:请确保您已开通目标检测服务,若未开通服务请立即开通

3. 创建AccessKey:请确保您已创建AccessKey,如果您使用的是子账号AccessKey,您需要给子账号赋予AliyunVIAPIFullAccess权限,具体操作,请参见RAM授权

4. 在线调试(可选):您可以通过OpenAPI Explorer在线调试能力,查看完整的调用示例代码及SDK依赖信息,也可以下载完整的工程。

5. 开发接入步骤:

  • SDK总览中选择您要接入使用的SDK语言。
  • 在对应语言的SDK文档中找到AI类目为目标检测(objectdet)类目的SDK包进行安装。
  • 参考文档中提供的示例代码进行适当修改后调用。

6. 示例代码:该能力常用语言的示例代码,请参见物体检测示例代码

7. 客户端直接调用:该能力常用的客户端调用方式包括以下几种。

输入限制

  • 图像格式:JPEG、JPG、PNG、BMP。
  • 图像大小:不超过3 MB。
  • 图像分辨率:大于20×20像素,小于4096×4096像素。
  • URL地址中不能包含中文字符。

计费说明

关于物体检测的计费方式及报价,请参见计费介绍

说明 下方调试接口为付费接口,如需免费体验调试请前往体验中心

调试

您可以在OpenAPI Explorer中直接运行该接口,免去您计算签名的困扰。运行成功后,OpenAPI Explorer可以自动生成SDK代码示例。

请求参数

名称

类型

是否必选

示例值

描述

Action String DetectObject

系统规定参数。取值:DetectObject

ImageURL String http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectObject/DetectObject1.jpg

图像URL地址。推荐使用上海地域的OSS链接,对于文件在本地或者非上海地域OSS链接的情况,请参见文件URL处理

返回数据

名称

类型

示例值

描述

RequestId String 6EF97B44-2763-4EAD-8737-FB9F5EE25FE2

请求ID。

Data Object

返回的结果数据内容。

Elements Array of Element

检测框数据集合。

Type String chair

检测框对应的物体名称。具体类型如下所示。

Boxes Array of Integer [468, 238, 531, 299]

检测框坐标,格式为[left, top, right, bottom]

Score Float 0.266

检测到物体的置信度,取值范围为0~1。

Width Integer 533

图片的宽度。

Height Integer 300

图片的高度。

Type类型包括:

human(人体)、sneakers(胶底运动鞋)、chair(椅子)、hat(帽子)、lamp(灯)、cabinet/shelf(橱柜/ 架子)、car(汽车)、glasses(眼镜)、picture/frame(照片/图画)、street lights(街灯)、helmet(头盔)、pillow(枕头)、glove(手套)、potted plant(盆栽植物)、flower(花)、monitor(显示屏)、plants pot/vase(花盆)、boots(靴子)、umbrella(伞)、boat(小船)、flag(旗帜)、speaker(扬声器/话筒)、trash bin/can(垃圾桶)、backpack( 双肩背包)、sofa(沙发)、belt(腰带)、carpet(地毯)、coffee table(咖啡桌/茶几)、tie(领带)、bed(床)、traffic light(红绿灯)、necklace(项链)、mirror(镜子)、bicycle(自行车)、watch(手表)、horse(马)、traffic sign(交通标志)、stuffed animal(填充玩具动物)、motorbike/motorcycle(摩托车)、wild bird(鸟)、laptop(笔记本电脑)、cow(奶牛)、clock(时钟)、bus(公共汽车)、nightstand(床头柜)、sheep(绵羊)、traffic cone(锥形交通路标)、keyboard(键盘)、hockey stick(曲棍球球棍)、fan(电扇)、dog(狗)、blackboard/whiteboard(白板/黑板)、mouse(鼠标)、telephone(电话)、airplane(飞机)、skis(滑雪板)、soccer(英式足球)、combine with glove(棒球手套)、train(火车)、tent(帐篷)、sailboat(帆船)、kite(风筝)、computer box(计算机主机机箱)、elephant(大象)、stroller(折叠式婴儿车)、baseball bat(棒球棒)、skateboard(溜冰板)、surfboard(冲浪板)、cat(猫)、zebra(斑马)、sports car(跑车)、giraffe(长颈鹿)、radiator(散热器)、tennis racket(网球拍)、skating and skiing shoes(溜冰鞋)、baseball(棒球)、american football(美式橄榄球)、basketball(篮球)、printer(打印机)、fire hydrant(消防栓)、projector(投影仪)、fire extinguisher(灭火器)、tennis ball(网球)、frisbee(飞盘)、fire truck(消防车)、helicopter(直升飞机)、carriage(四轮马车)、bear(熊)、globe(地球仪)、volleyball(排球)。

SDK参考

阿里云视觉AI目标检测类目下的物体检测能力推荐使用SDK调用,支持多种编程语言,调用时请选择AI类目为目标检测(objectdet)的SDK包,文件参数通过SDK调用可支持本地文件及任意URL,具体可参见SDK总览

示例代码

该能力常用语言的示例代码,请参见物体检测示例代码

示例

请求示例

http(s)://objectdet.cn-shanghai.aliyuncs.com/?Action=DetectObject    //更多关于访问域名(Endpoint)信息,请参见:https://help.aliyun.com/document_detail/143103.html
&ImageURL=http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/objectdet/DetectObject/DetectObject1.jpg
&<公共请求参数>

正常返回示例

XML格式

HTTP/1.1 200 OK
Content-Type:application/xml

<DetectObjectResponse>
    <RequestId>6EF97B44-2763-4EAD-8737-FB9F5EE25FE2</RequestId>
    <Data>
        <Height>300</Height>
        <Elements>
            <Score>0.266</Score>
            <Type>chair</Type>
            <Boxes>468</Boxes>
            <Boxes>238</Boxes>
            <Boxes>531</Boxes>
            <Boxes>299</Boxes>
        </Elements>
        <Elements>
            <Score>0.213</Score>
            <Type>chair</Type>
            <Boxes>452</Boxes>
            <Boxes>168</Boxes>
            <Boxes>531</Boxes>
            <Boxes>233</Boxes>
        </Elements>
        <Elements>
            <Score>0.308</Score>
            <Type>picture/frame</Type>
            <Boxes>487</Boxes>
            <Boxes>44</Boxes>
            <Boxes>501</Boxes>
            <Boxes>96</Boxes>
        </Elements>
        <Elements>
            <Score>0.257</Score>
            <Type>picture/frame</Type>
            <Boxes>477</Boxes>
            <Boxes>67</Boxes>
            <Boxes>484</Boxes>
            <Boxes>98</Boxes>
        </Elements>
        <Elements>
            <Score>0.201</Score>
            <Type>picture/frame</Type>
            <Boxes>503</Boxes>
            <Boxes>26</Boxes>
            <Boxes>524</Boxes>
            <Boxes>85</Boxes>
        </Elements>
        <Elements>
            <Score>0.515</Score>
            <Type>pillow</Type>
            <Boxes>161</Boxes>
            <Boxes>141</Boxes>
            <Boxes>181</Boxes>
            <Boxes>158</Boxes>
        </Elements>
        <Elements>
            <Score>0.293</Score>
            <Type>pillow</Type>
            <Boxes>473</Boxes>
            <Boxes>143</Boxes>
            <Boxes>496</Boxes>
            <Boxes>157</Boxes>
        </Elements>
        <Elements>
            <Score>0.214</Score>
            <Type>pillow</Type>
            <Boxes>241</Boxes>
            <Boxes>145</Boxes>
            <Boxes>253</Boxes>
            <Boxes>166</Boxes>
        </Elements>
        <Elements>
            <Score>0.374</Score>
            <Type>potted plant</Type>
            <Boxes>449</Boxes>
            <Boxes>97</Boxes>
            <Boxes>477</Boxes>
            <Boxes>140</Boxes>
        </Elements>
        <Elements>
            <Score>0.412</Score>
            <Type>sofa</Type>
            <Boxes>145</Boxes>
            <Boxes>135</Boxes>
            <Boxes>304</Boxes>
            <Boxes>202</Boxes>
        </Elements>
        <Elements>
            <Score>0.269</Score>
            <Type>sofa</Type>
            <Boxes>443</Boxes>
            <Boxes>136</Boxes>
            <Boxes>531</Boxes>
            <Boxes>190</Boxes>
        </Elements>
        <Elements>
            <Score>0.262</Score>
            <Type>sofa</Type>
            <Boxes>301</Boxes>
            <Boxes>136</Boxes>
            <Boxes>352</Boxes>
            <Boxes>168</Boxes>
        </Elements>
        <Elements>
            <Score>0.242</Score>
            <Type>sofa</Type>
            <Boxes>452</Boxes>
            <Boxes>167</Boxes>
            <Boxes>531</Boxes>
            <Boxes>230</Boxes>
        </Elements>
        <Elements>
            <Score>0.219</Score>
            <Type>carpet</Type>
            <Boxes>0</Boxes>
            <Boxes>153</Boxes>
            <Boxes>272</Boxes>
            <Boxes>293</Boxes>
        </Elements>
        <Elements>
            <Score>0.458</Score>
            <Type>coffee table</Type>
            <Boxes>171</Boxes>
            <Boxes>172</Boxes>
            <Boxes>214</Boxes>
            <Boxes>214</Boxes>
        </Elements>
        <Elements>
            <Score>0.358</Score>
            <Type>coffee table</Type>
            <Boxes>337</Boxes>
            <Boxes>185</Boxes>
            <Boxes>420</Boxes>
            <Boxes>274</Boxes>
        </Elements>
        <Elements>
            <Score>0.285</Score>
            <Type>coffee table</Type>
            <Boxes>386</Boxes>
            <Boxes>159</Boxes>
            <Boxes>428</Boxes>
            <Boxes>192</Boxes>
        </Elements>
        <Elements>
            <Score>0.214</Score>
            <Type>mirror</Type>
            <Boxes>503</Boxes>
            <Boxes>26</Boxes>
            <Boxes>524</Boxes>
            <Boxes>85</Boxes>
        </Elements>
        <Width>533</Width>
    </Data>
</DetectObjectResponse>

JSON格式

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "6EF97B44-2763-4EAD-8737-FB9F5EE25FE2",
  "Data" : {
    "Height" : 300,
    "Elements" : [ {
      "Score" : 0.266,
      "Type" : "chair",
      "Boxes" : [ 468, 238, 531, 299 ]
    }, {
      "Score" : 0.213,
      "Type" : "chair",
      "Boxes" : [ 452, 168, 531, 233 ]
    }, {
      "Score" : 0.308,
      "Type" : "picture/frame",
      "Boxes" : [ 487, 44, 501, 96 ]
    }, {
      "Score" : 0.257,
      "Type" : "picture/frame",
      "Boxes" : [ 477, 67, 484, 98 ]
    }, {
      "Score" : 0.201,
      "Type" : "picture/frame",
      "Boxes" : [ 503, 26, 524, 85 ]
    }, {
      "Score" : 0.515,
      "Type" : "pillow",
      "Boxes" : [ 161, 141, 181, 158 ]
    }, {
      "Score" : 0.293,
      "Type" : "pillow",
      "Boxes" : [ 473, 143, 496, 157 ]
    }, {
      "Score" : 0.214,
      "Type" : "pillow",
      "Boxes" : [ 241, 145, 253, 166 ]
    }, {
      "Score" : 0.374,
      "Type" : "potted plant",
      "Boxes" : [ 449, 97, 477, 140 ]
    }, {
      "Score" : 0.412,
      "Type" : "sofa",
      "Boxes" : [ 145, 135, 304, 202 ]
    }, {
      "Score" : 0.269,
      "Type" : "sofa",
      "Boxes" : [ 443, 136, 531, 190 ]
    }, {
      "Score" : 0.262,
      "Type" : "sofa",
      "Boxes" : [ 301, 136, 352, 168 ]
    }, {
      "Score" : 0.242,
      "Type" : "sofa",
      "Boxes" : [ 452, 167, 531, 230 ]
    }, {
      "Score" : 0.219,
      "Type" : "carpet",
      "Boxes" : [ 0, 153, 272, 293 ]
    }, {
      "Score" : 0.458,
      "Type" : "coffee table",
      "Boxes" : [ 171, 172, 214, 214 ]
    }, {
      "Score" : 0.358,
      "Type" : "coffee table",
      "Boxes" : [ 337, 185, 420, 274 ]
    }, {
      "Score" : 0.285,
      "Type" : "coffee table",
      "Boxes" : [ 386, 159, 428, 192 ]
    }, {
      "Score" : 0.214,
      "Type" : "mirror",
      "Boxes" : [ 503, 26, 524, 85 ]
    } ],
    "Width" : 533
  }
}

错误码

关于物体检测的错误码,详情请参见常见错误码

安全声明

  • 请确保上传的图片或文件来源符合相应的法律法规。
  • 通过体验调试上传的临时文件有效期为1小时,在24小时后会被系统自动清理删除。

  • 本页导读 (1)
文档反馈