/car/vehicle_inspection
1.接口描述
该 API 用于对车辆损坏情况的识别。
- 图片要求:
- 格式为 JPG(JPEG),PNG
- 宽和高大于 128px,小于等于 6000px
- 小于等于 5 MB
请求方式
POST
请求 URL
http://cloudapi.deepfinch.com/car/vehicle_inspection
2.请求参数
字段 |
类型 |
必需 |
描述 |
file |
file |
见下方注释 |
需上传的图片文件,上传本地图片进行检测时选取此参数 |
url |
string |
见下方注释 |
图片网络地址,采用抓取网络图片方式时需选取此参数 |
lang |
string |
否 |
多语言支持,返回结果增加子部件及损伤名称, en:英文, zh_cn:简体中文 |
至少需要1个方向的车辆图片,对应方向的请求参数file
与 url
二选一。
url 中含有不少特殊字符,若将 URL 放入 Query String 中则需要对这些字符进行转义,所有中文和特殊字符必需以UTF-8编码转义。
目前支持 http/https 等协议的网络地址。下载限时 5s,超时后仍未下载完成则属于失败。
参数 file
需把图片文件的内容以 multipart/form-data 的形式放到 POST 消息体中。
3.返回参数
字段 |
类型 |
说明 |
request_id |
string |
本次请求的id |
status |
string |
状态,正常为 OK |
result |
object |
识别结果 |
result
字段
字段 |
类型 |
说明 |
has_car |
bool |
是否有车, true: 有车, false: 无车 |
[0,1,2,3] |
objectArray |
车辆方向, 0:左前, 1:左后, 2:右前, 3:右后 |
车辆方向
字段
字段 |
类型 |
说明 |
type |
string |
见附录 |
scar |
objectArray |
损伤信息 |
scar
字段
字段 |
类型 |
说明 |
type |
string |
见附录 |
position |
object |
损伤位置点信息, Point(x,y) |
返回结果示例
{
"request_id": "TID917ca7fe23ba489b89838760a58e94ae",
"status": "OK",
"result": {
"has_car": true
"2": [
{
"scar": [
{
"position": [
{
"y": 732.5866666666666,
"x": 1486.9333333333332
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 558.5066666666667,
"x": 1254.8266666666666
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 558.5066666666667,
"x": 1204.0533333333333
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 522.24,
"x": 1160.5333333333333
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 485.9733333333333,
"x": 1552.2133333333331
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 493.22666666666663,
"x": 1349.12
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 485.9733333333333,
"x": 1029.9733333333334
}
],
"type": 1,
"name": "刮擦"
}
],
"type": 13,
"name": "挡风玻璃"
},
{
"scar": [
{
"position": [
{
"y": 246.61333333333332,
"x": 1131.52
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 217.6,
"x": 1305.6
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 203.0933333333333,
"x": 935.68
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 232.10666666666665,
"x": 623.7866666666666
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 145.06666666666666,
"x": 1211.3066666666666
}
],
"type": 1,
"name": "刮擦"
}
],
"type": 16,
"name": "车顶"
},
{
"scar": [
{
"position": [
{
"y": 1631.9999999999998,
"x": 1233.0666666666666
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 1334.6133333333332,
"x": 957.4399999999999
}
],
"type": 1,
"name": "刮擦"
},
{
"position": [
{
"y": 979.1999999999999,
"x": 877.6533333333333
}
],
"type": 1,
"name": "刮擦"
}
],
"type": 5,
"name": "翼子板"
},
{
"scar": [
{
"position": [
{
"y": 2125.2266666666665,
"x": 1951.1466666666665
}
],
"type": 1,
"name": "刮擦"
}
],
"type": 4,
"name": "保险杠"
},
{
"scar": [
{
"position": [
{
"y": 848.64,
"x": 602.0266666666666
}
],
"type": 1,
"name": "刮擦"
}
],
"type": 9,
"name": "反光镜"
},
{
"scar": [
{
"position": [
{
"y": 660.0533333333333,
"x": 210.34666666666666
}
],
"type": 1,
"name": "刮擦"
}
],
"type": 8,
"name": "门"
}
]
}
}
4.错误码
状态码 |
status 字段 |
说明 |
400 |
INVALID_ARGUMENT |
请求参数错误 |
400 |
DETECTION_FAILED |
图片检测失败 |
400 |
DOWNLOAD_ERROR |
网络地址图片获取失败 |
401 |
UNAUTHORIZED |
未授权或授权失败 |
401 |
KEY_EXPIRED |
账号过期 |
403 |
NO_PERMISSION |
无调用权限 |
403 |
OUT_OF_QUOTA |
调用次数超出限额 |
403 |
RATE_LIMIT_EXCEEDED |
调用频率超出限额 |
404 |
NOT_FOUND |
请求路径错误 |
500 |
INTERNAL_ERROR |
服务器内部错误 |
备注: 以上40X系列错误描述请参考reason
字段
输出样例
{
"status": "INVALID_ARGUMENT",
"reason": "must specify 'file' or 'url' argument",
"request_id": "TID8bf47ab6eda64476973cc5f5b6ebf57e"
}
5.附录
子部件
部件代码 |
部件名称 |
1 |
发动机盖 |
2 |
中网格栅 |
3 |
大灯 |
4 |
保险杆 |
5 |
翼子板 |
6 |
轮毂 |
7 |
行李箱盖 |
8 |
门 |
9 |
反光镜 |
10 |
底大边 |
11 |
门顶边 |
12 |
车门竖板 |
13 |
挡风玻璃 |
14 |
侧门玻璃 |
15 |
车轮 (包括轮胎+轮毂) |
16 |
车顶 |
损伤类型
6.输入示例
curl --request POST \
--url http://cloudapi.deepfinch.com/car/vehicle_inspection \
--header 'content-type: multipart/form-data; boundary=---011000010111000001101001' \
--header 'X-DF-API-ID: xxxxxxxxxxxxxxxxxxxx' \
--header 'X-DF-API-SECRET: xxxxxxxxxxxxxxxxxxxx' \
--form file=1.jpg
package main
import (
"fmt"
"strings"
"net/http"
"io/ioutil"
)
func main() {
url := "http://cloudapi.deepfinch.com/car/vehicle_inspection"
payload := strings.NewReader("-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n1.jpg\r\n-----011000010111000001101001--\r\n")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("X-DF-API-ID", "xxxxxxxxxxxxxxxxxxxx")
req.Header.Add("X-DF-API-SECRET", "xxxxxxxxxxxxxxxxxxxx")
req.Header.Add("content-type", "multipart/form-data; boundary=---011000010111000001101001")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := ioutil.ReadAll(res.Body)
fmt.Println(res)
fmt.Println(string(body))
}
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=---011000010111000001101001");
RequestBody body = RequestBody.create(mediaType, "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n1.jpg\r\n-----011000010111000001101001--\r\n");
Request request = new Request.Builder()
.url("http://cloudapi.deepfinch.com/car/vehicle_inspection")
.post(body)
.addHeader("X-DF-API-ID", "xxxxxxxxxxxxxxxxxxxx")
.addHeader("X-DF-API-SECRET", "xxxxxxxxxxxxxxxxxxxx")
.addHeader("content-type", "multipart/form-data; boundary=---011000010111000001101001")
.build();
Response response = client.newCall(request).execute();
addForm(array(
'file' => '1.jpg'
), NULL);
$request->setRequestUrl('http://cloudapi.deepfinch.com/car/vehicle_inspection');
$request->setRequestMethod('POST');
$request->setBody($body);
$request->setHeaders(array(
'X-DF-API-ID' => 'xxxxxxxxxxxxxxxxxxxx',
'X-DF-API-SECRET' => 'xxxxxxxxxxxxxxxxxxxx'
));
$client->enqueue($request)->send();
$response = $client->getResponse();
echo $response->getBody();
import requests
url = "http://cloudapi.deepfinch.com/car/vehicle_inspection"
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n1.jpg\r\n-----011000010111000001101001--\r\n"
headers = {
'X-DF-API-ID': "xxxxxxxxxxxxxxxxxxxx",
'X-DF-API-SECRET': "xxxxxxxxxxxxxxxxxxxx",
'content-type': "multipart/form-data; boundary=---011000010111000001101001"
}
response = requests.request("POST", url, data=payload, headers=headers)
print(response.text)
require 'uri'
require 'net/http'
url = URI("http://cloudapi.deepfinch.com/car/vehicle_inspection")
http = Net::HTTP.new(url.host, url.port)
request = Net::HTTP::Post.new(url)
request["X-DF-API-ID"] = 'xxxxxxxxxxxxxxxxxxxx'
request["X-DF-API-SECRET"] = 'xxxxxxxxxxxxxxxxxxxx'
request["content-type"] = 'multipart/form-data; boundary=---011000010111000001101001'
request.body = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"file\"\r\n\r\n1.jpg\r\n-----011000010111000001101001--\r\n"
response = http.request(request)
puts response.read_body
#import
NSDictionary *headers = @{ @"X-DF-API-ID": @"xxxxxxxxxxxxxxxxxxxx",
@"X-DF-API-SECRET": @"xxxxxxxxxxxxxxxxxxxx",
@"content-type": @"multipart/form-data; boundary=---011000010111000001101001" };
NSArray *parameters = @[ @{ @"name": @"file", @"value": @"1.jpg" } ];
NSString *boundary = @"---011000010111000001101001";
NSError *error;
NSMutableString *body = [NSMutableString string];
for (NSDictionary *param in parameters) {
[body appendFormat:@"--%@\r\n", boundary];
if (param[@"fileName"]) {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"; filename=\"%@\"\r\n", param[@"name"], param[@"fileName"]];
[body appendFormat:@"Content-Type: %@\r\n\r\n", param[@"contentType"]];
[body appendFormat:@"%@", [NSString stringWithContentsOfFile:param[@"fileName"] encoding:NSUTF8StringEncoding error:&error]];
if (error) {
NSLog(@"%@", error);
}
} else {
[body appendFormat:@"Content-Disposition:form-data; name=\"%@\"\r\n\r\n", param[@"name"]];
[body appendFormat:@"%@", param[@"value"]];
}
}
[body appendFormat:@"\r\n--%@--\r\n", boundary];
NSData *postData = [body dataUsingEncoding:NSUTF8StringEncoding];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://cloudapi.deepfinch.com/car/vehicle_inspection"]
cachePolicy:NSURLRequestUseProtocolCachePolicy
timeoutInterval:10.0];
[request setHTTPMethod:@"POST"];
[request setAllHTTPHeaderFields:headers];
[request setHTTPBody:postData];
NSURLSession *session = [NSURLSession sharedSession];
NSURLSessionDataTask *dataTask = [session dataTaskWithRequest:request
completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) {
if (error) {
NSLog(@"%@", error);
} else {
NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *) response;
NSLog(@"%@", httpResponse);
}
}];
[dataTask resume];
import Foundation
let headers = [
"X-DF-API-ID": "xxxxxxxxxxxxxxxxxxxx",
"X-DF-API-SECRET": "xxxxxxxxxxxxxxxxxxxx",
"content-type": "multipart/form-data; boundary=---011000010111000001101001"
]
let parameters = [
[
"name": "file",
"value": "1.jpg"
]
]
let boundary = "---011000010111000001101001"
var body = ""
var error: NSError? = nil
for param in parameters {
let paramName = param["name"]!
body += "--\(boundary)\r\n"
body += "Content-Disposition:form-data; name=\"\(paramName)\""
if let filename = param["fileName"] {
let contentType = param["content-type"]!
let fileContent = String(contentsOfFile: filename, encoding: String.Encoding.utf8)
if (error != nil) {
print(error)
}
body += "; filename=\"\(filename)\"\r\n"
body += "Content-Type: \(contentType)\r\n\r\n"
body += fileContent
} else if let paramValue = param["value"] {
body += "\r\n\r\n\(paramValue)"
}
}
let request = NSMutableURLRequest(url: NSURL(string: "http://cloudapi.deepfinch.com/car/vehicle_inspection")! as URL,
cachePolicy: .useProtocolCachePolicy,
timeoutInterval: 10.0)
request.httpMethod = "POST"
request.allHTTPHeaderFields = headers
request.httpBody = postData as Data
let session = URLSession.shared
let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in
if (error != nil) {
print(error)
} else {
let httpResponse = response as? HTTPURLResponse
print(httpResponse)
}
})
dataTask.resume()