diff --git a/navigate-8432/pom.xml b/navigate-8432/pom.xml index e3aa5f4..12f507a 100644 --- a/navigate-8432/pom.xml +++ b/navigate-8432/pom.xml @@ -109,5 +109,31 @@ tencentcloud-sdk-java-asr 3.1.1083 + + + ai.djl + api + 0.29.0 + + + + ai.djl.pytorch + pytorch-model-zoo + 0.29.0 + + + + ai.djl.pytorch + pytorch-engine + 0.29.0 + + + + ai.djl.pytorch + pytorch-native-auto + 1.9.1 + runtime + + \ No newline at end of file diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/NavigateController.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/NavigateController.java index 924e7e5..8be9c4b 100644 --- a/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/NavigateController.java +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/controller/NavigateController.java @@ -57,10 +57,29 @@ public class NavigateController { } @PostMapping("/ticket") - public Object scanTicket(@RequestPart MultipartFile file) throws IOException { + public Object scanTicket(@RequestPart MultipartFile file, @RequestParam String location) throws IOException { BufferedImage image = ImageIO.read(file.getInputStream()); Map map = navigateService.scanTicket(image); - return Result.ok(map); + Map result = new HashMap<>(); + if (map.containsKey("登机口")) { + String address = navigateService.deGeoCode(location); + address += map.get("登机口"); + address += "登机口"; + result.put("地址", address); + } else if (map.containsKey("检票口")) { + if (map.containsKey("左边车站")) { + String address = (String) map.get("左边车站"); + address += map.get("检票口"); + address += "检票口"; + result.put("地址", address); + } else { + String address = navigateService.deGeoCode(location); + address += map.get("检票口"); + address += "检票口"; + result.put("地址", address); + } + } + return Result.ok(result); } @GetMapping("/geocode") diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java index c942e1f..57cad45 100644 --- a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/NavigateService.java @@ -64,7 +64,7 @@ public class NavigateService { OcrClient client = new OcrClient(cred, "ap-shanghai", clientProfile); SmartStructuralOCRV2Request req = new SmartStructuralOCRV2Request(); req.setImageBase64(base64Img); - String[] itemNames1 = {"登机口", "检票口"}; + String[] itemNames1 = {"登机口", "检票口", "左边车站", "右边车站"}; req.setItemNames(itemNames1); resp = client.SmartStructuralOCRV2(req); } catch (TencentCloudSDKException e) { @@ -106,4 +106,23 @@ public class NavigateService { JSONObject location = array.getJSONObject(0); return location.getString("location"); } + + public String deGeoCode(String fomattedLoc) { + Map params = new HashMap<>(); + params.put("key", key); + params.put("location", fomattedLoc); + params.put("poitype", "飞机场|火车站|地铁站"); + HttpResponse response = HttpRequest.get("https://restapi.amap.com/v3/geocode/regeo") + .form(params) + .execute(); + String result = response.body(); + response.close(); + JSONObject resultObj = JSONObject.parseObject(result); + if (resultObj.getInteger("status")==0) { + return null; + } + JSONObject reGeoCode = resultObj.getJSONObject("regeocode"); + String address = reGeoCode.getString("formatted_address"); + return address; + } } diff --git a/navigate-8432/src/main/java/com/ivmiku/tutorial/service/RecogintionService.java b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/RecogintionService.java new file mode 100644 index 0000000..b4296ec --- /dev/null +++ b/navigate-8432/src/main/java/com/ivmiku/tutorial/service/RecogintionService.java @@ -0,0 +1,10 @@ +package com.ivmiku.tutorial.service; + +import org.springframework.stereotype.Service; + +@Service +public class RecogintionService { + static { + + } +}