API Reference

List of functions available through XML-RPC and SOAP.

core.imgdbapi.addDir(dbId, path, recurse)

Visits a directory recursively and add supported images into database space.

Parameters:
  • dbId (number) – Database space id.
  • path (string) – Target filesystem full path of the initial dir.
  • recurse (number) – 1 if should visit recursively
Return type:

number

Since:

0.7

Returns:

count of images succesfully added

core.imgdbapi.addImg(dbId, id, filename, fileIsUrl=False)

Add image to database space. Image file is read, processed and indexed. After this indexing is done, image can be removed from file system.

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id. The image located on filename will be indexed and from now on should be refered to isk-daemon as this supplied id.
  • filename (string) – Physical full file path for the image to be indexed. Should be in one of the supported formats (‘jpeg’, ‘jpg’, ‘gif’, ‘png’, ‘rgb’, ‘pbm’, ‘pgm’, ‘ppm’, ‘tiff’, ‘tif’, ‘rast’, ‘xbm’, ‘bmp’). For better results image should have dimension of at least 128x128. Thumbnails are ok. Bigger images will be scaled down to 128x128.
  • fileIsUrl (boolean) – if true, filename is interpreted as an HTTP url and the remote image it points to downloaded and saved to a temporary location (same directory where database file is) before being added to database.
Return type:

number

Since:

0.7

Returns:

1 in case of success.

core.imgdbapi.addImgBlob(dbId, id, data)

Add image to database space. Image data is passed directly. It is then processed and indexed.

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id. The image located on filename will be indexed and from now on should be refered to isk-daemon as this supplied id.
  • data (binary) – Image binary data
Return type:

number

Since:

0.9.3

Returns:

1 in case of success.

core.imgdbapi.addKeywordImg(dbId, imgId, hash)

Adds a keyword to an image.

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id.
  • hash (number) – Keyword id.
Return type:

boolean

Since:

0.7

Returns:

true if operation was succesful

core.imgdbapi.addKeywordsImg(dbId, imgId, hashes)

Associate keywords to image

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id.
  • hashes (list of number) – Keyword hashes to associate
Return type:

boolean

Since:

0.7

Returns:

true if image id exists

core.imgdbapi.calcImgAvglDiff(dbId, id1, id2)

Return average luminance (over three color channels) difference ratio

Parameters:
  • dbId (number) – Database space id.
  • id1 (number) – Target image 1 id.
  • id2 (number) – Target image 2 id.
Return type:

number

Since:

0.7

Returns:

float representing difference. The smaller, the most similar.

core.imgdbapi.calcImgDiff(dbId, id1, id2)

Return image similarity difference ratio. One value alone for an image pair doesn’t mean much. These values should be compared pairwise against each other.

The smaller the value between two images is (i.e. the more negative the value is), the more similar the 2 images are.

Comparing one image against itself is a degenerate case and the value returned should be ignored.

Parameters:
  • dbId (number) – Database space id.
  • id1 (number) – Target image 1 id.
  • id2 (number) – Target image 2 id.
Return type:

number

Since:

0.7

Returns:

float representing difference. The smaller, the most similar.

core.imgdbapi.createDb(dbId)

Create new db space. Overwrite database space statistics if one with supplied id already exists.

Parameters:dbId (number) – Database space id.
Return type:number
Since:0.7
Returns:dbId in case of success
core.imgdbapi.getAllImgsByKeywords(dbId, numres, kwJoinType, keywords)

Return all images with the given keywords

Parameters:
  • dbId (number) – Database space id.
  • numres (number) – Number of results desired
  • kwJoinType (number) – Logical operator for target keywords: 1 for AND, 0 for OR
  • keywords (string) – comma separated list of keyword ids. An empty string will return random images.
Return type:

array

Since:

0.7

Returns:

array of image ids

core.imgdbapi.getDbDetailedList()

Return details for all database spaces.

Return type:map
Since:0.7
Returns:map key is database space id (as an integer), associated value is array with [getImgCount, queryCount, lastQueryPerMin, queryMinCount, queryMinCur, lastAddPerMin, addMinCount, addMinCur, addCount, addSinceLastSave, lastId, lastSaveTime, fileName ]
core.imgdbapi.getDbImgCount(dbId)

Return count of indexed images on database space.

Parameters:dbId (number) – Database space id.
Return type:number
Since:0.7
Returns:image count
core.imgdbapi.getDbImgIdList(dbId)

Return list of image ids on database space.

Parameters:dbId (number) – Database space id.
Return type:array
Since:0.7
Returns:array of image ids
core.imgdbapi.getDbList()

Return list defined database spaces.

Return type:array
Since:0.7
Returns:array of db space ids
core.imgdbapi.getGlobalServerStats()

Return the most similar images to the supplied one.

Return type:map
Since:0.7
Returns:key is stat name, value is value. Keys are [‘isk-daemon uptime’, ‘Number of databases’, ‘Total memory usage’, ‘Resident memory usage’, ‘Stack memory usage’]
core.imgdbapi.getImgAvgl(dbId, id)

Return image average color levels on the three color channels (YIQ color system)

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id.
Return type:

array of double

Since:

0.7

Returns:

values for YIQ color channels

core.imgdbapi.getImgDimensions(dbId, id)

Returns image original dimensions when indexed into database.

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id.
Return type:

array

Since:

0.7

Returns:

array in the form M{[width, height]}

core.imgdbapi.getIskLog(window=30)

Returns the last lines of text in the iskdaemon instance log

Parameters:window (number) – number of lines to retrieve
Return type:string
Returns:text block
Since:0.9.3
core.imgdbapi.getKeywordsImg(dbId, imgId)

Returns all keywords currently associated with an image.

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id.
Return type:

array

Since:

0.7

Returns:

array of keyword ids

core.imgdbapi.isImgOnDb(dbId, id)

Return whether image id exists on database space.

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id.
Return type:

boolean

Since:

0.7

Returns:

true if image id exists

core.imgdbapi.isValidDb(dbId)

Return whether database space id has already been defined

Parameters:dbId (number) – Database space id.
Return type:boolean
Since:0.7
Returns:True if exists
core.imgdbapi.loadAllDbs()

Loads from disk all previously persisted database spaces on the data file defined at the config file I{settings.py}

Return type:number
Since:0.7
Returns:count of persisted db spaces
core.imgdbapi.loadAllDbsAs(path)

Loads from disk all previously persisted database spaces. (File resulting from a previous call to L{saveAllDbs}).

Parameters:path (string) – Target filesystem full path of the file where data is stored at.
Return type:number
Since:0.7
Returns:total db spaces read
core.imgdbapi.loadDb(dbId, filename)

Load the supplied single-database-space-dump into a database space of given id. An existing database space with the given id will be completely replaced.

Parameters:
  • dbId (number) – Database space id.
  • filename (string) – Target filesystem full path of the file where data is stored at. B{NOTE}: This data file contains a single database space and should be used for import/export purposes only. Do not try to load it with a call to L{loadAllDbs} and vice versa.
Return type:

number

Since:

0.7

Returns:

dbId in case of success.

core.imgdbapi.mostPopularKeywords(dbId, imgs, excludedKwds, count, mode)

Returns the most frequent keywords associated with a given set of images

Parameters:
  • dbId (number) – Database space id.
  • imgs (string) – Comma separated list of target image ids
  • excludedKwds (string) – Comma separated list of keywords ids to be excluded from the frequency count
  • count (number) – Number of keyword results desired
  • mode (number) – ignored, will be used on future versions.
Return type:

array

Since:

0.7

Returns:

array of keyword ids and frequencies: [kwd1_id, kwd1_freq, kwd2_id, kwd2_freq, ...]

core.imgdbapi.queryImgBlob(dbId, data, numres=12, sketch=0, fast=False)

Return the most similar images to the supplied one. The target image is specified by its raw binary file data. Most common formats are supported.

Parameters:
  • dbId (number) – Database space id.
  • data (binary data) – Target image file binary data.
  • numres (number) – Number of results to return. The target image is on the result list.
  • sketch (number) – 0 for photographs, 1 for hand-sketched images or low-resolution vector images.
  • fast (boolean) – if true, only the average color for each image is considered. Image geometry/features are ignored. Search is faster this way.
Return type:

array

Since:

0.9.3

Returns:

array of arrays: M{[[image id 1, score],[image id 2, score],[image id 3, score], ...]} (id is Integer, score is Double)

core.imgdbapi.queryImgID(dbId, id, numres=12, sketch=0, fast=False)

Return the most similar images to the supplied one. The supplied image must be already indexed, and is referenced by its ID.

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id.
  • numres (number) – Number of results to return. The target image is on the result list.
  • sketch (number) – 0 for photographs, 1 for hand-sketched images or low-resolution vector images.
  • fast (boolean) – if true, only the average color for each image is considered. Image geometry/features are ignored. Search is faster this way.
Return type:

array

Since:

0.7

Change:

0.9.3: added parameter ‘sketch’

Returns:

array of arrays: M{[[image id 1, score],[image id 2, score],[image id 3, score], ...]} (id is Integer, score is Double)

core.imgdbapi.queryImgIDFastKeywords(dbId, imgId, numres, kwJoinType, keywords)

Fast query (only considers average color) for similar images considering keywords

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id. If ‘0’, random images containing the target keywords will be returned.
  • numres (number) – Number of results desired
  • kwJoinType (number) – logical operator for keywords: 1 for AND, 0 for OR
  • keywords (string) – comma separated list of keyword ids.
Return type:

array

Since:

0.7

Returns:

array of arrays: M{[[image id 1, score],[image id 2, score],[image id 3, score], ...]} (id is Integer, score is Double)

core.imgdbapi.queryImgIDKeywords(dbId, imgId, numres, kwJoinType, keywords)

Query for similar images considering keywords. The input keywords are used for narrowing the search space.

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id. If ‘0’, random images containing the target keywords will be returned.
  • numres (number) – Number of results desired
  • kwJoinType (number) – logical operator for keywords: 1 for AND, 0 for OR
  • keywords (string) – comma separated list of keyword ids.
Return type:

array

Since:

0.7

Returns:

array of arrays: M{[[image id 1, score],[image id 2, score],[image id 3, score], ...]} (id is Integer, score is Double)

core.imgdbapi.queryImgPath(dbId, path, numres=12, sketch=0, fast=False)

Return the most similar images to the supplied one. The target image is specified using it’s full path on the server filesystem.

Parameters:
  • dbId (number) – Database space id.
  • path (string) – Target image pth on the server disk.
  • numres (number) – Number of results to return. The target image is on the result list.
  • sketch (number) – 0 for photographs, 1 for hand-sketched images or low-resolution vector images.
  • fast (boolean) – if true, only the average color for each image is considered. Image geometry/features are ignored. Search is faster this way.
Return type:

array

Since:

0.9.3

Returns:

array of arrays: M{[[image id 1, score],[image id 2, score],[image id 3, score], ...]} (id is Integer, score is Double)

core.imgdbapi.removeAllKeywordImg(dbId, imgId)

Remove all keyword associations this image has.

Known issue: keyword based queries will continue to consider the image to be associated to this keyword until the database is saved and restored.

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id.
Return type:

boolean

Since:

0.7

Returns:

true if operation succeeded

core.imgdbapi.removeDb(dbid)

Remove a database. All images associated with it are also removed.

Return type:boolean
Since:0.7
Returns:true if succesful
core.imgdbapi.removeImg(dbId, id)

Remove image from database space.

Parameters:
  • dbId (number) – Database space id.
  • id (number) – Target image id.
Return type:

number

Since:

0.7

Returns:

1 in case of success.

core.imgdbapi.removeKeywordImg(dbId, imgId, hash)

Remove the association of a keyword to an image

Known issue: keyword based queries will continue to consider the image to be associated to this keyword until the database is saved and restored.

Parameters:
  • dbId (number) – Database space id.
  • imgId (number) – Target image id.
  • hash (number) – Keyword id.
Return type:

boolean

Since:

0.7

Returns:

true if operation succeeded

core.imgdbapi.resetDb(dbId)

Removes all images from a database space, frees memory, reset statistics.

Parameters:dbId (number) – Database space id.
Return type:number
Since:0.7
Returns:1 in case of success.
core.imgdbapi.saveAllDbs()

Persist all existing database spaces on the data file defined at the config file I{settings.py}

Return type:number
Since:0.7
Returns:count of persisted db spaces
core.imgdbapi.saveAllDbsAs(path)

Persist all existing database spaces.

Parameters:path (string) – Target filesystem full path of the file where data is stored at.
Return type:number
Since:0.7
Returns:total db spaces written
core.imgdbapi.saveDb(dbId)

Save the supplied database space if the it has already been saved with a filename (previous call to L{saveDbAs}). B{NOTE}: This operation should be used for exporting single database spaces. For regular server instance database persistance, use L{saveAllDbs} and L{loadAllDbs}.

Parameters:dbId (number) – Database space id.
Return type:number
Since:0.7
Returns:1 in case of success.
core.imgdbapi.saveDbAs(dbId, filename)

Save the supplied database space if the it has already been saved with a filename (subsequent save calls can be made to L{saveDb}).

Parameters:
  • dbId (number) – Database space id.
  • filename (string) – Target filesystem full path of the file where data should be stored at. B{NOTE}: This data file contains a single database space and should be used for import/export purposes only. Do not try to load it with a call to L{loadAllDbs}.
Return type:

number

Since:

0.7

Returns:

1 in case of success.

core.imgdbapi.shutdownServer()

Request a shutdown of this server instance.

Return type:number
Since:0.7
Returns:always M{1}