ruby-opencv 0.0.13 → 0.0.14.pre

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a0ff56636b66427b7c48c3f19c3fa394856e24a4
4
- data.tar.gz: afca089849bc463f2e15bab8b80c2d156dc1b6e8
3
+ metadata.gz: 71aaaae8164e4c82e1c7c4a3b116e8787fcbb0e1
4
+ data.tar.gz: 95a6a2a13df382c9d67e756fb14a077e1b28502d
5
5
  SHA512:
6
- metadata.gz: 69511aeffb43ce83e86b922104378974f58081b233a4cdca7f410b5a532861323f34e4eb3efb128439535ef5544c158263cd2bd93fbc2eaa72fe03b24bcf63c2
7
- data.tar.gz: b965437dcc82b4343fb78d6fa3274bea8f19f177d4656b01e4637112f0bc179f43f65b99d728a15bb986a91931dc32a08afb1d21017d88ee241fd854b75ab5e1
6
+ metadata.gz: 2a1ec32344fb24d00f0fb7c723cfcc432caa10198264b84fe4e592dae316f1d8abc0a6abf6af263597f332b540b40331080c0655f59531a262130cb253013723
7
+ data.tar.gz: a5c995d554674fd4bb3de6e419106b095ea216aba738c070b6c16fdcf2ccff32230bf25ee3557e1439bcdab3b8d0bb0b98fd8e08d4d2ef6a26df91c1e5fc9d2e
data/README.md CHANGED
@@ -3,7 +3,7 @@
3
3
  An OpenCV wrapper for Ruby.
4
4
 
5
5
  * Web site: <https://github.com/ruby-opencv/ruby-opencv>
6
- * Ruby 1.9.3, 2.0.0, 2.1.x and OpenCV 2.4.8 are supported.
6
+ * Ruby 1.9.3, 2.x and OpenCV 2.4.9 are supported.
7
7
 
8
8
  ## Requirement
9
9
 
@@ -42,31 +42,49 @@ rb_allocate(VALUE klass)
42
42
 
43
43
  /*
44
44
  * Constructor
45
- * @overload new(storage = nil)
45
+ *
46
+ * @overload new(seq_flags = CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_GENERIC, storage = nil)
47
+ * @param [Fixnum] seq_flags Flags of the created sequence, which are combinations of
48
+ * the element types and sequence types.
49
+ * - Element type:
50
+ * - <tt>CV_SEQ_ELTYPE_POINT</tt>: {CvPoint}
51
+ * - <tt>CV_32FC2</tt>: {CvPoint2D32f}
52
+ * - <tt>CV_SEQ_ELTYPE_POINT3D</tt>: {CvPoint3D32f}
53
+ * - <tt>CV_SEQ_ELTYPE_INDEX</tt>: Fixnum
54
+ * - <tt>CV_SEQ_ELTYPE_CODE</tt>: Fixnum (Freeman code)
55
+ * - Sequence type:
56
+ * - <tt>CV_SEQ_KIND_GENERIC</tt>: Generic sequence
57
+ * - <tt>CV_SEQ_KIND_CURVE</tt>: Curve
46
58
  * @param [CvMemStorage] storage Sequence location
47
59
  * @return [CvContour] self
48
60
  * @opencv_func cvCreateSeq
61
+ * @example
62
+ * seq = CvContour.new(CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_CURVE)
63
+ * seq << CvPoint.new(1, 2)
64
+ * seq << 3 #=> TypeError
49
65
  */
50
66
  VALUE
51
67
  rb_initialize(int argc, VALUE *argv, VALUE self)
52
68
  {
53
- VALUE storage;
54
- rb_scan_args(argc, argv, "01", &storage);
69
+ VALUE seq_flags_value, storage_value;
70
+ rb_scan_args(argc, argv, "02", &seq_flags_value, &storage_value);
55
71
 
56
- if (NIL_P(storage))
57
- storage = cCvMemStorage::new_object(0);
58
- else
59
- storage = CHECK_CVMEMSTORAGE(storage);
72
+ int seq_flags = 0;
73
+ if (NIL_P(seq_flags_value)) {
74
+ seq_flags = CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_GENERIC;
75
+ }
76
+ else {
77
+ Check_Type(seq_flags_value, T_FIXNUM);
78
+ seq_flags = FIX2INT(seq_flags_value);
79
+ }
80
+ storage_value = CHECK_CVMEMSTORAGE(storage_value);
60
81
 
61
82
  try {
62
- DATA_PTR(self) = (CvContour*)cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvContour),
63
- sizeof(CvPoint), CVMEMSTORAGE(storage));
83
+ DATA_PTR(self) = (CvContour*)cCvSeq::create_seq(seq_flags, sizeof(CvContour), storage_value);
64
84
  }
65
85
  catch (cv::Exception& e) {
66
86
  raise_cverror(e);
67
87
  }
68
- cCvSeq::register_elem_class(CVSEQ(self), cCvPoint::rb_class());
69
- register_root_object(CVSEQ(self), storage);
70
88
 
71
89
  return self;
72
90
  }
@@ -193,6 +193,9 @@ rb_calc_hist_bang(int argc, VALUE* argv, VALUE self)
193
193
  rb_scan_args(argc, argv, "12", &images, &accumulate, &mask);
194
194
  Check_Type(images, T_ARRAY);
195
195
  int num_images = RARRAY_LEN(images);
196
+ if (num_images == 0) {
197
+ rb_raise(rb_eArgError, "One or more arrays are required.");
198
+ }
196
199
  IplImage** img = ALLOCA_N(IplImage*, num_images);
197
200
  VALUE* images_ptr = RARRAY_PTR(images);
198
201
  for (int i = 0; i < num_images; i++) {
@@ -205,7 +208,6 @@ rb_calc_hist_bang(int argc, VALUE* argv, VALUE self)
205
208
  catch (cv::Exception& e) {
206
209
  raise_cverror(e);
207
210
  }
208
-
209
211
  return self;
210
212
  }
211
213
 
data/ext/opencv/cvmat.cpp CHANGED
@@ -2276,6 +2276,47 @@ rb_min_max_loc(int argc, VALUE *argv, VALUE self)
2276
2276
  return rb_ary_new3(4, rb_float_new(min_val), rb_float_new(max_val), min_loc, max_loc);
2277
2277
  }
2278
2278
 
2279
+ /*
2280
+ * Calculates an absolute array norm, an absolute difference norm, or a relative difference norm.
2281
+ *
2282
+ * @overload norm(src1, src2=nil, norm_type=NORM_L2, mask=nil)
2283
+ * @param src1 [CvMat] First input array.
2284
+ * @param src2 [CvMat] Second input array of the same size and the same type as <tt>src1</tt>.
2285
+ * @param norm_type [Integer] Type of the norm.
2286
+ * @param mask [CvMat] Optional operation mask; it must have the same size as <tt>src1</tt> and <tt>CV_8UC1</tt> type.
2287
+ * @return [Number] The norm of two arrays.
2288
+ * @opencv_func cvNorm
2289
+ * @scope class
2290
+ */
2291
+ VALUE
2292
+ rb_norm(int argc, VALUE *argv, VALUE self)
2293
+ {
2294
+ VALUE src1, src2, norm_type_val, mask_val;
2295
+ rb_scan_args(argc, argv, "13", &src1, &src2, &norm_type_val, &mask_val);
2296
+
2297
+ CvMat *src1_ptr = NULL;
2298
+ CvMat *src2_ptr = NULL;
2299
+ int norm_type = NIL_P(norm_type_val) ? cv::NORM_L2 : NUM2INT(norm_type_val);
2300
+ CvMat *mask = NULL;
2301
+ double norm = 0.0;
2302
+
2303
+ try {
2304
+ src1_ptr = CVMAT_WITH_CHECK(src1);
2305
+ if (!NIL_P(src2)) {
2306
+ src2_ptr = CVMAT_WITH_CHECK(src2);
2307
+ }
2308
+ if (!NIL_P(mask_val)) {
2309
+ mask = CVMAT_WITH_CHECK(mask_val);
2310
+ }
2311
+ norm = cvNorm(src1_ptr, src2_ptr, norm_type, mask);
2312
+ }
2313
+ catch (cv::Exception& e) {
2314
+ raise_cverror(e);
2315
+ }
2316
+
2317
+ return DBL2NUM(norm);
2318
+ }
2319
+
2279
2320
  /*
2280
2321
  * Calculates the dot product of two arrays in Euclidean metrics.
2281
2322
  *
@@ -4055,17 +4096,19 @@ rb_dilate_bang(int argc, VALUE *argv, VALUE self)
4055
4096
  }
4056
4097
 
4057
4098
  /*
4058
- * call-seq:
4059
- * morpholohy(operation[,element = nil][,iteration = 1]) -> cvmat
4099
+ * Performs advanced morphological transformations using erosion and dilation as basic operations.
4060
4100
  *
4061
- * Performs advanced morphological transformations.
4062
- * <i>operation</i>
4063
- * Type of morphological operation, one of:
4064
- * CV_MOP_OPEN - opening
4065
- * CV_MOP_CLOSE - closing
4066
- * CV_MOP_GRADIENT - morphological gradient
4067
- * CV_MOP_TOPHAT - top hat
4068
- * CV_MOP_BLACKHAT - black hat
4101
+ * @overload morphology(operation, element = nil, iteration = 1)
4102
+ * @param operation [Integer] Type of morphological operation.
4103
+ * * <tt>CV_MOP_OPEN</tt> - Opening
4104
+ * * <tt>CV_MOP_CLOSE</tt> - Closing
4105
+ * * <tt>CV_MOP_GRADIENT</tt> - Morphological gradient
4106
+ * * <tt>CV_MOP_TOPHAT</tt> - Top hat
4107
+ * * <tt>CV_MOP_BLACKHAT</tt> - Black hat
4108
+ * @param element [IplConvKernel] Structuring element.
4109
+ * @param iteration [Integer] Number of times erosion and dilation are applied.
4110
+ * @return [CvMat] Result array
4111
+ * @opencv_func cvMorphologyEx
4069
4112
  */
4070
4113
  VALUE
4071
4114
  rb_morphology(int argc, VALUE *argv, VALUE self)
@@ -5087,7 +5130,7 @@ rb_inpaint(VALUE self, VALUE inpaint_method, VALUE mask, VALUE radius)
5087
5130
 
5088
5131
  /*
5089
5132
  * call-seq:
5090
- * equalize_hist - cvmat
5133
+ * equalize_hist -> cvmat
5091
5134
  *
5092
5135
  * Equalize histgram of grayscale of image.
5093
5136
  *
@@ -5911,6 +5954,7 @@ init_ruby_class()
5911
5954
  rb_define_method(rb_klass, "avg_sdv", RUBY_METHOD_FUNC(rb_avg_sdv), -1);
5912
5955
  rb_define_method(rb_klass, "sdv", RUBY_METHOD_FUNC(rb_sdv), -1);
5913
5956
  rb_define_method(rb_klass, "min_max_loc", RUBY_METHOD_FUNC(rb_min_max_loc), -1);
5957
+ rb_define_singleton_method(rb_klass, "norm", RUBY_METHOD_FUNC(rb_norm), -1);
5914
5958
  rb_define_method(rb_klass, "dot_product", RUBY_METHOD_FUNC(rb_dot_product), 1);
5915
5959
  rb_define_method(rb_klass, "cross_product", RUBY_METHOD_FUNC(rb_cross_product), 1);
5916
5960
  rb_define_method(rb_klass, "transform", RUBY_METHOD_FUNC(rb_transform), -1);
data/ext/opencv/cvmat.h CHANGED
@@ -119,7 +119,7 @@ VALUE rb_avg_sdv(int argc, VALUE *argv, VALUE self);
119
119
  VALUE rb_sdv(int argc, VALUE *argv, VALUE self);
120
120
  VALUE rb_min_max_loc(int argc, VALUE *argv, VALUE self);
121
121
 
122
- //VALUE rb_norm();
122
+ VALUE rb_norm(int argc, VALUE *argv, VALUE self);
123
123
  VALUE rb_dot_product(VALUE self, VALUE mat);
124
124
  VALUE rb_cross_product(VALUE self, VALUE mat);
125
125
  // VALUE rb_gemm();
@@ -39,13 +39,10 @@ CVMEMSTORAGE(VALUE object)
39
39
  inline VALUE
40
40
  CHECK_CVMEMSTORAGE(VALUE object)
41
41
  {
42
- if (rb_obj_is_kind_of(object, cCvMemStorage::rb_class()))
42
+ if (rb_obj_is_kind_of(object, cCvMemStorage::rb_class())) {
43
43
  return object;
44
- else {
45
- if (!NIL_P(object))
46
- rb_warn("invalid CvMemStorage object given. allocate new memory storage automatically.");
47
- return cCvMemStorage::new_object();
48
44
  }
45
+ return cCvMemStorage::new_object();
49
46
  }
50
47
 
51
48
  __NAMESPACE_END_OPENCV
data/ext/opencv/cvseq.cpp CHANGED
@@ -10,27 +10,6 @@
10
10
  #include "cvseq.h"
11
11
  /*
12
12
  * Document-class: OpenCV::CvSeq
13
- *
14
- * Generic Sequence class. CvSeq has the method like Array (push, pop, select, etc...).
15
- * But, CvSeq cannot store the object of a different class.
16
- * When storing object in CvSeq, conversion is automatically tried,
17
- * and the object occurs the error if it cannot be done.
18
- *
19
- * e.g.
20
- * seq = CvSeq.new(CvPoint) # Argument mean "this sequence contain only this class's object"
21
- * seq.push(CvPoint.new(0, 0)) # => it's ok
22
- * seq.push("hello") # => try convert "hello" to CvPoint. but can't do it. raise error.
23
- *
24
- * If the sequecne contain object of class A.
25
- * When storing object(named "obj") of class B to the sequence.
26
- * Try automatically : A.from_B(obj) => object of class A.
27
- *
28
- * The sequence might have another sequence outside. see below.
29
- * Each sequece has h_prev, h_next, v_prev, v_next method.
30
- * If the adjoining sequence exists, each method return the adjoining sequence.
31
- * Otherwise return nil.
32
- *
33
- * link:../images/CvSeq_relationmap.png
34
13
  */
35
14
  __NAMESPACE_BEGIN_OPENCV
36
15
  __NAMESPACE_BEGIN_CVSEQ
@@ -80,62 +59,116 @@ rb_allocate(VALUE klass)
80
59
  return Data_Wrap_Struct(klass, 0, unregister_elem_class, ptr);
81
60
  }
82
61
 
83
- /*
84
- * call-seq:
85
- * CvSeq.new(type[,storage])
86
- *
87
- * Return a new CvSeq. <i>type</i> should be following classes.
88
- *
89
- * * CvIndex
90
- * * CvPoint
91
- */
92
- VALUE
93
- rb_initialize(int argc, VALUE *argv, VALUE self)
62
+ CvSeq*
63
+ create_seq(int seq_flags, size_t header_size, VALUE storage_value)
94
64
  {
95
- VALUE klass, storage_value;
96
-
97
- rb_scan_args(argc, argv, "11", &klass, &storage_value);
98
- if (!rb_obj_is_kind_of(klass, rb_cClass))
99
- raise_typeerror(klass, rb_cClass);
65
+ VALUE klass = Qnil;
66
+ int eltype = seq_flags & CV_SEQ_ELTYPE_MASK;
67
+ storage_value = CHECK_CVMEMSTORAGE(storage_value);
68
+
69
+ switch (eltype) {
70
+ case CV_SEQ_ELTYPE_POINT:
71
+ klass = cCvPoint::rb_class();
72
+ break;
73
+ case CV_32FC2:
74
+ klass = cCvPoint2D32f::rb_class();
75
+ break;
76
+ case CV_SEQ_ELTYPE_POINT3D:
77
+ klass = cCvPoint3D32f::rb_class();
78
+ break;
79
+ case CV_SEQ_ELTYPE_CODE:
80
+ case CV_SEQ_ELTYPE_INDEX:
81
+ klass = rb_cFixnum;
82
+ break;
83
+ case CV_SEQ_ELTYPE_PPOINT: // or CV_SEQ_ELTYPE_PTR:
84
+ // Not supported
85
+ rb_raise(rb_eArgError, "seq_flags %d is not supported.", eltype);
86
+ break;
87
+ default:
88
+ seq_flags = CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_GENERIC;
89
+ klass = cCvPoint::rb_class();
90
+ break;
91
+ }
100
92
 
101
- int type = 0, size = 0;
102
- if (klass == rb_cFixnum) {
103
- type = CV_SEQ_ELTYPE_INDEX;
104
- size = sizeof(int);
93
+ int mat_type = CV_MAT_TYPE(seq_flags);
94
+ size_t elem_size = (size_t)(CV_ELEM_SIZE(mat_type));
95
+ CvSeq* seq = NULL;
96
+ try {
97
+ seq = cvCreateSeq(seq_flags, header_size, elem_size, CVMEMSTORAGE(storage_value));
105
98
  }
106
- else if (klass == cCvPoint::rb_class()) {
107
- type = CV_SEQ_ELTYPE_POINT;
108
- size = sizeof(CvPoint);
99
+ catch (cv::Exception& e) {
100
+ raise_cverror(e);
101
+ }
102
+ register_elem_class(seq, klass);
103
+ register_root_object(seq, storage_value);
104
+
105
+ return seq;
106
+ }
107
+
108
+ VALUE
109
+ class2seq_flags_value(VALUE klass) {
110
+ int seq_flags;
111
+ if (klass == cCvPoint::rb_class()) {
112
+ seq_flags = CV_SEQ_ELTYPE_POINT;
109
113
  }
110
114
  else if (klass == cCvPoint2D32f::rb_class()) {
111
- type = CV_SEQ_ELTYPE_POINT;
112
- size = sizeof(CvPoint2D32f);
115
+ seq_flags = CV_32FC2;
113
116
  }
114
117
  else if (klass == cCvPoint3D32f::rb_class()) {
115
- type = CV_SEQ_ELTYPE_POINT3D;
116
- size = sizeof(CvPoint3D32f);
118
+ seq_flags = CV_SEQ_ELTYPE_POINT3D;
117
119
  }
118
- else
119
- rb_raise(rb_eArgError, "unsupport %s class for sequence-block.", rb_class2name(klass));
120
-
121
- CvSeq* seq = NULL;
122
- if (NIL_P(storage_value)) {
123
- storage_value = cCvMemStorage::new_object(0);
120
+ else if (klass == rb_cFixnum) {
121
+ seq_flags = CV_SEQ_ELTYPE_INDEX;
124
122
  }
125
123
  else {
126
- storage_value = CHECK_CVMEMSTORAGE(storage_value);
124
+ rb_raise(rb_eTypeError, "unexpected type: %s", rb_class2name(klass));
127
125
  }
128
-
129
- try {
130
- seq = cvCreateSeq(type, sizeof(CvSeq), size, CVMEMSTORAGE(storage_value));
131
- }
132
- catch (cv::Exception& e) {
133
- raise_cverror(e);
126
+
127
+ return INT2NUM(seq_flags | CV_SEQ_KIND_GENERIC);
128
+ }
129
+
130
+ /*
131
+ * Constructor
132
+ *
133
+ * @overload new(seq_flags, storage = nil)
134
+ * @param [Fixnum] seq_flags Flags of the created sequence, which are combinations of
135
+ * the element types and sequence types.
136
+ * - Element type:
137
+ * - <tt>CV_SEQ_ELTYPE_POINT</tt>: {CvPoint}
138
+ * - <tt>CV_32FC2</tt>: {CvPoint2D32f}
139
+ * - <tt>CV_SEQ_ELTYPE_POINT3D</tt>: {CvPoint3D32f}
140
+ * - <tt>CV_SEQ_ELTYPE_INDEX</tt>: Fixnum
141
+ * - <tt>CV_SEQ_ELTYPE_CODE</tt>: Fixnum (Freeman code)
142
+ * - Sequence type:
143
+ * - <tt>CV_SEQ_KIND_GENERIC</tt>: Generic sequence
144
+ * - <tt>CV_SEQ_KIND_CURVE</tt>: Curve
145
+ * @param [CvMemStorage] storage Sequence location
146
+ * @return [CvSeq] self
147
+ * @opencv_func cvCreateSeq
148
+ * @example
149
+ * seq1 = CvSeq.new(CV_SEQ_ELTYPE_INDEX)
150
+ * seq1 << 1
151
+ * seq1 << CvPoint.new(1, 2) #=> TypeError
152
+ *
153
+ * seq2 = CvSeq.new(CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_CURVE)
154
+ * seq2 << CvPoint.new(1, 2)
155
+ * seq2 << 3 #=> TypeError
156
+ */
157
+ VALUE
158
+ rb_initialize(int argc, VALUE *argv, VALUE self)
159
+ {
160
+ VALUE seq_flags_value, storage_value;
161
+ rb_scan_args(argc, argv, "11", &seq_flags_value, &storage_value);
162
+ int seq_flags = 0;
163
+
164
+ if (TYPE(seq_flags_value) == T_CLASS) { // To maintain backward compatibility
165
+ seq_flags_value = class2seq_flags_value(seq_flags_value);
134
166
  }
135
- DATA_PTR(self) = seq;
136
- register_elem_class(seq, klass);
137
- register_root_object(seq, storage_value);
138
-
167
+ Check_Type(seq_flags_value, T_FIXNUM);
168
+ seq_flags = FIX2INT(seq_flags_value);
169
+
170
+ DATA_PTR(self) = create_seq(seq_flags, sizeof(CvSeq), storage_value);
171
+
139
172
  return self;
140
173
  }
141
174
 
@@ -174,17 +207,22 @@ rb_aref(VALUE self, VALUE index)
174
207
  {
175
208
  CvSeq *seq = CVSEQ(self);
176
209
  int idx = NUM2INT(index);
177
- if (seq->total == 0)
210
+ if (seq->total == 0) {
178
211
  return Qnil;
179
- if (idx >= seq->total)
212
+ }
213
+ if (idx >= seq->total) {
180
214
  rb_raise(rb_eIndexError, "index %d out of sequence", idx);
215
+ }
181
216
 
182
217
  VALUE result = Qnil;
183
218
  try {
184
- if (seqblock_class(seq) == rb_cFixnum)
219
+ VALUE klass = seqblock_class(seq);
220
+ if (RTEST(rb_class_inherited_p(klass, rb_cInteger))) {
185
221
  result = INT2NUM(*CV_GET_SEQ_ELEM(int, seq, idx));
186
- else
187
- result = REFER_OBJECT(seqblock_class(seq), cvGetSeqElem(seq, idx), self);
222
+ }
223
+ else {
224
+ result = REFER_OBJECT(klass, cvGetSeqElem(seq, idx), self);
225
+ }
188
226
  }
189
227
  catch (cv::Exception& e) {
190
228
  raise_cverror(e);
@@ -288,16 +326,20 @@ VALUE
288
326
  rb_seq_push(VALUE self, VALUE args, int flag)
289
327
  {
290
328
  CvSeq *seq = CVSEQ(self);
291
- VALUE klass = seqblock_class(seq), object;
329
+ VALUE klass = seqblock_class(seq);
292
330
  volatile void *elem = NULL;
293
331
  int len = RARRAY_LEN(args);
294
- for (int i = 0; i < len; ++i) {
295
- object = RARRAY_PTR(args)[i];
296
- if (CLASS_OF(object) == klass) {
297
- if (TYPE(object) == T_FIXNUM) {
298
- volatile int int_elem = FIX2INT(object);
332
+ for (int i = 0; i < len; i++) {
333
+ VALUE object = RARRAY_PTR(args)[i];
334
+ if (rb_obj_is_kind_of(object, klass)) {
335
+ if (rb_obj_is_kind_of(object, rb_cInteger)) {
336
+ volatile int int_elem = NUM2INT(object);
299
337
  elem = &int_elem;
300
338
  }
339
+ else if (rb_obj_is_kind_of(object, rb_cNumeric)) {
340
+ volatile double double_elem = NUM2DBL(object);
341
+ elem = &double_elem;
342
+ }
301
343
  else {
302
344
  elem = (void*)DATA_PTR(object);
303
345
  }
@@ -311,7 +353,8 @@ rb_seq_push(VALUE self, VALUE args, int flag)
311
353
  raise_cverror(e);
312
354
  }
313
355
  }
314
- else if (rb_obj_is_kind_of(object, rb_klass) && CLASS_OF(rb_first(object)) == klass) { // object is CvSeq
356
+ else if ((rb_obj_is_kind_of(object, rb_klass) == Qtrue) &&
357
+ RTEST(rb_class_inherited_p(seqblock_class(CVSEQ(object)), klass))) { // object is CvSeq
315
358
  void *buffer = NULL;
316
359
  try {
317
360
  buffer = cvCvtSeqToArray(CVSEQ(object), rb_cvAlloc(CVSEQ(object)->total * CVSEQ(object)->elem_size));
data/ext/opencv/cvseq.h CHANGED
@@ -24,6 +24,7 @@ void init_ruby_class();
24
24
  VALUE seqblock_class(void *ptr);
25
25
  void register_elem_class(CvSeq *seq, VALUE klass);
26
26
  void unregister_elem_class(void *ptr);
27
+ CvSeq* create_seq(int seq_flags, size_t header_size, VALUE storage_value);
27
28
 
28
29
  VALUE rb_allocate(VALUE klass);
29
30
 
@@ -388,6 +388,47 @@ init_ruby_module()
388
388
  rb_define_const(rb_module, "COLORMAP_PINK", INT2FIX(cv::COLORMAP_PINK));
389
389
  rb_define_const(rb_module, "COLORMAP_HOT", INT2FIX(cv::COLORMAP_HOT));
390
390
 
391
+ /* Sequence types */
392
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_BITS", INT2FIX(CV_SEQ_ELTYPE_BITS));
393
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_MASK", INT2FIX(CV_SEQ_ELTYPE_MASK));
394
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_POINT", INT2FIX(CV_SEQ_ELTYPE_POINT));
395
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_CODE", INT2FIX(CV_SEQ_ELTYPE_CODE));
396
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_GENERIC", INT2FIX(CV_SEQ_ELTYPE_GENERIC));
397
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_PTR", INT2FIX(CV_SEQ_ELTYPE_PTR));
398
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_PPOINT", INT2FIX(CV_SEQ_ELTYPE_PPOINT));
399
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_INDEX", INT2FIX(CV_SEQ_ELTYPE_INDEX));
400
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_GRAPH_EDGE", INT2FIX(CV_SEQ_ELTYPE_GRAPH_EDGE));
401
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_GRAPH_VERTEX", INT2FIX(CV_SEQ_ELTYPE_GRAPH_VERTEX));
402
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_TRIAN_ATR", INT2FIX(CV_SEQ_ELTYPE_TRIAN_ATR));
403
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_CONNECTED_COMP", INT2FIX(CV_SEQ_ELTYPE_CONNECTED_COMP));
404
+ rb_define_const(rb_module, "CV_SEQ_ELTYPE_POINT3D", INT2FIX(CV_SEQ_ELTYPE_POINT3D));
405
+ rb_define_const(rb_module, "CV_SEQ_KIND_BITS", INT2FIX(CV_SEQ_KIND_BITS));
406
+ rb_define_const(rb_module, "CV_SEQ_KIND_MASK", INT2FIX(CV_SEQ_KIND_MASK));
407
+ rb_define_const(rb_module, "CV_SEQ_KIND_GENERIC", INT2FIX(CV_SEQ_KIND_GENERIC));
408
+ rb_define_const(rb_module, "CV_SEQ_KIND_CURVE", INT2FIX(CV_SEQ_KIND_CURVE));
409
+ rb_define_const(rb_module, "CV_SEQ_KIND_BIN_TREE", INT2FIX(CV_SEQ_KIND_BIN_TREE));
410
+ rb_define_const(rb_module, "CV_SEQ_KIND_GRAPH", INT2FIX(CV_SEQ_KIND_GRAPH));
411
+ rb_define_const(rb_module, "CV_SEQ_KIND_SUBDIV2D", INT2FIX(CV_SEQ_KIND_SUBDIV2D));
412
+ rb_define_const(rb_module, "CV_SEQ_FLAG_SHIFT", INT2FIX(CV_SEQ_FLAG_SHIFT));
413
+ rb_define_const(rb_module, "CV_SEQ_FLAG_CLOSED", INT2FIX(CV_SEQ_FLAG_CLOSED));
414
+ rb_define_const(rb_module, "CV_SEQ_FLAG_SIMPLE", INT2FIX(CV_SEQ_FLAG_SIMPLE));
415
+ rb_define_const(rb_module, "CV_SEQ_FLAG_CONVEX", INT2FIX(CV_SEQ_FLAG_CONVEX));
416
+ rb_define_const(rb_module, "CV_SEQ_FLAG_HOLE", INT2FIX(CV_SEQ_FLAG_HOLE));
417
+ rb_define_const(rb_module, "CV_GRAPH_FLAG_ORIENTED", INT2FIX(CV_GRAPH_FLAG_ORIENTED));
418
+ rb_define_const(rb_module, "CV_GRAPH", INT2FIX(CV_GRAPH));
419
+ rb_define_const(rb_module, "CV_ORIENTED_GRAPH", INT2FIX(CV_ORIENTED_GRAPH));
420
+ rb_define_const(rb_module, "CV_SEQ_POINT_SET", INT2FIX(CV_SEQ_POINT_SET));
421
+ rb_define_const(rb_module, "CV_SEQ_POINT3D_SET", INT2FIX(CV_SEQ_POINT3D_SET));
422
+ rb_define_const(rb_module, "CV_SEQ_POLYLINE", INT2FIX(CV_SEQ_POLYLINE));
423
+ rb_define_const(rb_module, "CV_SEQ_POLYGON", INT2FIX(CV_SEQ_POLYGON));
424
+ rb_define_const(rb_module, "CV_SEQ_CONTOUR", INT2FIX(CV_SEQ_CONTOUR));
425
+ rb_define_const(rb_module, "CV_SEQ_SIMPLE_POLYGON", INT2FIX(CV_SEQ_SIMPLE_POLYGON));
426
+ rb_define_const(rb_module, "CV_SEQ_CHAIN", INT2FIX(CV_SEQ_CHAIN));
427
+ rb_define_const(rb_module, "CV_SEQ_CHAIN_CONTOUR", INT2FIX(CV_SEQ_CHAIN_CONTOUR));
428
+ rb_define_const(rb_module, "CV_SEQ_POLYGON_TREE", INT2FIX(CV_SEQ_POLYGON_TREE));
429
+ rb_define_const(rb_module, "CV_SEQ_CONNECTED_COMP", INT2FIX(CV_SEQ_CONNECTED_COMP));
430
+ rb_define_const(rb_module, "CV_SEQ_INDEX", INT2FIX(CV_SEQ_INDEX));
431
+
391
432
  VALUE inversion_method = rb_hash_new();
392
433
  /* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */
393
434
  rb_define_const(rb_module, "INVERSION_METHOD", inversion_method);
@@ -1,4 +1,4 @@
1
1
  module OpenCV
2
- VERSION = '0.0.13'
2
+ VERSION = '0.0.14.pre'
3
3
  end
4
4
 
data/ruby-opencv.gemspec CHANGED
@@ -1,15 +1,15 @@
1
1
  # -*- encoding: utf-8 -*-
2
- # stub: ruby-opencv 0.0.13.20140330211753 ruby lib
2
+ # stub: ruby-opencv 0.0.14.pre.20150125030210 ruby lib
3
3
  # stub: ext/opencv/extconf.rb
4
4
 
5
5
  Gem::Specification.new do |s|
6
6
  s.name = "ruby-opencv"
7
- s.version = "0.0.13.20140330211753"
7
+ s.version = "0.0.14.pre.20150125030210"
8
8
 
9
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
9
+ s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
10
10
  s.require_paths = ["lib"]
11
11
  s.authors = ["lsxi", "ser1zw", "pcting"]
12
- s.date = "2014-03-30"
12
+ s.date = "2015-01-24"
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."
14
14
  s.email = ["masakazu.yonekura@gmail.com", "azariahsawtikes@gmail.com", "pcting@gmail.com"]
15
15
  s.extensions = ["ext/opencv/extconf.rb"]
@@ -18,9 +18,9 @@ Gem::Specification.new do |s|
18
18
  s.homepage = "https://github.com/ruby-opencv/ruby-opencv/"
19
19
  s.licenses = ["The BSD License"]
20
20
  s.rdoc_options = ["--main", "README.md"]
21
- s.rubygems_version = "2.2.2"
21
+ s.rubygems_version = "2.4.5"
22
22
  s.summary = "OpenCV wrapper for Ruby"
23
- s.test_files = ["test/test_cvcontour.rb", "test/test_eigenfaces.rb", "test/test_cvmoments.rb", "test/test_cvseq.rb", "test/test_cvcontourtree.rb", "test/test_cvbox2d.rb", "test/test_iplimage.rb", "test/test_cvvideowriter.rb", "test/test_cvline.rb", "test/test_cvhumoments.rb", "test/test_cvfont.rb", "test/test_cvconnectedcomp.rb", "test/test_cvhistogram.rb", "test/test_trackbar.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvhaarclassifiercascade.rb", "test/test_cvcircle32f.rb", "test/test_cvcapture.rb", "test/test_cvmat_dxt.rb", "test/test_cvrect.rb", "test/test_iplconvkernel.rb", "test/test_cvsurfpoint.rb", "test/test_cvavgcomp.rb", "test/test_cvscalar.rb", "test/test_pointset.rb", "test/test_curve.rb", "test/test_cvtermcriteria.rb", "test/test_cvtwopoints.rb", "test/test_cvsurfparams.rb", "test/test_cvpoint2d32f.rb", "test/test_cvpoint3d32f.rb", "test/test_cvfeaturetree.rb", "test/test_mouseevent.rb", "test/test_cvchain.rb", "test/test_cvmat.rb", "test/test_fisherfaces.rb", "test/test_cverror.rb", "test/test_cvpoint.rb", "test/test_cvsize2d32f.rb", "test/test_preliminary.rb", "test/test_cvmat_drawing.rb", "test/test_lbph.rb", "test/test_cvsize.rb", "test/test_window.rb", "test/test_cvslice.rb", "test/test_opencv.rb"]
23
+ s.test_files = ["test/test_trackbar.rb", "test/test_cvhistogram.rb", "test/test_cvpoint.rb", "test/test_cvmat_dxt.rb", "test/test_iplconvkernel.rb", "test/test_cvconnectedcomp.rb", "test/test_curve.rb", "test/test_mouseevent.rb", "test/test_cvsurfpoint.rb", "test/test_eigenfaces.rb", "test/test_cvtwopoints.rb", "test/test_cvbox2d.rb", "test/test_cvmat_imageprocessing.rb", "test/test_cvtermcriteria.rb", "test/test_fisherfaces.rb", "test/test_cvvideowriter.rb", "test/test_cvmoments.rb", "test/test_cvsize2d32f.rb", "test/test_cvsize.rb", "test/test_cvcircle32f.rb", "test/test_cvavgcomp.rb", "test/test_cvscalar.rb", "test/test_cvhaarclassifiercascade.rb", "test/test_cvrect.rb", "test/test_cvfont.rb", "test/test_cvmat_drawing.rb", "test/test_cvhumoments.rb", "test/test_cvmat.rb", "test/test_cvcapture.rb", "test/test_pointset.rb", "test/test_cvcontour.rb", "test/test_opencv.rb", "test/test_cvline.rb", "test/test_lbph.rb", "test/test_iplimage.rb", "test/test_cvcontourtree.rb", "test/test_window.rb", "test/test_cvpoint3d32f.rb", "test/test_cvseq.rb", "test/test_preliminary.rb", "test/test_cvsurfparams.rb", "test/test_cvchain.rb", "test/test_cvfeaturetree.rb", "test/test_cvpoint2d32f.rb", "test/test_cverror.rb", "test/test_cvslice.rb"]
24
24
 
25
25
  if s.respond_to? :specification_version then
26
26
  s.specification_version = 4
@@ -29,17 +29,17 @@ Gem::Specification.new do |s|
29
29
  s.add_development_dependency(%q<rdoc>, ["~> 4.0"])
30
30
  s.add_development_dependency(%q<rake-compiler>, ["~> 0"])
31
31
  s.add_development_dependency(%q<hoe-gemspec>, ["~> 0"])
32
- s.add_development_dependency(%q<hoe>, ["~> 3.10"])
32
+ s.add_development_dependency(%q<hoe>, ["~> 3.13"])
33
33
  else
34
34
  s.add_dependency(%q<rdoc>, ["~> 4.0"])
35
35
  s.add_dependency(%q<rake-compiler>, ["~> 0"])
36
36
  s.add_dependency(%q<hoe-gemspec>, ["~> 0"])
37
- s.add_dependency(%q<hoe>, ["~> 3.10"])
37
+ s.add_dependency(%q<hoe>, ["~> 3.13"])
38
38
  end
39
39
  else
40
40
  s.add_dependency(%q<rdoc>, ["~> 4.0"])
41
41
  s.add_dependency(%q<rake-compiler>, ["~> 0"])
42
42
  s.add_dependency(%q<hoe-gemspec>, ["~> 0"])
43
- s.add_dependency(%q<hoe>, ["~> 3.10"])
43
+ s.add_dependency(%q<hoe>, ["~> 3.13"])
44
44
  end
45
45
  end
@@ -10,7 +10,7 @@ include OpenCV
10
10
  class TestCvConnectedComp < OpenCVTestCase
11
11
  def setup
12
12
  @connected_comp = CvConnectedComp.new(9216, CvScalar.new(1, 2, 3, 4),
13
- CvRect.new(1, 2, 3, 4), CvSeq.new(CvPoint))
13
+ CvRect.new(1, 2, 3, 4), CvSeq.new(CV_SEQ_ELTYPE_INDEX))
14
14
  end
15
15
 
16
16
  def test_initialize
@@ -22,7 +22,7 @@ class TestCvConnectedComp < OpenCVTestCase
22
22
  assert_not_nil(connected_comp.contour)
23
23
 
24
24
  connected_comp = CvConnectedComp.new(100, CvScalar.new(1, 2, 3, 4),
25
- CvRect.new(1, 2, 3, 4), CvSeq.new(CvPoint))
25
+ CvRect.new(1, 2, 3, 4), CvSeq.new(CV_SEQ_ELTYPE_POINT))
26
26
  assert_equal(CvConnectedComp, connected_comp.class)
27
27
  assert_not_nil(connected_comp.area)
28
28
  assert_not_nil(connected_comp.value)
@@ -9,11 +9,11 @@ include OpenCV
9
9
  # Tests for OpenCV::CvContourTree
10
10
  class TestCvContourTree < OpenCVTestCase
11
11
  def setup
12
- @tree = CvContourTree.new(CvPoint)
12
+ @tree = CvContourTree.new(CV_SEQ_ELTYPE_POINT)
13
13
  end
14
14
 
15
15
  def test_initialize
16
- tree = CvContourTree.new(CvPoint)
16
+ tree = CvContourTree.new(CV_SEQ_ELTYPE_POINT)
17
17
  assert_equal(CvContourTree, tree.class)
18
18
  assert(tree.is_a? CvSeq)
19
19
  end
@@ -74,7 +74,7 @@ class TestCvHistogram < OpenCVTestCase
74
74
  assert_raise(TypeError) {
75
75
  @hist1.calc_hist([img], true, DUMMY_OBJ)
76
76
  }
77
- assert_raise(CvStsBadArg) {
77
+ assert_raise(ArgumentError) {
78
78
  @hist1.calc_hist([])
79
79
  }
80
80
  end
data/test/test_cvmat.rb CHANGED
@@ -2161,6 +2161,39 @@ class TestCvMat < OpenCVTestCase
2161
2161
  }
2162
2162
  end
2163
2163
 
2164
+ def test_norm
2165
+ src1 = CvMat.new(3, 3, :cv32f, 1).set_data([1, 2, 3, 4, 5, 6, 7, 8, 9])
2166
+ src2 = CvMat.new(3, 3, :cv32f, 1).set_data([2, 3, 4, 5, 6, 7, 8, 9, 1])
2167
+ mask = CvMat.new(3, 3, :cv8u, 1).set_data([1, 1, 0, 1, 1, 0, 0, 0, 0])
2168
+
2169
+ assert_in_delta(CvMat.norm(src1), 16.88, 0.01)
2170
+
2171
+ assert_in_delta(CvMat.norm(src1, nil, CV_NORM_L1), 45.0, 0.01)
2172
+ assert_in_delta(CvMat.norm(src1, nil, CV_NORM_L2), 16.88, 0.01)
2173
+ assert_in_delta(CvMat.norm(src1, nil, CV_NORM_INF), 9.0, 0.01)
2174
+
2175
+ assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L1), 16.0, 0.01)
2176
+ assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L2), 8.49, 0.01)
2177
+ assert_in_delta(CvMat.norm(src1, src2, CV_NORM_INF), 8.0, 0.01)
2178
+
2179
+ assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L1, mask), 4.0, 0.01)
2180
+ assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L2, mask), 2.0, 0.01)
2181
+ assert_in_delta(CvMat.norm(src1, src2, CV_NORM_INF, mask), 1.0, 0.01)
2182
+
2183
+ assert_raise(TypeError) {
2184
+ CvMat.norm(DUMMY_OBJ)
2185
+ }
2186
+ assert_raise(TypeError) {
2187
+ CvMat.norm(src1, DUMMY_OBJ)
2188
+ }
2189
+ assert_raise(TypeError) {
2190
+ CvMat.norm(src1, src2, DUMMY_OBJ)
2191
+ }
2192
+ assert_raise(TypeError) {
2193
+ CvMat.norm(src1, src2, CV_NORM_L1, DUMMY_OBJ)
2194
+ }
2195
+ end
2196
+
2164
2197
  def test_dot_product
2165
2198
  m1 = create_cvmat(2, 2, :cv32f, 1) { |j, i, c|
2166
2199
  CvScalar.new(c * 0.5)
data/test/test_cvseq.rb CHANGED
@@ -9,17 +9,34 @@ include OpenCV
9
9
  # Tests for OpenCV::CvSeq
10
10
  class TestCvSeq < OpenCVTestCase
11
11
  def test_initialize
12
- # assert_not_nil(CvSeq.new(CvIndex))
13
- assert_not_nil(CvSeq.new(Fixnum))
14
- assert_not_nil(CvSeq.new(CvPoint))
15
- assert_not_nil(CvSeq.new(CvPoint2D32f))
16
- assert_not_nil(CvSeq.new(CvPoint3D32f))
12
+ types = [CV_SEQ_ELTYPE_POINT, CV_SEQ_ELTYPE_POINT3D, CV_SEQ_ELTYPE_CODE, CV_SEQ_ELTYPE_INDEX]
13
+ kinds = [CV_SEQ_KIND_GENERIC, CV_SEQ_KIND_CURVE, CV_SEQ_KIND_BIN_TREE, CV_SEQ_KIND_GRAPH, CV_SEQ_KIND_SUBDIV2D]
14
+ flags = [CV_SEQ_FLAG_CLOSED, CV_SEQ_FLAG_SIMPLE, CV_SEQ_FLAG_CONVEX, CV_SEQ_FLAG_HOLE]
15
+ types.each { |type|
16
+ kinds.each { |kind|
17
+ flags.each { |flag|
18
+ seq_flag = type | kind | flag
19
+ assert_equal(CvSeq, CvSeq.new(seq_flag).class)
20
+ }
21
+ }
22
+ }
23
+
24
+ [CV_SEQ_POINT_SET, CV_SEQ_POINT3D_SET, CV_SEQ_POLYLINE, CV_SEQ_POLYGON,
25
+ CV_SEQ_CONTOUR, CV_SEQ_SIMPLE_POLYGON, CV_SEQ_CHAIN, CV_SEQ_CHAIN_CONTOUR,
26
+ CV_SEQ_INDEX ].each { |seq_flag|
27
+ assert_equal(CvSeq, CvSeq.new(seq_flag).class)
28
+ }
17
29
 
18
- assert(CvSeq.new(CvPoint).is_a? Enumerable)
30
+ # Unsupported types
31
+ [CV_SEQ_ELTYPE_PTR, CV_SEQ_ELTYPE_PPOINT].each { |type|
32
+ assert_raise(ArgumentError) {
33
+ CvSeq.new(type)
34
+ }
35
+ }
19
36
  end
20
37
 
21
38
  def test_total
22
- seq1 = CvSeq.new(CvPoint)
39
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT)
23
40
  assert_equal(0, seq1.total)
24
41
 
25
42
  seq1.push(CvPoint.new(1, 2))
@@ -33,13 +50,12 @@ class TestCvSeq < OpenCVTestCase
33
50
  end
34
51
 
35
52
  def test_empty
36
- assert(CvSeq.new(CvPoint).empty?)
37
- assert(CvSeq.new(CvPoint2D32f).empty?)
38
- assert(CvSeq.new(CvPoint3D32f).empty?)
53
+ assert(CvSeq.new(CV_SEQ_ELTYPE_POINT).empty?)
39
54
  end
40
55
 
41
56
  def test_aref
42
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
57
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT)
58
+ seq1.push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
43
59
 
44
60
  assert_equal(CvPoint, seq1[0].class)
45
61
  assert_equal(10, seq1[0].x)
@@ -49,8 +65,8 @@ class TestCvSeq < OpenCVTestCase
49
65
  assert_equal(50, seq1[2].x)
50
66
  assert_equal(60, seq1[2].y)
51
67
 
52
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
53
-
68
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX)
69
+ seq2.push(10, 20, 30)
54
70
  assert_equal(Fixnum, seq2[0].class)
55
71
  assert_equal(10, seq2[0])
56
72
  assert_equal(20, seq2[1])
@@ -58,7 +74,7 @@ class TestCvSeq < OpenCVTestCase
58
74
  end
59
75
 
60
76
  def test_push
61
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
77
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
62
78
 
63
79
  assert_equal(2, seq1.total)
64
80
  assert_equal(CvPoint, seq1[0].class)
@@ -68,7 +84,7 @@ class TestCvSeq < OpenCVTestCase
68
84
  assert_equal(30, seq1[1].x)
69
85
  assert_equal(40, seq1[1].y)
70
86
 
71
- seq2 = CvSeq.new(CvPoint).push(CvPoint.new(50, 60))
87
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(50, 60))
72
88
  seq2.push(seq1)
73
89
  assert_equal(3, seq2.total)
74
90
  assert_equal(CvPoint, seq2[0].class)
@@ -81,8 +97,8 @@ class TestCvSeq < OpenCVTestCase
81
97
  assert_equal(30, seq2[2].x)
82
98
  assert_equal(40, seq2[2].y)
83
99
 
84
- seq3 = CvSeq.new(Fixnum).push(10)
85
- seq4 = CvSeq.new(Fixnum).push(20, 30)
100
+ seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10)
101
+ seq4 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(20, 30)
86
102
  seq3.push(seq4)
87
103
  assert_equal(3, seq3.total)
88
104
  assert_equal(Fixnum, seq3[0].class)
@@ -91,17 +107,17 @@ class TestCvSeq < OpenCVTestCase
91
107
  assert_equal(30, seq3[2])
92
108
 
93
109
  assert_raise(TypeError) {
94
- seq1.push(CvPoint2D32f.new(55.5, 66.6))
110
+ seq1.push(55.5, 66.6)
95
111
  }
96
112
 
97
113
  assert_raise(TypeError) {
98
- seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6))
114
+ seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(55, 66)
99
115
  seq1.push(seq3)
100
116
  }
101
117
  end
102
118
 
103
119
  def test_pop
104
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
120
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
105
121
  point1 = seq1.pop
106
122
  assert_equal(CvPoint, point1.class)
107
123
  assert_equal(30, point1.x)
@@ -112,23 +128,23 @@ class TestCvSeq < OpenCVTestCase
112
128
  assert_equal(10, seq1[0].x)
113
129
  assert_equal(20, seq1[0].y)
114
130
 
115
- assert_nil(CvSeq.new(CvPoint).pop)
131
+ assert_nil(CvSeq.new(CV_SEQ_ELTYPE_POINT).pop)
116
132
 
117
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
133
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30)
118
134
  assert_equal(30, seq2.pop)
119
135
  assert_equal(20, seq2.pop)
120
136
  assert_equal(10, seq2.pop)
121
137
  end
122
138
 
123
139
  def test_clear
124
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
140
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
125
141
  seq1.clear
126
142
  assert_not_nil(seq1)
127
143
  assert_equal(0, seq1.total)
128
144
  end
129
145
 
130
146
  def test_unshift
131
- seq1 = CvSeq.new(CvPoint).unshift(CvPoint.new(10, 20), CvPoint.new(30, 40))
147
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).unshift(CvPoint.new(10, 20), CvPoint.new(30, 40))
132
148
 
133
149
  assert_equal(2, seq1.total)
134
150
  assert_equal(CvPoint, seq1[0].class)
@@ -138,7 +154,7 @@ class TestCvSeq < OpenCVTestCase
138
154
  assert_equal(10, seq1[1].x)
139
155
  assert_equal(20, seq1[1].y)
140
156
 
141
- seq2 = CvSeq.new(CvPoint).unshift(CvPoint.new(50, 60))
157
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_POINT).unshift(CvPoint.new(50, 60))
142
158
  seq2.unshift(seq1)
143
159
  assert_equal(3, seq2.total)
144
160
  assert_equal(CvPoint, seq1[0].class)
@@ -151,24 +167,24 @@ class TestCvSeq < OpenCVTestCase
151
167
  assert_equal(50, seq2[2].x)
152
168
  assert_equal(60, seq2[2].y)
153
169
 
154
- seq3 = CvSeq.new(Fixnum).unshift(10, 20, 30)
170
+ seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).unshift(10, 20, 30)
155
171
  assert_equal(3, seq3.total)
156
172
  assert_equal(30, seq3[0])
157
173
  assert_equal(20, seq3[1])
158
174
  assert_equal(10, seq3[2])
159
175
 
160
176
  assert_raise(TypeError) {
161
- seq1.unshift(CvPoint2D32f.new(55.5, 66.6))
177
+ seq1.unshift(10)
162
178
  }
163
179
 
164
180
  assert_raise(TypeError) {
165
- seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6))
181
+ seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30)
166
182
  seq1.unshift(seq3)
167
183
  }
168
184
  end
169
185
 
170
186
  def test_shift
171
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
187
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
172
188
  point1 = seq1.shift
173
189
  assert_equal(CvPoint, point1.class)
174
190
  assert_equal(10, point1.x)
@@ -179,38 +195,38 @@ class TestCvSeq < OpenCVTestCase
179
195
  assert_equal(30, seq1[0].x)
180
196
  assert_equal(40, seq1[0].y)
181
197
 
182
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
198
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30)
183
199
  assert_equal(10, seq2.shift)
184
200
  assert_equal(20, seq2.shift)
185
201
  assert_equal(30, seq2.shift)
186
202
 
187
- assert_nil(CvSeq.new(CvPoint).shift)
203
+ assert_nil(CvSeq.new(CV_SEQ_ELTYPE_POINT).shift)
188
204
  end
189
205
 
190
206
  def test_first
191
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
207
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
192
208
  point1 = seq1.first
193
209
  assert_equal(CvPoint, point1.class)
194
210
  assert_equal(10, point1.x)
195
211
  assert_equal(20, point1.y)
196
212
 
197
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
213
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30)
198
214
  assert_equal(10, seq2.first)
199
215
  end
200
216
 
201
217
  def test_last
202
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
218
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
203
219
  point1 = seq1.last
204
220
  assert_equal(CvPoint, point1.class)
205
221
  assert_equal(50, point1.x)
206
222
  assert_equal(60, point1.y)
207
223
 
208
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
224
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30)
209
225
  assert_equal(30, seq2.last)
210
226
  end
211
227
 
212
228
  def test_each
213
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
229
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
214
230
  i = 0
215
231
  seq1.each { |s|
216
232
  assert_equal(CvPoint, s.class)
@@ -220,7 +236,7 @@ class TestCvSeq < OpenCVTestCase
220
236
  }
221
237
  assert_equal(3, i)
222
238
 
223
- seq2 = CvSeq.new(Fixnum).push(10, 20, 30)
239
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30)
224
240
  i = 0
225
241
  seq2.each { |s|
226
242
  assert_equal(seq2[i], s)
@@ -230,7 +246,7 @@ class TestCvSeq < OpenCVTestCase
230
246
  end
231
247
 
232
248
  def test_each_index
233
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
249
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
234
250
  n = 0
235
251
  seq1.each_index { |i|
236
252
  assert_equal(n, i)
@@ -240,7 +256,7 @@ class TestCvSeq < OpenCVTestCase
240
256
  end
241
257
 
242
258
  def test_insert
243
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
259
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40))
244
260
  seq1.insert(1, CvPoint.new(50, 60))
245
261
  assert_equal(3, seq1.total)
246
262
  assert_equal(CvPoint, seq1[0].class)
@@ -253,7 +269,7 @@ class TestCvSeq < OpenCVTestCase
253
269
  assert_equal(30, seq1[2].x)
254
270
  assert_equal(40, seq1[2].y)
255
271
 
256
- seq2 = CvSeq.new(Fixnum).push(10, 20)
272
+ seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20)
257
273
  seq2.insert(1, 15)
258
274
  assert_equal(3, seq2.total)
259
275
  assert_equal(10, seq2[0])
@@ -262,7 +278,7 @@ class TestCvSeq < OpenCVTestCase
262
278
  end
263
279
 
264
280
  def test_remove
265
- seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
281
+ seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60))
266
282
 
267
283
  seq1.remove(1)
268
284
  assert_equal(2, seq1.total)
data/test/test_opencv.rb CHANGED
@@ -9,14 +9,14 @@ include OpenCV
9
9
  class TestOpenCV < OpenCVTestCase
10
10
  def test_constants
11
11
  # OpenCV version
12
- assert_equal('2.4.8', CV_VERSION)
12
+ assert_equal('2.4.10', CV_VERSION)
13
13
  assert_equal(2, CV_MAJOR_VERSION)
14
14
  assert_equal(4, CV_MINOR_VERSION)
15
- assert_equal(8, CV_SUBMINOR_VERSION)
15
+ assert_equal(10, CV_SUBMINOR_VERSION)
16
16
 
17
17
  assert_equal(2, CV_VERSION_EPOCH)
18
18
  assert_equal(4, CV_VERSION_MAJOR)
19
- assert_equal(8, CV_VERSION_MINOR)
19
+ assert_equal(10, CV_VERSION_MINOR)
20
20
  assert_equal(0, CV_VERSION_REVISION)
21
21
 
22
22
  # Depths
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.13
4
+ version: 0.0.14.pre
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: 2014-03-30 00:00:00.000000000 Z
13
+ date: 2015-01-24 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: rdoc
@@ -60,14 +60,14 @@ dependencies:
60
60
  requirements:
61
61
  - - "~>"
62
62
  - !ruby/object:Gem::Version
63
- version: '3.10'
63
+ version: '3.13'
64
64
  type: :development
65
65
  prerelease: false
66
66
  version_requirements: !ruby/object:Gem::Requirement
67
67
  requirements:
68
68
  - - "~>"
69
69
  - !ruby/object:Gem::Version
70
- version: '3.10'
70
+ version: '3.13'
71
71
  description: ruby-opencv is a wrapper of OpenCV for Ruby. It helps you to write computer
72
72
  vision programs (e.g. detecting faces from pictures) with Ruby.
73
73
  email:
@@ -341,59 +341,59 @@ required_ruby_version: !ruby/object:Gem::Requirement
341
341
  version: '0'
342
342
  required_rubygems_version: !ruby/object:Gem::Requirement
343
343
  requirements:
344
- - - ">="
344
+ - - ">"
345
345
  - !ruby/object:Gem::Version
346
- version: '0'
346
+ version: 1.3.1
347
347
  requirements: []
348
348
  rubyforge_project:
349
- rubygems_version: 2.2.2
349
+ rubygems_version: 2.4.5
350
350
  signing_key:
351
351
  specification_version: 4
352
352
  summary: OpenCV wrapper for Ruby
353
353
  test_files:
354
- - test/test_cvcontour.rb
355
- - test/test_eigenfaces.rb
356
- - test/test_cvmoments.rb
357
- - test/test_cvseq.rb
358
- - test/test_cvcontourtree.rb
359
- - test/test_cvbox2d.rb
360
- - test/test_iplimage.rb
361
- - test/test_cvvideowriter.rb
362
- - test/test_cvline.rb
363
- - test/test_cvhumoments.rb
364
- - test/test_cvfont.rb
365
- - test/test_cvconnectedcomp.rb
366
- - test/test_cvhistogram.rb
367
354
  - test/test_trackbar.rb
368
- - test/test_cvmat_imageprocessing.rb
369
- - test/test_cvhaarclassifiercascade.rb
370
- - test/test_cvcircle32f.rb
371
- - test/test_cvcapture.rb
355
+ - test/test_cvhistogram.rb
356
+ - test/test_cvpoint.rb
372
357
  - test/test_cvmat_dxt.rb
373
- - test/test_cvrect.rb
374
358
  - test/test_iplconvkernel.rb
375
- - test/test_cvsurfpoint.rb
376
- - test/test_cvavgcomp.rb
377
- - test/test_cvscalar.rb
378
- - test/test_pointset.rb
359
+ - test/test_cvconnectedcomp.rb
379
360
  - test/test_curve.rb
380
- - test/test_cvtermcriteria.rb
381
- - test/test_cvtwopoints.rb
382
- - test/test_cvsurfparams.rb
383
- - test/test_cvpoint2d32f.rb
384
- - test/test_cvpoint3d32f.rb
385
- - test/test_cvfeaturetree.rb
386
361
  - test/test_mouseevent.rb
387
- - test/test_cvchain.rb
388
- - test/test_cvmat.rb
362
+ - test/test_cvsurfpoint.rb
363
+ - test/test_eigenfaces.rb
364
+ - test/test_cvtwopoints.rb
365
+ - test/test_cvbox2d.rb
366
+ - test/test_cvmat_imageprocessing.rb
367
+ - test/test_cvtermcriteria.rb
389
368
  - test/test_fisherfaces.rb
390
- - test/test_cverror.rb
391
- - test/test_cvpoint.rb
369
+ - test/test_cvvideowriter.rb
370
+ - test/test_cvmoments.rb
392
371
  - test/test_cvsize2d32f.rb
393
- - test/test_preliminary.rb
372
+ - test/test_cvsize.rb
373
+ - test/test_cvcircle32f.rb
374
+ - test/test_cvavgcomp.rb
375
+ - test/test_cvscalar.rb
376
+ - test/test_cvhaarclassifiercascade.rb
377
+ - test/test_cvrect.rb
378
+ - test/test_cvfont.rb
394
379
  - test/test_cvmat_drawing.rb
380
+ - test/test_cvhumoments.rb
381
+ - test/test_cvmat.rb
382
+ - test/test_cvcapture.rb
383
+ - test/test_pointset.rb
384
+ - test/test_cvcontour.rb
385
+ - test/test_opencv.rb
386
+ - test/test_cvline.rb
395
387
  - test/test_lbph.rb
396
- - test/test_cvsize.rb
388
+ - test/test_iplimage.rb
389
+ - test/test_cvcontourtree.rb
397
390
  - test/test_window.rb
391
+ - test/test_cvpoint3d32f.rb
392
+ - test/test_cvseq.rb
393
+ - test/test_preliminary.rb
394
+ - test/test_cvsurfparams.rb
395
+ - test/test_cvchain.rb
396
+ - test/test_cvfeaturetree.rb
397
+ - test/test_cvpoint2d32f.rb
398
+ - test/test_cverror.rb
398
399
  - test/test_cvslice.rb
399
- - test/test_opencv.rb