This version (2012/06/05 11:15) is a draft.
Approvals: 0/1

1. Titre

if __name__ == '__main__':
  logging.basicConfig(level=logging.INFO)
  _LOG = logging.getLogger('manual_zone_extraction')
  
  lsUsage = "Usage: %prog -p <port>"
  
  loArgumentParser = OptionParser(usage=lsUsage)
  loArgumentParser.add_option("-p", "--port", dest="port", help="Http listening port", default='8080')
  loArgumentParser.add_option("-a", "--admins", dest="admins", help="List of administrators", default='admin')
  loArgumentParser.add_option("-u", "--users", dest="users", help="List of users with their passwords", default='admin:admin_ltutechnologies,ltutech:ltutechnologies')
  (loOptions, args) = loArgumentParser.parse_args()
     
  try:
    #Handling port option
    if loOptions.port:
      cherrypy.config.update({'server.socket_port': int(loOptions.port)})
        
    #Building admin list
    if loOptions.admins:
      ldAdmins = buildAdminsList(loOptions.admins)
    
    #Building list of users
    if loOptions.users:
      ldUsers = buildUsersList(loOptions.users)
      
    loManualZoneExtractor = ManualZoneExtractor(ldAdmins, ldUsers)
    _LOG.warning("Server launched. Please visit %s to start annotation", cherrypy.url())
    
    lsConfiguration=os.path.join('..', 'conf','extractzone_cherrypy.conf')
    cherrypy.quickstart(loManualZoneExtractor, "/", lsConfiguration)
    
  #Interruption by keyboard (ctrl-C)
  except (KeyboardInterrupt) :
    _LOG.debug("KeyboardInterrupt caught. Stopping.")
    cherrypy.server.stop()

1.1.1. Sous sous titre

Titre Titre 2
Comment 1 Comment 2

Hide CONTENT

What's new

What's new

The latest version of Firefox has the following changes:

Please see the complete list of changes in this version. Web and extension developers should also view the curated list of platform changes. You may also be interested in the list of changes in the previous version.

Note: External parties tracking Firefox release uptake should be aware that we manage and monitor the rate of automatic updates to ensure a smooth release. Users can always manually check for updates from the About Firefox window to see whether they are up to date.

The principal API's are used for

  • Image Management (add and delete images: AddImage; DeleteImage)
  • Image Search (retrieving images: SearchImageByUpload; SearchImageById; SearchImageByDna; SearchImageByKeywords)


Special Use API's are used for:

  • Status Information on Images (GetImageByID - exists in two forms)
  • Status Information on Applications (GetApplicationStatus - exists in two forms)


All LTU engine queries fall into one of two general API categories: MODIFY or QUERY.

:!: For LTU engine/ON demand, the url of the query examples given in the following pages should be modified as follows :


For LTU engine/server

  • MODIFY - addressed via port 7789
  • QUERY - addressed via port 8080



Some LTU engine API queries exist in two versions (MODIFY & QUERY), discussed below under “Special USE API's”.

The LTU engine API is accessible over the HTTP protocol. LTU engine requires a GET or a POST request as input, and returns an HTTP response with the application/json mimetype, which contains the response serialized as a JSON string.

Example:

GET http://localhost:8080/api/v2.0/ltuquery/json/SearchImageById?application_key=j6hcA7bwb1jcF8grn6msWNoziUSbXWab&image_id=myimage.jpg


JSON response


  {
 "images":[
    {
     "keywords":["office"],
     "score":0,
     "id":"TO-018.jpg",
     "result_info":"{
  "category" : "LOCALMA..."
    }],
 "status":
  {
   "message":"No error",
   "code":0
  },
 "nb_results_found":1
}

In this documentation, you will find a list of all API methods.

Each section will :

  • quickly explain what the method does.
  • define what type of HTTP request is accepted (GET, POST or both).
  • define each parameter the method takes as input, its type, valid values, and whether it is mandatory or optional.
  • give an example response, with comments.

Some notions are common to quite a few API methods :

  • application key : it is a unique identifier for an application. It needs to be present in ALL your LTU engine requests.
  • image id : it is a unique identifier of an image inside an application. When adding an image, you provide an image id. The results of searches in a LTU engine application will be image ids.

The modify API is usually exposed on http://localhost:7789/api/v2.0/ltumodify/json

AddImage

  • Request type : POST
  • Parameters :
    • application_key : string.
    • image_id : string. The unique identifier of the image.
    • image_content : binary. the content of the image file (the raw array of bytes in the image).
    • dna : binary. a byte array representing the precomputed DNA for the image. Note that you are supposed to provide at least image_content or dna, but never both.
    • keywords : strings. (can be repeated within the request) : one or more keywords that will be associated to this image. See syntax below.
  • Simple example, curl, adding an image with two keywords (a,b):

CURL query

curl -sL -F "image_content=@pinpin.jpg" 
'http://hostaddress:7789/api/v2.0/ltumodify/json/AddImage?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&image_id=pinpin&keywordsa&keywords=b'

JSON response
{
 "status":
  {
   "message":"Image added to the reference database",
   "code":0
  },
 "task_id":0
}

DeleteImage

  • Request type : GET
  • Parameters :
    • application_key.
    • image_id : a string. The unique identifier of the image.


CURL query

curl -sL 
'http://hostaddress:7789/api/v2.0/ltumodify/json/DeleteImage?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&image_id=pinpin'


JSON response

{
 "status":
  {
   "message":"Image deleted from the reference database",
   "code":0
  },
 "task_id":0
}

The modify API is usually exposed on http://localhost:7789/api/v2.0/ltuquery/json

There are 4 main methods to run search queries :

  • SearchImageByUpload
  • SearchImageByDna
  • SearchImageById
  • SearchImageByKeywords


All of these search methods have parameters in common. They are described here :

Common Parameters

Parameter Description
keywords Restrict the search to a list of keywords. Images that do not have these keywords will be discarded in the search.
color_weight Applicable only to “Image Similarity” applications.”Color Weight” is the default color weight used when not specified in the query(SearchImageByDna or SearchImageByUpload). Default: “50” (balance between Color and Shape). Weighted for form: “0”. Weighted for color: '100”.
nb_results Return at most this many result images, never more. Even if there are 100 matching images, setting nb_results means the result will contain only ten images. They will be the ten images with the best scores if starting_index is 0.
starting_index Do not return results starting with the best score, but with the given index in the results. For example, setting starting_index to 10 will return images starting with image that has the 11th score.
ids_list Restrict the search to the images in this list. ex: “id1; id2; id3”

SearchImageByUpload


  • Runs an image search on an application, using an uploaded image as the query.
  • Request type : POST
  • Required Parameters :
    • application_key
    • image_content : The contents (raw array of bytes) of the request image.
  • Optional Parameters :
    • keywords: A list of keywords to which the search should be restricted
    • color_weight. (Similarity Search only) Uses application default color_weight if parameter not provided.
    • starting_index.
    • nb_results.
    • ids_list.


CURL query

curl -sL -F "image_content=@pinpin.jpg" 
'http://hostaddress:8080/api/v2.0/ltuquery/json/SearchImageByUpload?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI'



JSON response

{
  "images":[
    {
     "keywords":[],
     "score":0,
     "id":"some_image.jpg",
     "result_info":""
    },
    {
     "keywords":[],
     "score":0.719954,
     "id":"some_other_image.jpg",
     "result_info":""
    }],
 "status":
  {
   "message":"No error",
   "code":0
  },
 "nb_results_found":100
}

SearchImageById

SearchImageById is not available with asymetric DNA. This means you cannot send a SearchImageById request on Mobile Matching applications. You will receive instead a -2609 error code.

  • Runs an image search on an application, taking an image from the database as the query.
  • Request type : GET
  • Required Parameters :
    • application_key
    • image_id : The id of the query image.
  • Optional Parameters :
    • keywords: A list of keywords to which the search should be restricted
    • color_weight. (Similarity Search only) Uses application default color_weight if parameter not provided.
    • starting_index.
    • nb_results.
    • ids_list.

\\
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/SearchImageById?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&image_id=pinpin'


JSON response

{
  "images":[
    {
     "keywords":[],
     "score":0,
     "id":"some_image.jpg",
     "result_info":""
    },
    {
     "keywords":[],
     "score":0.719954,
     "id":"some_other_image.jpg",
     "result_info":""
    }],
 "status":
  {
   "message":"No error",
   "code":0
  },
 "nb_results_found":100
}

SearchImageByDna

  • The equivalent of a SearchImageByUpload, but where the DNA is precomputed

on the client, and sent directly, without sending the image.

  • Request type : POST
  • Required Parameters :
    • application_key
    • dna : The DNA of the image.
  • Optional Parameters :
    • keywords: A list of keywords to which the search should be restricted
    • color_weight. (Similarity Search only) Uses application default color_weight if parameter not provided.
    • starting_index.
    • nb_results.
    • ids_list.


For information concerning use of pre-computed DNA's, please contact JASTEC France support.

JSON response

{
  "images":[
    {
     "keywords":[],
     "score":0,
     "id":"some_image.jpg",
     "result_info":""
    },
    {
     "keywords":[],
     "score":0.719954,
     "id":"some_other_image.jpg",
     "result_info":""
    }],
 "status":
  {
   "message":"No error",
   "code":0
  },
 "nb_results_found":100
}

SearchImageByKeywords

  • Returns all image ids that contain all keywords in a list.
  • Request type : POST
  • Required Parameters :
    • application_key
    • keywords.
  • Optional Parameters :
    • keywords: A list of keywords to which the search should be restricted
    • color_weight. (Similarity Search only) Uses application default color_weight if parameter not provided.
    • starting_index.
    • nb_results.
    • ids_list.


Simple example, curl, keywords (a,b):
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/SearchImageByKeywords?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&keywords=a&keywords=b'


JSON response
{
  "images":[
    {
     "keywords":['keyword'],
     "score":0,
     "id":"some_image.jpg",
     "result_info":""
    },
    {
     "keywords":['keyword'],
     "score":0.719954,
     "id":"some_other_image.jpg",
     "result_info":""
    }],
 "status":
  {
   "message":"No error",
   "code":0
  },
 "nb_results_found":100
}

The Color Search API's apply only to applications created as “Color similarity” application types.

GetImageColorsById

This query identifies the dominant colors present in an image.

  • Request type : GET
  • Required Parameters :
    • application_key
    • image_id
  • Optional Parameters :None


Simple example, curl:
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/GetImageColorsById?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&image_id=pinpin'

JSON response

{
 "status":
  {
   "message":"",
   "code":0
  },
 "colors":["F2F2F2@94","A9B5B6@2","EAA453@1","D5C0A3@1","2B9755@1","A0C99A@1"]
}

GetImageColorsByUpload

This query identifies the dominant colors present in an uploaded image.


  • Request type : GET
  • Required Parameters :
    • application_key
    • image_content: the path to the image to be uploaded.
  • Optional Parameters :None


Simple example, curl: CURL query

curl -sL -F "image_content=@pinpin.jpg" 
'http://hostaddress:8080/api/v2.0/ltuquery/json/GetImageColorsByUpload?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI'


JSON response

{
 "status":
  {
   "message":"",
   "code":0
  },
 "colors":["B9A595@24","71715A@20","E1DFDB@12","494938@10","1E1B12@7","946C57@5","030203@5","0A0915@3","866939@3","0B0B07@2","5B3E26@2","3C2909@2","CAB978@1","B79439@1","382911@1","150E14@1","6E6076@1"]
}

SearchImageByColors


  • Request type : GET
  • Required Parameters :
    • application_key
    • colors (array of strings) as hex value (see syntax below). It is possible to add target weights for color (FFFFFF@50 would search for colors of which 50% of pixels are white (FFFFFF).
  • Optional Parameters :
    • keywords (array of strings)
    • starting_index (integer)
    • nb_results (integer)
    • ids_list (string)


Simple example, curl:
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/SearcImageByColors?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&colors=FF6633&colors=FF99'

JSON response:

{
 "images":[
    {
     "keywords":["Seurat"],
     "score":0.741319597,
     "id":"Sunday_Afternoon_Island_G...",
     "result_info":""
    }],
 "status":
  {
   "message":"No error",
   "code":0
  },
 "nb_results_found":1
}

GetPalette

http://127.0.0.1:8080/api/v2.0/ltuquery/json/GetPalette

Method: GET

  • Request type : GET
  • Required Parameters :
    • application_key
  • Optional Parameters :
    • colors (array of strings) as hex value (Returns palette of all images which contain these colors).
    • keywords (array of strings)
    • nb_colors (integer):
    • ids_list (string):

Simple example, curl:
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/GetPalette?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&colors=FF6633&colors=FF99'


{
 "status":
  {
   "message":"",
   "code":0
  },
 "colors":["735238","8F938E","2D5E95","382711","393126","846834","C3973A","CFB076","E9EAEB","943112","AA834F","D91E25","090A05","0A0E30","B15A4A"],
 "image_count":[5,4,3,3,3,3,3,3,3,2,2,2,1,1,1]
}

Image Fine Comparison


Fine comparison is designed to provide additional details on the results of query and reference matches using LTU’s image matching functionality. The fine image comparison feature provides visual feedback about matched images, pinpointing where the subtlest differences are located.

Fine comparison also provides a numeric score to quantify the differences between the two images.

Fine comparison is used to: Automate the identification of differences between two matching images R Visually highlight the differences between two images.
http://hostaddress:8080/api/v2.0/ltuquery/json/FineComparison

  • Request type : POST
  • Required Parameters :
    • application_key
    • ref_image
    • query_image


The reference image and the query image are base64 encoded.


Simple curl example: CURL query

curl -F "reference_image=@fic1.jpg" -F "query_image=@fic2.jpg" "http://hostaddress:8080/api/v2.0/ltuquery/json/FineComparison?application_key=VmLGHUj9yXA731RD0Hzp9svWCb5MtMY1" 

JSON response:

{
  "ref_image": "base 64 encoded diff on the reference image",
  "query_image": "base 64 encoded diff on the query image",
  "score": 1.2381811141967773,
  "status": {
    "message": "",
    "code": 0
  }
}

Filtering


Filtering is designed to decide whether an image corresponds to a given profile, such as Porn.

It also provides a numeric score to quantify the confidence of the classification.
http://hostaddress:8080/api/v2.0/ltuquery/json/Filter

  • Request type: POST
  • Required parameters:
    • application_key
    • query_image


In this kind of applications, no reference image is needed, as the query image is directly compared to the profile.


Simple curl example:
CURL query

curl -F "image_content=@filter.jpg" "http://hostaddress:8080/api/v2.0/ltuquery/json/Filter?application_key=VmLGHUj9yXA731RD0Hzp9svWCb5MtMY1" 

JSON response:

{
 "status":
  {
   "message":"No error",
   "code":0
  },
 "scores":
  {
   "Porn":-0.7200000286102295
  }
}

GetApplicationStatus - QUERY version

  • Returns the status of an application (how many images are loaded, etc.)
  • Request type : GET
  • Required Parameter: application_key


Simple curl example:
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/GetApplicationStatus?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI'


JSON response

{
  "status": {
    "message": "No error",
    "code": 0
  },
  "nb_loaded_images": 227
}

GetApplicationStatus - MODIFY version

  • Returns the status of an application (wether it is correctly loaded, etc.)
  • Request type : GET
  • Required Parameter : application_key


Simple curl example:
CURL query

curl -sL 
'http://hostaddress:7789/api/v2.0/ltumodify/GetApplicationStatus?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI'



JSON response

{
  "status": {
    "message": "No error",
    "code": 0
  },
  "application_db_status": "available",
  "main_db_status": "available"
}

GetImageById - QUERY version

  • Returns the image that has the given unique id. Request type : GET
  • Parameters : application_key, image_id


JSON response

{
  "status": {
    "message": "No error",
    "code": 0
  },
  "image": {
    "keywords": ["keyword"],
    "score": 0,
    "id": "COSMOS00145488_000001.jpg",
    "result_info": ""
  }
}

GetImageById - MODIFY version

  • Returns information about an added image. Request type : GET
  • Parameters : application_key, image_id

Simple example, curl:
CURL query

curl -sL 
'http://hostaddress:8080/api/v2.0/ltuquery/json/GetImageById?application_key=PXly9fRUfUt0oizKTcmpzFS8AAtqrTgI&image_id=pinpin'


JSON response

{
  "status": {
    "message": "No error",
    "code": 0
  },
  "image": {
    "keywords": [
      "some_keyword"
    ],
    "score": 0,
    "id": "da97e15e6b2faa06b1cd3708bf52ee1e.jpg",
    "result_info": ""
  }
}