Random values printing a Mat

asked 2014-03-26 11:40:39 -0500

matteo gravatar image

Hi, I would like to print out a matrix Mat after having written the desired values in it. I'm doing this way:

Mat Rot(3,3, CV_32FC1);

Rot.at<double>(0,0)=cos(roll)*cos(pitch);
Rot.at<double>(0,1)=cos(roll)*sin(pitch)*sin(yaw)-sin(roll)*cos(yaw);
Rot.at<double>(0,2)=cos(roll)*sin(pitch)*cos(yaw)+sin(roll)*sin(yaw);
Rot.at<double>(1,0)=sin(roll)*cos(pitch);
Rot.at<double>(1,1)=sin(roll)*sin(pitch)*sin(yaw)+cos(roll)*cos(yaw);
Rot.at<double>(1,2)=sin(roll)*sin(pitch)*cos(yaw)-cos(roll)*sin(yaw);
Rot.at<double>(2,0)=-sin(pitch);
Rot.at<double>(2,1)=cos(pitch)*sin(yaw);
Rot.at<double>(2,2)=cos(pitch)*cos(yaw);

    cout << " Rot " << Rot << endl;

    cout << " Rot(0,0) " <<   Rot.at<double>(0,0) << endl;

The strange thing is that, when I print out Rot, random values come out but the output of Rot(0,0) is correct!

Any idea? Thanks

edit retag flag offensive close merge delete

Comments

4

Mat Rot(3,3, CV_32FC1); is a float Mat.

- - - - - - - ^ , CV_64F); // for double

berak gravatar imageberak ( 2014-03-26 11:56:20 -0500 )edit

I stupid....thanks!

matteo gravatar imagematteo ( 2014-03-26 12:02:38 -0500 )edit