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

modified CvMat, and added some tests

This commit is contained in:
ser1zw 2011-01-06 01:57:33 +09:00
parent 7e068bc34b
commit 2d416857a9
2 changed files with 15 additions and 8 deletions

View file

@ -1147,13 +1147,15 @@ rb_aref(VALUE self, VALUE args)
scalar = cvGet1D(CVARR(self), index[0]);
break;
case 2:
// scalar = cvGet2D(CVARR(self), index[1], index[0]);
scalar = cvGet2D(CVARR(self), index[0], index[1]);
break;
/*
// cvGet3D should not be used in this method.
// "self" is always an instance of CvMat, and its data are 1D or 2D array.
case 3:
// scalar = cvGet3D(CVARR(self), index[2], index[1], index[0]);
scalar = cvGet3D(CVARR(self), index[0], index[1], index[2]);
break;
*/
default:
scalar = cvGetND(CVARR(self), index);
}
@ -1182,9 +1184,13 @@ rb_aset(VALUE self, VALUE args)
case 2:
cvSet2D(CVARR(self), index[0], index[1], scalar);
break;
// cvGet3D should not be used in this method.
// "self" is always an instance of CvMat, and its data are 1D or 2D array.
/*
case 3:
cvSet3D(CVARR(self), index[0], index[1], index[2], scalar);
cvSet3D(CVARR(self), index[0], index[1], index[2], scalar);
break;
*/
default:
cvSetND(CVARR(self), index, scalar);
}

View file

@ -458,22 +458,23 @@ class TestCvMat < OpenCVTestCase
assert_cvscalar_equal(CvScalar.new(5, 5, 5, 5), m[4])
assert_cvscalar_equal(CvScalar.new(2, 2, 2, 2), m[0, 1])
assert_cvscalar_equal(CvScalar.new(4, 4, 4, 4), m[1, 0])
assert_cvscalar_equal(CvScalar.new(2, 2, 2, 2), m[0, 1, 2])
assert_cvscalar_equal(CvScalar.new(4, 4, 4, 4), m[1, 0, 3, 4])
# Alias
assert_cvscalar_equal(CvScalar.new(1, 1, 1, 1), m.at(0))
flunk('FIXME: cvGetND cases do not seem to work well')
end
def test_aset
m = create_cvmat(2, 3)
m[0] = CvScalar.new(10, 10, 10, 10)
assert_cvscalar_equal(CvScalar.new(10, 10, 10, 10), m[0])
m[1, 0] = CvScalar.new(20, 20, 20, 20)
assert_cvscalar_equal(CvScalar.new(20, 20, 20, 20), m[1, 0])
flunk('FIXME: cvSetND cases do not seem to work well')
m[1, 0, 2] = CvScalar.new(4, 4, 4, 4)
assert_cvscalar_equal(CvScalar.new(4, 4, 4, 4), m[1, 0])
m[1, 0, 2, 4] = CvScalar.new(5, 5, 5, 5)
assert_cvscalar_equal(CvScalar.new(5, 5, 5, 5), m[1, 0])
end
def test_fill