hornetseye-dc1394 0.2.1 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -7,7 +7,7 @@ require 'rake/loaders/makefile'
7
7
  require 'rbconfig'
8
8
 
9
9
  PKG_NAME = 'hornetseye-dc1394'
10
- PKG_VERSION = '0.2.1'
10
+ PKG_VERSION = '0.3.0'
11
11
  CFG = RbConfig::CONFIG
12
12
  CXX = ENV[ 'CXX' ] || 'g++'
13
13
  RB_FILES = FileList[ 'lib/**/*.rb' ]
data/ext/dc1394.cc CHANGED
@@ -34,7 +34,22 @@ DC1394::DC1394(void) throw (Error):
34
34
 
35
35
  DC1394::~DC1394(void)
36
36
  {
37
- dc1394_free( m_dc1394 );
37
+ close();
38
+ }
39
+
40
+ void DC1394::close(void)
41
+ {
42
+ if ( m_dc1394 != NULL ) {
43
+ dc1394_free( m_dc1394 );
44
+ m_dc1394 = NULL;
45
+ };
46
+ }
47
+
48
+ dc1394_t *DC1394::get(void) throw (Error)
49
+ {
50
+ ERRORMACRO( m_dc1394 != NULL, Error, , "DC1394 device is closed. Did you call "
51
+ "\"close\" before?" );
52
+ return m_dc1394;
38
53
  }
39
54
 
40
55
  string DC1394::inspect(void) const
@@ -49,6 +64,7 @@ VALUE DC1394::registerRubyClass( VALUE module )
49
64
  cRubyClass = rb_define_class_under( module, "DC1394", rb_cObject );
50
65
  rb_define_singleton_method( cRubyClass, "new",
51
66
  RUBY_METHOD_FUNC( wrapNew ), 0 );
67
+ rb_define_method( cRubyClass, "close", RUBY_METHOD_FUNC( wrapClose ), 0 );
52
68
  return cRubyClass;
53
69
  }
54
70
 
@@ -70,3 +86,10 @@ VALUE DC1394::wrapNew( VALUE rbClass )
70
86
  return retVal;
71
87
  }
72
88
 
89
+ VALUE DC1394::wrapClose( VALUE rbSelf )
90
+ {
91
+ DC1394Ptr *self; Data_Get_Struct( rbSelf, DC1394Ptr, self );
92
+ (*self)->close();
93
+ return rbSelf;
94
+ }
95
+
data/ext/dc1394.hh CHANGED
@@ -26,11 +26,13 @@ public:
26
26
  DC1394(void) throw (Error);
27
27
  virtual ~DC1394(void);
28
28
  std::string inspect(void) const;
29
- dc1394_t *get(void) { return m_dc1394; }
29
+ void close(void);
30
+ dc1394_t *get(void) throw (Error);
30
31
  static VALUE cRubyClass;
31
32
  static VALUE registerRubyClass( VALUE module );
32
33
  static void deleteRubyObject( void *ptr );
33
34
  static VALUE wrapNew( VALUE rbClass );
35
+ static VALUE wrapClose( VALUE rbSelf );
34
36
  protected:
35
37
  dc1394_t *m_dc1394;
36
38
  };
data/ext/dc1394input.cc CHANGED
@@ -304,17 +304,28 @@ VALUE DC1394Input::registerRubyClass( VALUE module )
304
304
  rb_define_const( cRubyClass, "SPEED_800", INT2NUM( DC1394_ISO_SPEED_800 ) );
305
305
  rb_define_const( cRubyClass, "SPEED_1600", INT2NUM( DC1394_ISO_SPEED_1600 ) );
306
306
  rb_define_const( cRubyClass, "SPEED_3200", INT2NUM( DC1394_ISO_SPEED_3200 ) );
307
- rb_define_const( cRubyClass, "MONO8", INT2NUM( DC1394_COLOR_CODING_MONO8 ) );
308
- rb_define_const( cRubyClass, "YUV411", INT2NUM( DC1394_COLOR_CODING_YUV411 ) );
309
- rb_define_const( cRubyClass, "YUV422", INT2NUM( DC1394_COLOR_CODING_YUV422 ) );
310
- rb_define_const( cRubyClass, "YUV444", INT2NUM( DC1394_COLOR_CODING_YUV444 ) );
311
- rb_define_const( cRubyClass, "RGB8", INT2NUM( DC1394_COLOR_CODING_RGB8 ) );
312
- rb_define_const( cRubyClass, "MONO16", INT2NUM( DC1394_COLOR_CODING_MONO16 ) );
313
- rb_define_const( cRubyClass, "RGB16", INT2NUM( DC1394_COLOR_CODING_RGB16 ) );
314
- rb_define_const( cRubyClass, "MONO16S", INT2NUM( DC1394_COLOR_CODING_MONO16S ) );
315
- rb_define_const( cRubyClass, "RGB16S", INT2NUM( DC1394_COLOR_CODING_RGB16S ) );
316
- rb_define_const( cRubyClass, "RAW8", INT2NUM( DC1394_COLOR_CODING_RAW8 ) );
317
- rb_define_const( cRubyClass, "RAW16", INT2NUM( DC1394_COLOR_CODING_RAW16 ) );
307
+ rb_define_const( cRubyClass, "MODE_MONO8",
308
+ INT2NUM( DC1394_COLOR_CODING_MONO8 ) );
309
+ rb_define_const( cRubyClass, "MODE_YUV411",
310
+ INT2NUM( DC1394_COLOR_CODING_YUV411 ) );
311
+ rb_define_const( cRubyClass, "MODE_YUV422",
312
+ INT2NUM( DC1394_COLOR_CODING_YUV422 ) );
313
+ rb_define_const( cRubyClass, "MODE_YUV444",
314
+ INT2NUM( DC1394_COLOR_CODING_YUV444 ) );
315
+ rb_define_const( cRubyClass, "MODE_RGB8",
316
+ INT2NUM( DC1394_COLOR_CODING_RGB8 ) );
317
+ rb_define_const( cRubyClass, "MODE_MONO16",
318
+ INT2NUM( DC1394_COLOR_CODING_MONO16 ) );
319
+ rb_define_const( cRubyClass, "MODE_RGB16",
320
+ INT2NUM( DC1394_COLOR_CODING_RGB16 ) );
321
+ rb_define_const( cRubyClass, "MODE_MONO16S",
322
+ INT2NUM( DC1394_COLOR_CODING_MONO16S ) );
323
+ rb_define_const( cRubyClass, "MODE_RGB16S",
324
+ INT2NUM( DC1394_COLOR_CODING_RGB16S ) );
325
+ rb_define_const( cRubyClass, "MODE_RAW8",
326
+ INT2NUM( DC1394_COLOR_CODING_RAW8 ) );
327
+ rb_define_const( cRubyClass, "MODE_RAW16",
328
+ INT2NUM( DC1394_COLOR_CODING_RAW16 ) );
318
329
  rb_define_const( cRubyClass, "FRAMERATE_1_875", INT2NUM( DC1394_FRAMERATE_1_875 ) );
319
330
  rb_define_const( cRubyClass, "FRAMERATE_3_75" , INT2NUM( DC1394_FRAMERATE_3_75 ) );
320
331
  rb_define_const( cRubyClass, "FRAMERATE_7_5" , INT2NUM( DC1394_FRAMERATE_7_5 ) );
@@ -26,26 +26,32 @@ module Hornetseye
26
26
  alias_method :orig_new, :new
27
27
 
28
28
  def new( node = 0, speed = SPEED_400, frame_rate = nil, &action )
29
- @@dc1394 = DC1394.new unless @@dc1394
30
- orig_new @@dc1394, node, speed, frame_rate != nil,
31
- frame_rate || FRAMERATE_240 do |modes|
32
- map = { MONO8 => UBYTE,
33
- YUV422 => UYVY,
34
- RGB8 => UBYTERGB,
35
- MONO16 => USINT }
36
- frame_types, index = [], []
37
- modes.each_with_index do |mode,i|
38
- target = map[ mode.first ]
39
- if target
40
- frame_types.push Hornetseye::Frame( target, *mode[ 1 .. 2 ] )
41
- index.push i
29
+ dc1394 = @@dc1394 || DC1394.new
30
+ begin
31
+ retval = orig_new dc1394, node, speed, frame_rate != nil,
32
+ frame_rate || FRAMERATE_240 do |modes|
33
+ map = { MODE_MONO8 => UBYTE,
34
+ MODE_YUV422 => UYVY,
35
+ MODE_RGB8 => UBYTERGB,
36
+ MODE_MONO16 => USINT }
37
+ frame_types, index = [], []
38
+ modes.each_with_index do |mode,i|
39
+ target = map[ mode.first ]
40
+ if target
41
+ frame_types.push Hornetseye::Frame( target, *mode[ 1 .. 2 ] )
42
+ index.push i
43
+ end
42
44
  end
45
+ desired = action.call frame_types
46
+ unless frame_types.member? desired
47
+ raise "Frame type #{desired} not supported by camera"
48
+ end
49
+ index[ frame_types.index( desired ) ]
43
50
  end
44
- desired = action.call frame_types
45
- unless frame_types.member? desired
46
- raise "Frame type #{desired} not supported by camera"
47
- end
48
- index[ frame_types.index( desired ) ]
51
+ @@dc1394 = dc1394
52
+ retval
53
+ ensure
54
+ dc1394.close unless @@dc1394
49
55
  end
50
56
  end
51
57
 
metadata CHANGED
@@ -4,9 +4,9 @@ version: !ruby/object:Gem::Version
4
4
  prerelease: false
5
5
  segments:
6
6
  - 0
7
- - 2
8
- - 1
9
- version: 0.2.1
7
+ - 3
8
+ - 0
9
+ version: 0.3.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-28 00:00:00 +01:00
17
+ date: 2010-11-20 00:00:00 +00:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency