Skip to content

core(MatExpr): .size() implementation bug #16689

@alalek

Description

@alalek

relates #16655 #16653

Test code to FAIL:

Mat a(Size(10, 5), CV_32FC1, 5);
Mat b(Size(10, 5), CV_32FC1, 2);
MatExpr r = a * b.t();  // gemm
cout << r.size() << endl;
cout << Mat(r).size() << endl;
Mat dst;
cv::add(r, Scalar(1), dst);  // Exception raised

output:

[10 x 5]
[5 x 5]
... matrix_iterator.cpp:72: error: (-215:Assertion failed) A.size == arrays[i0]->size in function 'init'

Test code to PASS:

Mat a(Size(10, 5), CV_32FC1, 5);
Mat b(Size(10, 5), CV_32FC1, 2);
MatExpr r = a * b.t();  // gemm
Mat dst;
cv::add(Mat(r), Scalar(1), dst);
cout << dst << endl;
cout << r << endl;

(but gemm() is called twice due MatExpr "optimization")


More checks: master...alalek:check_matexpr_size

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions