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 +1 -1
- data/ext/dc1394.cc +24 -1
- data/ext/dc1394.hh +3 -1
- data/ext/dc1394input.cc +22 -11
- data/lib/hornetseye-dc1394/dc1394input.rb +24 -18
- metadata +4 -4
data/Rakefile
CHANGED
data/ext/dc1394.cc
CHANGED
@@ -34,7 +34,22 @@ DC1394::DC1394(void) throw (Error):
|
|
34
34
|
|
35
35
|
DC1394::~DC1394(void)
|
36
36
|
{
|
37
|
-
|
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
|
-
|
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, "
|
308
|
-
|
309
|
-
rb_define_const( cRubyClass, "
|
310
|
-
|
311
|
-
rb_define_const( cRubyClass,
|
312
|
-
|
313
|
-
rb_define_const( cRubyClass,
|
314
|
-
|
315
|
-
rb_define_const( cRubyClass,
|
316
|
-
|
317
|
-
rb_define_const( cRubyClass,
|
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
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
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
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
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-
|
17
|
+
date: 2010-11-20 00:00:00 +00:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|