【发布时间】:2019-11-01 11:09:50
【问题描述】:
您好如何在mongodb中存储字节图像并执行doocr进程(通过public static void main)。是否可以通过对来自 mongodb 的存储图像执行 doocr
型号:
public class Photo {
@Id
private String id;
private byte[] image; } getter & setter
控制器:
@Controller
public class PhotoController {
@GetMapping("/photos/upload")
public String uploadPhoto(Model model) {
model.addAttribute("message", "hello");
return "uploadPhoto";
}
在存储图像之后添加了 mongodb 图像路径。 ?这样做是正确的方法
主要:
public static void main(String[] args)
{
SpringApplication.run(StackoverflowApplication.class, args);
/// mongodb data path is it right ? for doocr
File image = new File("mongodb://localhost:27017//test-db//user");
// encode nd decode sample
String encodedString =Base64.getEncoder().encodeToString(originalInput.
getBytes());
byte[] decodedBytes = Base64.getDecoder().decode(encodedString);
String decodedString = new String(decodedBytes);
Tesseract tessInst = new Tesseract();
tessInst.setDatapath("C:\\Users\\Administrator\\Desktop\\tessdata");
try {
String result= tessInst.doOCR(image);
System.out.println(result);
} catch (TesseractException e) {
System.err.println(e.getMessage());
} }
是否可能或需要任何其他 base64。
【问题讨论】:
-
您是否在 mongoDB 中查找过 GridF。如果您想将文件存储在 mongoDB 中,那就太棒了
-
实际上我不希望在我的控制器中执行 doocr [图像到文本] 过程并将图像、文本存储在 mongodb 中。这种图像类型是否可行,因为 byte [] 类型只执行这些任务。
标签: mongodb rest spring-mvc ocr tesseract