package com.goafanti.common.service;

import org.springframework.stereotype.Service;
import org.springframework.web.multipart.MultipartFile;

@Service
public class ImageService {

    private static final String DATA_PATH = "D:\\tessdata";
    private static final String LANGUAGE = "chi_sim";


    public Object ImageOCR(MultipartFile file) {
        String result = null;
//        try {
//            byte[] bytes = file.getBytes();
//            BufferedImage image = ImageIO.read(new ByteArrayInputStream(bytes));
//            ITesseract instance = new Tesseract();
//            instance.setDatapath(DATA_PATH);
//            instance.setLanguage(LANGUAGE);
//            result = instance.doOCR(image);
//            System.out.println(result);
//            result=result.replaceAll("\\r|\\n","-").replaceAll(" ","");
//            System.out.println(result);
//        } catch (IOException | TesseractException e) {
//            throw new RuntimeException(e);
//        }
        return result;
    }
}
