ruby-opencv 0.0.15 → 0.0.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/ext/opencv/cvcapture.cpp +29 -3
- data/ext/opencv/cvcapture.h +13 -3
- data/lib/opencv/version.rb +1 -1
- data/ruby-opencv.gemspec +4 -4
- data/test/test_cvcapture.rb +8 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4167570217e86b8b50a744e19375a4e6691f879a
|
4
|
+
data.tar.gz: 3bb849ae998b8330cecfcc29ba8e2cd164b0168d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a5a43d61e47c1364e42b0a33b27b589939caace91b878dcfda4174a02d0be78ac631e39c20e7b2af55766089bb01abd1c8be8a8f701542d36ef3806ddb121fb3
|
7
|
+
data.tar.gz: a577c48d4261d033b25fd5e72e1f108db091920604ab95d1bc7482ba129303d2bc6641ca8c5e993fa41e73c6c65588f331001eec1f84aaf5038855e60f8cd536
|
data/ext/opencv/cvcapture.cpp
CHANGED
@@ -27,8 +27,12 @@ rb_class()
|
|
27
27
|
void
|
28
28
|
cvcapture_free(void *ptr)
|
29
29
|
{
|
30
|
-
if (ptr)
|
31
|
-
|
30
|
+
if (ptr) {
|
31
|
+
sCvCapture* scap = (sCvCapture*)ptr;
|
32
|
+
if (scap->opened)
|
33
|
+
cvReleaseCapture(&scap->ptr);
|
34
|
+
delete scap;
|
35
|
+
}
|
32
36
|
}
|
33
37
|
|
34
38
|
/*
|
@@ -49,6 +53,7 @@ rb_open(int argc, VALUE *argv, VALUE self)
|
|
49
53
|
VALUE device;
|
50
54
|
rb_scan_args(argc, argv, "01", &device);
|
51
55
|
CvCapture *capture = 0;
|
56
|
+
sCvCapture *scap = new sCvCapture();
|
52
57
|
try {
|
53
58
|
switch (TYPE(device)) {
|
54
59
|
case T_STRING:
|
@@ -74,7 +79,27 @@ rb_open(int argc, VALUE *argv, VALUE self)
|
|
74
79
|
}
|
75
80
|
if (!capture)
|
76
81
|
rb_raise(rb_eStandardError, "Invalid capture format.");
|
77
|
-
|
82
|
+
scap->ptr = capture;
|
83
|
+
scap->opened = true;
|
84
|
+
return Data_Wrap_Struct(rb_klass, 0, cvcapture_free, scap);
|
85
|
+
}
|
86
|
+
|
87
|
+
/*
|
88
|
+
* Releases an opened video file or a capturing device
|
89
|
+
* @return [boolean] False if the device was already closed
|
90
|
+
*/
|
91
|
+
|
92
|
+
VALUE
|
93
|
+
rb_close(VALUE self)
|
94
|
+
{
|
95
|
+
sCvCapture *scap;
|
96
|
+
Data_Get_Struct(self, sCvCapture, scap);
|
97
|
+
if (scap->opened) {
|
98
|
+
scap->opened = false;
|
99
|
+
cvReleaseCapture(&scap->ptr);
|
100
|
+
return true;
|
101
|
+
} else
|
102
|
+
return false;
|
78
103
|
}
|
79
104
|
|
80
105
|
/*
|
@@ -570,6 +595,7 @@ init_ruby_class()
|
|
570
595
|
rb_hash_aset(video_interface, ID2SYM(rb_intern("quicktime")), INT2FIX(CV_CAP_QT));
|
571
596
|
|
572
597
|
rb_define_singleton_method(rb_klass, "open", RUBY_METHOD_FUNC(rb_open), -1);
|
598
|
+
rb_define_method(rb_klass, "close", RUBY_METHOD_FUNC(rb_close), 0);
|
573
599
|
|
574
600
|
rb_define_method(rb_klass, "grab", RUBY_METHOD_FUNC(rb_grab), 0);
|
575
601
|
rb_define_method(rb_klass, "retrieve", RUBY_METHOD_FUNC(rb_retrieve), 0);
|
data/ext/opencv/cvcapture.h
CHANGED
@@ -16,6 +16,12 @@
|
|
16
16
|
#define __NAMESPACE_END_CVCAPTURE }
|
17
17
|
|
18
18
|
__NAMESPACE_BEGIN_OPENCV
|
19
|
+
|
20
|
+
typedef struct {
|
21
|
+
CvCapture* ptr;
|
22
|
+
bool opened;
|
23
|
+
} sCvCapture;
|
24
|
+
|
19
25
|
__NAMESPACE_BEGIN_CVCAPTURE
|
20
26
|
|
21
27
|
|
@@ -26,6 +32,8 @@ void init_ruby_class();
|
|
26
32
|
void cvcapture_free(void *ptr);
|
27
33
|
VALUE rb_open(int argc, VALUE *argv, VALUE klass);
|
28
34
|
|
35
|
+
VALUE rb_close(VALUE self);
|
36
|
+
|
29
37
|
VALUE rb_grab(VALUE self);
|
30
38
|
VALUE rb_retrieve(VALUE self);
|
31
39
|
VALUE rb_query(VALUE self);
|
@@ -62,9 +70,11 @@ __NAMESPACE_END_CVCAPTURE
|
|
62
70
|
|
63
71
|
inline CvCapture*
|
64
72
|
CVCAPTURE(VALUE object) {
|
65
|
-
|
66
|
-
Data_Get_Struct(object,
|
67
|
-
|
73
|
+
sCvCapture *scap;
|
74
|
+
Data_Get_Struct(object, sCvCapture, scap);
|
75
|
+
if (!scap->opened)
|
76
|
+
rb_raise(rb_eIOError, "Resource is not available!");
|
77
|
+
return scap->ptr;
|
68
78
|
}
|
69
79
|
|
70
80
|
__NAMESPACE_END_OPENCV
|
data/lib/opencv/version.rb
CHANGED
data/ruby-opencv.gemspec
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
# -*- encoding: utf-8 -*-
|
2
|
-
# stub: ruby-opencv 0.0.
|
2
|
+
# stub: ruby-opencv 0.0.16.20160417000540 ruby lib
|
3
3
|
# stub: ext/opencv/extconf.rb
|
4
4
|
|
5
5
|
Gem::Specification.new do |s|
|
6
6
|
s.name = "ruby-opencv".freeze
|
7
|
-
s.version = "0.0.
|
7
|
+
s.version = "0.0.16.20160417000540"
|
8
8
|
|
9
9
|
s.required_rubygems_version = Gem::Requirement.new(">= 0".freeze) if s.respond_to? :required_rubygems_version=
|
10
10
|
s.require_paths = ["lib".freeze]
|
11
11
|
s.authors = ["lsxi".freeze, "ser1zw".freeze, "pcting".freeze]
|
12
|
-
s.date = "2016-04-
|
12
|
+
s.date = "2016-04-16"
|
13
13
|
s.description = "ruby-opencv is a wrapper of OpenCV for Ruby. It helps you to write computer vision programs (e.g. detecting faces from pictures) with Ruby.".freeze
|
14
14
|
s.email = ["masakazu.yonekura@gmail.com".freeze, "azariahsawtikes@gmail.com".freeze, "pcting@gmail.com".freeze]
|
15
15
|
s.extensions = ["ext/opencv/extconf.rb".freeze]
|
@@ -18,7 +18,7 @@ Gem::Specification.new do |s|
|
|
18
18
|
s.homepage = "https://github.com/ruby-opencv/ruby-opencv/".freeze
|
19
19
|
s.licenses = ["The BSD License".freeze]
|
20
20
|
s.rdoc_options = ["--main".freeze, "README.md".freeze]
|
21
|
-
s.rubygems_version = "2.6.
|
21
|
+
s.rubygems_version = "2.6.3".freeze
|
22
22
|
s.summary = "OpenCV wrapper for Ruby".freeze
|
23
23
|
|
24
24
|
if s.respond_to? :specification_version then
|
data/test/test_cvcapture.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-opencv
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- lsxi
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2016-04-
|
13
|
+
date: 2016-04-16 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rdoc
|
@@ -346,7 +346,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
346
346
|
version: '0'
|
347
347
|
requirements: []
|
348
348
|
rubyforge_project:
|
349
|
-
rubygems_version: 2.6.
|
349
|
+
rubygems_version: 2.6.3
|
350
350
|
signing_key:
|
351
351
|
specification_version: 4
|
352
352
|
summary: OpenCV wrapper for Ruby
|