1. 程式人生 > >face++ 行駛證OCR識別

face++ 行駛證OCR識別

官方API地址為: https://console.faceplusplus.com.cn/documents/5671706
首先建立自己的賬號 生成api_key api_secret
請求引數

返回值說明
具體程式碼如下

public String ocrVehicleLicenseOrMergeFace(@RequestParam("imageUrl") String imageUrl,@RequestParam("group") String group,@RequestParam("type") Integer type) throws IOException {
		String image_url=FILE_INNER_URL+group+"/"+imageUrl;
		CloseableHttpClient httpClient = HttpClients.createDefault();
		HttpPost uploadFile = new HttpPost(LICENSE_URL);
		MultipartEntityBuilder builder = MultipartEntityBuilder.create();
		builder.addTextBody("api_key", API_KEY, ContentType.TEXT_PLAIN);
		builder.addTextBody("api_secret", API_SECRET, ContentType.TEXT_PLAIN);
		builder.addTextBody("image_url", image_url, ContentType.TEXT_PLAIN);
		// 把檔案加到HTTP的post請求中
		HttpEntity multipart = builder.build();
		uploadFile.setEntity(multipart);
		CloseableHttpResponse  response = httpClient.execute(uploadFile);
		HttpEntity responseEntity = response.getEntity();
		//轉換值
		String sResponse = EntityUtils.toString(responseEntity, "UTF-8");
		LicenseResult licenseResult = JSONObject.parseObject(sResponse, LicenseResult.class);
		return	JSONUtil.toJsonStringSUSSESS("查詢成功", licenseResult);
	}
	```