visualtag 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +19 -0
- data/Gemfile +4 -0
- data/LICENSE +22 -0
- data/README.md +33 -0
- data/Rakefile +2 -0
- data/bin/visualtag +72 -0
- data/lib/visualtag/version.rb +3 -0
- data/lib/visualtag.rb +30 -0
- data/visualtag.gemspec +19 -0
- metadata +72 -0
data/.gitignore
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
*.gem
|
2
|
+
*.rbc
|
3
|
+
.bundle
|
4
|
+
.config
|
5
|
+
.yardoc
|
6
|
+
Gemfile.lock
|
7
|
+
InstalledFiles
|
8
|
+
_yardoc
|
9
|
+
coverage
|
10
|
+
doc/
|
11
|
+
lib/bundler/man
|
12
|
+
pkg
|
13
|
+
rdoc
|
14
|
+
spec/reports
|
15
|
+
test/tmp
|
16
|
+
test/version_tmp
|
17
|
+
tmp
|
18
|
+
visualtag.sublime-project
|
19
|
+
visualtag.sublime-workspace
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Francesco Sacchi
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,33 @@
|
|
1
|
+
# Visualtag
|
2
|
+
|
3
|
+
With this gem is possible to generate a visual tag, which is a subset of artoolkit marker, characterized by a 6x6 binary matrix as image
|
4
|
+
|
5
|
+
## Installation
|
6
|
+
|
7
|
+
Add this line to your application's Gemfile:
|
8
|
+
|
9
|
+
gem 'visualtag'
|
10
|
+
|
11
|
+
And then execute:
|
12
|
+
|
13
|
+
$ bundle
|
14
|
+
|
15
|
+
Or install it yourself as:
|
16
|
+
|
17
|
+
$ gem install visualtag
|
18
|
+
|
19
|
+
## Usage
|
20
|
+
|
21
|
+
visualtag [--pattern pattern] [--filename filename] [--border-dimension border-dimension] --[pattern-dimension
|
22
|
+
pattern-dimension]
|
23
|
+
Running this command it will generate the file tag.svg containing the tag number 6.
|
24
|
+
|
25
|
+
Now working on parameterization
|
26
|
+
|
27
|
+
## Contributing
|
28
|
+
|
29
|
+
1. Fork it
|
30
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
31
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
32
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
33
|
+
5. Create new Pull Request
|
data/Rakefile
ADDED
data/bin/visualtag
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require "optparse"
|
3
|
+
require "visualtag"
|
4
|
+
|
5
|
+
options = { :pattern_dimension => 1800,
|
6
|
+
:border_dimension => 720,
|
7
|
+
:filename => 'tag.svg',
|
8
|
+
:pattern => [[1,0,1,0,1,0],[0,1,0,1,0,1]]*3}
|
9
|
+
|
10
|
+
ARGV.options do |opts|
|
11
|
+
opts.banner = "Usage: #{File.basename($PROGRAM_NAME)} [OPTIONS] OTHER_ARGS"
|
12
|
+
|
13
|
+
opts.separator ""
|
14
|
+
opts.separator "Specific Options:"
|
15
|
+
|
16
|
+
opts.on( "-d D", "--pattern-dimension", Integer,
|
17
|
+
"Dimension of the pattern, in pixels." ) do |opt|
|
18
|
+
options[:pattern_dimension] = opt
|
19
|
+
end
|
20
|
+
|
21
|
+
opts.on( "-b D", "--border-dimension", Integer,
|
22
|
+
"Dimension of the border, in pixels." ) do |opt|
|
23
|
+
options[:border_dimension] = opt
|
24
|
+
end
|
25
|
+
|
26
|
+
opts.on( "-f F", "--filename", String,
|
27
|
+
"Filename for the created tag." ) do |opt|
|
28
|
+
options[:filename] = opt
|
29
|
+
end
|
30
|
+
|
31
|
+
opts.on( "-p P", "--pattern", String,
|
32
|
+
"The pattern of the tag, matlab (mat2str surrounded with \") or ruby (to_s) representations are allowed" ) do |opt|
|
33
|
+
options[:pattern] = []
|
34
|
+
begin
|
35
|
+
options[:pattern] = eval(opt)
|
36
|
+
rescue Exception => exc
|
37
|
+
puts 'Not a ruby matrix.. maybe its matlab..'
|
38
|
+
end
|
39
|
+
|
40
|
+
begin
|
41
|
+
opt.each_line(';') do |row|
|
42
|
+
rubyrow = []
|
43
|
+
row.scan(/false|true|1|0/) do |match|
|
44
|
+
value = eval(match)
|
45
|
+
rubyrow << (value.class.name == 'Fixnum'? value > 0: value)
|
46
|
+
end
|
47
|
+
options[:pattern] << rubyrow.map { |e| e ? 1 : 0 }
|
48
|
+
end
|
49
|
+
rescue
|
50
|
+
puts 'Not matlab.. its unknown'
|
51
|
+
end
|
52
|
+
puts options[:pattern]
|
53
|
+
end
|
54
|
+
|
55
|
+
opts.separator "Common Options:"
|
56
|
+
|
57
|
+
opts.on( "-h", "--help",
|
58
|
+
"Show this message." ) do
|
59
|
+
puts opts
|
60
|
+
exit
|
61
|
+
end
|
62
|
+
|
63
|
+
begin
|
64
|
+
opts.parse!
|
65
|
+
rescue
|
66
|
+
puts opts
|
67
|
+
exit
|
68
|
+
end
|
69
|
+
|
70
|
+
Visualtag::create(options[:pattern], options[:filename], options[:pattern_dimension], options[:border_dimension])
|
71
|
+
|
72
|
+
end
|
data/lib/visualtag.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
require "visualtag/version"
|
2
|
+
require 'rasem'
|
3
|
+
|
4
|
+
module Visualtag
|
5
|
+
def Visualtag.create(pattern, filename, pattern_dimension, border_dimension)
|
6
|
+
|
7
|
+
|
8
|
+
cell_dimension = Float(pattern_dimension)/6
|
9
|
+
|
10
|
+
tag_dimension = pattern_dimension + border_dimension*2
|
11
|
+
|
12
|
+
img = Rasem::SVGImage.new(tag_dimension,tag_dimension) do
|
13
|
+
rectangle 0, 0, tag_dimension,tag_dimension, :stroke=>'black', :fill=>'black'
|
14
|
+
pattern.each.with_index do |row, row_index|
|
15
|
+
row.reverse.each.with_index do |cell, column_index|
|
16
|
+
if cell == 0
|
17
|
+
color = 'black'
|
18
|
+
else
|
19
|
+
color = 'white'
|
20
|
+
end
|
21
|
+
rectangle row_index*cell_dimension+border_dimension, column_index*cell_dimension+border_dimension, cell_dimension, cell_dimension, :stroke=>color, :fill=>color
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
File.open(filename, "w") do |f|
|
27
|
+
f << img.output
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/visualtag.gemspec
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
require File.expand_path('../lib/visualtag/version', __FILE__)
|
3
|
+
|
4
|
+
Gem::Specification.new do |gem|
|
5
|
+
gem.authors = ["Francesco Sacchi"]
|
6
|
+
gem.email = ["depsir@gmail.com"]
|
7
|
+
gem.description = %q{Gem to generate a visual tag}
|
8
|
+
gem.summary = %q{With this gem is possible to generate a visual tag, which is a subset of artoolkit marker, characterized by a 6x6 binary matrix as image}
|
9
|
+
gem.homepage = "https://github.com/depsir/visualtag"
|
10
|
+
|
11
|
+
gem.files = `git ls-files`.split($\)
|
12
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
13
|
+
gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
|
14
|
+
gem.name = "visualtag"
|
15
|
+
gem.require_paths = ["lib"]
|
16
|
+
gem.version = Visualtag::VERSION
|
17
|
+
|
18
|
+
gem.add_dependency('rasem')
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,72 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: visualtag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Francesco Sacchi
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-08-07 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: rasem
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
description: Gem to generate a visual tag
|
31
|
+
email:
|
32
|
+
- depsir@gmail.com
|
33
|
+
executables:
|
34
|
+
- visualtag
|
35
|
+
extensions: []
|
36
|
+
extra_rdoc_files: []
|
37
|
+
files:
|
38
|
+
- .gitignore
|
39
|
+
- Gemfile
|
40
|
+
- LICENSE
|
41
|
+
- README.md
|
42
|
+
- Rakefile
|
43
|
+
- bin/visualtag
|
44
|
+
- lib/visualtag.rb
|
45
|
+
- lib/visualtag/version.rb
|
46
|
+
- visualtag.gemspec
|
47
|
+
homepage: https://github.com/depsir/visualtag
|
48
|
+
licenses: []
|
49
|
+
post_install_message:
|
50
|
+
rdoc_options: []
|
51
|
+
require_paths:
|
52
|
+
- lib
|
53
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
54
|
+
none: false
|
55
|
+
requirements:
|
56
|
+
- - ! '>='
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
requirements: []
|
66
|
+
rubyforge_project:
|
67
|
+
rubygems_version: 1.8.19
|
68
|
+
signing_key:
|
69
|
+
specification_version: 3
|
70
|
+
summary: With this gem is possible to generate a visual tag, which is a subset of
|
71
|
+
artoolkit marker, characterized by a 6x6 binary matrix as image
|
72
|
+
test_files: []
|