Template Matching

_images/image_matching.png

Find the areas that matches the template in the query image, returns one or more points sets. Each set contains 4 point p1,p2,p3,p4 which forms quadrilateral.

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

Template http://farm8.staticflickr.com/7377/11584703323_3a6d858c0d_o.png

_images/template_image.png

Query Image http://farm4.staticflickr.com/3774/11585293936_0952375081_o.jpg

_images/query_image.png

Response Image

_images/image_matching_response.png
POST /services/image_match

Replies face/set of objects with its predictions.

Parameters:
  • instance_token – generated token
Form Parameters:
 
  • template_url / template – template url link or template file.
  • 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/image_match'
headers={'InstanceToken' : 'YOUR TOKEN','Accept':'application/json'}
data={"template_url":"http://farm8.staticflickr.com/7377/11584703323_3a6d858c0d_o.png","query_url":"http://farm4.staticflickr.com/3774/11585293936_0952375081_o.jpg"}
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/image_match";
        HttpPost post=new HttpPost(url);
        HttpClient client=new DefaultHttpClient();
        List<BasicNameValuePair> nameValuePairs = new ArrayList<BasicNameValuePair>();
        nameValuePairs.add(new BasicNameValuePair("query_url","http://farm4.staticflickr.com/3774/11585293936_0952375081_o.jpg"));
        nameValuePairs.add(new BasicNameValuePair("template_url","http://farm8.staticflickr.com/7377/11584703323_3a6d858c0d_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;
        }

}