提交修改

This commit is contained in:
quyixiao 2025-03-27 23:59:49 +08:00
parent f0089f6f31
commit e1c86fe309
7 changed files with 252 additions and 3 deletions

View File

@ -1,13 +1,14 @@
package com.heyu.api.baidu.handle.traffic;
import com.heyu.api.data.annotation.CustomPath;
import com.heyu.api.baidu.BaiduBaseHandle;
import com.heyu.api.baidu.request.traffic.BRoadTransportCertificateRequest;
import com.heyu.api.baidu.response.traffic.BRoadTransportCertificateResp;
import com.heyu.api.data.annotation.CustomPath;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import java.util.Map;
/**
* https://console.bce.baidu.com/support/?_=1740411162437&timestamp=1740413029871#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Froad_transport_certificate&method=post
@ -18,7 +19,7 @@ import org.springframework.stereotype.Component;
@Component
@Slf4j
@CustomPath("roadTransportCertificate")
public class BRoadTransportCertificateHandle extends BaiduBaseHandle<BRoadTransportCertificateRequest, BRoadTransportCertificateResp> {
public class BRoadTransportCertificateHandle extends BaiduBaseHandle<BRoadTransportCertificateRequest, Map> {
@Override
public String getUri() {

View File

@ -71,6 +71,11 @@ public class BLicensePlateResp extends BBaseResp {
private String number;
@JsonProperty("probability")
private List<Double> probability;
@JsonProperty("cover_info")
private String coverInfo;
@JsonProperty("edit_tool")
private String editTool;
@JsonProperty("vertexes_location")
private List<VertexesLocationDTO> vertexesLocation;

View File

@ -25,6 +25,17 @@ import org.springframework.web.bind.annotation.RestController;
* 驾驶证识别能力可以识别驾驶证首页和副页关键字段内容包括档案编号姓名有效期时长性别发证日期驾驶证号驾驶证准驾车型有效期开始时间地址 9 个关键字段信息
*
*
*
*
* https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740325062124#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Fdriving_license&method=post
*
*
* 驾驶证识别
*
*
*
*
*
*/
@Slf4j
@RestController
@ -37,6 +48,10 @@ public class RecognizeDriverLicenseController extends BaseController {
private ARecognizeDriverLicenseHandle aRecognizeDriverLicenseHandle;
@RequestMapping("/recognize")
public R recognize(ARecognizeDriverLicenseRequest request) {

View File

@ -0,0 +1,87 @@
package com.heyu.api.controller.traffic;
import com.heyu.api.baidu.handle.traffic.BLicensePlateHandle;
import com.heyu.api.baidu.request.traffic.BLicensePlateRequest;
import com.heyu.api.baidu.response.traffic.BLicensePlateResp;
import com.heyu.api.controller.BaseController;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.traffic.LicensePlateResp;
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;
import java.util.ArrayList;
import java.util.List;
/**
* https://console.bce.baidu.com/support/?_=1740219852952&timestamp=1740325926517#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Flicense_plate&method=post
* <p>
* 车牌识别
*
*
* 接口描述
* 支持识别中国大陆机动车蓝牌黄牌单双行绿牌大型新能源黄绿领使馆车牌警牌武警牌单双行军牌单双行港澳出入境车牌
* 农用车牌民航车牌非机动车车牌北京地区的地域编号和车牌号并能同时识别图像中的多张车牌
*
*
*/
@Slf4j
@RestController
@RequestMapping("/license/plate")
@NotIntercept
public class LicensePlateController extends BaseController {
@Autowired
private BLicensePlateHandle bLicensePlateHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BLicensePlateRequest request) {
List<LicensePlateResp> respList = new ArrayList<>();
ApiR<BLicensePlateResp> bR = bLicensePlateHandle.handle(request);
if (bR.isSuccess()) {
BLicensePlateResp bLicensePlateResp = bR.getData();
List<BLicensePlateResp.WordsResultDTO> wordsResultDTOS = bLicensePlateResp.getWordsResult();
for (BLicensePlateResp.WordsResultDTO wordsResultDTO : wordsResultDTOS) {
LicensePlateResp licensePlateResp = new LicensePlateResp();
licensePlateResp.setColor(wordsResultDTO.getColor());
licensePlateResp.setProbability(wordsResultDTO.getProbability());
licensePlateResp.setCoverInfo(wordsResultDTO.getCoverInfo());
licensePlateResp.setNumber(wordsResultDTO.getNumber());
licensePlateResp.setEditTool(wordsResultDTO.getEditTool());
List<BLicensePlateResp.WordsResultDTO.VertexesLocationDTO> vertexesLocationDTOS = wordsResultDTO.getVertexesLocation();
if (CollectionUtils.isNotEmpty(vertexesLocationDTOS)) {
List<LicensePlateResp.VertexesLocationDTO> vertexesLocationDTOS1 = new ArrayList<>();
for (BLicensePlateResp.WordsResultDTO.VertexesLocationDTO vertexesLocationDTO : vertexesLocationDTOS) {
LicensePlateResp.VertexesLocationDTO locationDTO = new LicensePlateResp.VertexesLocationDTO();
locationDTO.setX(vertexesLocationDTO.getX());
locationDTO.setY(vertexesLocationDTO.getY());
vertexesLocationDTOS1.add(locationDTO);
}
licensePlateResp.setVertexesLocation(vertexesLocationDTOS1);
}
respList.add(licensePlateResp);
}
return R.ok().setData(respList);
}
return R.error(bR.getErrorMsg());
}
}

View File

@ -0,0 +1,76 @@
package com.heyu.api.controller.traffic;
import com.heyu.api.baidu.handle.traffic.BRoadTransportCertificateHandle;
import com.heyu.api.baidu.request.traffic.BRoadTransportCertificateRequest;
import com.heyu.api.controller.BaseController;
import com.heyu.api.data.annotation.CacheResult;
import com.heyu.api.data.annotation.NotIntercept;
import com.heyu.api.data.utils.ApiR;
import com.heyu.api.data.utils.MapUtils;
import com.heyu.api.data.utils.R;
import com.heyu.api.resp.traffic.RoadTransportCertificateResp;
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;
import java.util.Map;
/**
* https://console.bce.baidu.com/support/?_=1740411162437&timestamp=1740413029871#/api?product=AI&project=%E6%96%87%E5%AD%97%E8%AF%86%E5%88%AB&parent=%E4%BA%A4%E9%80%9A%E5%9C%BA%E6%99%AFOCR&api=rest%2F2.0%2Focr%2Fv1%2Froad_transport_certificate&method=post
* <p>
* <p>
* 道路运输证识别
*
*接口描述
* 结构化识别道路运输证的业户名称地址车辆号牌经营许可证经济类型车辆类型吨座位车辆规格经营范围初领日期备注发证日期道路运输证号等15个关键字段支持识别横版及竖版两种道路运输证
*
*/
@Slf4j
@RestController
@RequestMapping("/road/transport")
@NotIntercept
public class RoadTransportCertificateController extends BaseController {
@Autowired
private BRoadTransportCertificateHandle bRoadTransportCertificateHandle;
@RequestMapping("/recognize")
@CacheResult
public R recognize(BRoadTransportCertificateRequest request) {
RoadTransportCertificateResp resp = new RoadTransportCertificateResp();
ApiR<Map> bR = bRoadTransportCertificateHandle.handle(request);
if (bR.isSuccess()) {
Map<String, Object> data = bR.getData();
resp.setRoadTransportLicenseNumber(MapUtils.getByExpr(data, "words_result.道路运输证号.[0].word")); // 道路运输证号
resp.setVehicleLicensePlate(MapUtils.getByExpr(data, "words_result.车辆号牌.[0].word")); // 车辆号牌
resp.setEconomicType(MapUtils.getByExpr(data, "words_result.经济类型.[0].word")); //经济类型
resp.setBusinessScope(MapUtils.getByExpr(data, "words_result.经营范围.[0].word")); // 经营范围
resp.setVehicleType(MapUtils.getByExpr(data, "words_result.车辆类型.[0].word")); //车辆类型
resp.setTonsOfSeats(MapUtils.getByExpr(data, "words_result.吨座位.[0].word")); // 吨座位
resp.setRemark(MapUtils.getByExpr(data, "words_result.备注.[0].word"));//备注
resp.setBusinessLicense(MapUtils.getByExpr(data, "words_result.经营许可证.[0].word")); // 经营许可证
resp.setVehicleMMH(MapUtils.getByExpr(data, "words_result.车辆毫米_高.[0].word")); // 车辆毫米_高
resp.setVehicleMMWidth(MapUtils.getByExpr(data, "words_result.车辆毫米_宽.[0].word"));//车辆毫米_宽
resp.setCertificateIssuanceDate(MapUtils.getByExpr(data, "words_result.发证日期.[0].word")); // 发证日期
resp.setAddress(MapUtils.getByExpr(data, "words_result.地址.[0].word"));//地址
resp.setVehicleMMLength(MapUtils.getByExpr(data, "words_result.车辆毫米_长.[0].word"));// 车辆毫米_长
resp.setBusinessAccountName(MapUtils.getByExpr(data, "words_result.业户名称.[0].word")); // 业户名称
resp.setFirstDate(MapUtils.getByExpr(data, "words_result.初领日期.[0].word")); // 初领日期
return R.ok().setData(resp);
}
return R.error(bR.getErrorMsg());
}
}

View File

@ -0,0 +1,34 @@
package com.heyu.api.resp.traffic;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
import java.util.List;
@Data
public class LicensePlateResp extends BaseResp {
private String color; // 车牌颜色支持bluegreenyellowwhiteblackyellow_green新能源大型汽车黄绿车牌unknow未知颜色penyin大货车喷印车牌
private String number; // 车牌号码
private List<Double> probability; //7个数字分别为车牌中每个字符的置信度从左往右区间为0-1如需平均置信度将全部数值相加计算平均值即可
private List<VertexesLocationDTO> vertexesLocation;
/***
* 判断车牌有没有被遮挡 detect_complete=true 时生效
* - incomplete没有被遮挡
* - complete被遮挡
*/
private String coverInfo;
/***
* 判断车牌有没有被遮挡 detect_risk=true 时生效如果检测车牌被编辑过该字段指定编辑软件名称:Adobe Photoshop CC 2014 (Macintosh)如果没有被编辑过则返回值为空
*/
private String editTool;
@Data
public static class VertexesLocationDTO {
private Integer x; // 水平坐标坐标0点为左上角
private Integer y; //垂直坐标坐标0点为左上角
}
}

View File

@ -0,0 +1,31 @@
package com.heyu.api.resp.traffic;
import com.heyu.api.data.dto.BaseResp;
import lombok.Data;
@Data
public class RoadTransportCertificateResp extends BaseResp {
private String roadTransportLicenseNumber; // 道路运输证号
private String vehicleLicensePlate; // 车辆号牌
private String economicType; //经济类型
private String businessScope; // 经营范围
private String vehicleType; //车辆类型
private String tonsOfSeats; // 吨座位
private String remark;//备注
private String businessLicense; // 经营许可证
private String vehicleMMH; // 车辆毫米_高
private String vehicleMMWidth;//车辆毫米_宽
private String certificateIssuanceDate; // 发证日期
private String address;//地址
private String vehicleMMLength;// 车辆毫米_长
private String businessAccountName; // 业户名称
private String firstDate; // 初领日期
}