I am trying to evalute ABBYY but every time I get this exception

Exception in thread "main" java.lang.Exception: Error: Invalid task state
at com.abbyy.ocrsdk.Client.getResponse(Client.java:297)
at com.abbyy.ocrsdk.Client.processDocument(Client.java:62)
at TestApp.main(TestApp.java:43)

I have modified only a couple of lines in TestApp.java

restClient = new Client();
// replace with 'https://cloud.ocrsdk.com' to enable secure connection
restClient.serverUrl = "http://cloud.ocrsdk.com";
restClient.applicationId = ClientSettings.APPLICATION_ID;
restClient.password = ClientSettings.PASSWORD;

/* ******************************************Modifications **************************/
File filePath = new File("C:\\Users\\nali\\Desktop\\Tiff Image\\New Image.JPG");
restClient.submitImage(filePath.getAbsolutePath(), null);

ProcessingSettings settings = new ProcessingSettings();
settings.setOutputFormat(OutputFormat.txt);
Task task = restClient.processImage(filePath.getAbsolutePath(), settings);
Task task1 = null;
do{
 task1 = restClient.processDocument(task.Id, settings);
}
while(!task1.Status.equals("Completed"));

System.out.print("What should do with the task");

Vector<String> argList = new Vector<String>(Arrays.asList(args));"

asked 10 Feb '13, 23:20

naz's gravatar image

naz
112

edited 11 Feb '13, 11:07

Dmitry%20Me's gravatar image

Dmitry Me ♦♦
2387


There're several problems in your code.

First, this loop

do{
 task1 = restClient.processDocument(task.Id, settings);

} while(!task1.Status.equals("Completed"));

has no delay in the body. This loop will slam into our service several times per second. Our Developer Agreement contains a clause against abuse. No delay -> abuse clause -> you're banned.

Second, the code makes absolutely no sense. Yes, I mean exactly that. This loop

do{
 task1 = restClient.processDocument(task.Id, settings);
}

asks our service to reprocess the same task over and over again and your code never cares of the processing result. That makes no sense.

The Java sample we ship illustrates all the main concepts of using our service.

link

answered 11 Feb '13, 11:18

Dmitry%20Me's gravatar image

Dmitry Me ♦♦
2387

Dear Dmitry.

thanks for the reply. The supplied Java code does not illustrates how to Process a sample or any Image. Even the API documentation present on ABBYY's website is not enough. There is not any running simple application. That can show a simple thing: This is the sample image and this is the output. This is your custom image and this is the output.

The reason I have used do while loop in the code, I was trying to figure out the problem. What I understand is :

1) Submit an image to the ABBY's server. File filePath = new File("C:\Users\nali\Desktop\Tiff Image\testImage.PNG"); restClient.submitImage(filePath.getAbsolutePath(), null);

2) The Abbyy's server will make a task for this image, process the image and return the result. ProcessingSettings settings = new ProcessingSettings(); settings.setOutputFormat(OutputFormat.txt); Task task = restClient.processImage(filePath.getAbsolutePath(), settings);

but I am not receiving any result. The task status is "Processing" for three times "responseCode == 200" and on third turn it returns "Respond Code 450", and the message is "Invalid task state".

Could you please provide a simple sample code or any proper documentation(I have already view API documentation) ?

link

answered 12 Feb '13, 01:23

naz's gravatar image

naz
112

This is the most concise thing for what you want I could have expected https://github.com/abbyysdk/ocrsdk.com/blob/55a662b0ee2ae1e13b3358b085d1fd4344ca8817/Java/Abbyy.Ocrsdk.client/src/TestApp.java#L150 The bottom line is you don't call processImage in a loop because it makes no sense.

(12 Feb '13, 11:19) Dmitry Me ♦♦

Dear Dmitry. One question please. Is ".tif" format supported by cloud ocr. I am getting "Unsupported Image file formate exception message"

(12 Feb '13, 21:04) naz
(13 Feb '13, 11:07) Dmitry Me ♦♦
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×28
×7

Asked: 10 Feb '13, 23:20

Seen: 2,467 times

Last updated: 13 Feb '13, 11:07

© 2016 ABBYY. All rights Reserved. www.ABBYY.com | Privacy Policy | Legal