hornetseye-dc1394 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +14 -14
- data/ext/dc1394input.cc +30 -29
- data/ext/dc1394input.hh +1 -1
- data/ext/dc1394select.cc +2 -2
- data/ext/dc1394select.hh +1 -1
- metadata +3 -3
data/Rakefile
CHANGED
@@ -7,15 +7,15 @@ require 'rake/loaders/makefile'
|
|
7
7
|
require 'rbconfig'
|
8
8
|
|
9
9
|
PKG_NAME = 'hornetseye-dc1394'
|
10
|
-
PKG_VERSION = '0.2.
|
10
|
+
PKG_VERSION = '0.2.1'
|
11
|
+
CFG = RbConfig::CONFIG
|
11
12
|
CXX = ENV[ 'CXX' ] || 'g++'
|
12
|
-
STRIP = ENV[ 'STRIP' ] || 'strip'
|
13
13
|
RB_FILES = FileList[ 'lib/**/*.rb' ]
|
14
14
|
CC_FILES = FileList[ 'ext/*.cc' ]
|
15
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
|
-
SO_FILE = "ext/#{PKG_NAME.tr '\-', '_'}
|
18
|
+
SO_FILE = "ext/#{PKG_NAME.tr '\-', '_'}.#{CFG[ 'DLEXT' ]}"
|
19
19
|
PKG_FILES = [ 'Rakefile', 'README.md', 'COPYING', '.document' ] +
|
20
20
|
RB_FILES + CC_FILES + HH_FILES + TS_FILES + TC_FILES
|
21
21
|
BIN_FILES = [ 'README.md', 'COPYING', '.document', SO_FILE ] +
|
@@ -27,17 +27,18 @@ EMAIL = %q{jan@wedesoft.de}
|
|
27
27
|
HOMEPAGE = %q{http://wedesoft.github.com/hornetseye-dc1394/}
|
28
28
|
|
29
29
|
OBJ = CC_FILES.ext 'o'
|
30
|
-
$CXXFLAGS =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
"-I#{RbConfig::CONFIG[ 'rubyhdrdir' ]}/#{RbConfig::CONFIG[ 'arch' ]}"
|
30
|
+
$CXXFLAGS = "-DNDEBUG #{CFG[ 'CPPFLAGS' ]} #{CFG[ 'CFLAGS' ]}"
|
31
|
+
if CFG[ 'rubyhdrdir' ]
|
32
|
+
$CXXFLAGS = "#{$CXXFLAGS} -I#{CFG[ 'rubyhdrdir' ]} " +
|
33
|
+
"-I#{CFG[ 'rubyhdrdir' ]}/#{CFG[ 'arch' ]}"
|
35
34
|
else
|
36
|
-
$CXXFLAGS = "#{$CXXFLAGS} -I#{
|
35
|
+
$CXXFLAGS = "#{$CXXFLAGS} -I#{CFG[ 'archdir' ]}"
|
37
36
|
end
|
38
|
-
$LIBRUBYARG =
|
39
|
-
|
40
|
-
$
|
37
|
+
$LIBRUBYARG = "-L#{CFG[ 'libdir' ]} #{CFG[ 'LIBRUBYARG' ]} #{CFG[ 'LDFLAGS' ]} " +
|
38
|
+
"#{CFG[ 'SOLIBS' ]} #{CFG[ 'DLDLIBS' ]}"
|
39
|
+
$SITELIBDIR = CFG[ 'sitelibdir' ]
|
40
|
+
$SITEARCHDIR = CFG[ 'sitearchdir' ]
|
41
|
+
$LDSHARED = CFG[ 'LDSHARED' ][ CFG[ 'LDSHARED' ].index( ' ' ) .. -1 ]
|
41
42
|
|
42
43
|
task :default => :all
|
43
44
|
|
@@ -46,7 +47,6 @@ task :all => [ SO_FILE ]
|
|
46
47
|
|
47
48
|
file SO_FILE => OBJ do |t|
|
48
49
|
sh "#{CXX} -shared -o #{t.name} #{OBJ} -ldc1394 #{$LIBRUBYARG}"
|
49
|
-
sh "#{STRIP} --strip-all #{t.name}"
|
50
50
|
end
|
51
51
|
|
52
52
|
task :test => [ SO_FILE ]
|
@@ -171,7 +171,7 @@ rule '.o' => '.cc' do |t|
|
|
171
171
|
end
|
172
172
|
|
173
173
|
file ".depends.mf" do |t|
|
174
|
-
sh "g++ -MM #{
|
174
|
+
sh "g++ -MM #{CC_FILES.join ' '} | " +
|
175
175
|
"sed -e :a -e N -e 's/\\n/\\$/g' -e ta | " +
|
176
176
|
"sed -e 's/ *\\\\\\$ */ /g' -e 's/\\$/\\n/g' | sed -e 's/^/ext\\//' > #{t.name}"
|
177
177
|
end
|
data/ext/dc1394input.cc
CHANGED
@@ -25,7 +25,7 @@ using namespace std;
|
|
25
25
|
|
26
26
|
VALUE DC1394Input::cRubyClass = Qnil;
|
27
27
|
|
28
|
-
DC1394Input::DC1394Input( DC1394Ptr dc1394, int node, dc1394speed_t speed,
|
28
|
+
DC1394Input::DC1394Input( DC1394Ptr dc1394, unsigned int node, dc1394speed_t speed,
|
29
29
|
DC1394SelectPtr select, bool forceFrameRate,
|
30
30
|
dc1394framerate_t frameRate )
|
31
31
|
throw (Error):
|
@@ -42,7 +42,7 @@ DC1394Input::DC1394Input( DC1394Ptr dc1394, int node, dc1394speed_t speed,
|
|
42
42
|
"'ieee1394','raw1394' and 'ohci1394' are loaded and whether you "
|
43
43
|
"have read/write permission on \"/dev/raw1394\". Also make sure "
|
44
44
|
"that the camera is connected and powered up." );
|
45
|
-
ERRORMACRO( node
|
45
|
+
ERRORMACRO( node < list->num, Error, ,
|
46
46
|
"Camera node number " << node << " out of range. The range is "
|
47
47
|
"[ 0; " << list->num << " )" );
|
48
48
|
m_camera = dc1394_camera_new( dc1394->get(), list->ids[ node ].guid );
|
@@ -52,20 +52,16 @@ DC1394Input::DC1394Input( DC1394Ptr dc1394, int node, dc1394speed_t speed,
|
|
52
52
|
<< setbase( 10 ) << ")" );
|
53
53
|
dc1394video_modes_t videoModes;
|
54
54
|
err = dc1394_video_get_supported_modes( m_camera, &videoModes );
|
55
|
-
for ( int i=0; i<videoModes.num; i++ ) {
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
select->add( coding, width, height );
|
63
|
-
} else {
|
64
|
-
ERRORMACRO( false, Error, , "Scalable video modes not implemented yet" );
|
65
|
-
};
|
55
|
+
for ( unsigned int i=0; i<videoModes.num; i++ ) {
|
56
|
+
dc1394video_mode_t videoMode = videoModes.modes[i];
|
57
|
+
dc1394color_coding_t coding;
|
58
|
+
dc1394_get_color_coding_from_video_mode( m_camera, videoMode, &coding );
|
59
|
+
unsigned int width, height;
|
60
|
+
dc1394_get_image_size_from_video_mode( m_camera, videoMode, &width, &height );
|
61
|
+
select->add( coding, width, height );
|
66
62
|
};
|
67
|
-
int selection = select->make();
|
68
|
-
ERRORMACRO( selection
|
63
|
+
unsigned int selection = select->make();
|
64
|
+
ERRORMACRO( selection < videoModes.num, Error, ,
|
69
65
|
"Index of selected video mode out of range" );
|
70
66
|
dc1394video_mode_t videoMode = videoModes.modes[ selection ];
|
71
67
|
err = dc1394_video_set_iso_speed( m_camera, speed );
|
@@ -89,19 +85,24 @@ DC1394Input::DC1394Input( DC1394Ptr dc1394, int node, dc1394speed_t speed,
|
|
89
85
|
<< " not implemented yet" );
|
90
86
|
};
|
91
87
|
dc1394_get_image_size_from_video_mode( m_camera, videoMode, &m_width, &m_height );
|
92
|
-
if (
|
93
|
-
|
94
|
-
|
95
|
-
<< dc1394_error_get_string( err ) );
|
88
|
+
if ( dc1394_is_video_mode_scalable( videoMode ) ) {
|
89
|
+
ERRORMACRO( !forceFrameRate, Error, , "Cannot set framerate in format6 or "
|
90
|
+
"format7 mode" );
|
96
91
|
} else {
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
92
|
+
if ( forceFrameRate ) {
|
93
|
+
err = dc1394_video_set_framerate( m_camera, frameRate );
|
94
|
+
ERRORMACRO( err == DC1394_SUCCESS, Error, , "Error setting framerate: "
|
95
|
+
<< dc1394_error_get_string( err ) );
|
96
|
+
} else {
|
97
|
+
dc1394framerates_t frameRates;
|
98
|
+
err = dc1394_video_get_supported_framerates( m_camera, videoMode, &frameRates );
|
99
|
+
ERRORMACRO( err == DC1394_SUCCESS, Error, , "Error querying supported frame "
|
100
|
+
"rates: " << dc1394_error_get_string( err ) );
|
101
|
+
err = dc1394_video_set_framerate( m_camera,
|
102
|
+
frameRates.framerates[ frameRates.num - 1 ] );
|
103
|
+
ERRORMACRO( err == DC1394_SUCCESS, Error, , "Error setting framerate: "
|
104
|
+
<< dc1394_error_get_string( err ) );
|
105
|
+
};
|
105
106
|
};
|
106
107
|
err = dc1394_capture_setup( m_camera, 4, DC1394_CAPTURE_FLAGS_DEFAULT );
|
107
108
|
ERRORMACRO( err == DC1394_SUCCESS, Error, , "Could not setup camera (video mode "
|
@@ -419,7 +420,7 @@ VALUE DC1394Input::wrapNew( VALUE rbClass, VALUE rbDC1394, VALUE rbNode,
|
|
419
420
|
try {
|
420
421
|
DC1394Ptr *dc1394; Data_Get_Struct( rbDC1394, DC1394Ptr, dc1394 );
|
421
422
|
DC1394SelectPtr select( new DC1394Select );
|
422
|
-
DC1394InputPtr ptr( new DC1394Input( *dc1394,
|
423
|
+
DC1394InputPtr ptr( new DC1394Input( *dc1394, NUM2UINT( rbNode ),
|
423
424
|
(dc1394speed_t)NUM2INT( rbSpeed ),
|
424
425
|
select, rbForceFrameRate != Qfalse,
|
425
426
|
(dc1394framerate_t)NUM2INT( rbFrameRate ) ) );
|
@@ -556,7 +557,7 @@ VALUE DC1394Input::wrapFeatureModes( VALUE rbSelf, VALUE rbFeature )
|
|
556
557
|
dc1394feature_modes_t retVal = (*self)->
|
557
558
|
featureModes( (dc1394feature_t)NUM2INT( rbFeature ) );
|
558
559
|
rbRetVal = rb_ary_new();
|
559
|
-
for ( int i=0; i<retVal.num; i++ )
|
560
|
+
for ( unsigned int i=0; i<retVal.num; i++ )
|
560
561
|
rb_ary_push( rbRetVal, INT2NUM( retVal.modes[i] ) );
|
561
562
|
} catch ( std::exception &e ) {
|
562
563
|
rb_raise( rb_eRuntimeError, "%s", e.what() );
|
data/ext/dc1394input.hh
CHANGED
@@ -25,7 +25,7 @@
|
|
25
25
|
class DC1394Input
|
26
26
|
{
|
27
27
|
public:
|
28
|
-
DC1394Input( DC1394Ptr dc1394, int node, dc1394speed_t speed,
|
28
|
+
DC1394Input( DC1394Ptr dc1394, unsigned int node, dc1394speed_t speed,
|
29
29
|
DC1394SelectPtr select, bool forceFrameRate,
|
30
30
|
dc1394framerate_t frameRate ) throw (Error);
|
31
31
|
virtual ~DC1394Input(void);
|
data/ext/dc1394select.cc
CHANGED
@@ -37,7 +37,7 @@ static VALUE yield( VALUE arg )
|
|
37
37
|
return rb_yield( arg );
|
38
38
|
}
|
39
39
|
|
40
|
-
int DC1394Select::make(void) throw (Error)
|
40
|
+
unsigned int DC1394Select::make(void) throw (Error)
|
41
41
|
{
|
42
42
|
int error;
|
43
43
|
VALUE rbRetVal = rb_protect( yield, m_rbArray, &error );
|
@@ -48,7 +48,7 @@ int DC1394Select::make(void) throw (Error)
|
|
48
48
|
};
|
49
49
|
ERRORMACRO( TYPE( rbRetVal ) == T_FIXNUM, Error, , "Block must return a value of "
|
50
50
|
"type 'Fixnum'" );
|
51
|
-
return
|
51
|
+
return NUM2UINT(rbRetVal);
|
52
52
|
}
|
53
53
|
|
54
54
|
VALUE DC1394Select::wrapRescue( VALUE rbValue )
|
data/ext/dc1394select.hh
CHANGED
@@ -27,7 +27,7 @@ public:
|
|
27
27
|
DC1394Select(void) throw (Error);
|
28
28
|
virtual ~DC1394Select(void);
|
29
29
|
void add( dc1394color_coding_t coding, unsigned int width, unsigned int height );
|
30
|
-
int make(void) throw (Error);
|
30
|
+
unsigned int make(void) throw (Error);
|
31
31
|
static VALUE wrapRescue( VALUE rbValue );
|
32
32
|
protected:
|
33
33
|
VALUE m_rbArray;
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 2
|
8
|
-
-
|
9
|
-
version: 0.2.
|
8
|
+
- 1
|
9
|
+
version: 0.2.1
|
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-
|
17
|
+
date: 2010-10-28 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|