ProcessBarcodeField processing failed

  • 1.5K Views
  • Last Post 31 January 2013
GaryW posted this 28 January 2013

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.

Order By: Standard | Newest | Votes
Dmitry Me posted this 28 January 2013

What parameters (query string) do you use exactly?

GaryW posted this 29 January 2013

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);

Dmitry Me posted this 29 January 2013

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.

GaryW posted this 29 January 2013

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.

GaryW posted this 29 January 2013

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?

Dmitry Me posted this 29 January 2013

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

Dmitry Me posted this 29 January 2013

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

GaryW posted this 31 January 2013

Duh. Thanks Dmitry.

Close