From e1c86fe309e281cbc68753ded745f97d5881f86e Mon Sep 17 00:00:00 2001 From: quyixiao <2621048238@qq.com> Date: Thu, 27 Mar 2025 23:59:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BRoadTransportCertificateHandle.java | 7 +- .../response/traffic/BLicensePlateResp.java | 5 ++ .../car/RecognizeDriverLicenseController.java | 15 ++++ .../traffic/LicensePlateController.java | 87 +++++++++++++++++++ .../RoadTransportCertificateController.java | 76 ++++++++++++++++ .../api/resp/traffic/LicensePlateResp.java | 34 ++++++++ .../traffic/RoadTransportCertificateResp.java | 31 +++++++ 7 files changed, 252 insertions(+), 3 deletions(-) create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/LicensePlateController.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/RoadTransportCertificateController.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/LicensePlateResp.java create mode 100644 api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/RoadTransportCertificateResp.java diff --git a/api-third/src/main/java/com/heyu/api/baidu/handle/traffic/BRoadTransportCertificateHandle.java b/api-third/src/main/java/com/heyu/api/baidu/handle/traffic/BRoadTransportCertificateHandle.java index 0937bf7..5881283 100644 --- a/api-third/src/main/java/com/heyu/api/baidu/handle/traffic/BRoadTransportCertificateHandle.java +++ b/api-third/src/main/java/com/heyu/api/baidu/handle/traffic/BRoadTransportCertificateHandle.java @@ -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×tamp=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 { +public class BRoadTransportCertificateHandle extends BaiduBaseHandle { @Override public String getUri() { diff --git a/api-third/src/main/java/com/heyu/api/baidu/response/traffic/BLicensePlateResp.java b/api-third/src/main/java/com/heyu/api/baidu/response/traffic/BLicensePlateResp.java index d552180..076bcba 100644 --- a/api-third/src/main/java/com/heyu/api/baidu/response/traffic/BLicensePlateResp.java +++ b/api-third/src/main/java/com/heyu/api/baidu/response/traffic/BLicensePlateResp.java @@ -71,6 +71,11 @@ public class BLicensePlateResp extends BBaseResp { private String number; @JsonProperty("probability") private List probability; + @JsonProperty("cover_info") + private String coverInfo; + @JsonProperty("edit_tool") + private String editTool; + @JsonProperty("vertexes_location") private List vertexesLocation; diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/car/RecognizeDriverLicenseController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/car/RecognizeDriverLicenseController.java index 03264d9..5062b59 100644 --- a/api-web/api-interface/src/main/java/com/heyu/api/controller/car/RecognizeDriverLicenseController.java +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/car/RecognizeDriverLicenseController.java @@ -25,6 +25,17 @@ import org.springframework.web.bind.annotation.RestController; * 驾驶证识别能力可以识别驾驶证首页和副页关键字段内容,包括:档案编号、姓名、有效期时长、性别、发证日期、驾驶证号、驾驶证准驾车型、有效期开始时间、地址,共 9 个关键字段信息。 * * + * + * + * https://console.bce.baidu.com/support/?_=1740219852952×tamp=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) { diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/LicensePlateController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/LicensePlateController.java new file mode 100644 index 0000000..b54076b --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/LicensePlateController.java @@ -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×tamp=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 + *

+ * 车牌识别 + * + * + * 接口描述 + * 支持识别中国大陆机动车蓝牌、黄牌(单双行)、绿牌、大型新能源(黄绿)、领使馆车牌、警牌、武警牌(单双行)、军牌(单双行)、港澳出入境车牌、 + * 农用车牌、民航车牌、非机动车车牌(北京地区)的地域编号和车牌号,并能同时识别图像中的多张车牌。 + * + * + */ +@Slf4j +@RestController +@RequestMapping("/license/plate") +@NotIntercept +public class LicensePlateController extends BaseController { + + + @Autowired + private BLicensePlateHandle bLicensePlateHandle; + + + @RequestMapping("/recognize") + @CacheResult + public R recognize(BLicensePlateRequest request) { + + List respList = new ArrayList<>(); + + + ApiR bR = bLicensePlateHandle.handle(request); + if (bR.isSuccess()) { + BLicensePlateResp bLicensePlateResp = bR.getData(); + List 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 vertexesLocationDTOS = wordsResultDTO.getVertexesLocation(); + if (CollectionUtils.isNotEmpty(vertexesLocationDTOS)) { + List 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()); + } +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/RoadTransportCertificateController.java b/api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/RoadTransportCertificateController.java new file mode 100644 index 0000000..0c042f2 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/controller/traffic/RoadTransportCertificateController.java @@ -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×tamp=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 + *

+ *

+ * 道路运输证识别 + * + *接口描述 + * 结构化识别道路运输证的业户名称、地址、车辆号牌、经营许可证、经济类型、车辆类型、吨座位、车辆规格、经营范围、初领日期、备注、发证日期、道路运输证号等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 bR = bRoadTransportCertificateHandle.handle(request); + + if (bR.isSuccess()) { + Map 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()); + } + + +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/LicensePlateResp.java b/api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/LicensePlateResp.java new file mode 100644 index 0000000..d26a65b --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/LicensePlateResp.java @@ -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; // 车牌颜色:支持blue、green、yellow、white、black、yellow_green(新能源大型汽车黄绿车牌)、unknow(未知颜色)、penyin(大货车喷印车牌) + private String number; // 车牌号码 + private List probability; //7个数字分别为车牌中每个字符的置信度(从左往右),区间为0-1,如需平均置信度,将全部数值相加,计算平均值即可 + private List 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点为左上角) + } + +} diff --git a/api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/RoadTransportCertificateResp.java b/api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/RoadTransportCertificateResp.java new file mode 100644 index 0000000..9759d30 --- /dev/null +++ b/api-web/api-interface/src/main/java/com/heyu/api/resp/traffic/RoadTransportCertificateResp.java @@ -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; // 初领日期 + + + + + + +}