"ProcessingFailed" status. How do I figure out why?

This is the output from my attempt to OCR a picture:

Hello! Starting OCR operation....

check for simplexml_load_string(): OK

$post_array contents is: array(1) { ["my_file"]=> string(46) "@D:\wwwroot\htdocs\mobicomp/preOCR/hejhopp.jpg" }



first...: object(SimpleXMLElement)#1 (1) { ["task"]=> object(SimpleXMLElement)#4 (1) { ["@attributes"]=> array(7) { ["id"]=> string(36) "16743fc4-acbc-4302-a054-707cc6e4f14f" ["registrationTime"]=> string(20) "2012-06-04T21:34:17Z" ["statusChangeTime"]=> string(20) "2012-06-04T21:34:17Z" ["status"]=> string(6) "Queued" ["filesCount"]=> string(1) "1" ["credits"]=> string(1) "5" ["estimatedProcessingTime"]=> string(1) "1" } } }

end of first...:

iteration 1: object(SimpleXMLElement)#6 (1) { ["task"]=> object(SimpleXMLElement)#2 (1) { ["@attributes"]=> array(6) { ["id"]=> string(36) "16743fc4-acbc-4302-a054-707cc6e4f14f" ["registrationTime"]=> string(20) "2012-06-04T21:34:17Z" ["statusChangeTime"]=> string(20) "2012-06-04T21:34:18Z" ["status"]=> string(16) "ProcessingFailed" ["filesCount"]=> string(1) "1" ["credits"]=> string(1) "5" } } }*

Newlines and bold font have been edited manually...

The problem is that ProcessingFailed. I managed to OCR the exact same picture (and another one that this script doesn't work for either) with the online OCR service. Hints anyone?


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<title>Hitta b&auml;st abbonemanget f&ouml;r dig.</title>

<BR> <BR>
Hello! Starting OCR operation.... <BR> <BR>


//checking for simple_xml_load_string
echo 'check for simplexml_load_string(): ';
if (function_exists(simplexml_load_string)){echo 'OK';} else {echo'NOK';};
echo '<br><br>';

  // 1. Send image to Cloud OCR SDK using processImage call
  // 2. Get response as xml
  // 3. Read taskId from xml

  // !!!!!!!!!! Enter your data here !!!!!!!!!!
  $applicationId = 'XXXXXXXX';
  $password = 'XXXXXXXX';
  $fileName = 'hejhopp.jpg';

  // Get path to file that we are going to recognize

  // Recognizing with English language to rtf
  // You can use combination of languages like ?language=english,russian or
  // ?language=english,french,dutch
  // For details, see API reference for processImage method
  $url = 'http://cloud.ocrsdk.com/processImage';

  // Send HTTP POST request and ret xml response
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  curl_setopt($ch, CURLOPT_USERPWD, "$applicationId:$password");
  curl_setopt($ch, CURLOPT_POST, 1);
  $post_array = array(
    echo '$post_array contents is:  ';
  echo '<br>';

    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_array); 
  $response = curl_exec($ch);

    echo '<br>response: '.$response.'<br>';
    echo 'xml: '; 

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

    echo '<br><br>first...: <br><br>';
    echo '<br><br>end of first...: <br><br>';

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

  // 4. Get task information in a loop until task processing finishes
  // 5. If response contains "Completed" staus - extract url with result
  // 6. Download recognition result (text) and display it

  $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
    echo 'iteration '.$iter.': ';
        echo '                                                  ';
        echo '                                                  ';
        echo '                                                  ';
        echo '                                                  ';
        echo '                                                  ';
        $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url.$qry_str);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_USERPWD, "$applicationId:$password");
    $response = curl_exec($ch);

    // parse xml
    $xml = simplexml_load_string($response);
    $arr = $xml->task[0]->attributes();
        echo '<BR><BR><BR><BR>';
  while($arr["status"] != "Completed");

  // Result is ready. Download it

  $url = $arr["resultUrl"];   
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, $url);
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  $response = curl_exec($ch);

  // Let user donwload rtf result
  header('Content-type: application/rtf');
  header('Content-Disposition: attachment; filename="file.rtf"');
  echo $response;


Was this article helpful?

0 out of 0 found this helpful


1 comment

  • Avatar
    Dmitry Mesheryakov

    ProcessingFailed status is returned when the service fails to process a specific task. That usually happens due to an internal error and in such cases it is not the user's fault but the service's fault. Because of this details of what exactly went wrong are not useful for the user and so are not returned to the user, yet they are logged.

    If you're concerned about some specific image not being processed please contact the team using the feedback e-mail address displayed in the service dashboard. You'll have to provide the problematic image and the processing parameters so that the team can investigate the problem and make appropriate changes to the service if needed.


Please sign in to leave a comment.