提交修改
This commit is contained in:
parent
65adcbbb32
commit
234f5f78df
@ -290,4 +290,9 @@ public class ApiConstants {
|
||||
public static final String SUCCESS = "1";
|
||||
public static final String FAILED = "0";
|
||||
|
||||
|
||||
|
||||
public static final String face = "face";
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -1,12 +1,12 @@
|
||||
package com.heyu.api.controller.certificate;
|
||||
package com.heyu.api.controller.certificate.car;
|
||||
|
||||
import com.aliyun.ocr20191230.models.RecognizeDriverLicenseResponse;
|
||||
import com.aliyun.ocr20191230.models.RecognizeDriverLicenseResponseBody;
|
||||
import com.heyu.api.alibaba.handle.common.text.ARecognizeDriverLicenseHandle;
|
||||
import com.heyu.api.alibaba.request.common.text.ARecognizeDriverLicenseRequest;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.controller.resp.RecognizeDriverLicenseBackResp;
|
||||
import com.heyu.api.controller.resp.RecognizeDriverLicenseFaceResp;
|
||||
import com.heyu.api.controller.resp.car.RecognizeDriverLicenseBackResp;
|
||||
import com.heyu.api.controller.resp.car.RecognizeDriverLicenseFaceResp;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
@ -0,0 +1,84 @@
|
||||
package com.heyu.api.controller.certificate.car;
|
||||
|
||||
|
||||
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponse;
|
||||
import com.aliyun.ocr20191230.models.RecognizeDrivingLicenseResponseBody;
|
||||
import com.heyu.api.alibaba.handle.common.text.ARecognizeDrivingLicenseHandle;
|
||||
import com.heyu.api.alibaba.request.common.text.ARecognizeDrivingLicenseRequest;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.controller.resp.car.RecognizeDrivingLicenseBackResp;
|
||||
import com.heyu.api.controller.resp.car.RecognizeDrivingLicenseFaceResp;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.constants.ApiConstants;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/***
|
||||
*
|
||||
* https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeDrivingLicense?tab=DEMO&lang=JAVA
|
||||
*行驶证识别
|
||||
*
|
||||
* RecognizeDrivingLicense
|
||||
* 行驶证识别能力可以识别行驶证首页和副页关键字段内容,输出品牌型号、车辆类型、车牌号码、检验记录、核定载质量、核定载人数等 21 个关键字段信息。
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/driving/license")
|
||||
@NotIntercept
|
||||
public class RecognizeDrivingLicenseController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ARecognizeDrivingLicenseHandle arRecognizeDrivingLicenseHandle;
|
||||
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
public R recognize(ARecognizeDrivingLicenseRequest aRecognizeDrivingLicenseRequest) {
|
||||
|
||||
RecognizeDrivingLicenseBackResp backResp = new RecognizeDrivingLicenseBackResp();
|
||||
RecognizeDrivingLicenseFaceResp faceResp = new RecognizeDrivingLicenseFaceResp();
|
||||
|
||||
ApiR<RecognizeDrivingLicenseResponse> aR = arRecognizeDrivingLicenseHandle.handle(aRecognizeDrivingLicenseRequest);
|
||||
if (aR.isSuccess() && aR.getData() != null && isSuccessStatusCode(aR.getData().statusCode)) {
|
||||
RecognizeDrivingLicenseResponse response = aR.getData();
|
||||
RecognizeDrivingLicenseResponseBody responseBody = response.getBody();
|
||||
RecognizeDrivingLicenseResponseBody.RecognizeDrivingLicenseResponseBodyData responseBodyData = responseBody.getData();
|
||||
|
||||
RecognizeDrivingLicenseResponseBody.RecognizeDrivingLicenseResponseBodyDataFaceResult faceResult = responseBodyData.getFaceResult();
|
||||
RecognizeDrivingLicenseResponseBody.RecognizeDrivingLicenseResponseBodyDataBackResult backResult = responseBodyData.getBackResult();
|
||||
if (ApiConstants.face.equals(aRecognizeDrivingLicenseRequest.getSide())) {
|
||||
faceResp.setIssueDate(faceResult.getIssueDate());
|
||||
faceResp.setModel(faceResult.getModel());
|
||||
faceResp.setVehicleType(faceResult.getVehicleType());
|
||||
faceResp.setOwner(faceResult.getOwner());
|
||||
faceResp.setEngineNumber(faceResult.getEngineNumber());
|
||||
faceResp.setPlateNumber(faceResult.getPlateNumber());
|
||||
faceResp.setAddress(faceResult.getAddress());
|
||||
faceResp.setUseCharacter(faceResult.getUseCharacter());
|
||||
faceResp.setVin(faceResult.getVin());
|
||||
faceResp.setRegisterDate(faceResult.getRegisterDate());
|
||||
return R.ok().setData(faceResp);
|
||||
}
|
||||
if (ApiConstants.back.equals(aRecognizeDrivingLicenseRequest.getSide())) {
|
||||
backResp.setOverallDimension(backResult.getOverallDimension());
|
||||
backResp.setInspectionRecord(backResult.getInspectionRecord());
|
||||
backResp.setUnladenMass(backResult.getUnladenMass());
|
||||
backResp.setFileNumber(backResult.getFileNumber());
|
||||
backResp.setTractionMass(backResult.getTractionMass());
|
||||
backResp.setGrossMass(backResp.getGrossMass());
|
||||
backResp.setPlateNumber(backResp.getPlateNumber());
|
||||
backResp.setApprovedPassengerCapacity(backResp.getApprovedPassengerCapacity());
|
||||
backResp.setEnergyType(backResp.getEnergyType());
|
||||
backResp.setApprovedLoad(backResp.getApprovedLoad());
|
||||
return R.ok().setData(backResp);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@ -0,0 +1,69 @@
|
||||
package com.heyu.api.controller.certificate.car;
|
||||
|
||||
|
||||
import com.aliyun.ocr20191230.models.RecognizeLicensePlateResponse;
|
||||
import com.aliyun.ocr20191230.models.RecognizeLicensePlateResponseBody;
|
||||
import com.heyu.api.alibaba.handle.common.text.ARecognizeLicensePlateHandle;
|
||||
import com.heyu.api.alibaba.request.common.text.ARecognizeDrivingLicenseRequest;
|
||||
import com.heyu.api.alibaba.request.common.text.ARecognizeLicensePlateRequest;
|
||||
import com.heyu.api.controller.BaseController;
|
||||
import com.heyu.api.controller.resp.car.RecognizeLicensePlateResp;
|
||||
import com.heyu.api.data.annotation.NotIntercept;
|
||||
import com.heyu.api.data.utils.ApiR;
|
||||
import com.heyu.api.data.utils.R;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeLicensePlate?useCommon=true&tab=DOC&lang=JAVA&sdkStyle=dara
|
||||
*
|
||||
*车牌识别
|
||||
*
|
||||
* RecognizeLicensePlate
|
||||
*
|
||||
*
|
||||
* 车牌识别能力可以准确识别出图像中车牌位置,输出车牌位置坐标、车牌类型、车牌号码、车牌号码置信度、车牌置信度,共 5 个关键字段信息。
|
||||
*
|
||||
* 车牌识别能力目前支持的地域(Region)有上海和深圳,当您开通服务时选择的是上海地域,推荐使用上海地域的 OSS 链接,对于文件在本地或者非上海地域 OSS 链接的情况,请参见文件 URL 处理。当您开通服务时选择的是深圳地域时,仅支持深圳地域 OSS 链接进行调用。
|
||||
*
|
||||
* 示例值:
|
||||
* http://viapi-test.oss-cn-shanghai.aliyuncs.com/viapi-3.0domepic/ocr/RecognizeLicensePlate/cpsb1.jpg
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("/car/license/plate")
|
||||
@NotIntercept
|
||||
public class RecognizeLicensePlateController extends BaseController {
|
||||
|
||||
|
||||
@Autowired
|
||||
private ARecognizeLicensePlateHandle aRecognizeLicensePlateHandle;
|
||||
|
||||
|
||||
@RequestMapping("/recognize")
|
||||
public R recognize(ARecognizeLicensePlateRequest request) {
|
||||
RecognizeLicensePlateResp resp = new RecognizeLicensePlateResp();
|
||||
ApiR<RecognizeLicensePlateResponse> aR = aRecognizeLicensePlateHandle.handle(request);
|
||||
if (aR.isSuccess() && isSuccessStatusCode(aR.getData().getStatusCode())) {
|
||||
RecognizeLicensePlateResponse response = aR.getData();
|
||||
RecognizeLicensePlateResponseBody responseBody = response.getBody();
|
||||
RecognizeLicensePlateResponseBody.RecognizeLicensePlateResponseBodyData responseBodyData = responseBody.getData();
|
||||
if (CollectionUtils.isNotEmpty(responseBodyData.getPlates())) {
|
||||
RecognizeLicensePlateResponseBody.RecognizeLicensePlateResponseBodyDataPlates responseBodyDataPlates = responseBodyData.getPlates().get(0);
|
||||
resp.setConfidence(responseBodyDataPlates.getConfidence());
|
||||
resp.setPlateTypeConfidence(responseBodyDataPlates.getPlateTypeConfidence());
|
||||
resp.setPlateType(responseBodyDataPlates.getPlateType());
|
||||
resp.setPlateNumber(responseBodyDataPlates.getPlateNumber());
|
||||
return R.ok().setData(resp);
|
||||
}
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
@ -76,7 +76,6 @@ public class IdCardController {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 百度识别
|
||||
BIdcardRequest bIdcardRequest = new BIdcardRequest();
|
||||
bIdcardRequest.setImageUrl(apiIdentityCardRequest.getImageUrl());
|
||||
@ -108,13 +107,7 @@ public class IdCardController {
|
||||
}
|
||||
|
||||
|
||||
|
||||
return R.error("识别失败").setData(frontResp);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
@ -0,0 +1,23 @@
|
||||
package com.heyu.api.controller.request.car;
|
||||
|
||||
import com.heyu.api.data.dto.BaseRequest;
|
||||
import lombok.Data;
|
||||
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeDrivingLicense?tab=DEMO&lang=JAVA
|
||||
*
|
||||
*
|
||||
* 行驶证识别
|
||||
*
|
||||
* RecognizeDrivingLicense
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeDriverLicenseReq extends BaseRequest {
|
||||
|
||||
|
||||
|
||||
}
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.controller.resp;
|
||||
package com.heyu.api.controller.resp.car;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
package com.heyu.api.controller.resp;
|
||||
package com.heyu.api.controller.resp.car;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@ -0,0 +1,103 @@
|
||||
package com.heyu.api.controller.resp.car;
|
||||
|
||||
import com.heyu.api.data.dto.BaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeDrivingLicense?tab=DOC&lang=JAVAn
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeDrivingLicenseBackResp extends BaseResp {
|
||||
|
||||
|
||||
/***
|
||||
* 外廓尺寸。
|
||||
*
|
||||
* 示例值:
|
||||
* 4945x1845x1480
|
||||
*/
|
||||
private String overallDimension;
|
||||
|
||||
|
||||
/***
|
||||
* 检验记录。
|
||||
*
|
||||
* 示例值:
|
||||
* 检验有效期至2014年09月云A(01)n
|
||||
*/
|
||||
private String inspectionRecord;
|
||||
|
||||
|
||||
/***
|
||||
* 整备质量。
|
||||
*
|
||||
* 示例值:
|
||||
* 2000
|
||||
*/
|
||||
private String unladenMass;
|
||||
|
||||
|
||||
/***
|
||||
* 档案编号。
|
||||
*
|
||||
* 示例值:
|
||||
* 苏F123E9
|
||||
*/
|
||||
private String fileNumber;
|
||||
|
||||
|
||||
/***
|
||||
* 准牵引总质量。
|
||||
*
|
||||
* 示例值:
|
||||
* 100
|
||||
*/
|
||||
private String tractionMass;
|
||||
|
||||
|
||||
/***
|
||||
* 总质量。
|
||||
*
|
||||
* 示例值:
|
||||
* 2205
|
||||
*/
|
||||
private String grossMass;
|
||||
|
||||
/***
|
||||
* 号牌号码。
|
||||
*
|
||||
* 示例值:
|
||||
* 苏F123E9
|
||||
*/
|
||||
private String plateNumber;
|
||||
|
||||
|
||||
/***
|
||||
* 核定载人数。
|
||||
*
|
||||
* 示例值:
|
||||
* 5
|
||||
*/
|
||||
private String approvedPassengerCapacity;
|
||||
|
||||
/***
|
||||
* 能源标志。
|
||||
*
|
||||
* 示例值:
|
||||
* -
|
||||
*/
|
||||
private String energyType;
|
||||
|
||||
|
||||
/***
|
||||
* 核定载质量。
|
||||
*
|
||||
* 示例值:
|
||||
* 300
|
||||
*/
|
||||
private String approvedLoad;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -0,0 +1,97 @@
|
||||
package com.heyu.api.controller.resp.car;
|
||||
|
||||
|
||||
import com.heyu.api.data.dto.BaseResp;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
*
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeDrivingLicenseFaceResp extends BaseResp {
|
||||
|
||||
|
||||
/***
|
||||
* 地址。
|
||||
*
|
||||
* 示例值:
|
||||
* 中牟县三刘寨村
|
||||
*/
|
||||
public String address;
|
||||
|
||||
/**
|
||||
* 发动机号码。
|
||||
*
|
||||
* 示例值:
|
||||
* 111111
|
||||
*/
|
||||
public String engineNumber;
|
||||
|
||||
/***
|
||||
* 发证日期,格式:YYYYMMDD,例如 19800101,即 1980 年 01 月 01 日。
|
||||
*
|
||||
* 示例值:
|
||||
* 20180313
|
||||
*/
|
||||
public String issueDate;
|
||||
|
||||
|
||||
/***
|
||||
* 品牌型号。
|
||||
*
|
||||
* 示例值:
|
||||
* 大众汽车牌SVW6666DFD
|
||||
*/
|
||||
public String model;
|
||||
|
||||
/**
|
||||
* 所有人名称。
|
||||
*
|
||||
* 示例值:
|
||||
* 张三
|
||||
*/
|
||||
public String owner;
|
||||
|
||||
|
||||
/**
|
||||
* 车牌号码。
|
||||
*
|
||||
* 示例值:
|
||||
* 苏F123E9
|
||||
*/
|
||||
|
||||
public String plateNumber;
|
||||
|
||||
/***
|
||||
* 注册日期,格式:YYYYMMDD,例如 19800101,即 1980 年 01 月 01 日。
|
||||
*
|
||||
* 示例值:
|
||||
* 20180312
|
||||
*/
|
||||
public String registerDate;
|
||||
|
||||
|
||||
/**
|
||||
* 使用性质。
|
||||
*
|
||||
* 示例值:
|
||||
* 非营运
|
||||
*/
|
||||
public String useCharacter;
|
||||
/**
|
||||
* 车辆类型。
|
||||
*
|
||||
* 示例值:
|
||||
* 小型普通客车
|
||||
*/
|
||||
public String vehicleType;
|
||||
|
||||
/**
|
||||
* 车辆识别代号。
|
||||
*
|
||||
* 示例值:
|
||||
* SSVUDDTT2J2022555
|
||||
*/
|
||||
public String vin;
|
||||
|
||||
}
|
||||
@ -0,0 +1,53 @@
|
||||
package com.heyu.api.controller.resp.car;
|
||||
|
||||
|
||||
import com.heyu.api.baidu.response.convert.BTextreviewQueryResp;
|
||||
import lombok.Data;
|
||||
|
||||
/***
|
||||
* https://next.api.aliyun.com/api/ocr/2019-12-30/RecognizeLicensePlate?useCommon=true&tab=DOC&lang=JAVA&sdkStyle=dara
|
||||
*
|
||||
* 车牌识别
|
||||
*
|
||||
* RecognizeLicensePlate
|
||||
*/
|
||||
@Data
|
||||
public class RecognizeLicensePlateResp {
|
||||
|
||||
|
||||
/***
|
||||
* 车牌类型的置信度,取值范围 0~1。
|
||||
*
|
||||
* 示例值:
|
||||
* 1
|
||||
*/
|
||||
private Float plateTypeConfidence;
|
||||
|
||||
/**
|
||||
* 车牌类型。包括:小型汽车、新能源车、大型汽车、挂车、教练车、警车、军车、使领馆车、港澳车。
|
||||
*
|
||||
* 示例值:
|
||||
* 小型汽车
|
||||
*/
|
||||
private String plateType;
|
||||
|
||||
|
||||
/***
|
||||
* 车牌号码的置信度,取值范围 0~1。
|
||||
*
|
||||
* 示例值:
|
||||
* 0.99745339155197144
|
||||
*/
|
||||
private float confidence;
|
||||
|
||||
|
||||
/***
|
||||
* 车牌号码。
|
||||
*
|
||||
* 示例值:
|
||||
* 粤BP57E7
|
||||
*/
|
||||
private String plateNumber;
|
||||
|
||||
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user