Dòng Thời Gian Của Khối Tesseract Là Gì ? Nhận Diện Văn Bản Bằng Tesseract

[ad_1]

Sử dụng Tesseract tạo server OCR với Spring boot

1. Tesseract là gì?

Sử dụng Tesseract tạo server OCR với Spring bootTesseract là một OCR ( Optical Character Recognition ) engine số 1 lúc bấy giờ. Công cụ này được phân phối với bản quyền mã nguồn mở Apache 2.0. Nó tương hỗ nhận diện kí tự trên những tập tin hình ảnh và xuất ra dưới dạng kí tự thuần, html, pdf, tsv, invisible-text-only pdf. Người dùng hoàn toàn có thể sử dụng trực tiếp hoặc lập trình viên hoàn toàn có thể sử dụng những tính năng trải qua API .

Bạn đang xem: Tesseract là gì

Bạn đang đọc: Dòng Thời Gian Của Khối Tesseract Là Gì ? Nhận Diện Văn Bản Bằng Tesseract

Tesseract được tăng trưởng bởi Hewlett-Packard Laboratories Bristol tại Hewleett-Packard Co, Greeley Colorado từ 1985 đến 1994. Sau đó, nó được update 1 số ít biến hóa nhỏ và tạm ngưng tăng trưởng từ sau 1998. Đến năm 2005, Tesseract được phân bổ dưới dạng mã nguồn mở bởi HP và được tăng trưởng bởi Google từ năm 2006 .Xem thêm : 15 Đoạn Văn Kể Về Một Chuyến Đi Du Lịch Bằng Tiếng Anh Hay NhấtHiện tại, Tesseract đã tăng trưởng đến version 3.0 x và hoàn toàn có thể hoạt động giải trí trên 3 hệ điều hành quản lý phổ cập là Window, Mac và Linux. Công cụ này tương hỗ nhận diện kí tự của hơn 100 ngôn từ khác nhau, gồm có cả tiếng Việt. Không những thế, tất cả chúng ta hoàn toàn có thể giảng dạy chương trình dùng Tesseract để hoàn toàn có thể nhận diện một ngôn từ nào đó .

2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)

a> Maven Dependency

net.sourceforge.tess4j tess4j 3.2.1b> Tải dữ liệu tessdata từ Github

https://github.com/tesseract-ocr/tessdata

c> Cài đặt Tesseract cho Linux bằng câu lệnh:

sudo apt-get install tesseract-ocr*Kiểm tra versiontesseract – v*

3. Tạo project

Bước 1: tạo project Spring Boot cơ bản

Xem thêm: Công nghệ đèn UVC là gì – Ánh sáng tia cực tím diệt vi khuẩn ? – DaiThuCompany – 0904723825

Bước 2: Đổi tên thư mục dữ liệu tessdata-master mà bạn download từ git về thành tessdata và copy vào trong project

Bước 3: Thêm Dependency vào trong project

net.sourceforge.tess4j tess4j 3.2.1Cấu trúc project

Class DemoOrcServerApplication

import net.sourceforge.tess4j.Tesseract;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;import org.springframework.context.annotation.Bean;
SpringBootApplicationpublic class DemoOrcServerApplication { public static void main(String args) { SpringApplication.run(DemoOrcServerApplication.class, args); }
Bean Tesseract getTesseract(){ Tesseract tesseract = new Tesseract(); tesseract.setDatapath(“./tessdata”); return tesseract; } }Class OcrController

import com.example.demoorcserver.dto.OcrResult;import com.example.demoorcserver.services.OcrService;import net.sourceforge.tess4j.TesseractException;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.http.ResponseEntity;import org.springframework.web.bind.annotation.PostMapping;import org.springframework.web.bind.annotation.RequestMapping;import org.springframework.web.bind.annotation.RequestParam;import org.springframework.web.bind.annotation.RestController;import org.springframework.web.multipart.MultipartFile; import java.io.IOException;
RestController
RequestMapping(“/ocr”)public class OcrController {
Autowired private OcrService ocrService;
PostMapping(“/upload”) public ResponseEntity upload(
RequestParam(“file”) MultipartFile file) throws IOException, TesseractException { return ResponseEntity.ok(ocrService.ocr(file)); }}Class OcrResult

import lombok.Data;
Datapublic class OcrResult { private String result;}Class OcrService

import com.example.demoorcserver.dto.OcrResult;import net.sourceforge.tess4j.Tesseract;import net.sourceforge.tess4j.TesseractException;import org.springframework.beans.factory.annotation.Autowired;import org.springframework.stereotype.Service;import org.springframework.web.multipart.MultipartFile; import java.io.File;import java.io.FileOutputStream;import java.io.IOException;
Servicepublic class OcrService {
Autowired private Tesseract tesseract; public OcrResult ocr(MultipartFile file) throws IOException, TesseractException { File convFile = convert(file); String text = tesseract.doOCR(convFile); OcrResult ocrResult = new OcrResult(); ocrResult.setResult(text); return ocrResult; } public static File convert(MultipartFile file) throws IOException { File convFile = new File(file.getOriginalFilename()); convFile.createNewFile(); FileOutputStream fos = new FileOutputStream(convFile); fos.write(file.getBytes()); fos.close(); return convFile; }}

4. Kiểm tra kết quả

Input của chúng ta là tấm ảnhInput của tất cả chúng ta là tấm ảnh*Dùng postman để kiểm tra :

Xem thêm: Nước tiểu – Wikipedia tiếng Việt

*Như vậy chương trình của tất cả chúng ta đã hoạt động giải trí tốt .

Bài hướng dẫn của mình đến đây là kết thúc. Cám ơn các bạn đã xem!

ocr Java Spring boot Tesseract
ocr Java Spring boot TesseractĐã ĐK Bản quyền

[ad_2]

Related Posts

Trò chơi Randy chiến đấu

[ad_1] Contents1. Tesseract là gì?2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)3. Tạo project4. Kiểm tra kết quảBài hướng dẫn của mình đến…

Trò chơi Ben 10 giải cứu thế giới 2

[ad_1]  Contents1. Tesseract là gì?2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)3. Tạo project4. Kiểm tra kết quảBài hướng dẫn của mình…

Trò chơi sút Penalty Y8

[ad_1] Contents1. Tesseract là gì?2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)3. Tạo project4. Kiểm tra kết quảBài hướng dẫn của mình đến…

Game nối hình: Trò chơi nối hình

[ad_1]  Contents1. Tesseract là gì?2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)3. Tạo project4. Kiểm tra kết quảBài hướng dẫn của mình…

Trò chơi cấp cứu tai nạn

[ad_1]  Contents1. Tesseract là gì?2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)3. Tạo project4. Kiểm tra kết quảBài hướng dẫn của mình…

Game cừu chiến: Trò chơi cừu chiến

[ad_1]  Contents1. Tesseract là gì?2. Cài đặt và chuẩn bị cho project (trên môi trường Linux)3. Tạo project4. Kiểm tra kết quảBài hướng dẫn của mình…

Leave a Reply