mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
added a constructor for CvConnectedComp, and modified it's test
This commit is contained in:
parent
6841c2f417
commit
62e46603a9
3 changed files with 35 additions and 21 deletions
|
@ -9,24 +9,20 @@ include OpenCV
|
|||
# Tests for OpenCV::CvConnectedComp
|
||||
class TestCvConnectedComp < OpenCVTestCase
|
||||
def setup
|
||||
mat0 = create_cvmat(128, 128, :cv8u, 1) { |j, i, c|
|
||||
if (i >= 32 and i < 96) and (j >= 32 and j < 96)
|
||||
CvScalar.new(255)
|
||||
elsif (i >= 16 and i < 112) and (j >= 16 and j < 112)
|
||||
CvScalar.new(192)
|
||||
else
|
||||
CvScalar.new(128)
|
||||
end
|
||||
}
|
||||
|
||||
point = CvPoint.new(20, 20)
|
||||
@mat, @connected_comp, @mask = mat0.flood_fill(point, 0, CvScalar.new(0), CvScalar.new(64),
|
||||
:connectivity => 8, :fixed_range => true, :mask_only => true)
|
||||
@connected_comp = CvConnectedComp.new(9216, CvScalar.new(1, 2, 3, 4),
|
||||
CvRect.new(1, 2, 3, 4), CvSeq.new(CvPoint))
|
||||
end
|
||||
|
||||
def test_initialize
|
||||
connected_comp = CvConnectedComp.new
|
||||
assert_not_nil(connected_comp)
|
||||
assert_equal(CvConnectedComp, connected_comp.class)
|
||||
assert_not_nil(connected_comp.area)
|
||||
assert_not_nil(connected_comp.value)
|
||||
assert_not_nil(connected_comp.rect)
|
||||
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))
|
||||
assert_equal(CvConnectedComp, connected_comp.class)
|
||||
assert_not_nil(connected_comp.area)
|
||||
assert_not_nil(connected_comp.value)
|
||||
|
@ -40,21 +36,21 @@ class TestCvConnectedComp < OpenCVTestCase
|
|||
|
||||
def test_value
|
||||
assert_equal(CvScalar, @connected_comp.value.class)
|
||||
assert_cvscalar_equal(CvScalar.new(220, 0, 0, 0), @connected_comp.value)
|
||||
assert_cvscalar_equal(CvScalar.new(1, 2, 3, 4), @connected_comp.value)
|
||||
end
|
||||
|
||||
def test_rect
|
||||
assert_equal(CvRect, @connected_comp.rect.class)
|
||||
assert_equal(16, @connected_comp.rect.x)
|
||||
assert_equal(16, @connected_comp.rect.y)
|
||||
assert_equal(96, @connected_comp.rect.width)
|
||||
assert_equal(96, @connected_comp.rect.height)
|
||||
|
||||
@connected_comp.rect = CvRect.new(1, 2, 3, 4);
|
||||
assert_equal(1, @connected_comp.rect.x)
|
||||
assert_equal(2, @connected_comp.rect.y)
|
||||
assert_equal(3, @connected_comp.rect.width)
|
||||
assert_equal(4, @connected_comp.rect.height)
|
||||
|
||||
@connected_comp.rect = CvRect.new(10, 20, 30, 40);
|
||||
assert_equal(10, @connected_comp.rect.x)
|
||||
assert_equal(20, @connected_comp.rect.y)
|
||||
assert_equal(30, @connected_comp.rect.width)
|
||||
assert_equal(40, @connected_comp.rect.height)
|
||||
end
|
||||
|
||||
def test_contour
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue