|
@@ -1,5 +1,6 @@
|
|
|
package com.ruixuan.isc.controller;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.ruixuan.common.core.controller.BaseController;
|
|
|
import com.ruixuan.common.core.domain.AjaxResult;
|
|
|
import com.ruixuan.common.core.page.TableDataInfo;
|
|
@@ -109,23 +110,18 @@ public class KuaishouPromoterController extends BaseController {
|
|
|
*/
|
|
|
@PostMapping(value = "/readImage")
|
|
|
@ApiOperation(value = "读取图片文字信息")
|
|
|
- public String readImage(@RequestParam("file") MultipartFile file) {
|
|
|
+ public JSONObject readImage(@RequestParam("file") MultipartFile file) {
|
|
|
+ JSONObject result = new JSONObject();
|
|
|
try {
|
|
|
- Tess4jClient t = new Tess4jClient();
|
|
|
-// ITesseract tesseract = new Tesseract();
|
|
|
-// File savefile = new File("C:\\Users\\Administrator\\Desktop\\test005.png");
|
|
|
-// //设置中文字体库路径
|
|
|
-// tesseract.setDatapath("D:\\download\\tessdata");
|
|
|
-// //中文识别
|
|
|
-// tesseract.setLanguage("chi_sim");
|
|
|
-// //执行ocr识别
|
|
|
-// String result = tesseract.doOCR(savefile);
|
|
|
- String result = t.getWords(file);
|
|
|
- System.out.println(result);
|
|
|
+ result.put("code", 0);
|
|
|
+ result.put("message", "success");
|
|
|
+ result.put("data", Tess4jClient.getWords(file));
|
|
|
return result;
|
|
|
} catch (Exception e) {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
- return "";
|
|
|
+ result.put("code", -1);
|
|
|
+ result.put("message", "fail");
|
|
|
+ return result;
|
|
|
}
|
|
|
}
|