1
0
Fork 0
mirror of https://github.com/ruby-opencv/ruby-opencv synced 2023-03-27 23:22:12 -04:00

implemented to_a to CvCircle32f, CvPoint, CvPoint2D32f, CvPoint3D32f, CvScalar, CvSize, CvSize2D32f, CvTermCriteria, CvTwoPoints, CvVector, and added tests for them

This commit is contained in:
ser1zw 2011-01-10 01:18:11 +09:00
parent c98f5efbc9
commit 9791dae3bd
16 changed files with 41 additions and 2 deletions

View file

@ -45,6 +45,7 @@ define_ruby_class()
//rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
VALUE

View file

@ -54,6 +54,7 @@ define_ruby_class()
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
/*

View file

@ -54,6 +54,7 @@ define_ruby_class()
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
/*

View file

@ -58,6 +58,7 @@ define_ruby_class()
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
/*

View file

@ -66,6 +66,7 @@ define_ruby_class()
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
rb_define_const(rb_klass, "Black", cCvScalar::new_object(cvScalar(0x0,0x0,0x0)));
rb_define_const(rb_klass, "Silver", cCvScalar::new_object(cvScalar(0x0c,0x0c,0x0c)));

View file

@ -54,6 +54,7 @@ define_ruby_class()
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
/*

View file

@ -53,6 +53,7 @@ define_ruby_class()
rb_define_method(rb_klass, "height=", RUBY_METHOD_FUNC(rb_set_height), 1);
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
/*

View file

@ -53,6 +53,7 @@ define_ruby_class()
rb_define_alias(rb_klass, "epsilon", "eps");
rb_define_alias(rb_klass, "epsilon=", "eps=");
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
VALUE

View file

@ -48,6 +48,7 @@ define_ruby_class()
rb_define_method(rb_klass, "point1", RUBY_METHOD_FUNC(rb_point1), 0);
rb_define_method(rb_klass, "point2", RUBY_METHOD_FUNC(rb_point2), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
VALUE

View file

@ -47,6 +47,7 @@ define_ruby_class()
rb_define_method(rb_klass, "to_s", RUBY_METHOD_FUNC(rb_to_s), 0);
rb_define_method(rb_klass, "to_ary", RUBY_METHOD_FUNC(rb_to_ary), 0);
rb_define_alias(rb_klass, "to_a", "to_ary");
}
/*

View file

@ -64,6 +64,11 @@ class TestCvPoint < OpenCVTestCase
a = CvPoint.new(10, 20).to_ary
assert_equal(10, a[0])
assert_equal(20, a[1])
# Alias
a = CvPoint.new(10, 20).to_a
assert_equal(10, a[0])
assert_equal(20, a[1])
end
end

View file

@ -64,6 +64,11 @@ class TestCvPoint2D32f < OpenCVTestCase
a = CvPoint2D32f.new(1.1, 2.2).to_ary
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
# Alias
a = CvPoint2D32f.new(1.1, 2.2).to_a
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
end
end

View file

@ -78,6 +78,12 @@ class TestCvPoint3D32f < OpenCVTestCase
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
assert_in_delta(3.3, a[2], 0.001)
# Alias
a = CvPoint3D32f.new(1.1, 2.2, 3.3).to_a
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
assert_in_delta(3.3, a[2], 0.001)
end
end

View file

@ -83,8 +83,11 @@ class TestCvScalar < OpenCVTestCase
[[10, 20, 30, 40], [0.1, 0.2, 0.3, 0.4]].each { |a|
s = CvScalar.new(*a)
b = s.to_ary
assert_equal(Array, b.class)
assert_in_delta(a, b, 0.01)
c = s.to_a # Alias
[b, c].each { |x|
assert_equal(Array, x.class)
assert_in_delta(a, x, 0.01)
}
}
end

View file

@ -65,6 +65,11 @@ class TestCvSize < OpenCVTestCase
a = CvSize.new(10, 20).to_ary
assert_equal(10, a[0])
assert_equal(20, a[1])
# Alias
a = CvSize.new(10, 20).to_a
assert_equal(10, a[0])
assert_equal(20, a[1])
end
end

View file

@ -65,6 +65,11 @@ class TestCvSize2D32f < OpenCVTestCase
a = CvSize2D32f.new(1.1, 2.2).to_ary
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
# Alias
a = CvSize2D32f.new(1.1, 2.2).to_a
assert_in_delta(1.1, a[0], 0.001)
assert_in_delta(2.2, a[1], 0.001)
end
end