diff --git a/README.md b/README.md index 4389b26..ca41aa1 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ An OpenCV wrapper for Ruby. * Web site: -* Ruby 1.9.3, 2.0.0, 2.1.x and OpenCV 2.4.8 are supported. +* Ruby 1.9.3, 2.x and OpenCV 2.4.9 are supported. ## Requirement diff --git a/ext/opencv/cvcontour.cpp b/ext/opencv/cvcontour.cpp index 6be883d..f3409b4 100644 --- a/ext/opencv/cvcontour.cpp +++ b/ext/opencv/cvcontour.cpp @@ -42,31 +42,49 @@ rb_allocate(VALUE klass) /* * Constructor - * @overload new(storage = nil) + * + * @overload new(seq_flags = CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_GENERIC, storage = nil) + * @param [Fixnum] seq_flags Flags of the created sequence, which are combinations of + * the element types and sequence types. + * - Element type: + * - CV_SEQ_ELTYPE_POINT: {CvPoint} + * - CV_32FC2: {CvPoint2D32f} + * - CV_SEQ_ELTYPE_POINT3D: {CvPoint3D32f} + * - CV_SEQ_ELTYPE_INDEX: Fixnum + * - CV_SEQ_ELTYPE_CODE: Fixnum (Freeman code) + * - Sequence type: + * - CV_SEQ_KIND_GENERIC: Generic sequence + * - CV_SEQ_KIND_CURVE: Curve * @param [CvMemStorage] storage Sequence location * @return [CvContour] self * @opencv_func cvCreateSeq + * @example + * seq = CvContour.new(CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_CURVE) + * seq << CvPoint.new(1, 2) + * seq << 3 #=> TypeError */ VALUE rb_initialize(int argc, VALUE *argv, VALUE self) { - VALUE storage; - rb_scan_args(argc, argv, "01", &storage); + VALUE seq_flags_value, storage_value; + rb_scan_args(argc, argv, "02", &seq_flags_value, &storage_value); - if (NIL_P(storage)) - storage = cCvMemStorage::new_object(0); - else - storage = CHECK_CVMEMSTORAGE(storage); + int seq_flags = 0; + if (NIL_P(seq_flags_value)) { + seq_flags = CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_GENERIC; + } + else { + Check_Type(seq_flags_value, T_FIXNUM); + seq_flags = FIX2INT(seq_flags_value); + } + storage_value = CHECK_CVMEMSTORAGE(storage_value); try { - DATA_PTR(self) = (CvContour*)cvCreateSeq(CV_SEQ_ELTYPE_POINT, sizeof(CvContour), - sizeof(CvPoint), CVMEMSTORAGE(storage)); + DATA_PTR(self) = (CvContour*)cCvSeq::create_seq(seq_flags, sizeof(CvContour), storage_value); } catch (cv::Exception& e) { raise_cverror(e); } - cCvSeq::register_elem_class(CVSEQ(self), cCvPoint::rb_class()); - register_root_object(CVSEQ(self), storage); return self; } diff --git a/ext/opencv/cvhistogram.cpp b/ext/opencv/cvhistogram.cpp index 6e3ca33..1c2449e 100644 --- a/ext/opencv/cvhistogram.cpp +++ b/ext/opencv/cvhistogram.cpp @@ -193,6 +193,9 @@ rb_calc_hist_bang(int argc, VALUE* argv, VALUE self) rb_scan_args(argc, argv, "12", &images, &accumulate, &mask); Check_Type(images, T_ARRAY); int num_images = RARRAY_LEN(images); + if (num_images == 0) { + rb_raise(rb_eArgError, "One or more arrays are required."); + } IplImage** img = ALLOCA_N(IplImage*, num_images); VALUE* images_ptr = RARRAY_PTR(images); for (int i = 0; i < num_images; i++) { @@ -205,7 +208,6 @@ rb_calc_hist_bang(int argc, VALUE* argv, VALUE self) catch (cv::Exception& e) { raise_cverror(e); } - return self; } diff --git a/ext/opencv/cvmat.cpp b/ext/opencv/cvmat.cpp index e1cbfdf..8129dbe 100644 --- a/ext/opencv/cvmat.cpp +++ b/ext/opencv/cvmat.cpp @@ -2276,6 +2276,47 @@ rb_min_max_loc(int argc, VALUE *argv, VALUE self) return rb_ary_new3(4, rb_float_new(min_val), rb_float_new(max_val), min_loc, max_loc); } +/* + * Calculates an absolute array norm, an absolute difference norm, or a relative difference norm. + * + * @overload norm(src1, src2=nil, norm_type=NORM_L2, mask=nil) + * @param src1 [CvMat] First input array. + * @param src2 [CvMat] Second input array of the same size and the same type as src1. + * @param norm_type [Integer] Type of the norm. + * @param mask [CvMat] Optional operation mask; it must have the same size as src1 and CV_8UC1 type. + * @return [Number] The norm of two arrays. + * @opencv_func cvNorm + * @scope class + */ +VALUE +rb_norm(int argc, VALUE *argv, VALUE self) +{ + VALUE src1, src2, norm_type_val, mask_val; + rb_scan_args(argc, argv, "13", &src1, &src2, &norm_type_val, &mask_val); + + CvMat *src1_ptr = NULL; + CvMat *src2_ptr = NULL; + int norm_type = NIL_P(norm_type_val) ? cv::NORM_L2 : NUM2INT(norm_type_val); + CvMat *mask = NULL; + double norm = 0.0; + + try { + src1_ptr = CVMAT_WITH_CHECK(src1); + if (!NIL_P(src2)) { + src2_ptr = CVMAT_WITH_CHECK(src2); + } + if (!NIL_P(mask_val)) { + mask = CVMAT_WITH_CHECK(mask_val); + } + norm = cvNorm(src1_ptr, src2_ptr, norm_type, mask); + } + catch (cv::Exception& e) { + raise_cverror(e); + } + + return DBL2NUM(norm); +} + /* * Calculates the dot product of two arrays in Euclidean metrics. * @@ -5913,6 +5954,7 @@ init_ruby_class() rb_define_method(rb_klass, "avg_sdv", RUBY_METHOD_FUNC(rb_avg_sdv), -1); rb_define_method(rb_klass, "sdv", RUBY_METHOD_FUNC(rb_sdv), -1); rb_define_method(rb_klass, "min_max_loc", RUBY_METHOD_FUNC(rb_min_max_loc), -1); + rb_define_singleton_method(rb_klass, "norm", RUBY_METHOD_FUNC(rb_norm), -1); rb_define_method(rb_klass, "dot_product", RUBY_METHOD_FUNC(rb_dot_product), 1); rb_define_method(rb_klass, "cross_product", RUBY_METHOD_FUNC(rb_cross_product), 1); rb_define_method(rb_klass, "transform", RUBY_METHOD_FUNC(rb_transform), -1); diff --git a/ext/opencv/cvmat.h b/ext/opencv/cvmat.h index 2046040..168c280 100644 --- a/ext/opencv/cvmat.h +++ b/ext/opencv/cvmat.h @@ -119,7 +119,7 @@ VALUE rb_avg_sdv(int argc, VALUE *argv, VALUE self); VALUE rb_sdv(int argc, VALUE *argv, VALUE self); VALUE rb_min_max_loc(int argc, VALUE *argv, VALUE self); -//VALUE rb_norm(); +VALUE rb_norm(int argc, VALUE *argv, VALUE self); VALUE rb_dot_product(VALUE self, VALUE mat); VALUE rb_cross_product(VALUE self, VALUE mat); // VALUE rb_gemm(); diff --git a/ext/opencv/cvmemstorage.h b/ext/opencv/cvmemstorage.h index 7dcefe6..9cb7533 100644 --- a/ext/opencv/cvmemstorage.h +++ b/ext/opencv/cvmemstorage.h @@ -39,13 +39,10 @@ CVMEMSTORAGE(VALUE object) inline VALUE CHECK_CVMEMSTORAGE(VALUE object) { - if (rb_obj_is_kind_of(object, cCvMemStorage::rb_class())) + if (rb_obj_is_kind_of(object, cCvMemStorage::rb_class())) { return object; - else { - if (!NIL_P(object)) - rb_warn("invalid CvMemStorage object given. allocate new memory storage automatically."); - return cCvMemStorage::new_object(); } + return cCvMemStorage::new_object(); } __NAMESPACE_END_OPENCV diff --git a/ext/opencv/cvseq.cpp b/ext/opencv/cvseq.cpp index a9da209..58ec754 100644 --- a/ext/opencv/cvseq.cpp +++ b/ext/opencv/cvseq.cpp @@ -10,27 +10,6 @@ #include "cvseq.h" /* * Document-class: OpenCV::CvSeq - * - * Generic Sequence class. CvSeq has the method like Array (push, pop, select, etc...). - * But, CvSeq cannot store the object of a different class. - * When storing object in CvSeq, conversion is automatically tried, - * and the object occurs the error if it cannot be done. - * - * e.g. - * seq = CvSeq.new(CvPoint) # Argument mean "this sequence contain only this class's object" - * seq.push(CvPoint.new(0, 0)) # => it's ok - * seq.push("hello") # => try convert "hello" to CvPoint. but can't do it. raise error. - * - * If the sequecne contain object of class A. - * When storing object(named "obj") of class B to the sequence. - * Try automatically : A.from_B(obj) => object of class A. - * - * The sequence might have another sequence outside. see below. - * Each sequece has h_prev, h_next, v_prev, v_next method. - * If the adjoining sequence exists, each method return the adjoining sequence. - * Otherwise return nil. - * - * link:../images/CvSeq_relationmap.png */ __NAMESPACE_BEGIN_OPENCV __NAMESPACE_BEGIN_CVSEQ @@ -80,62 +59,116 @@ rb_allocate(VALUE klass) return Data_Wrap_Struct(klass, 0, unregister_elem_class, ptr); } -/* - * call-seq: - * CvSeq.new(type[,storage]) - * - * Return a new CvSeq. type should be following classes. - * - * * CvIndex - * * CvPoint - */ -VALUE -rb_initialize(int argc, VALUE *argv, VALUE self) +CvSeq* +create_seq(int seq_flags, size_t header_size, VALUE storage_value) { - VALUE klass, storage_value; + VALUE klass = Qnil; + int eltype = seq_flags & CV_SEQ_ELTYPE_MASK; + storage_value = CHECK_CVMEMSTORAGE(storage_value); - rb_scan_args(argc, argv, "11", &klass, &storage_value); - if (!rb_obj_is_kind_of(klass, rb_cClass)) - raise_typeerror(klass, rb_cClass); + switch (eltype) { + case CV_SEQ_ELTYPE_POINT: + klass = cCvPoint::rb_class(); + break; + case CV_32FC2: + klass = cCvPoint2D32f::rb_class(); + break; + case CV_SEQ_ELTYPE_POINT3D: + klass = cCvPoint3D32f::rb_class(); + break; + case CV_SEQ_ELTYPE_CODE: + case CV_SEQ_ELTYPE_INDEX: + klass = rb_cFixnum; + break; + case CV_SEQ_ELTYPE_PPOINT: // or CV_SEQ_ELTYPE_PTR: + // Not supported + rb_raise(rb_eArgError, "seq_flags %d is not supported.", eltype); + break; + default: + seq_flags = CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_GENERIC; + klass = cCvPoint::rb_class(); + break; + } - int type = 0, size = 0; - if (klass == rb_cFixnum) { - type = CV_SEQ_ELTYPE_INDEX; - size = sizeof(int); - } - else if (klass == cCvPoint::rb_class()) { - type = CV_SEQ_ELTYPE_POINT; - size = sizeof(CvPoint); - } - else if (klass == cCvPoint2D32f::rb_class()) { - type = CV_SEQ_ELTYPE_POINT; - size = sizeof(CvPoint2D32f); - } - else if (klass == cCvPoint3D32f::rb_class()) { - type = CV_SEQ_ELTYPE_POINT3D; - size = sizeof(CvPoint3D32f); - } - else - rb_raise(rb_eArgError, "unsupport %s class for sequence-block.", rb_class2name(klass)); - + int mat_type = CV_MAT_TYPE(seq_flags); + size_t elem_size = (size_t)(CV_ELEM_SIZE(mat_type)); CvSeq* seq = NULL; - if (NIL_P(storage_value)) { - storage_value = cCvMemStorage::new_object(0); - } - else { - storage_value = CHECK_CVMEMSTORAGE(storage_value); - } - try { - seq = cvCreateSeq(type, sizeof(CvSeq), size, CVMEMSTORAGE(storage_value)); + seq = cvCreateSeq(seq_flags, header_size, elem_size, CVMEMSTORAGE(storage_value)); } catch (cv::Exception& e) { raise_cverror(e); } - DATA_PTR(self) = seq; register_elem_class(seq, klass); register_root_object(seq, storage_value); + return seq; +} + +VALUE +class2seq_flags_value(VALUE klass) { + int seq_flags; + if (klass == cCvPoint::rb_class()) { + seq_flags = CV_SEQ_ELTYPE_POINT; + } + else if (klass == cCvPoint2D32f::rb_class()) { + seq_flags = CV_32FC2; + } + else if (klass == cCvPoint3D32f::rb_class()) { + seq_flags = CV_SEQ_ELTYPE_POINT3D; + } + else if (klass == rb_cFixnum) { + seq_flags = CV_SEQ_ELTYPE_INDEX; + } + else { + rb_raise(rb_eTypeError, "unexpected type: %s", rb_class2name(klass)); + } + + return INT2NUM(seq_flags | CV_SEQ_KIND_GENERIC); +} + +/* + * Constructor + * + * @overload new(seq_flags, storage = nil) + * @param [Fixnum] seq_flags Flags of the created sequence, which are combinations of + * the element types and sequence types. + * - Element type: + * - CV_SEQ_ELTYPE_POINT: {CvPoint} + * - CV_32FC2: {CvPoint2D32f} + * - CV_SEQ_ELTYPE_POINT3D: {CvPoint3D32f} + * - CV_SEQ_ELTYPE_INDEX: Fixnum + * - CV_SEQ_ELTYPE_CODE: Fixnum (Freeman code) + * - Sequence type: + * - CV_SEQ_KIND_GENERIC: Generic sequence + * - CV_SEQ_KIND_CURVE: Curve + * @param [CvMemStorage] storage Sequence location + * @return [CvSeq] self + * @opencv_func cvCreateSeq + * @example + * seq1 = CvSeq.new(CV_SEQ_ELTYPE_INDEX) + * seq1 << 1 + * seq1 << CvPoint.new(1, 2) #=> TypeError + * + * seq2 = CvSeq.new(CV_SEQ_ELTYPE_POINT | CV_SEQ_KIND_CURVE) + * seq2 << CvPoint.new(1, 2) + * seq2 << 3 #=> TypeError + */ +VALUE +rb_initialize(int argc, VALUE *argv, VALUE self) +{ + VALUE seq_flags_value, storage_value; + rb_scan_args(argc, argv, "11", &seq_flags_value, &storage_value); + int seq_flags = 0; + + if (TYPE(seq_flags_value) == T_CLASS) { // To maintain backward compatibility + seq_flags_value = class2seq_flags_value(seq_flags_value); + } + Check_Type(seq_flags_value, T_FIXNUM); + seq_flags = FIX2INT(seq_flags_value); + + DATA_PTR(self) = create_seq(seq_flags, sizeof(CvSeq), storage_value); + return self; } @@ -174,17 +207,22 @@ rb_aref(VALUE self, VALUE index) { CvSeq *seq = CVSEQ(self); int idx = NUM2INT(index); - if (seq->total == 0) + if (seq->total == 0) { return Qnil; - if (idx >= seq->total) + } + if (idx >= seq->total) { rb_raise(rb_eIndexError, "index %d out of sequence", idx); + } VALUE result = Qnil; try { - if (seqblock_class(seq) == rb_cFixnum) + VALUE klass = seqblock_class(seq); + if (RTEST(rb_class_inherited_p(klass, rb_cInteger))) { result = INT2NUM(*CV_GET_SEQ_ELEM(int, seq, idx)); - else - result = REFER_OBJECT(seqblock_class(seq), cvGetSeqElem(seq, idx), self); + } + else { + result = REFER_OBJECT(klass, cvGetSeqElem(seq, idx), self); + } } catch (cv::Exception& e) { raise_cverror(e); @@ -288,16 +326,20 @@ VALUE rb_seq_push(VALUE self, VALUE args, int flag) { CvSeq *seq = CVSEQ(self); - VALUE klass = seqblock_class(seq), object; + VALUE klass = seqblock_class(seq); volatile void *elem = NULL; int len = RARRAY_LEN(args); - for (int i = 0; i < len; ++i) { - object = RARRAY_PTR(args)[i]; - if (CLASS_OF(object) == klass) { - if (TYPE(object) == T_FIXNUM) { - volatile int int_elem = FIX2INT(object); + for (int i = 0; i < len; i++) { + VALUE object = RARRAY_PTR(args)[i]; + if (rb_obj_is_kind_of(object, klass)) { + if (rb_obj_is_kind_of(object, rb_cInteger)) { + volatile int int_elem = NUM2INT(object); elem = &int_elem; } + else if (rb_obj_is_kind_of(object, rb_cNumeric)) { + volatile double double_elem = NUM2DBL(object); + elem = &double_elem; + } else { elem = (void*)DATA_PTR(object); } @@ -311,7 +353,8 @@ rb_seq_push(VALUE self, VALUE args, int flag) raise_cverror(e); } } - else if (rb_obj_is_kind_of(object, rb_klass) && CLASS_OF(rb_first(object)) == klass) { // object is CvSeq + else if ((rb_obj_is_kind_of(object, rb_klass) == Qtrue) && + RTEST(rb_class_inherited_p(seqblock_class(CVSEQ(object)), klass))) { // object is CvSeq void *buffer = NULL; try { buffer = cvCvtSeqToArray(CVSEQ(object), rb_cvAlloc(CVSEQ(object)->total * CVSEQ(object)->elem_size)); diff --git a/ext/opencv/cvseq.h b/ext/opencv/cvseq.h index 218ae5e..d4e4172 100644 --- a/ext/opencv/cvseq.h +++ b/ext/opencv/cvseq.h @@ -24,6 +24,7 @@ void init_ruby_class(); VALUE seqblock_class(void *ptr); void register_elem_class(CvSeq *seq, VALUE klass); void unregister_elem_class(void *ptr); +CvSeq* create_seq(int seq_flags, size_t header_size, VALUE storage_value); VALUE rb_allocate(VALUE klass); diff --git a/ext/opencv/opencv.cpp b/ext/opencv/opencv.cpp index de88cf8..e02bbdb 100644 --- a/ext/opencv/opencv.cpp +++ b/ext/opencv/opencv.cpp @@ -388,6 +388,47 @@ init_ruby_module() rb_define_const(rb_module, "COLORMAP_PINK", INT2FIX(cv::COLORMAP_PINK)); rb_define_const(rb_module, "COLORMAP_HOT", INT2FIX(cv::COLORMAP_HOT)); + /* Sequence types */ + rb_define_const(rb_module, "CV_SEQ_ELTYPE_BITS", INT2FIX(CV_SEQ_ELTYPE_BITS)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_MASK", INT2FIX(CV_SEQ_ELTYPE_MASK)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_POINT", INT2FIX(CV_SEQ_ELTYPE_POINT)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_CODE", INT2FIX(CV_SEQ_ELTYPE_CODE)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_GENERIC", INT2FIX(CV_SEQ_ELTYPE_GENERIC)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_PTR", INT2FIX(CV_SEQ_ELTYPE_PTR)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_PPOINT", INT2FIX(CV_SEQ_ELTYPE_PPOINT)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_INDEX", INT2FIX(CV_SEQ_ELTYPE_INDEX)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_GRAPH_EDGE", INT2FIX(CV_SEQ_ELTYPE_GRAPH_EDGE)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_GRAPH_VERTEX", INT2FIX(CV_SEQ_ELTYPE_GRAPH_VERTEX)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_TRIAN_ATR", INT2FIX(CV_SEQ_ELTYPE_TRIAN_ATR)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_CONNECTED_COMP", INT2FIX(CV_SEQ_ELTYPE_CONNECTED_COMP)); + rb_define_const(rb_module, "CV_SEQ_ELTYPE_POINT3D", INT2FIX(CV_SEQ_ELTYPE_POINT3D)); + rb_define_const(rb_module, "CV_SEQ_KIND_BITS", INT2FIX(CV_SEQ_KIND_BITS)); + rb_define_const(rb_module, "CV_SEQ_KIND_MASK", INT2FIX(CV_SEQ_KIND_MASK)); + rb_define_const(rb_module, "CV_SEQ_KIND_GENERIC", INT2FIX(CV_SEQ_KIND_GENERIC)); + rb_define_const(rb_module, "CV_SEQ_KIND_CURVE", INT2FIX(CV_SEQ_KIND_CURVE)); + rb_define_const(rb_module, "CV_SEQ_KIND_BIN_TREE", INT2FIX(CV_SEQ_KIND_BIN_TREE)); + rb_define_const(rb_module, "CV_SEQ_KIND_GRAPH", INT2FIX(CV_SEQ_KIND_GRAPH)); + rb_define_const(rb_module, "CV_SEQ_KIND_SUBDIV2D", INT2FIX(CV_SEQ_KIND_SUBDIV2D)); + rb_define_const(rb_module, "CV_SEQ_FLAG_SHIFT", INT2FIX(CV_SEQ_FLAG_SHIFT)); + rb_define_const(rb_module, "CV_SEQ_FLAG_CLOSED", INT2FIX(CV_SEQ_FLAG_CLOSED)); + rb_define_const(rb_module, "CV_SEQ_FLAG_SIMPLE", INT2FIX(CV_SEQ_FLAG_SIMPLE)); + rb_define_const(rb_module, "CV_SEQ_FLAG_CONVEX", INT2FIX(CV_SEQ_FLAG_CONVEX)); + rb_define_const(rb_module, "CV_SEQ_FLAG_HOLE", INT2FIX(CV_SEQ_FLAG_HOLE)); + rb_define_const(rb_module, "CV_GRAPH_FLAG_ORIENTED", INT2FIX(CV_GRAPH_FLAG_ORIENTED)); + rb_define_const(rb_module, "CV_GRAPH", INT2FIX(CV_GRAPH)); + rb_define_const(rb_module, "CV_ORIENTED_GRAPH", INT2FIX(CV_ORIENTED_GRAPH)); + rb_define_const(rb_module, "CV_SEQ_POINT_SET", INT2FIX(CV_SEQ_POINT_SET)); + rb_define_const(rb_module, "CV_SEQ_POINT3D_SET", INT2FIX(CV_SEQ_POINT3D_SET)); + rb_define_const(rb_module, "CV_SEQ_POLYLINE", INT2FIX(CV_SEQ_POLYLINE)); + rb_define_const(rb_module, "CV_SEQ_POLYGON", INT2FIX(CV_SEQ_POLYGON)); + rb_define_const(rb_module, "CV_SEQ_CONTOUR", INT2FIX(CV_SEQ_CONTOUR)); + rb_define_const(rb_module, "CV_SEQ_SIMPLE_POLYGON", INT2FIX(CV_SEQ_SIMPLE_POLYGON)); + rb_define_const(rb_module, "CV_SEQ_CHAIN", INT2FIX(CV_SEQ_CHAIN)); + rb_define_const(rb_module, "CV_SEQ_CHAIN_CONTOUR", INT2FIX(CV_SEQ_CHAIN_CONTOUR)); + rb_define_const(rb_module, "CV_SEQ_POLYGON_TREE", INT2FIX(CV_SEQ_POLYGON_TREE)); + rb_define_const(rb_module, "CV_SEQ_CONNECTED_COMP", INT2FIX(CV_SEQ_CONNECTED_COMP)); + rb_define_const(rb_module, "CV_SEQ_INDEX", INT2FIX(CV_SEQ_INDEX)); + VALUE inversion_method = rb_hash_new(); /* {:lu, :svd, :svd_sym(:svd_symmetric)}: Inversion method */ rb_define_const(rb_module, "INVERSION_METHOD", inversion_method); diff --git a/lib/opencv/version.rb b/lib/opencv/version.rb index b301baa..4b23b40 100755 --- a/lib/opencv/version.rb +++ b/lib/opencv/version.rb @@ -1,4 +1,4 @@ module OpenCV - VERSION = '0.0.13' + VERSION = '0.0.14.pre' end diff --git a/ruby-opencv.gemspec b/ruby-opencv.gemspec index a8baac3..2541516 100644 --- a/ruby-opencv.gemspec +++ b/ruby-opencv.gemspec @@ -1,15 +1,15 @@ # -*- encoding: utf-8 -*- -# stub: ruby-opencv 0.0.13.20140330211753 ruby lib +# stub: ruby-opencv 0.0.14.pre.20150125030210 ruby lib # stub: ext/opencv/extconf.rb Gem::Specification.new do |s| s.name = "ruby-opencv" - s.version = "0.0.13.20140330211753" + s.version = "0.0.14.pre.20150125030210" - s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= + s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version= s.require_paths = ["lib"] s.authors = ["lsxi", "ser1zw", "pcting"] - s.date = "2014-03-30" + s.date = "2015-01-24" 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." s.email = ["masakazu.yonekura@gmail.com", "azariahsawtikes@gmail.com", "pcting@gmail.com"] s.extensions = ["ext/opencv/extconf.rb"] @@ -18,9 +18,9 @@ Gem::Specification.new do |s| s.homepage = "https://github.com/ruby-opencv/ruby-opencv/" s.licenses = ["The BSD License"] s.rdoc_options = ["--main", "README.md"] - s.rubygems_version = "2.2.2" + s.rubygems_version = "2.4.5" s.summary = "OpenCV wrapper for Ruby" - 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"] + 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"] if s.respond_to? :specification_version then s.specification_version = 4 @@ -29,17 +29,17 @@ Gem::Specification.new do |s| s.add_development_dependency(%q, ["~> 4.0"]) s.add_development_dependency(%q, ["~> 0"]) s.add_development_dependency(%q, ["~> 0"]) - s.add_development_dependency(%q, ["~> 3.10"]) + s.add_development_dependency(%q, ["~> 3.13"]) else s.add_dependency(%q, ["~> 4.0"]) s.add_dependency(%q, ["~> 0"]) s.add_dependency(%q, ["~> 0"]) - s.add_dependency(%q, ["~> 3.10"]) + s.add_dependency(%q, ["~> 3.13"]) end else s.add_dependency(%q, ["~> 4.0"]) s.add_dependency(%q, ["~> 0"]) s.add_dependency(%q, ["~> 0"]) - s.add_dependency(%q, ["~> 3.10"]) + s.add_dependency(%q, ["~> 3.13"]) end end diff --git a/test/test_cvconnectedcomp.rb b/test/test_cvconnectedcomp.rb index 2bf84ba..4105c40 100755 --- a/test/test_cvconnectedcomp.rb +++ b/test/test_cvconnectedcomp.rb @@ -10,7 +10,7 @@ include OpenCV class TestCvConnectedComp < OpenCVTestCase def setup @connected_comp = CvConnectedComp.new(9216, CvScalar.new(1, 2, 3, 4), - CvRect.new(1, 2, 3, 4), CvSeq.new(CvPoint)) + CvRect.new(1, 2, 3, 4), CvSeq.new(CV_SEQ_ELTYPE_INDEX)) end def test_initialize @@ -22,7 +22,7 @@ class TestCvConnectedComp < OpenCVTestCase assert_not_nil(connected_comp.contour) connected_comp = CvConnectedComp.new(100, CvScalar.new(1, 2, 3, 4), - CvRect.new(1, 2, 3, 4), CvSeq.new(CvPoint)) + CvRect.new(1, 2, 3, 4), CvSeq.new(CV_SEQ_ELTYPE_POINT)) assert_equal(CvConnectedComp, connected_comp.class) assert_not_nil(connected_comp.area) assert_not_nil(connected_comp.value) diff --git a/test/test_cvcontourtree.rb b/test/test_cvcontourtree.rb index 79a1a5a..9ab0dd7 100755 --- a/test/test_cvcontourtree.rb +++ b/test/test_cvcontourtree.rb @@ -9,11 +9,11 @@ include OpenCV # Tests for OpenCV::CvContourTree class TestCvContourTree < OpenCVTestCase def setup - @tree = CvContourTree.new(CvPoint) + @tree = CvContourTree.new(CV_SEQ_ELTYPE_POINT) end def test_initialize - tree = CvContourTree.new(CvPoint) + tree = CvContourTree.new(CV_SEQ_ELTYPE_POINT) assert_equal(CvContourTree, tree.class) assert(tree.is_a? CvSeq) end diff --git a/test/test_cvhistogram.rb b/test/test_cvhistogram.rb index 8734d4e..aa58353 100755 --- a/test/test_cvhistogram.rb +++ b/test/test_cvhistogram.rb @@ -74,7 +74,7 @@ class TestCvHistogram < OpenCVTestCase assert_raise(TypeError) { @hist1.calc_hist([img], true, DUMMY_OBJ) } - assert_raise(CvStsBadArg) { + assert_raise(ArgumentError) { @hist1.calc_hist([]) } end diff --git a/test/test_cvmat.rb b/test/test_cvmat.rb index 9d1274d..0187551 100755 --- a/test/test_cvmat.rb +++ b/test/test_cvmat.rb @@ -2161,6 +2161,39 @@ class TestCvMat < OpenCVTestCase } end + def test_norm + src1 = CvMat.new(3, 3, :cv32f, 1).set_data([1, 2, 3, 4, 5, 6, 7, 8, 9]) + src2 = CvMat.new(3, 3, :cv32f, 1).set_data([2, 3, 4, 5, 6, 7, 8, 9, 1]) + mask = CvMat.new(3, 3, :cv8u, 1).set_data([1, 1, 0, 1, 1, 0, 0, 0, 0]) + + assert_in_delta(CvMat.norm(src1), 16.88, 0.01) + + assert_in_delta(CvMat.norm(src1, nil, CV_NORM_L1), 45.0, 0.01) + assert_in_delta(CvMat.norm(src1, nil, CV_NORM_L2), 16.88, 0.01) + assert_in_delta(CvMat.norm(src1, nil, CV_NORM_INF), 9.0, 0.01) + + assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L1), 16.0, 0.01) + assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L2), 8.49, 0.01) + assert_in_delta(CvMat.norm(src1, src2, CV_NORM_INF), 8.0, 0.01) + + assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L1, mask), 4.0, 0.01) + assert_in_delta(CvMat.norm(src1, src2, CV_NORM_L2, mask), 2.0, 0.01) + assert_in_delta(CvMat.norm(src1, src2, CV_NORM_INF, mask), 1.0, 0.01) + + assert_raise(TypeError) { + CvMat.norm(DUMMY_OBJ) + } + assert_raise(TypeError) { + CvMat.norm(src1, DUMMY_OBJ) + } + assert_raise(TypeError) { + CvMat.norm(src1, src2, DUMMY_OBJ) + } + assert_raise(TypeError) { + CvMat.norm(src1, src2, CV_NORM_L1, DUMMY_OBJ) + } + end + def test_dot_product m1 = create_cvmat(2, 2, :cv32f, 1) { |j, i, c| CvScalar.new(c * 0.5) diff --git a/test/test_cvseq.rb b/test/test_cvseq.rb index 19677f7..a984282 100755 --- a/test/test_cvseq.rb +++ b/test/test_cvseq.rb @@ -9,17 +9,34 @@ include OpenCV # Tests for OpenCV::CvSeq class TestCvSeq < OpenCVTestCase def test_initialize - # assert_not_nil(CvSeq.new(CvIndex)) - assert_not_nil(CvSeq.new(Fixnum)) - assert_not_nil(CvSeq.new(CvPoint)) - assert_not_nil(CvSeq.new(CvPoint2D32f)) - assert_not_nil(CvSeq.new(CvPoint3D32f)) + types = [CV_SEQ_ELTYPE_POINT, CV_SEQ_ELTYPE_POINT3D, CV_SEQ_ELTYPE_CODE, CV_SEQ_ELTYPE_INDEX] + kinds = [CV_SEQ_KIND_GENERIC, CV_SEQ_KIND_CURVE, CV_SEQ_KIND_BIN_TREE, CV_SEQ_KIND_GRAPH, CV_SEQ_KIND_SUBDIV2D] + flags = [CV_SEQ_FLAG_CLOSED, CV_SEQ_FLAG_SIMPLE, CV_SEQ_FLAG_CONVEX, CV_SEQ_FLAG_HOLE] + types.each { |type| + kinds.each { |kind| + flags.each { |flag| + seq_flag = type | kind | flag + assert_equal(CvSeq, CvSeq.new(seq_flag).class) + } + } + } - assert(CvSeq.new(CvPoint).is_a? Enumerable) + [CV_SEQ_POINT_SET, CV_SEQ_POINT3D_SET, CV_SEQ_POLYLINE, CV_SEQ_POLYGON, + CV_SEQ_CONTOUR, CV_SEQ_SIMPLE_POLYGON, CV_SEQ_CHAIN, CV_SEQ_CHAIN_CONTOUR, + CV_SEQ_INDEX ].each { |seq_flag| + assert_equal(CvSeq, CvSeq.new(seq_flag).class) + } + + # Unsupported types + [CV_SEQ_ELTYPE_PTR, CV_SEQ_ELTYPE_PPOINT].each { |type| + assert_raise(ArgumentError) { + CvSeq.new(type) + } + } end def test_total - seq1 = CvSeq.new(CvPoint) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT) assert_equal(0, seq1.total) seq1.push(CvPoint.new(1, 2)) @@ -33,13 +50,12 @@ class TestCvSeq < OpenCVTestCase end def test_empty - assert(CvSeq.new(CvPoint).empty?) - assert(CvSeq.new(CvPoint2D32f).empty?) - assert(CvSeq.new(CvPoint3D32f).empty?) + assert(CvSeq.new(CV_SEQ_ELTYPE_POINT).empty?) end def test_aref - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT) + seq1.push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) assert_equal(CvPoint, seq1[0].class) assert_equal(10, seq1[0].x) @@ -49,8 +65,8 @@ class TestCvSeq < OpenCVTestCase assert_equal(50, seq1[2].x) assert_equal(60, seq1[2].y) - seq2 = CvSeq.new(Fixnum).push(10, 20, 30) - + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX) + seq2.push(10, 20, 30) assert_equal(Fixnum, seq2[0].class) assert_equal(10, seq2[0]) assert_equal(20, seq2[1]) @@ -58,7 +74,7 @@ class TestCvSeq < OpenCVTestCase end def test_push - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) assert_equal(2, seq1.total) assert_equal(CvPoint, seq1[0].class) @@ -68,7 +84,7 @@ class TestCvSeq < OpenCVTestCase assert_equal(30, seq1[1].x) assert_equal(40, seq1[1].y) - seq2 = CvSeq.new(CvPoint).push(CvPoint.new(50, 60)) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(50, 60)) seq2.push(seq1) assert_equal(3, seq2.total) assert_equal(CvPoint, seq2[0].class) @@ -81,8 +97,8 @@ class TestCvSeq < OpenCVTestCase assert_equal(30, seq2[2].x) assert_equal(40, seq2[2].y) - seq3 = CvSeq.new(Fixnum).push(10) - seq4 = CvSeq.new(Fixnum).push(20, 30) + seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10) + seq4 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(20, 30) seq3.push(seq4) assert_equal(3, seq3.total) assert_equal(Fixnum, seq3[0].class) @@ -91,17 +107,17 @@ class TestCvSeq < OpenCVTestCase assert_equal(30, seq3[2]) assert_raise(TypeError) { - seq1.push(CvPoint2D32f.new(55.5, 66.6)) + seq1.push(55.5, 66.6) } assert_raise(TypeError) { - seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6)) + seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(55, 66) seq1.push(seq3) } end def test_pop - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) point1 = seq1.pop assert_equal(CvPoint, point1.class) assert_equal(30, point1.x) @@ -112,23 +128,23 @@ class TestCvSeq < OpenCVTestCase assert_equal(10, seq1[0].x) assert_equal(20, seq1[0].y) - assert_nil(CvSeq.new(CvPoint).pop) + assert_nil(CvSeq.new(CV_SEQ_ELTYPE_POINT).pop) - seq2 = CvSeq.new(Fixnum).push(10, 20, 30) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30) assert_equal(30, seq2.pop) assert_equal(20, seq2.pop) assert_equal(10, seq2.pop) end def test_clear - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) seq1.clear assert_not_nil(seq1) assert_equal(0, seq1.total) end def test_unshift - seq1 = CvSeq.new(CvPoint).unshift(CvPoint.new(10, 20), CvPoint.new(30, 40)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).unshift(CvPoint.new(10, 20), CvPoint.new(30, 40)) assert_equal(2, seq1.total) assert_equal(CvPoint, seq1[0].class) @@ -138,7 +154,7 @@ class TestCvSeq < OpenCVTestCase assert_equal(10, seq1[1].x) assert_equal(20, seq1[1].y) - seq2 = CvSeq.new(CvPoint).unshift(CvPoint.new(50, 60)) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_POINT).unshift(CvPoint.new(50, 60)) seq2.unshift(seq1) assert_equal(3, seq2.total) assert_equal(CvPoint, seq1[0].class) @@ -151,24 +167,24 @@ class TestCvSeq < OpenCVTestCase assert_equal(50, seq2[2].x) assert_equal(60, seq2[2].y) - seq3 = CvSeq.new(Fixnum).unshift(10, 20, 30) + seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).unshift(10, 20, 30) assert_equal(3, seq3.total) assert_equal(30, seq3[0]) assert_equal(20, seq3[1]) assert_equal(10, seq3[2]) assert_raise(TypeError) { - seq1.unshift(CvPoint2D32f.new(55.5, 66.6)) + seq1.unshift(10) } assert_raise(TypeError) { - seq3 = CvSeq.new(CvPoint2D32f).push(CvPoint2D32f.new(55.5, 66.6)) + seq3 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30) seq1.unshift(seq3) } end def test_shift - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) point1 = seq1.shift assert_equal(CvPoint, point1.class) assert_equal(10, point1.x) @@ -179,38 +195,38 @@ class TestCvSeq < OpenCVTestCase assert_equal(30, seq1[0].x) assert_equal(40, seq1[0].y) - seq2 = CvSeq.new(Fixnum).push(10, 20, 30) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30) assert_equal(10, seq2.shift) assert_equal(20, seq2.shift) assert_equal(30, seq2.shift) - assert_nil(CvSeq.new(CvPoint).shift) + assert_nil(CvSeq.new(CV_SEQ_ELTYPE_POINT).shift) end def test_first - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) point1 = seq1.first assert_equal(CvPoint, point1.class) assert_equal(10, point1.x) assert_equal(20, point1.y) - seq2 = CvSeq.new(Fixnum).push(10, 20, 30) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30) assert_equal(10, seq2.first) end def test_last - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) point1 = seq1.last assert_equal(CvPoint, point1.class) assert_equal(50, point1.x) assert_equal(60, point1.y) - seq2 = CvSeq.new(Fixnum).push(10, 20, 30) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30) assert_equal(30, seq2.last) end def test_each - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) i = 0 seq1.each { |s| assert_equal(CvPoint, s.class) @@ -220,7 +236,7 @@ class TestCvSeq < OpenCVTestCase } assert_equal(3, i) - seq2 = CvSeq.new(Fixnum).push(10, 20, 30) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20, 30) i = 0 seq2.each { |s| assert_equal(seq2[i], s) @@ -230,7 +246,7 @@ class TestCvSeq < OpenCVTestCase end def test_each_index - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) n = 0 seq1.each_index { |i| assert_equal(n, i) @@ -240,7 +256,7 @@ class TestCvSeq < OpenCVTestCase end def test_insert - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40)) seq1.insert(1, CvPoint.new(50, 60)) assert_equal(3, seq1.total) assert_equal(CvPoint, seq1[0].class) @@ -253,7 +269,7 @@ class TestCvSeq < OpenCVTestCase assert_equal(30, seq1[2].x) assert_equal(40, seq1[2].y) - seq2 = CvSeq.new(Fixnum).push(10, 20) + seq2 = CvSeq.new(CV_SEQ_ELTYPE_INDEX).push(10, 20) seq2.insert(1, 15) assert_equal(3, seq2.total) assert_equal(10, seq2[0]) @@ -262,7 +278,7 @@ class TestCvSeq < OpenCVTestCase end def test_remove - seq1 = CvSeq.new(CvPoint).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) + seq1 = CvSeq.new(CV_SEQ_ELTYPE_POINT).push(CvPoint.new(10, 20), CvPoint.new(30, 40), CvPoint.new(50, 60)) seq1.remove(1) assert_equal(2, seq1.total) diff --git a/test/test_opencv.rb b/test/test_opencv.rb index ddea724..eed0672 100755 --- a/test/test_opencv.rb +++ b/test/test_opencv.rb @@ -9,14 +9,14 @@ include OpenCV class TestOpenCV < OpenCVTestCase def test_constants # OpenCV version - assert_equal('2.4.8', CV_VERSION) + assert_equal('2.4.10', CV_VERSION) assert_equal(2, CV_MAJOR_VERSION) assert_equal(4, CV_MINOR_VERSION) - assert_equal(8, CV_SUBMINOR_VERSION) + assert_equal(10, CV_SUBMINOR_VERSION) assert_equal(2, CV_VERSION_EPOCH) assert_equal(4, CV_VERSION_MAJOR) - assert_equal(8, CV_VERSION_MINOR) + assert_equal(10, CV_VERSION_MINOR) assert_equal(0, CV_VERSION_REVISION) # Depths