I want initialize "chi_sim.traineddata" via TessBaseAPI.init() method锛宐ut my program only permit to initialize from InputStream,
//The way only load file via filename
if (tessBaseAPI.Init("/user/share/tessdata", "chi_sim") != 0) {
log.error("Could not initialize tesseract.");
throw new IOException();
}
how to initialize from inputStream? please
I don't think Tesseract supports that any other way than by creating a temporary file.
@saudet thank you , if Tesseract don't support use inputstream to initialize tessdata, the following coe will help others when tessdata from inputstream.
InputStream inputStream = resource.getInputStream();
File somethingFile = File.createTempFile("chi_sim", ".traineddata");
FileUtils.copyInputStreamToFile(inputStream, somethingFile);
if (tessBaseAPI.Init(somethingFile.getParent(),
FilenameUtils.getBaseName(somethingFile.getName())) != 0) {
log.error("Could not initialize tesseract.");
throw new IOException();
}
Most helpful comment
@saudet thank you , if Tesseract don't support use inputstream to initialize tessdata, the following coe will help others when tessdata from inputstream.