Class: Isk
- Inherits:
-
Object
- Object
- Isk
- Defined in:
- lib/iskr.rb
Overview
ruby binding for isk v0.9.3 not all function implemented 2012-02-06 cvigny
Constant Summary collapse
- @@host =
default values
"solr1"
- @@path =
"/RPC"
- @@port =
31128
- @@db_id =
1
Instance Method Summary collapse
- #add_dir(path, recurse) ⇒ Object
-
#add_img(id, file) ⇒ Object
add image id et file.
- #add_img_blog(id, data) ⇒ Object
- #add_keyword_img(id, keyword) ⇒ Object
-
#add_keywords_img(id, hashes) ⇒ Object
addKeywordsImg(dbId, imgId, hashes) .
- #cacl_img_diff(id1, id2) ⇒ Object
- #calc_img_avg_ldif(id1, id2) ⇒ Object
- #create_db ⇒ Object
- #db_id ⇒ Object
-
#get_all_imgs_by_keywords(numres, kwjointype, keywords) ⇒ Object
getAllImgsByKeywords(dbId, numres, kwJoinType, keywords) .
- #get_db_detailed_list ⇒ Object
-
#get_db_img_count ⇒ Object
img count.
- #get_db_img_id_list ⇒ Object
- #get_db_list ⇒ Object
- #get_global_server_stat ⇒ Object
- #get_img_avgl(id) ⇒ Object
- #get_img_dimensions(id) ⇒ Object
- #get_isk_log(window = 30) ⇒ Object
- #get_keywords_img(id) ⇒ Object
-
#initialize(db_id = @@db_id, host = @@host, path = @@path, port = @@port, proxy_host = nil, proxy_port = nil, user = nil, password = nil, use_ssl = nil, timeout = nil) ⇒ Isk
constructor
A new instance of Isk.
- #is_img_on_db(id) ⇒ Object
- #is_valid_db ⇒ Object
- #load_all_dbs ⇒ Object
- #load_all_dbs_as(path) ⇒ Object
- #load_db(id) ⇒ Object
-
#most_popular_keywords(imgs, exclude_keywords, count, mode) ⇒ Object
mostPopularKeywords(dbId, imgs, excludedKwds, count, mode) .
- #query_img_blob(data, numres = 12, sketch = 0, fast = False) ⇒ Object
-
#query_img_id(id, numres = 12, sketch = 0, fast = false) ⇒ Object
queryImgID(dbId, id, numres=12, sketch=0, fast=False) .
- #query_img_id_fast_keywords(id, numers, kwjointype, keywords) ⇒ Object
- #query_img_id_keywords(id, numers, kwjointype, keywords) ⇒ Object
- #query_img_path(path, numres = 12, sketch = 0, fast = False) ⇒ Object
- #remove_all_keyword_img(id) ⇒ Object
- #remove_db ⇒ Object
- #remove_img(id) ⇒ Object
- #reset_db(id) ⇒ Object
- #save_all_dbs ⇒ Object
- #save_all_dbs_as(path) ⇒ Object
- #save_db ⇒ Object
- #save_db_as(filename) ⇒ Object
- #shutdown_server ⇒ Object
Constructor Details
#initialize(db_id = @@db_id, host = @@host, path = @@path, port = @@port, proxy_host = nil, proxy_port = nil, user = nil, password = nil, use_ssl = nil, timeout = nil) ⇒ Isk
Returns a new instance of Isk.
16 17 18 19 |
# File 'lib/iskr.rb', line 16 def initialize(db_id=@@db_id,host=@@host, path=@@path, port=@@port, proxy_host=nil, proxy_port=nil, user=nil, password=nil, use_ssl=nil, timeout=nil) @db_id = db_id @server = XMLRPC::Client.new( host, path,port,proxy_host,proxy_port,user,password,use_ssl,timeout) end |
Instance Method Details
#add_dir(path, recurse) ⇒ Object
227 228 229 |
# File 'lib/iskr.rb', line 227 def add_dir(path,recurse) @server.call("addDir",db_id,path,recurse) end |
#add_img(id, file) ⇒ Object
add image id et file
61 62 63 |
# File 'lib/iskr.rb', line 61 def add_img(id, file) @server.call("addImg",db_id,id,file) end |
#add_img_blog(id, data) ⇒ Object
56 57 58 |
# File 'lib/iskr.rb', line 56 def add_img_blog(id,data) @server.call("addImgBlob",db_id, id, data) end |
#add_keyword_img(id, keyword) ⇒ Object
136 137 138 |
# File 'lib/iskr.rb', line 136 def add_keyword_img(id,keyword) @server.call("addKeywordImg",db_id,id,keyword) end |
#add_keywords_img(id, hashes) ⇒ Object
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
Returns: boolean
true if image id exists
223 224 225 |
# File 'lib/iskr.rb', line 223 def add_keywords_img(id,hashes) @server.call("addKeywordsImg",db_id,hashes) end |
#cacl_img_diff(id1, id2) ⇒ Object
111 112 113 |
# File 'lib/iskr.rb', line 111 def cacl_img_diff(id1,id2) @server.call("calcImgDiff",db_id,id1,id2) end |
#calc_img_avg_ldif(id1, id2) ⇒ Object
107 108 109 |
# File 'lib/iskr.rb', line 107 def calc_img_avg_ldif(id1,id2) @server.call("calcImgAvglDiff",db_id,id1,id2) end |
#create_db ⇒ Object
86 87 88 |
# File 'lib/iskr.rb', line 86 def create_db() @server.call("createDb",db_id) end |
#db_id ⇒ Object
21 22 23 |
# File 'lib/iskr.rb', line 21 def db_id @db_id end |
#get_all_imgs_by_keywords(numres, kwjointype, keywords) ⇒ Object
getAllImgsByKeywords(dbId, numres, kwJoinType, keywords)
Return all images with the given keywords
Parameters:
dbId (number) - Database space id.
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.
Returns: array
array of image ids
155 156 157 |
# File 'lib/iskr.rb', line 155 def get_all_imgs_by_keywords(numres,kwjointype,keywords) @server.call("getAllImgsByKeywords",db_id,numres,kwjointype,keywords) end |
#get_db_detailed_list ⇒ Object
128 129 130 |
# File 'lib/iskr.rb', line 128 def get_db_detailed_list @server.call("getDbDetailedList",db_id) end |
#get_db_img_count ⇒ Object
img count
95 96 97 |
# File 'lib/iskr.rb', line 95 def get_db_img_count @server.call("getDbImgCount",db_id) end |
#get_db_img_id_list ⇒ Object
124 125 126 |
# File 'lib/iskr.rb', line 124 def get_db_img_id_list @server.call("getDbImgIdList",db_id) end |
#get_db_list ⇒ Object
119 120 121 |
# File 'lib/iskr.rb', line 119 def get_db_list @server.call("getDbList") end |
#get_global_server_stat ⇒ Object
249 250 251 |
# File 'lib/iskr.rb', line 249 def get_global_server_stat @server.call("getGlobalServerStats") end |
#get_img_avgl(id) ⇒ Object
115 116 117 |
# File 'lib/iskr.rb', line 115 def get_img_avgl(id) @server.call("calcImgDiff",db_id,id) end |
#get_img_dimensions(id) ⇒ Object
103 104 105 |
# File 'lib/iskr.rb', line 103 def get_img_dimensions(id) @server.call("getImgDimensions",db_id,id) end |
#get_isk_log(window = 30) ⇒ Object
257 258 259 |
# File 'lib/iskr.rb', line 257 def get_isk_log(window=30) @server.call("getIskLog",window) end |
#get_keywords_img(id) ⇒ Object
202 203 204 |
# File 'lib/iskr.rb', line 202 def get_keywords_img(id) @server.call("getKeywordsImg",db_id,id) end |
#is_img_on_db(id) ⇒ Object
99 100 101 |
# File 'lib/iskr.rb', line 99 def is_img_on_db(id) @server.call("isImgOnDb",db_id,id) end |
#is_valid_db ⇒ Object
253 254 255 |
# File 'lib/iskr.rb', line 253 def is_valid_db() @server.call("isValidDb",db_id) end |
#load_all_dbs ⇒ Object
239 240 241 242 |
# File 'lib/iskr.rb', line 239 def load_all_dbs @server.call("loadAllDbs") @load_all_dbs = true end |
#load_all_dbs_as(path) ⇒ Object
231 232 233 |
# File 'lib/iskr.rb', line 231 def load_all_dbs_as(path) @server.call("loadAllDbs",path) end |
#load_db(id) ⇒ Object
73 74 75 |
# File 'lib/iskr.rb', line 73 def load_db(id) @server.call("loadDb",db_id, id, data) end |
#most_popular_keywords(imgs, exclude_keywords, count, mode) ⇒ Object
mostPopularKeywords(dbId, imgs, excludedKwds, count, mode)
Returns the most frequent keywords associated with a given set of images
Parameters:
imgs (string) - Comma separated list of target image ids
excludedKwds (string) - Comma separated list of keywords ids to be excluded from the frequency count
mode (number) - ignored, will be used on future versions.
dbId (number @param dbId Database space id.)
count (number @param count Number of keyword results desired)
Returns: array
array of keyword ids and frequencies: [kwd1_id, kwd1_freq, kwd2_id, kwd2_freq, ...]
198 199 200 |
# File 'lib/iskr.rb', line 198 def most_popular_keywords(imgs,exclude_keywords,count,mode) @server.call("mostPopularKeywords",db_id,imgs,exclude_keywords,count,mode) end |
#query_img_blob(data, numres = 12, sketch = 0, fast = False) ⇒ Object
49 50 51 |
# File 'lib/iskr.rb', line 49 def query_img_blob(data,numres=12, sketch=0, fast=False) @server.call("queryImgBlob",db_id,data,numres,sketch,fast) end |
#query_img_id(id, numres = 12, sketch = 0, fast = false) ⇒ Object
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.
Returns: array
array of arrays: [[image id 1, score],[image id 2, score],[image id 3, score], ...] (id is Integer, score is Double)
42 43 44 45 46 47 48 |
# File 'lib/iskr.rb', line 42 def query_img_id(id,numres=12, sketch=0, fast=false) if is_img_on_db(id) @server.call("queryImgID",db_id,id,numres,sketch,fast) else puts "not in image database #{id}" end end |
#query_img_id_fast_keywords(id, numers, kwjointype, keywords) ⇒ Object
159 160 161 |
# File 'lib/iskr.rb', line 159 def query_img_id_fast_keywords(id,numers,kwjointype,keywords) @server.call("queryImgIDFastKeywords",db_id,numres,kwjointype,keywords) end |
#query_img_id_keywords(id, numers, kwjointype, keywords) ⇒ Object
179 180 181 |
# File 'lib/iskr.rb', line 179 def query_img_id_keywords(id,numers,kwjointype,keywords) @server.call("queryImgIDKeywords",db_id,numres,kwjointype,keywords) end |
#query_img_path(path, numres = 12, sketch = 0, fast = False) ⇒ Object
52 53 54 |
# File 'lib/iskr.rb', line 52 def query_img_path(path,numres=12, sketch=0, fast=False) @server.call("queryImgPath",db_id,path,numres,sketch,fast) end |
#remove_all_keyword_img(id) ⇒ Object
206 207 208 |
# File 'lib/iskr.rb', line 206 def remove_all_keyword_img(id) @server.call("removeAllKeywordImg",db_id,id) end |
#remove_db ⇒ Object
244 245 246 |
# File 'lib/iskr.rb', line 244 def remove_db() @server.call("removeDb") end |
#remove_img(id) ⇒ Object
77 78 79 |
# File 'lib/iskr.rb', line 77 def remove_img(id) @server.call("removeImg",db_id,id) end |
#reset_db(id) ⇒ Object
82 83 84 |
# File 'lib/iskr.rb', line 82 def reset_db(id) @server.call("resetDb",db_id) end |
#save_all_dbs ⇒ Object
235 236 237 |
# File 'lib/iskr.rb', line 235 def save_all_dbs @server.call("saveAllDbs") end |
#save_all_dbs_as(path) ⇒ Object
132 133 134 |
# File 'lib/iskr.rb', line 132 def save_all_dbs_as(path) @server.call("saveAllDbsAs",db_id) end |
#save_db ⇒ Object
65 66 67 |
# File 'lib/iskr.rb', line 65 def save_db() @server.call("saveDb",db_id) end |
#save_db_as(filename) ⇒ Object
69 70 71 |
# File 'lib/iskr.rb', line 69 def save_db_as(filename) @server.call("saveDbAs",db_id, filename) end |
#shutdown_server ⇒ Object
90 91 92 |
# File 'lib/iskr.rb', line 90 def shutdown_server() @server.call("shutdownServer") end |