diff --git a/test/samples/smooth1.jpg b/test/samples/smooth1.jpg index 7b2619d..ff2d09b 100644 Binary files a/test/samples/smooth1.jpg and b/test/samples/smooth1.jpg differ diff --git a/test/samples/smooth2.jpg b/test/samples/smooth2.jpg index 5fb4ff8..090958e 100644 Binary files a/test/samples/smooth2.jpg and b/test/samples/smooth2.jpg differ diff --git a/test/test_iplimage.rb b/test/test_iplimage.rb index 965b93d..c0aca30 100755 --- a/test/test_iplimage.rb +++ b/test/test_iplimage.rb @@ -8,6 +8,10 @@ include OpenCV # Tests for OpenCV::IplImage class TestIplImage < OpenCVTestCase + def should_classify_images_as(filename, classification) + assert_equal(OpenCV::IplImage::load(filename, OpenCV::CV_LOAD_IMAGE_GRAYSCALE).smoothness[0], classification) + end + def test_initialize img = IplImage.new(10, 20) assert_equal(10, img.width) @@ -127,6 +131,26 @@ class TestIplImage < OpenCVTestCase img.coi = 1 assert_equal(1, img.coi) end + + def test_smoothness + asset_path = File.join(File.dirname(__FILE__), 'samples') + + for image in Array.new(7) { |e| e = File.join(asset_path, "smooth%d.jpg") % e } do + should_classify_images_as image, :smooth + end + + for image in Array.new(2) { |e| e = File.join(asset_path, "messy%d.jpg") % e } do + should_classify_images_as image, :messy + end + + for image in Array.new(10) { |e| e = File.join(asset_path, "blank%d.jpg") % e } do + should_classify_images_as image, :blank + end + + for image in Array.new(2) { |e| e = File.join(asset_path, "partially_blank%d.jpg") % e } do + should_classify_images_as image, :blank + end + end end