mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
removed CvMat#parent and CvMat#has_parent?
This commit is contained in:
parent
7b378e7608
commit
059762efac
3 changed files with 9 additions and 52 deletions
|
@ -159,8 +159,6 @@ void define_ruby_class()
|
||||||
// Ruby/OpenCV original functions
|
// Ruby/OpenCV original functions
|
||||||
rb_define_method(rb_klass, "method_missing", RUBY_METHOD_FUNC(rb_method_missing), -1);
|
rb_define_method(rb_klass, "method_missing", RUBY_METHOD_FUNC(rb_method_missing), -1);
|
||||||
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
|
||||||
rb_define_method(rb_klass, "has_parent?", RUBY_METHOD_FUNC(rb_has_parent_q), 0);
|
|
||||||
rb_define_method(rb_klass, "parent", RUBY_METHOD_FUNC(rb_parent), 0);
|
|
||||||
rb_define_method(rb_klass, "inside?", RUBY_METHOD_FUNC(rb_inside_q), 1);
|
rb_define_method(rb_klass, "inside?", RUBY_METHOD_FUNC(rb_inside_q), 1);
|
||||||
rb_define_method(rb_klass, "to_IplConvKernel", RUBY_METHOD_FUNC(rb_to_IplConvKernel), 1);
|
rb_define_method(rb_klass, "to_IplConvKernel", RUBY_METHOD_FUNC(rb_to_IplConvKernel), 1);
|
||||||
rb_define_method(rb_klass, "create_mask", RUBY_METHOD_FUNC(rb_create_mask), 0);
|
rb_define_method(rb_klass, "create_mask", RUBY_METHOD_FUNC(rb_create_mask), 0);
|
||||||
|
@ -535,31 +533,6 @@ rb_to_s(VALUE self)
|
||||||
return rb_f_sprintf(i, str);
|
return rb_f_sprintf(i, str);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* has_parent? -> true or false
|
|
||||||
*
|
|
||||||
* Return <tt>true</tt> if this matrix has parent object, otherwise <tt>false</tt>.
|
|
||||||
*/
|
|
||||||
VALUE
|
|
||||||
rb_has_parent_q(VALUE self)
|
|
||||||
{
|
|
||||||
return lookup_root_object(CVMAT(self)) ? Qtrue : Qfalse;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* call-seq:
|
|
||||||
* parent -> obj or nil
|
|
||||||
*
|
|
||||||
* Return root object that refer this object.
|
|
||||||
*/
|
|
||||||
VALUE
|
|
||||||
rb_parent(VALUE self)
|
|
||||||
{
|
|
||||||
VALUE root = lookup_root_object(CVMAT(self));
|
|
||||||
return root ? root : Qnil;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* inside?(obj) -> true or false
|
* inside?(obj) -> true or false
|
||||||
|
@ -679,7 +652,7 @@ rb_data(VALUE self)
|
||||||
* call-seq:
|
* call-seq:
|
||||||
* clone -> cvmat
|
* clone -> cvmat
|
||||||
*
|
*
|
||||||
* Clone matrix. The parent and child relation is not succeeded.
|
* Clone matrix.
|
||||||
* Instance-specific method is succeeded.
|
* Instance-specific method is succeeded.
|
||||||
*
|
*
|
||||||
* module M
|
* module M
|
||||||
|
@ -709,7 +682,7 @@ rb_clone(VALUE self)
|
||||||
* copy(<i>mat</i>) -> mat
|
* copy(<i>mat</i>) -> mat
|
||||||
* copy(<i>val</i>) -> array(include cvmat)
|
* copy(<i>val</i>) -> array(include cvmat)
|
||||||
*
|
*
|
||||||
* Copy matrix. The parent and child relation is not succeeded.
|
* Copy matrix.
|
||||||
* Instance-specific method is *NOT* succeeded. see also #clone.
|
* Instance-specific method is *NOT* succeeded. see also #clone.
|
||||||
*
|
*
|
||||||
* There are 3 kind behavior depending on the argument.
|
* There are 3 kind behavior depending on the argument.
|
||||||
|
@ -740,11 +713,13 @@ rb_copy(int argc, VALUE *argv, VALUE self)
|
||||||
copied = new_object(cvGetSize(src), cvGetElemType(src));
|
copied = new_object(cvGetSize(src), cvGetElemType(src));
|
||||||
cvCopy(src, CVMAT(copied));
|
cvCopy(src, CVMAT(copied));
|
||||||
return copied;
|
return copied;
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
if (rb_obj_is_kind_of(value, rb_klass)) {
|
if (rb_obj_is_kind_of(value, rb_klass)) {
|
||||||
cvCopy(src, CVMAT(value));
|
cvCopy(src, CVMAT(value));
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}else if (rb_obj_is_kind_of(value, rb_cFixnum)) {
|
}
|
||||||
|
else if (rb_obj_is_kind_of(value, rb_cFixnum)) {
|
||||||
int n = FIX2INT(value);
|
int n = FIX2INT(value);
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
copied = rb_ary_new2(n);
|
copied = rb_ary_new2(n);
|
||||||
|
@ -754,7 +729,8 @@ rb_copy(int argc, VALUE *argv, VALUE self)
|
||||||
rb_ary_store(copied, i, tmp);
|
rb_ary_store(copied, i, tmp);
|
||||||
}
|
}
|
||||||
return copied;
|
return copied;
|
||||||
}else{
|
}
|
||||||
|
else {
|
||||||
return Qnil;
|
return Qnil;
|
||||||
}
|
}
|
||||||
}else
|
}else
|
||||||
|
@ -909,16 +885,9 @@ rb_square_q(VALUE self)
|
||||||
* Return CvMat object with reference to caller-object.
|
* Return CvMat object with reference to caller-object.
|
||||||
*
|
*
|
||||||
* src = CvMat.new(10, 10)
|
* src = CvMat.new(10, 10)
|
||||||
* src.has_parent? #=> false
|
|
||||||
* src.parent #=> nil
|
|
||||||
* mat = src.to_CvMat
|
* mat = src.to_CvMat
|
||||||
* mat.has_parent? #=> true
|
|
||||||
* mat.parent #=> CvMat object "src"
|
|
||||||
*
|
*
|
||||||
* This case, 'src' is root-object. and 'mat' is child-object refer to 'src'.
|
* In C, src->data and mat->data are common. Therefore, they cause changes with each other.
|
||||||
* src <=refer= mat
|
|
||||||
* In C, 'src->data' and 'mat->data' is common. Therefore, they cause the change each other.
|
|
||||||
* object 'src' don't GC.
|
|
||||||
*/
|
*/
|
||||||
VALUE
|
VALUE
|
||||||
rb_to_CvMat(VALUE self)
|
rb_to_CvMat(VALUE self)
|
||||||
|
|
|
@ -29,8 +29,6 @@ VALUE rb_load_imageM(int argc, VALUE *argv, VALUE self);
|
||||||
|
|
||||||
VALUE rb_method_missing(int argc, VALUE *argv, VALUE self);
|
VALUE rb_method_missing(int argc, VALUE *argv, VALUE self);
|
||||||
VALUE rb_to_s(VALUE self);
|
VALUE rb_to_s(VALUE self);
|
||||||
VALUE rb_has_parent_q(VALUE self);
|
|
||||||
VALUE rb_parent(VALUE self);
|
|
||||||
VALUE rb_inside_q(VALUE self, VALUE object);
|
VALUE rb_inside_q(VALUE self, VALUE object);
|
||||||
VALUE rb_to_IplConvKernel(VALUE self, VALUE anchor);
|
VALUE rb_to_IplConvKernel(VALUE self, VALUE anchor);
|
||||||
VALUE rb_create_mask(VALUE self);
|
VALUE rb_create_mask(VALUE self);
|
||||||
|
|
|
@ -122,16 +122,6 @@ class TestCvMat < OpenCVTestCase
|
||||||
assert_equal('<OpenCV::CvMat:20x10,depth=cv32f,channel=1>', m.to_s)
|
assert_equal('<OpenCV::CvMat:20x10,depth=cv32f,channel=1>', m.to_s)
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_parent
|
|
||||||
m1 = CvMat.new(10, 20)
|
|
||||||
assert((not m1.has_parent?))
|
|
||||||
assert_nil(m1.parent)
|
|
||||||
|
|
||||||
m2 = m1.to_CvMat
|
|
||||||
assert(m2.has_parent?)
|
|
||||||
assert_same(m1, m2.parent)
|
|
||||||
end
|
|
||||||
|
|
||||||
def test_inside
|
def test_inside
|
||||||
m = CvMat.new(20, 10)
|
m = CvMat.new(20, 10)
|
||||||
assert(m.inside? CvPoint.new(0, 0))
|
assert(m.inside? CvPoint.new(0, 0))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue