I'm using the processBarcodeField method, and the getTaskStatus returns the following:

error="Region is outside image boundaries. {X=140,Y=2060,Width=350,Height=345}"

I'm not specifying a region but asking the system to read the entire page and find the one QR code. It seems like it is working as the output XML after it fails includes the correct data.

I've tried specifying a region and the results are the same.

asked 28 Jan '13, 06:35

GaryW's gravatar image

GaryW
114

What parameters (query string) do you use exactly?

(28 Jan '13, 10:48) Dmitry Me ♦♦

Are you aware that you can just edit your original question instead of posting 100500 "answers"?

(29 Jan '13, 19:04) Dmitry Me ♦♦

I've taken the PHP sample code and modified as below:

// Get path to file that we are going to recognize $local_directory=dirname(FILE).''; $filePath = $local_directory.'/'.$fileName; if(!file_exists($filePath)) { die('File '.$filePath.' not found.'); }

// set URL to use processBarcodeField

$url = 'http://cloud.ocrsdk.com/processBarcodeField';

// Send HTTP POST request and ret xml response $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $url); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandle, CURLOPT_USERPWD, "$applicationId:$password"); curl_setopt($curlHandle, CURLOPT_POST, 1); $post_array = array( "my_file"=>"@".$filePath, ); curl_setopt($curlHandle, CURLOPT_POSTFIELDS, $post_array); $response = curl_exec($curlHandle); if($response == FALSE) { $errorText = curl_error($curlHandle); curl_close($curlHandle); die($errorText); } curl_close($curlHandle);

// Parse xml response $xml = simplexml_load_string($response); $arr = $xml->task[0]->attributes();

// Task id $taskid = $arr["id"];

$handle = fopen("output.txt", "w"); fwrite($handle, $response); fclose($handle);

$url = 'http://cloud.ocrsdk.com/getTaskStatus'; $qry_str = "?taskid=$taskid";

// Check task status in a loop until it is finished // TODO: support states indicating error do { sleep(5); $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $url.$qry_str); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandle, CURLOPT_USERPWD, "$applicationId:$password"); $response = curl_exec($curlHandle); curl_close($curlHandle);

// parse xml
$xml = simplexml_load_string($response);
$arr = $xml->task[0]->attributes();

// if the document can't be processed display the error and quit
if ($arr["status"] = "ProcessingFailed") {
    echo "Processing Failed".$arr["error"];

    $handle = fopen("log.xml", "w");
fwrite($handle, $response);
fclose($handle);
    break;
}

} while($arr["status"] != "Completed");

// Result is ready. Download it

$url = $arr["resultUrl"]; $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $url); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); // Warning! This is for easier out-of-the box usage of the sample only. // The URL to the result has https:// prefix, so SSL is required to // download from it. For whatever reason PHP runtime fails to perform // a request unless SSL certificate verification is off. curl_setopt($curlHandle, CURLOPT_SSL_VERIFYPEER, false); $response = curl_exec($curlHandle); curl_close($curlHandle);

link

answered 29 Jan '13, 05:38

GaryW's gravatar image

GaryW
114

We see an error message you provided in the question in our internal logs, but the task for which it is logged was started using processFields, not processBarcodeField.

(29 Jan '13, 14:42) Dmitry Me ♦♦

Here it is: if ($arr["status"] = "ProcessingFailed") {. Should be == instead of =.

(29 Jan '13, 19:06) Dmitry Me ♦♦

Duh. Thanks Dmitry.

(31 Jan '13, 15:12) GaryW

Ok, I reviewed my code and also put in a statement to capture the URL in the log files.

I was definitely passing the correct URL. So I assumed maybe my AppID was somehow caching my old code because my previous code did use processFields, and I just modified it to use processBarcode with the same AppID. So I created a new AppID and prepaid for 100 pages. I was still getting the same error, so maybe something was still cached somehow.

After a few tries, it suddenly started working.

My code is still echo-ing the Processing Failed message for some reason, even though the status in the log file shows Completed. So I'm working on debugging that now.

link

answered 29 Jan '13, 16:03

GaryW's gravatar image

GaryW
114

ok, I'm confused. Perhaps you can help. I modified the loop to understand why I get the processing failed message. Here is my code: // Check task status in a loop until it is finished // TODO: support states indicating error

$loghandle = fopen("log.txt", "w"); fwrite($loghandle, "first time through"); fwrite($loghandle, $response."

"); do { sleep(5); $curlHandle = curl_init(); curl_setopt($curlHandle, CURLOPT_URL, $url.$qry_str); curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, 1); curl_setopt($curlHandle, CURLOPT_USERPWD, "$applicationId:$password"); $response = curl_exec($curlHandle); curl_close($curlHandle);

// parse xml
$xml = simplexml_load_string($response);
$arr = $xml->task[0]->attributes();

    fwrite($loghandle, "looping until completed");
fwrite($loghandle, $response."<br><br>");

// if the document can't be processed display the error and quit
if ($arr["status"] = "ProcessingFailed") {
    echo "Processing Failed Status: ".$arr["status"]."<br> Error: ".$arr["error"];

    fwrite($loghandle, "processing failed, now break");
fwrite($loghandle, $response."<br><br>");

    break;
}

} while($arr["status"] != "Completed"); fwrite($loghandle, "now completed"); fwrite($loghandle, $response); fclose($loghandle);

Here is the log file (I've replaced <> with .. so it will display)

first time through.?xml version="1.0" encoding="utf-8"?..response..task id="b5759d36-blah-fdc3236655c3" registrationTime="2013-01-29T12:22:19Z" statusChangeTime="2013-01-29T12:22:19Z" status="Queued" filesCount="1" credits="0" estimatedProcessingTime="1" /../response..br..br.

looping until completed.?xml version="1.0" encoding="utf-8"?..response..task id="b5759d36-blah-fdc3236655c3" registrationTime="2013-01-29T12:22:19Z" statusChangeTime="2013-01-29T12:22:21Z" status="Completed" filesCount="1" credits="0" resultUrl="https://ocrsdk.blob.core.windows.net/files/b5759d36-blah-fdc3236655c3.result?se=2013-01-29T22%3A00%3A00Z&sr=b&si=downloadResults&sig=lHPVHUASO-blah-%2FLA%3D" /../response.

.br..br.processing failed, now break.?xml version="1.0" encoding="utf-8"?..response..task id="b5759d36-blah-fdc3236655c3" registrationTime="2013-01-29T12:22:19Z" statusChangeTime="2013-01-29T12:22:21Z" status="Completed" filesCount="1" credits="0" resultUrl="https://ocrsdk.blob.core.windows.net/files/b5759d36-blah-fdc3236655c3.result?se=2013-01-29T22%3A00%3A00Z&sr=b&si=downloadResults&sig=lHPVHUASO-blah-%2FLA%3D" /../response.

.br..br.now completed.?xml version="1.0" encoding="utf-8"?..response..task id="b5759d36-blah-fdc3236655c3" registrationTime="2013-01-29T12:22:19Z" statusChangeTime="2013-01-29T12:22:21Z" status="Completed" filesCount="1" credits="0" resultUrl="https://ocrsdk.blob.core.windows.net/files/b5759d36-blah-fdc3236655c3.result?se=2013-01-29T22%3A00%3A00Z&sr=b&si=downloadResults&sig=lHPVHUASO-blah-%2FLA%3D" /../response. And here is what it displays in the browser when it echo's at the break statement:

Processing Failed Status: ProcessingFailed Error:

any ideas what is wrong?

link

answered 29 Jan '13, 16:32

GaryW's gravatar image

GaryW
114

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:

×14
×3

Asked: 28 Jan '13, 06:35

Seen: 1,485 times

Last updated: 31 Jan '13, 15:12

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