Skip to content

Bug in operator x+=p when x is a scalar and p a row matrix #9688

@LaurentBerger

Description

@LaurentBerger

Hi,

My code is :

    Mat x(1,1,CV_64FC1);
    Mat p(10,4,CV_64FC1);
    x.setTo(0);
    p.setTo(Scalar::all(5));
    cout << " x " << x << endl;
    cout << " p " << p << endl;
    for (int i = 0; i < p.rows; i++)
    {
        x += p.row(i);
    }
    cout<<" x "<<x<<endl;
    }

Results are

 x [0]
 p [5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5;
 5, 5, 5, 5]
 x [-6.277438562204192e+66, -6.277438562204192e+66, -6.277438562204192e+66, -6.277438562204192e+66]

First I don't understand my code ! I copy this code here. I can say _std.rows is 1 (and _std.cols is 4 ). It is my example.
Why no exception is thrown ?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions