2011-06-10 13:46:52 -04:00
|
|
|
#!/usr/bin/env ruby
|
|
|
|
# -*- mode: ruby; coding: utf-8-unix -*-
|
|
|
|
require 'test/unit'
|
|
|
|
require 'opencv'
|
|
|
|
require File.expand_path(File.dirname(__FILE__)) + '/helper'
|
|
|
|
|
|
|
|
include OpenCV
|
|
|
|
|
|
|
|
# Tests for OpenCV::CvVideoWriter
|
|
|
|
class TestCvVideoWriter < OpenCVTestCase
|
2011-07-26 08:53:33 -04:00
|
|
|
OUTPUT_FILENAME = 'videowriter_result.avi'
|
|
|
|
|
2011-06-10 13:46:52 -04:00
|
|
|
def test_initialize
|
2011-07-26 08:53:33 -04:00
|
|
|
vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240))
|
2011-06-10 13:46:52 -04:00
|
|
|
assert_equal(CvVideoWriter, vw.class)
|
|
|
|
vw.close
|
|
|
|
|
2011-07-26 08:53:33 -04:00
|
|
|
vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240), false)
|
2011-06-10 13:46:52 -04:00
|
|
|
assert_equal(CvVideoWriter, vw.class)
|
|
|
|
vw.close
|
|
|
|
|
|
|
|
## Supported only Windows(?)
|
2011-07-26 08:53:33 -04:00
|
|
|
# vw = CvVideoWriter.new(OUTPUT_FILENAME, nil, 15, CvSize.new(320, 240), false)
|
2011-06-10 13:46:52 -04:00
|
|
|
# assert_equal(CvVideoWriter, vw.class)
|
|
|
|
# vw.close
|
|
|
|
|
2011-07-26 08:53:33 -04:00
|
|
|
CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240)) { |vw|
|
2011-06-10 13:46:52 -04:00
|
|
|
assert_equal(CvVideoWriter, vw.class)
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_raise(TypeError) {
|
|
|
|
vw = CvVideoWriter.new(123, 'MJPG', 15, CvSize.new(320, 240), false)
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_write
|
2011-07-23 06:51:58 -04:00
|
|
|
img = IplImage.load(FILENAME_LENA256x256)
|
2011-07-26 08:53:33 -04:00
|
|
|
vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(256, 256))
|
2011-07-23 06:51:58 -04:00
|
|
|
vw.write img
|
2011-06-10 13:46:52 -04:00
|
|
|
vw.close
|
|
|
|
|
2011-07-26 08:53:33 -04:00
|
|
|
CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(256, 256)) { |vw|
|
2011-07-23 06:51:58 -04:00
|
|
|
vw.write img
|
|
|
|
}
|
|
|
|
|
|
|
|
assert_raise(TypeError) {
|
2011-07-26 08:53:33 -04:00
|
|
|
CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(256, 256)) { |vw|
|
2011-07-23 06:51:58 -04:00
|
|
|
vw.write DUMMY_OBJ
|
|
|
|
}
|
2011-06-10 13:46:52 -04:00
|
|
|
}
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_close
|
2011-07-26 08:53:33 -04:00
|
|
|
vw = CvVideoWriter.new(OUTPUT_FILENAME, 'MJPG', 15, CvSize.new(320, 240))
|
2011-06-10 13:46:52 -04:00
|
|
|
vw.close
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|