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

Commented out CvMat#>, CvMat#>=, CvMat#<, CvMat#<=, CvMat#==, CvMat#!=, and added some tests

I commented out the operators above because they are very confusing.
They always return non-nil and non-false objects.
This commit is contained in:
ser1zw 2011-01-03 17:30:36 +09:00
parent 9ab9a4d915
commit 63f8cf8bb6
3 changed files with 110 additions and 7 deletions

View file

@ -6,6 +6,36 @@ require 'opencv'
include OpenCV
class OpenCVTestCase < Test::Unit::TestCase
CvMat.class_eval do
# Range check for debug
alias original_aref []
alias original_aset []=;
def [](*idx)
if idx.size == 1
n = idx[0]
throw ArgumentError.new("index #{n} is out of range") if n >= rows * cols
else
j, i = *idx
throw ArgumentError.new("index for row #{j} is out of range") if j >= rows
throw ArgumentError.new("index for column #{i} is out of range") if i >= cols
end
original_aref(*idx)
end
def []=(*idx, val)
if idx.size == 1
n = idx[0]
throw ArgumentError.new("index #{n} is out of range") if n >= rows * cols
else
j, i = *idx
throw ArgumentError.new("index for row #{j} is out of range") if j >= rows
throw ArgumentError.new("index for column #{i} is out of range") if i >= cols
end
original_aset(*idx, val)
end
end
def get_sample(filename, iscolor = nil)
IplImage::load('samples/' + filename, iscolor)
end