hornetseye-v4l2 0.3.4 → 0.3.5
Sign up to get free protection for your applications and to get access to all the features.
- data/Rakefile +1 -1
- data/ext/v4l2input.cc +8 -4
- data/ext/v4l2input.hh +2 -2
- data/lib/hornetseye-v4l2/v4l2input.rb +3 -2
- metadata +3 -3
data/Rakefile
CHANGED
data/ext/v4l2input.cc
CHANGED
@@ -30,7 +30,8 @@ using namespace std;
|
|
30
30
|
|
31
31
|
VALUE V4L2Input::cRubyClass = Qnil;
|
32
32
|
|
33
|
-
V4L2Input::V4L2Input( const std::string &device,
|
33
|
+
V4L2Input::V4L2Input( const std::string &device, int channel,
|
34
|
+
V4L2SelectPtr select ) throw (Error):
|
34
35
|
m_device(device), m_fd(-1), m_io(IO_READ), m_frameUsed(false)
|
35
36
|
{
|
36
37
|
m_map[ 0 ] = MAP_FAILED;
|
@@ -57,6 +58,9 @@ V4L2Input::V4L2Input( const std::string &device, V4L2SelectPtr select ) throw (E
|
|
57
58
|
#endif
|
58
59
|
ERRORMACRO( capability.capabilities & V4L2_CAP_VIDEO_CAPTURE != 0,
|
59
60
|
Error, , m_device << " is no video capture device" );
|
61
|
+
ERRORMACRO( xioctl( VIDIOC_S_INPUT, &channel ) == 0, Error, ,
|
62
|
+
"Error selecting channel " << channel << " for device \""
|
63
|
+
<< m_device << "\"" );
|
60
64
|
unsigned int formatIndex = 0;
|
61
65
|
while ( true ) {
|
62
66
|
struct v4l2_fmtdesc format;
|
@@ -670,7 +674,7 @@ VALUE V4L2Input::registerRubyClass( VALUE module )
|
|
670
674
|
INT2NUM(V4L2_CID_VCENTER) );
|
671
675
|
rb_define_const( cRubyClass, "FEATURE_LASTP1",
|
672
676
|
INT2NUM(V4L2_CID_LASTP1) );
|
673
|
-
rb_define_singleton_method( cRubyClass, "new", RUBY_METHOD_FUNC( wrapNew ),
|
677
|
+
rb_define_singleton_method( cRubyClass, "new", RUBY_METHOD_FUNC( wrapNew ), 2 );
|
674
678
|
rb_define_method( cRubyClass, "close",
|
675
679
|
RUBY_METHOD_FUNC( wrapClose ), 0 );
|
676
680
|
rb_define_method( cRubyClass, "read",
|
@@ -707,13 +711,13 @@ void V4L2Input::deleteRubyObject( void *ptr )
|
|
707
711
|
delete (V4L2InputPtr *)ptr;
|
708
712
|
}
|
709
713
|
|
710
|
-
VALUE V4L2Input::wrapNew( VALUE rbClass, VALUE rbDevice )
|
714
|
+
VALUE V4L2Input::wrapNew( VALUE rbClass, VALUE rbDevice, VALUE rbChannel )
|
711
715
|
{
|
712
716
|
VALUE retVal = Qnil;
|
713
717
|
try {
|
714
718
|
rb_check_type( rbDevice, T_STRING );
|
715
719
|
V4L2SelectPtr select( new V4L2Select );
|
716
|
-
V4L2InputPtr ptr(
|
720
|
+
V4L2InputPtr ptr(new V4L2Input(StringValuePtr(rbDevice), NUM2INT(rbChannel), select));
|
717
721
|
retVal = Data_Wrap_Struct( rbClass, 0, deleteRubyObject,
|
718
722
|
new V4L2InputPtr( ptr ) );
|
719
723
|
} catch ( std::exception &e ) {
|
data/ext/v4l2input.hh
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
class V4L2Input
|
30
30
|
{
|
31
31
|
public:
|
32
|
-
V4L2Input( const std::string &device, V4L2SelectPtr select ) throw (Error);
|
32
|
+
V4L2Input( const std::string &device, int channel, V4L2SelectPtr select ) throw (Error);
|
33
33
|
virtual ~V4L2Input(void);
|
34
34
|
void close(void);
|
35
35
|
FramePtr read(void) throw (Error);
|
@@ -49,7 +49,7 @@ public:
|
|
49
49
|
static VALUE cRubyClass;
|
50
50
|
static VALUE registerRubyClass( VALUE module );
|
51
51
|
static void deleteRubyObject( void *ptr );
|
52
|
-
static VALUE wrapNew( VALUE rbClass, VALUE rbDevice );
|
52
|
+
static VALUE wrapNew( VALUE rbClass, VALUE rbDevice, VALUE rbChannel );
|
53
53
|
static VALUE wrapClose( VALUE rbSelf );
|
54
54
|
static VALUE wrapRead( VALUE rbSelf );
|
55
55
|
static VALUE wrapStatus( VALUE rbSelf );
|
@@ -39,10 +39,11 @@ module Hornetseye
|
|
39
39
|
# camera = V4L2Input.new { |modes| modes.last }
|
40
40
|
#
|
41
41
|
# @param [String] device The device file name.
|
42
|
+
# @param [Integer] channel Number of the input channel to use.
|
42
43
|
# @param [Proc] action An optional block for selecting the desired video mode.
|
43
44
|
# @return [V4L2Input] An object for accessing the camera.
|
44
|
-
def new( device = '/dev/video0', &action )
|
45
|
-
orig_new device do |modes|
|
45
|
+
def new( device = '/dev/video0', channel = 0, &action )
|
46
|
+
orig_new device, channel do |modes|
|
46
47
|
map = { MODE_UYVY => UYVY,
|
47
48
|
MODE_YUYV => YUY2,
|
48
49
|
MODE_YUV420 => I420,
|
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
|
+
- 5
|
9
|
+
version: 0.3.5
|
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-13 00:00:00 +01:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|