hornetseye-frame 0.3.0 → 0.5.0

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/Rakefile CHANGED
@@ -7,12 +7,12 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'hornetseye-frame'
10
- PKG_VERSION = '0.3.0'
10
+ PKG_VERSION = '0.5.0'
11
11
  CXX = ENV[ 'CXX' ] || 'g++'
12
12
  STRIP = ENV[ 'STRIP' ] || 'strip'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
14
14
  CC_FILES = FileList[ 'ext/*.cc' ]
15
- HH_FILES = FileList[ 'ext/*.hh' ]
15
+ HH_FILES = FileList[ 'ext/*.hh' ] + FileList[ 'ext/*.tcc' ]
16
16
  TC_FILES = FileList[ 'test/tc_*.rb' ]
17
17
  TS_FILES = FileList[ 'test/ts_*.rb' ]
18
18
  SO_FILE = "ext/#{PKG_NAME.tr '\-', '_'}.so"
@@ -169,7 +169,9 @@ rule '.o' => '.cc' do |t|
169
169
  end
170
170
 
171
171
  file ".depends.mf" do |t|
172
- sh "makedepend -f- -- #{$CXXFLAGS} -- #{CC_FILES.join ' '} > #{t.name}"
172
+ sh "g++ -MM #{$CXXFLAGS} #{CC_FILES.join ' '} | " +
173
+ "sed -e :a -e N -e 's/\\n/\\$/g' -e ta | " +
174
+ "sed -e 's/ *\\\\\\$ */ /g' -e 's/\\$/\\n/g' | sed -e 's/^/ext\\//' > #{t.name}"
173
175
  end
174
176
  CC_FILES.each do |t|
175
177
  file t.ext(".o") => t
data/ext/colourspace.cc CHANGED
@@ -60,8 +60,8 @@ static void setupFormat( const string &typecode, int width, int height, char *me
60
60
  width2 = width / 2,
61
61
  height2 = height / 2;
62
62
  data[ 0 ] = (uint8_t *)memory;
63
- data[ 2 ] = (uint8_t *)memory + width * height;
64
- data[ 1 ] = (uint8_t *)data[ 2 ] + width2 * height2;
63
+ data[ 1 ] = (uint8_t *)memory + width * height;
64
+ data[ 2 ] = (uint8_t *)data[ 1 ] + width2 * height2;
65
65
  lineSize[ 0 ] = width;
66
66
  lineSize[ 1 ] = width2;
67
67
  lineSize[ 2 ] = width2;
data/ext/frame.cc CHANGED
@@ -23,9 +23,7 @@ Frame::Frame( const string &typecode, int width, int height, char *data ):
23
23
  VALUE mModule = rb_define_module( "Hornetseye" );
24
24
  VALUE cMalloc = rb_define_class_under( mModule, "Malloc", rb_cObject );
25
25
  VALUE cFrame = rb_define_class_under( mModule, "Frame", rb_cObject );
26
- VALUE rbSize = rb_funcall( cFrame, rb_intern( "storage_size" ), 3,
27
- rb_const_get( mModule, rb_intern( typecode.c_str() ) ),
28
- INT2NUM( width ), INT2NUM( height ) );
26
+ VALUE rbSize = INT2NUM( storageSize( typecode, width, height ) );
29
27
  VALUE rbMemory;
30
28
  if ( data != NULL ) {
31
29
  rbMemory = Data_Wrap_Struct( cMalloc, 0, 0, (void *)data );
@@ -67,3 +65,12 @@ void Frame::markRubyMember(void)
67
65
  rb_gc_mark( m_frame );
68
66
  }
69
67
 
68
+ int Frame::storageSize( const std::string &typecode, int width, int height )
69
+ {
70
+ VALUE mModule = rb_define_module( "Hornetseye" );
71
+ VALUE cFrame = rb_define_class_under( mModule, "Frame", rb_cObject );
72
+ return NUM2INT( rb_funcall( cFrame, rb_intern( "storage_size" ), 3,
73
+ rb_const_get( mModule, rb_intern( typecode.c_str() ) ),
74
+ INT2NUM( width ), INT2NUM( height ) ) );
75
+ }
76
+
data/ext/frame.hh CHANGED
@@ -32,6 +32,7 @@ public:
32
32
  char *data(void);
33
33
  VALUE rubyObject(void) { return m_frame; }
34
34
  void markRubyMember(void);
35
+ static int storageSize( const std::string &typecode, int width, int height );
35
36
  protected:
36
37
  VALUE m_frame;
37
38
  };
@@ -85,6 +85,10 @@ module Hornetseye
85
85
  self.class.height
86
86
  end
87
87
 
88
+ def storage_size
89
+ self.class.storage_size
90
+ end
91
+
88
92
  alias_method :orig_to_type, :to_type
89
93
 
90
94
  def to_type( target )
@@ -0,0 +1,71 @@
1
+ # multiarray - Lazy multi-dimensional arrays for Ruby
2
+ # Copyright (C) 2010 Jan Wedekind
3
+ #
4
+ # This program is free software: you can redistribute it and/or modify
5
+ # it under the terms of the GNU General Public License as published by
6
+ # the Free Software Foundation, either version 3 of the License, or
7
+ # (at your option) any later version.
8
+ #
9
+ # This program is distributed in the hope that it will be useful,
10
+ # but WITHOUT ANY WARRANTY; without even the implied warranty of
11
+ # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
+ # GNU General Public License for more details.
13
+ #
14
+ # You should have received a copy of the GNU General Public License
15
+ # along with this program. If not, see <http://www.gnu.org/licenses/>.
16
+
17
+ # Namespace of Hornetseye computer vision library
18
+ module Hornetseye
19
+
20
+ module FrameConstructor
21
+
22
+ def method_missing( name, *args )
23
+ if name.to_s =~ /^[a-z0-9]+$/
24
+ target = name.to_s.upcase
25
+ if Hornetseye.const_defined? target
26
+ target = Hornetseye.const_get target
27
+ if target.is_a? FourCC
28
+ new target, *args
29
+ else
30
+ super name, *args
31
+ end
32
+ else
33
+ super name, *args
34
+ end
35
+ else
36
+ super name, *args
37
+ end
38
+ end
39
+
40
+ end
41
+
42
+ Frame.extend FrameConstructor
43
+
44
+ module FrameConversion
45
+
46
+ def method_missing( name, *args )
47
+ if name.to_s =~ /^to_[a-z0-9]+$/
48
+ target = name.to_s[ 3 .. -1 ].upcase
49
+ if Hornetseye.const_defined? target
50
+ target = Hornetseye.const_get target
51
+ if ( target.is_a? Class and target < Element ) or target.is_a? FourCC
52
+ to_type target, *args
53
+ else
54
+ super target, *args
55
+ end
56
+ else
57
+ super name, *args
58
+ end
59
+ else
60
+ super name, *args
61
+ end
62
+ end
63
+
64
+ end
65
+
66
+ Frame_.class_eval { include FrameConversion }
67
+
68
+ Node.class_eval { include FrameConversion }
69
+
70
+ end
71
+
@@ -19,3 +19,5 @@ require 'multiarray'
19
19
  require 'hornetseye-frame/fourcc'
20
20
  require 'hornetseye-frame/frame'
21
21
  require 'hornetseye-frame/node'
22
+ require 'hornetseye-frame/shortcuts'
23
+
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 3
7
+ - 5
8
8
  - 0
9
- version: 0.3.0
9
+ version: 0.5.0
10
10
  platform: ruby
11
11
  authors:
12
12
  - Jan Wedekind
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-10-05 00:00:00 +01:00
17
+ date: 2010-10-07 00:00:00 +01:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -71,6 +71,7 @@ files:
71
71
  - README.md
72
72
  - COPYING
73
73
  - .document
74
+ - lib/hornetseye-frame/shortcuts.rb
74
75
  - lib/hornetseye-frame/fourcc.rb
75
76
  - lib/hornetseye-frame/frame.rb
76
77
  - lib/hornetseye-frame/node.rb