Thanks for reply, but I tested the code and still doesn't working. Sorry if it's a stupid question, I'm a beginner and trying to understand it. I have to set a diferent class for API? I'm using 'api = TessAPI.INSTANCE;'
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, i've tried this week make what you said, but i hadn't sucess. I made the code of TessAPITest but it doesn't stopped, and I tried to use the 'end_time' variable, and it doesn't make sense to me. I read the doc and it says "time to stop if not 0", but it ever stop at same time and with blank out put.
My code:
Tesseract.java
ETEXT_DESC monitor = new ETEXT_DESC();
ITessAPI.TimeVal timeout = new ITessAPI.TimeVal();
timeout.tv_sec = new NativeLong(0L);
monitor.end_time = timeout;
ProgressMonitor pmo = new ProgressMonitor(monitor);
pmo.start();
api.TessBaseAPIRecognize(handle, monitor);
It looks almost correct. I would make a small correction:
if (((System.currentTimeMillis() - startTime) / 1000) >= 10 ) {
Nevertheless, it does not work anyway when I test now. If I remember correctly, it worked at one time when I first coded the cancellation. Things could have changed since inside Tesseract's native code.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Tess4J operates on individual images. If you perform OCR on multiple images, as in multi-page TIFF, you can use SwingWorker to control, and cancel, the OCR process, which would still complete on the current image but not subsequent ones.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
How can i stop the Tess4j process or set a time out?
See https://github.com/nguyenq/tess4j/issues/29
Last edit: Quan Nguyen 2018-04-27
Thanks for reply, but I tested the code and still doesn't working. Sorry if it's a stupid question, I'm a beginner and trying to understand it. I have to set a diferent class for API? I'm using 'api = TessAPI.INSTANCE;'
Not really. There is an example in the unit tests -- you may want to take a look.
Hi, i've tried this week make what you said, but i hadn't sucess. I made the code of TessAPITest but it doesn't stopped, and I tried to use the 'end_time' variable, and it doesn't make sense to me. I read the doc and it says "time to stop if not 0", but it ever stop at same time and with blank out put.
My code:
Tesseract.java
ProgressMonitor.java
Last edit: Alex Lopes 2018-05-11
It looks almost correct. I would make a small correction:
if (((System.currentTimeMillis() - startTime) / 1000) >= 10 ) {
Nevertheless, it does not work anyway when I test now. If I remember correctly, it worked at one time when I first coded the cancellation. Things could have changed since inside Tesseract's native code.
Do you have any sugestion or another way to stop the tesseract process?
Tess4J operates on individual images. If you perform OCR on multiple images, as in multi-page TIFF, you can use
SwingWorker
to control, and cancel, the OCR process, which would still complete on the current image but not subsequent ones.If I send a pdf file with a sigle page, would it work?
No, it would still finish that page. If the PDF has multiple pages, then yes.