Optical Character Recognition

_images/ocr.png

Convert the text in image to text

Example Go to our flickr photostream http://www.flickr.com/photos/112645524@N07/

Query Image http://farm8.staticflickr.com/7299/11589328513_3179a413a6_o.png

_images/ocr_meter.png

Response Text

_images/ocr_resp.png
POST /services/ocr

Replies face/set of objects with its predictions.

Parameters:
  • instance_token – generated token
Form Parameters:
 
  • query_url / query – query url link or query file.
Request Headers:
 
  • Accept – the response content type is “application/json”
  • InstanceToken – token to authenticate (optional if param instance_token is present)
Response Headers:
 
  • Content-Type – success content type is “application/json”
Status Codes:
  • 200 – success responce
  • 400 – when form parameters are missing
  • 401 – when param instance_token or header InstanceToken is not present present

Example in Python:

import requests
import json
url='http://api.pixuate.com/rest/v1/services/ocr'
headers={'InstanceToken' : 'YOUR TOKEN','Accept':'application/json'}
data={"query_url":"http://farm8.staticflickr.com/7299/11589328513_3179a413a6_o.png"}
response=requests.post(url=url,data=data,headers=headers)
print response.content

Example in Java

public class pixuate extends AsyncTask<Void,Void,Void>
{

        @Override
        protected Void doInBackground(Void... params) {

        try
        {
        String url="http://api.pixuate.com/rest/v1/services/ocr";
        HttpPost post=new HttpPost(url);
        HttpClient client=new DefaultHttpClient();
        List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("query_url","http://farm8.staticflickr.com/7299/11589328513_3179a413a6_o.png"));
        post.setEntity(new UrlEncodedFormEntity(nameValuePairs));
        post.setHeader("Accept","application/json");
        post.setHeader("InstanceToken","YOUR TOKEN");
        HttpResponse http_response=client.execute(post);
        HttpEntity en=http_response.getEntity();
        String s=EntityUtils.toString(en);
        System.out.println(s);
        }catch (ClientProtocolException e) {

        } catch (IOException e) {
        // TODO Auto-generated catch block
        }
                return null;
        }

}