Android Question How to use the Tessract in my B4A project

Rosin

Member
Licensed User
it almost drive me crazy....i wish to find a reliable offline ocr to finish my app,in csdn,a java project shows the way it uses the Tesseract(an open source project)to implement the offline ocr...since the B4A is based on java...i wonder if i can use the way too..
in his code
the tess4j is a Java JNA Encapsulates object which contains the Tesseract ocr
<!-- Tess4Jdepend -->
<dependency>
<groupId>net.sourceforge.tess4j</groupId>
<artifactId>tess4j</artifactId>
<version>5.4.0</version>
</dependency>
1683386292166.png

// do OCR
private void execute(BufferedImage targetImage) {
try {
File tempFile = new File(tempImage);
if (tempFile == null) {
tempFile.mkdirs();
}
tempFile.mkdirs();
ImageIO.write(targetImage, "jpg", tempFile);
} catch (IOException e) {
e.printStackTrace();
}
File file = new File(tempImage);

ITesseract instance = new Tesseract();
// set the position of the language data
instance.setDatapath("src/main/resources/data");
// set language
instance.setLanguage(language);
Thread thread = new Thread() {
public void run() {
String result = null;
try {
result = instance.doOCR(file);
} catch (Exception e) {
e.printStackTrace();
}
resultArea.setText(result);
}
};
ProgressBar.show(this, thread, "please wait....the ocr is ready", "finish", "cancel");
}
i would be pay for it if any i can help me to do this....
 

Star-Dust

Expert
Licensed User
Longtime User
 
Upvote 0

Rosin

Member
Licensed User
thank you,Star-Dust....but it seems that the Tesseract4android 2.1.0 can not be downloaded in its websites....it may be too...old?i open the website and try to download the file,and it shows the page of 403,where can i find a link to download the arr file?????
 
Upvote 0

Rosin

Member
Licensed User
thank you,star-dust,I get the file from our BBS.....but it seems that the initial of the ocr doesn't work good....first the traning data is lost ,so i download it from https://github.com/tesseract-ocr/tessdata and replace the empty file,but in the application...it debugs like this...how should i do next..
i guess it might be the problem of Google service...because it was banned in our area...how can i do to solve this problem....i will pay it for you....thank you.
1683452965217.png
 
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
thank you,star-dust,I get the file from our BBS.....but it seems that the initial of the ocr doesn't work good....first the traning data is lost ,so i download it from https://github.com/tesseract-ocr/tessdata and replace the empty file,but in the application...it debugs like this...how should i do next..
i guess it might be the problem of Google service...because it was banned in our area...how can i do to solve this problem....i will pay it for you....thank you.
View attachment 141829
TesserACT does not use external services, it works offline. I use it in my App.

Unfortunately I can't help you right now. I'll check in the next few days.
In the meantime, check that there are some necessary files missing
 
Upvote 0

Rosin

Member
Licensed User
TesserACT does not use external services, it works offline. I use it in my App.

Unfortunately I can't help you right now. I'll check in the next few days.
In the meantime, check that there are some necessary files missing
Thank you
 
Upvote 0
Top