阿里视觉训练营Day4——车辆保险应用
开通服务
首先在视觉智能开放平台https://vision.aliyun.com/开通车辆识别服务
功能描述
可以识别图片(完整或部件图片)中汽车的类型,目前主要有小轿车、多用途汽车、SUV等类别。
示例代码
import com.aliyuncs.DefaultAcsClient;`
import com.aliyuncs.IAcsClient;`
import com.aliyuncs.exceptions.ClientException;`
import com.aliyuncs.exceptions.ServerException;`
import com.aliyuncs.profile.DefaultProfile;`
import com.google.gson.Gson;`
import java.util.*;
import com.aliyuncs.imagerecog.model.v20190930.*;`
public class RecognizeVehicleType {
public static void main(String[] args) {
DefaultProfile profile = DefaultProfile.getProfile("cn-shanghai", "<accessKeyId>", "<accessSecret>");
IAcsClient client = new DefaultAcsClient(profile);
RecognizeVehicleTypeRequest request = new RecognizeVehicleTypeRequest();
request.setRegionId("cn-shanghai");
request.setImageURL("http://viapi-test.oss-cn-shanghai.aliyuncs.com/sanjiye-meizi/%E8%BD%A6%E5%9E%8B%E8%AF%86%E5%88%AB-%E5%BE%85%E6%B5%8B%E8%AF%95.jpg");
try {
RecognizeVehicleTypeResponse response = client.getAcsResponse(request);
System.out.println(new Gson().toJson(response));
} catch (ServerException e) {
e.printStackTrace();
} catch (ClientException e) {
System.out.println("ErrCode:" + e.getErrCode());
System.out.println("ErrMsg:" + e.getErrMsg());
System.out.println("RequestId:" + e.getRequestId());
}
}
}
请求实例
http(s)://[Endpoint]/?Action=RecognizeVehicleType
&ImageURL=https://viapi-test.oss-cn-shanghai.aliyuncs.com/test-team/%E6%B5%8B%E8%AF%95002/detvichle.jpg
&<公共请求参数>
正常返回实例
<RequestId>DC2DD4F6-524F-461E-99E0-79A51A6C457B</RequestId>
<Data>
<Elements>
<Score>0.9952</Score>
<Name>car</Name>
</Elements>
<Elements>
<Score>0.0001</Score>
<Name>MPV_mian</Name>
</Elements>
<Elements>
<Score>0.0029</Score>
<Name>others</Name>
</Elements>
<Elements>
<Score>0.0018</Score>
<Name>SUV</Name>
</Elements>
<Threshold>0.9952</Threshold>
</Data>
json格式
{
"RequestId": "DC2DD4F6-524F-461E-99E0-79A51A6C457B",
"Data": {
"Elements": [
{
"Score": 0.9952,
"Name": "car"
},
{
"Score": 0.0001,
"Name": "MPV_mian"
},
{
"Score": 0.0029,
"Name": "others"
},
{
"Score": 0.0018,
"Name": "SUV"
}
],
"Threshold": 0.9952
}
}