bubo 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.document +5 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +24 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +24 -0
- data/Rakefile +53 -0
- data/VERSION +1 -0
- data/lib/bubo.rb +107 -0
- data/test/helper.rb +18 -0
- data/test/test_bubo.rb +7 -0
- metadata +167 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
gem "json", ">= 0"
|
5
|
+
|
6
|
+
# Add dependencies to develop your gem here.
|
7
|
+
# Include everything needed to run rake, tests, features, etc.
|
8
|
+
group :development do
|
9
|
+
gem "shoulda", ">= 0"
|
10
|
+
gem "bundler", "~> 1.0.0"
|
11
|
+
gem "jeweler", "~> 1.5.2"
|
12
|
+
gem "rcov", ">= 0"
|
13
|
+
gem "fakeweb", ">= 1.2.8"
|
14
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
fakeweb (1.3.0)
|
5
|
+
git (1.2.5)
|
6
|
+
jeweler (1.5.2)
|
7
|
+
bundler (~> 1.0.0)
|
8
|
+
git (>= 1.2.5)
|
9
|
+
rake
|
10
|
+
json (1.4.6)
|
11
|
+
rake (0.8.7)
|
12
|
+
rcov (0.9.9)
|
13
|
+
shoulda (2.11.3)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
bundler (~> 1.0.0)
|
20
|
+
fakeweb (>= 1.2.8)
|
21
|
+
jeweler (~> 1.5.2)
|
22
|
+
json
|
23
|
+
rcov
|
24
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2010 Hajo Nils Krabbenhöft
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,24 @@
|
|
1
|
+
= Bubo
|
2
|
+
|
3
|
+
Bubo is an amazing owl. It can memorize your whole image collection and perform fast near-duplicate searches.
|
4
|
+
See askbubo.com for more detail.
|
5
|
+
|
6
|
+
== Using the Bubo search engine
|
7
|
+
|
8
|
+
* b = Bubo.new('email@example.com','API_KEY_HERE')
|
9
|
+
* b.add_image('MyFirstImage','https://example.com/images/1.jpg')
|
10
|
+
* b.add_image ...
|
11
|
+
* Now you might need to wait some time for the system to finish indexing your images. You can check the current status with: b.images_status
|
12
|
+
* b.retrieve('https://example.com/images/1-cropped.jpg')
|
13
|
+
|
14
|
+
== If you encounter any problems
|
15
|
+
Feel free to contact me:
|
16
|
+
Hajo Nils Krabbenhoeft
|
17
|
+
spratpix GmbH & Co. KG
|
18
|
+
hajo AT spratpix DOT com
|
19
|
+
|
20
|
+
== Copyright
|
21
|
+
|
22
|
+
Copyright (c) 2010 Hajo Nils Krabbenhoeft | spratpix GmbH & Co. KG. See LICENSE.txt for
|
23
|
+
further details.
|
24
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'rake'
|
11
|
+
|
12
|
+
require 'jeweler'
|
13
|
+
Jeweler::Tasks.new do |gem|
|
14
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
15
|
+
gem.name = "bubo"
|
16
|
+
gem.homepage = "http://github.com/fxtentacle/bubo"
|
17
|
+
gem.license = "MIT"
|
18
|
+
gem.summary = "Bubo Image Search API"
|
19
|
+
gem.description = "Index your image collection, then do an optical search in it."
|
20
|
+
gem.email = "hajo@spratpix.com"
|
21
|
+
gem.authors = ["Hajo Nils Krabbenhöft"]
|
22
|
+
# Include your dependencies below. Runtime dependencies are required when using your gem,
|
23
|
+
# and development dependencies are only needed for development (ie running rake tasks, tests, etc)
|
24
|
+
# gem.add_runtime_dependency 'jabber4r', '> 0.1'
|
25
|
+
# gem.add_development_dependency 'rspec', '> 1.2.3'
|
26
|
+
end
|
27
|
+
Jeweler::RubygemsDotOrgTasks.new
|
28
|
+
|
29
|
+
require 'rake/testtask'
|
30
|
+
Rake::TestTask.new(:test) do |test|
|
31
|
+
test.libs << 'lib' << 'test'
|
32
|
+
test.pattern = 'test/**/test_*.rb'
|
33
|
+
test.verbose = true
|
34
|
+
end
|
35
|
+
|
36
|
+
require 'rcov/rcovtask'
|
37
|
+
Rcov::RcovTask.new do |test|
|
38
|
+
test.libs << 'test'
|
39
|
+
test.pattern = 'test/**/test_*.rb'
|
40
|
+
test.verbose = true
|
41
|
+
end
|
42
|
+
|
43
|
+
task :default => :test
|
44
|
+
|
45
|
+
require 'rake/rdoctask'
|
46
|
+
Rake::RDocTask.new do |rdoc|
|
47
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
48
|
+
|
49
|
+
rdoc.rdoc_dir = 'rdoc'
|
50
|
+
rdoc.title = "bubo #{version}"
|
51
|
+
rdoc.rdoc_files.include('README*')
|
52
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
53
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
0.0.2
|
data/lib/bubo.rb
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
require 'uri'
|
2
|
+
require 'net/http'
|
3
|
+
require 'net/https'
|
4
|
+
require 'json'
|
5
|
+
|
6
|
+
|
7
|
+
class Bubo
|
8
|
+
# Create a new Bubo API object.
|
9
|
+
#
|
10
|
+
# You can freely generate API keys on http://api.askbubo.com/users/new
|
11
|
+
#
|
12
|
+
# If you have any questions, mail {Hajo Nils Krabbenhoeft}[mailto:hajo@spratpix.com].
|
13
|
+
def initialize(email, api_key, host='bubo.heroku.com', port=80)
|
14
|
+
@settings = { :email => email, :api_key => api_key, :host => host, :port => port }
|
15
|
+
end
|
16
|
+
|
17
|
+
# Returns the email and api_key you specified when generating this object.
|
18
|
+
def api_verification
|
19
|
+
{ :email => @settings[:email], :api_key => @settings[:api_key] }
|
20
|
+
end
|
21
|
+
|
22
|
+
# Returns the hostname of the currently used Bubo API provider.
|
23
|
+
def host
|
24
|
+
@settings[:host]
|
25
|
+
end
|
26
|
+
|
27
|
+
# Returns the port number of the currently used Bubo API provider.
|
28
|
+
def port
|
29
|
+
@settings[:port]
|
30
|
+
end
|
31
|
+
|
32
|
+
# Retrieve current system status.
|
33
|
+
# Return value will look like:
|
34
|
+
#
|
35
|
+
# {"FAIL"=>0, "OK"=>13, "TODO"=>0, "UPDATE"=>"IDLE"}
|
36
|
+
def images_status
|
37
|
+
JSON.parse( send('images') )
|
38
|
+
end
|
39
|
+
|
40
|
+
# Add a new image to your searchable collection.
|
41
|
+
# Returns true or false
|
42
|
+
def add_image(key, url)
|
43
|
+
send('images/add', :post, {:key => key, :url => url}) == 'OK'
|
44
|
+
end
|
45
|
+
|
46
|
+
# Remove an image from your searchable collection.
|
47
|
+
# Returns true or false
|
48
|
+
def remove_image(key)
|
49
|
+
send('images/remove', :post, {:key => key}) == 'OK'
|
50
|
+
end
|
51
|
+
|
52
|
+
# Get the analysis status of an image in your collection.
|
53
|
+
# Returns either:
|
54
|
+
#
|
55
|
+
# "OK\t<NUMBER>" where <NUMBER> is the number of feature points used for searching
|
56
|
+
#
|
57
|
+
# or
|
58
|
+
#
|
59
|
+
# "FAIL\t<ERROR MESSAGE>"
|
60
|
+
def inspect_image(key)
|
61
|
+
send('images/inspect', :get, {:key => key})
|
62
|
+
end
|
63
|
+
|
64
|
+
# Retrieve an array of keys of images, which failed to import.
|
65
|
+
# Returns something like:
|
66
|
+
#
|
67
|
+
# ["keyA", "anotherKey", "keyC"]
|
68
|
+
def failed_image_keys
|
69
|
+
send('images/failures').split("\n")
|
70
|
+
end
|
71
|
+
|
72
|
+
# Download the url given and search for matching images using an optical near-duplicate search algorithm.
|
73
|
+
# Returns an array of strings. Each member is either a comment line starting with # or a search result.
|
74
|
+
# Search result lines are formatted as:
|
75
|
+
#
|
76
|
+
# "<KEY>\t<SCORE>\t<MATRIX>"
|
77
|
+
#
|
78
|
+
# KEY is the key you specified when adding the image
|
79
|
+
# SCORE is a confidence score from 0 to 1 with anything above 0.9 considered excellent
|
80
|
+
# MATRIX is a 2x3 affine transformation matrix which can be used to transform the image specified by KEY as to cover the search image.
|
81
|
+
def retrieve(url)
|
82
|
+
send('images/retrieve', :post, {:url => url}).split("\n")
|
83
|
+
end
|
84
|
+
|
85
|
+
private
|
86
|
+
|
87
|
+
def send(path, method = :get, form_data = {})
|
88
|
+
form_data = form_data.merge(api_verification)
|
89
|
+
form_data = form_data.inject({}) { |m, (k, v)| m[k.to_s] = v; m }
|
90
|
+
|
91
|
+
response = ''
|
92
|
+
http = Net::HTTP.new(host, port)
|
93
|
+
http.start do |http|
|
94
|
+
if(method == :get)
|
95
|
+
request = Net::HTTP::Get.new('/'+path)
|
96
|
+
else
|
97
|
+
request = Net::HTTP::Post.new('/'+path)
|
98
|
+
end
|
99
|
+
request.set_form_data(form_data)
|
100
|
+
response = http.request(request)
|
101
|
+
response = response.body.strip
|
102
|
+
end
|
103
|
+
|
104
|
+
response
|
105
|
+
end
|
106
|
+
|
107
|
+
end
|
data/test/helper.rb
ADDED
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'bundler'
|
3
|
+
begin
|
4
|
+
Bundler.setup(:default, :development)
|
5
|
+
rescue Bundler::BundlerError => e
|
6
|
+
$stderr.puts e.message
|
7
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
8
|
+
exit e.status_code
|
9
|
+
end
|
10
|
+
require 'test/unit'
|
11
|
+
require 'shoulda'
|
12
|
+
|
13
|
+
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
14
|
+
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
15
|
+
require 'bubo'
|
16
|
+
|
17
|
+
class Test::Unit::TestCase
|
18
|
+
end
|
data/test/test_bubo.rb
ADDED
metadata
ADDED
@@ -0,0 +1,167 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: bubo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 27
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 0
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- "Hajo Nils Krabbenh\xC3\xB6ft"
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2011-01-01 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
23
|
+
none: false
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
hash: 3
|
28
|
+
segments:
|
29
|
+
- 0
|
30
|
+
version: "0"
|
31
|
+
type: :runtime
|
32
|
+
name: json
|
33
|
+
prerelease: false
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
37
|
+
none: false
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
hash: 3
|
42
|
+
segments:
|
43
|
+
- 0
|
44
|
+
version: "0"
|
45
|
+
type: :development
|
46
|
+
name: shoulda
|
47
|
+
prerelease: false
|
48
|
+
version_requirements: *id002
|
49
|
+
- !ruby/object:Gem::Dependency
|
50
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ~>
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
hash: 23
|
56
|
+
segments:
|
57
|
+
- 1
|
58
|
+
- 0
|
59
|
+
- 0
|
60
|
+
version: 1.0.0
|
61
|
+
type: :development
|
62
|
+
name: bundler
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: *id003
|
65
|
+
- !ruby/object:Gem::Dependency
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ~>
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 7
|
72
|
+
segments:
|
73
|
+
- 1
|
74
|
+
- 5
|
75
|
+
- 2
|
76
|
+
version: 1.5.2
|
77
|
+
type: :development
|
78
|
+
name: jeweler
|
79
|
+
prerelease: false
|
80
|
+
version_requirements: *id004
|
81
|
+
- !ruby/object:Gem::Dependency
|
82
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
83
|
+
none: false
|
84
|
+
requirements:
|
85
|
+
- - ">="
|
86
|
+
- !ruby/object:Gem::Version
|
87
|
+
hash: 3
|
88
|
+
segments:
|
89
|
+
- 0
|
90
|
+
version: "0"
|
91
|
+
type: :development
|
92
|
+
name: rcov
|
93
|
+
prerelease: false
|
94
|
+
version_requirements: *id005
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
hash: 15
|
102
|
+
segments:
|
103
|
+
- 1
|
104
|
+
- 2
|
105
|
+
- 8
|
106
|
+
version: 1.2.8
|
107
|
+
type: :development
|
108
|
+
name: fakeweb
|
109
|
+
prerelease: false
|
110
|
+
version_requirements: *id006
|
111
|
+
description: Index your image collection, then do an optical search in it.
|
112
|
+
email: hajo@spratpix.com
|
113
|
+
executables: []
|
114
|
+
|
115
|
+
extensions: []
|
116
|
+
|
117
|
+
extra_rdoc_files:
|
118
|
+
- LICENSE.txt
|
119
|
+
- README.rdoc
|
120
|
+
files:
|
121
|
+
- .document
|
122
|
+
- Gemfile
|
123
|
+
- Gemfile.lock
|
124
|
+
- LICENSE.txt
|
125
|
+
- README.rdoc
|
126
|
+
- Rakefile
|
127
|
+
- VERSION
|
128
|
+
- lib/bubo.rb
|
129
|
+
- test/helper.rb
|
130
|
+
- test/test_bubo.rb
|
131
|
+
has_rdoc: true
|
132
|
+
homepage: http://github.com/fxtentacle/bubo
|
133
|
+
licenses:
|
134
|
+
- MIT
|
135
|
+
post_install_message:
|
136
|
+
rdoc_options: []
|
137
|
+
|
138
|
+
require_paths:
|
139
|
+
- lib
|
140
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
141
|
+
none: false
|
142
|
+
requirements:
|
143
|
+
- - ">="
|
144
|
+
- !ruby/object:Gem::Version
|
145
|
+
hash: 3
|
146
|
+
segments:
|
147
|
+
- 0
|
148
|
+
version: "0"
|
149
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
150
|
+
none: false
|
151
|
+
requirements:
|
152
|
+
- - ">="
|
153
|
+
- !ruby/object:Gem::Version
|
154
|
+
hash: 3
|
155
|
+
segments:
|
156
|
+
- 0
|
157
|
+
version: "0"
|
158
|
+
requirements: []
|
159
|
+
|
160
|
+
rubyforge_project:
|
161
|
+
rubygems_version: 1.3.7
|
162
|
+
signing_key:
|
163
|
+
specification_version: 3
|
164
|
+
summary: Bubo Image Search API
|
165
|
+
test_files:
|
166
|
+
- test/helper.rb
|
167
|
+
- test/test_bubo.rb
|