mirror of
https://github.com/ruby-opencv/ruby-opencv
synced 2023-03-27 23:22:12 -04:00
fixed a bug of CvMat#copy
This commit is contained in:
parent
817f57df86
commit
3b36804879
2 changed files with 7 additions and 2 deletions
|
@ -675,7 +675,7 @@ rb_clone(VALUE self)
|
|||
VALUE
|
||||
rb_copy(int argc, VALUE *argv, VALUE self)
|
||||
{
|
||||
VALUE value, copied;
|
||||
VALUE value, copied, tmp;
|
||||
CvMat *src = CVMAT(self);
|
||||
rb_scan_args(argc, argv, "01", &value);
|
||||
if (argc == 0) {
|
||||
|
@ -692,7 +692,9 @@ rb_copy(int argc, VALUE *argv, VALUE self)
|
|||
if (n > 0) {
|
||||
copied = rb_ary_new2(n);
|
||||
for (int i = 0; i < n; i++) {
|
||||
rb_ary_store(copied, i, new_object(src->rows, src->cols, cvGetElemType(src)));
|
||||
tmp = new_object(src->rows, src->cols, cvGetElemType(src));
|
||||
cvCopy(src, CVMAT(tmp));
|
||||
rb_ary_store(copied, i, tmp);
|
||||
}
|
||||
return copied;
|
||||
}else{
|
||||
|
|
|
@ -145,7 +145,10 @@ class TestCvMat < OpenCVTestCase
|
|||
|
||||
a = m1.copy(2)
|
||||
assert_equal(2, a.size)
|
||||
|
||||
a.each { |m|
|
||||
assert_equal(m1.height, m.height)
|
||||
assert_equal(m1.width, m.width)
|
||||
m1.height.times { |j|
|
||||
m1.width.times { |i|
|
||||
assert_cvscalar_equal(m1[i, j], m[i, j])
|
||||
|
|
Loading…
Reference in a new issue