hornetseye-v4l2 0.3.3 → 0.3.4
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 +1 -1
- data/ext/v4l2input.cc +14 -8
- data/ext/v4l2select.cc +11 -12
- data/ext/v4l2select.hh +5 -4
- data/lib/hornetseye-v4l2/v4l2input.rb +8 -10
- metadata +3 -3
data/Rakefile
CHANGED
data/ext/v4l2input.cc
CHANGED
@@ -64,6 +64,9 @@ V4L2Input::V4L2Input( const std::string &device, V4L2SelectPtr select ) throw (E
|
|
64
64
|
format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
65
65
|
format.index = formatIndex++;
|
66
66
|
int r = xioctl( VIDIOC_ENUM_FMT, &format );
|
67
|
+
#ifndef NDEBUG
|
68
|
+
cerr << "Requesting format " << (formatIndex - 1) << " with result " << r << endl;
|
69
|
+
#endif
|
67
70
|
if ( r != 0 ) break;
|
68
71
|
unsigned int frameSizeIndex = 0;
|
69
72
|
while ( true ) {
|
@@ -72,6 +75,10 @@ V4L2Input::V4L2Input( const std::string &device, V4L2SelectPtr select ) throw (E
|
|
72
75
|
pix.pixel_format = format.pixelformat;
|
73
76
|
pix.index = frameSizeIndex++;
|
74
77
|
int r = xioctl( VIDIOC_ENUM_FRAMESIZES, &pix );
|
78
|
+
#ifndef NDEBUG
|
79
|
+
cerr << "Requesting frame size " << (frameSizeIndex - 1) << " for format "
|
80
|
+
<< (formatIndex - 1) << " with result " << r << endl;
|
81
|
+
#endif
|
75
82
|
if ( r != 0 ) break;
|
76
83
|
if ( pix.type == V4L2_FRMSIZE_TYPE_DISCRETE )
|
77
84
|
select->add( format.pixelformat, pix.discrete.width, pix.discrete.height );
|
@@ -90,18 +97,17 @@ V4L2Input::V4L2Input( const std::string &device, V4L2SelectPtr select ) throw (E
|
|
90
97
|
};
|
91
98
|
};
|
92
99
|
};
|
93
|
-
|
94
|
-
unsigned int coding = select->coding(
|
100
|
+
select->make();
|
101
|
+
unsigned int coding = select->coding();
|
95
102
|
#ifndef NDEBUG
|
96
|
-
cerr << "
|
97
|
-
<< "
|
98
|
-
<< "
|
99
|
-
<< "h = " << select->height( selection ) << endl;
|
103
|
+
cerr << "coding = " << select->coding() << endl
|
104
|
+
<< "w = " << select->width() << endl
|
105
|
+
<< "h = " << select->height() << endl;
|
100
106
|
#endif
|
101
107
|
m_format.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
102
108
|
m_format.fmt.pix.field = V4L2_FIELD_NONE;
|
103
|
-
m_format.fmt.pix.width = select->width(
|
104
|
-
m_format.fmt.pix.height = select->height(
|
109
|
+
m_format.fmt.pix.width = select->width();
|
110
|
+
m_format.fmt.pix.height = select->height();
|
105
111
|
m_format.fmt.pix.pixelformat = coding;
|
106
112
|
m_format.fmt.pix.field = V4L2_FIELD_SEQ_TB;
|
107
113
|
ERRORMACRO( xioctl( VIDIOC_S_FMT, &m_format ) == 0, Error, ,
|
data/ext/v4l2select.cc
CHANGED
@@ -17,7 +17,7 @@
|
|
17
17
|
#include "v4l2select.hh"
|
18
18
|
|
19
19
|
V4L2Select::V4L2Select(void) throw (Error):
|
20
|
-
m_rbArray(rb_ary_new())
|
20
|
+
m_rbArray(rb_ary_new()), m_rbSelection(Qnil)
|
21
21
|
{
|
22
22
|
}
|
23
23
|
|
@@ -36,33 +36,32 @@ static VALUE yield( VALUE arg )
|
|
36
36
|
return rb_yield( arg );
|
37
37
|
}
|
38
38
|
|
39
|
-
|
39
|
+
void V4L2Select::make(void) throw (Error)
|
40
40
|
{
|
41
41
|
int error;
|
42
|
-
|
42
|
+
m_rbSelection = rb_protect( yield, m_rbArray, &error );
|
43
43
|
if ( error ) {
|
44
44
|
VALUE rbError = rb_funcall( rb_gv_get( "$!" ), rb_intern( "message" ), 0 );
|
45
45
|
ERRORMACRO( false, Error, , "Error in block to \"V4L2Input.new\": "
|
46
46
|
<< StringValuePtr( rbError ) );
|
47
47
|
};
|
48
|
-
ERRORMACRO( TYPE(
|
49
|
-
"type '
|
50
|
-
return NUM2UINT(rbRetVal);
|
48
|
+
ERRORMACRO( TYPE( m_rbSelection ) == T_ARRAY, Error, , "Block must return a value of "
|
49
|
+
"type 'Array'" );
|
51
50
|
}
|
52
51
|
|
53
|
-
unsigned int V4L2Select::coding(
|
52
|
+
unsigned int V4L2Select::coding(void)
|
54
53
|
{
|
55
|
-
return NUM2INT(
|
54
|
+
return NUM2INT(RARRAY_PTR(m_rbSelection)[ 0 ]);
|
56
55
|
}
|
57
56
|
|
58
|
-
unsigned int V4L2Select::width(
|
57
|
+
unsigned int V4L2Select::width(void)
|
59
58
|
{
|
60
|
-
return NUM2INT(
|
59
|
+
return NUM2INT(RARRAY_PTR(m_rbSelection)[ 1 ]);
|
61
60
|
}
|
62
61
|
|
63
|
-
unsigned int V4L2Select::height(
|
62
|
+
unsigned int V4L2Select::height(void)
|
64
63
|
{
|
65
|
-
return NUM2INT(
|
64
|
+
return NUM2INT(RARRAY_PTR(m_rbSelection)[ 2 ]);
|
66
65
|
}
|
67
66
|
|
68
67
|
VALUE V4L2Select::wrapRescue( VALUE rbValue )
|
data/ext/v4l2select.hh
CHANGED
@@ -26,13 +26,14 @@ public:
|
|
26
26
|
V4L2Select(void) throw (Error);
|
27
27
|
virtual ~V4L2Select(void);
|
28
28
|
void add( unsigned int coding, unsigned int width, unsigned int height );
|
29
|
-
|
30
|
-
unsigned int coding(
|
31
|
-
unsigned int width(
|
32
|
-
unsigned int height(
|
29
|
+
void make(void) throw (Error);
|
30
|
+
unsigned int coding(void);
|
31
|
+
unsigned int width(void);
|
32
|
+
unsigned int height(void);
|
33
33
|
static VALUE wrapRescue( VALUE rbValue );
|
34
34
|
protected:
|
35
35
|
VALUE m_rbArray;
|
36
|
+
VALUE m_rbSelection;
|
36
37
|
};
|
37
38
|
|
38
39
|
typedef boost::shared_ptr< V4L2Select > V4L2SelectPtr;
|
@@ -49,26 +49,24 @@ module Hornetseye
|
|
49
49
|
MODE_GREY => UBYTE,
|
50
50
|
MODE_RGB24 => UBYTERGB,
|
51
51
|
MODE_BGR24 => BGR }
|
52
|
-
frame_types
|
53
|
-
modes.each_with_index do |mode
|
54
|
-
target = map[
|
52
|
+
frame_types = []
|
53
|
+
modes.each_with_index do |mode|
|
54
|
+
target = map[mode.first]
|
55
55
|
if target
|
56
|
-
frame_types.push Hornetseye::Frame(
|
57
|
-
index.push i
|
56
|
+
frame_types.push Hornetseye::Frame(target, *mode[1 .. 2])
|
58
57
|
end
|
59
58
|
end
|
60
59
|
if action
|
61
60
|
desired = action.call frame_types
|
62
61
|
else
|
63
|
-
preference = [
|
62
|
+
preference = [I420, UYVY, YUY2, UBYTERGB, BGR, UBYTE]
|
64
63
|
desired = frame_types.sort_by do |mode|
|
65
64
|
[ -preference.index( mode.typecode ), mode.width * mode.height ]
|
66
65
|
end.last
|
67
66
|
end
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
index[ frame_types.index( desired ) ]
|
67
|
+
mode = map.invert[desired.typecode]
|
68
|
+
raise "Video mode #{desired.typecode} not supported" unless mode
|
69
|
+
[mode, desired.width, desired.height]
|
72
70
|
end
|
73
71
|
end
|
74
72
|
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 3
|
8
|
-
-
|
9
|
-
version: 0.3.
|
8
|
+
- 4
|
9
|
+
version: 0.3.4
|
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: 2011-06-
|
17
|
+
date: 2011-06-10 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|