public class Test {
public static void main(String[] args) {
try {
File imageFile = new File("Sample1_3.png");
ITesseract instance = new Tesseract(); // JNA Interface Mapping
System.out.print(imageFile.canRead());
instance.setDatapath("tessdata");
instance.setTessVariable("user_defined_dpi", "300");
instance.setLanguage("eng");
//instance.setDatapath(tessDataFolder.getPath());;
String text = instance.doOCR(imageFile);
// path of your image file
} catch (TesseractException e) {
e.printStackTrace();
}
}
}
As I mentioned earlier, you need to get the orientation information by using psm 0. You will get the orientation angle from there, and then use that to rotate the image to 0 degree.
Regards
Lakshay