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

30 lines
593 B
Ruby
Raw Normal View History

2010-12-31 03:29:31 -05:00
#!/usr/bin/env ruby
# -*- mode: ruby; coding: utf-8-unix -*-
require 'test/unit'
require 'opencv'
require 'pp'
require File.expand_path(File.dirname(__FILE__)) + '/test_opencv'
include OpenCV
2010-12-31 03:32:28 -05:00
# Tests for OpenCV::CvMat
2010-12-31 03:29:31 -05:00
class TestCvMat < TestOpenCV
def test_avg_sdv
m = CvMat.new(1, 8, CV_32F)
[2, 4, 4, 4, 5, 5, 7, 9].each_with_index { |v, i|
# m[i] = CvScalar.new(v, 0, 0, 0)
m[i][0] = v
}
avg = m.avg
assert_in_delta(avg[0], 5.0, 0.01)
avg, sdv = m.avg_sdv
assert_in_delta(avg[0], 5.0, 0.01)
assert_in_delta(sdv[0], 2.0, 0.01)
end
end