Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to convert a CV_32SC1 to int

I'm now using opencv for super-resolution. In one step I have to get the affine matrix and apply the transform to another matrix (which is not a Mat). I have some problems when trying to get the data from affine matrix (a 2*3 Mat). My code: Mat affine = Mat(2,3,CV_32SC1); affine = getAffineTransform(corners_cur, corners_ref); cout<<affine&lt;<endl; for(int="" y="0;y&lt;2;y++)" {="" for(int="" x="0;x&lt;3;x++)" cout&lt;<affine.at<int="">(y,x)<<' '; cout<<endl; }="" i="" output="" the="" 'affine'="" matrix="" twice,="" using="" different="" methods.="" the="" results="" is="" as="" below:<="" p="">

[1.004656149032001, -0.02000349563412032, 2.860194169683911; 0.01286062523971824, 0.9765526069572313, 1.203057387073405]

1400706429 1072698130 -566786328 -428060329 1066030763 1085705763

The first one seems to be reasonable, but the second one is totally a mess. I suppose the problem occurs when forcing CV_32SC1 to int but I don't know how to convert the data type properly.

How to convert a CV_32SC1 to int

I'm now using opencv for super-resolution. In one step I have to get the affine matrix and apply the transform to another matrix (which is not a Mat). I have some problems when trying to get the data from affine matrix (a 2*3 Mat). My code: code:

    Mat affine = Mat(2,3,CV_32SC1);
     affine = getAffineTransform(corners_cur, corners_ref);
        cout<<affine&lt;<endl; for(int="" y="0;y&lt;2;y++)" {="" for(int="" x="0;x&lt;3;x++)" cout&lt;<affine.at<int="">(y,x)<<' cout<<affine<<endl;
    for(int y=0;y<2;y++)
    {
        for(int x=0;x<3;x++)
            cout<<affine.at<int>(y,x)<<' ';
            cout<<endl; }="" i="" output="" the="" 'affine'="" matrix="" twice,="" using="" different="" methods.="" the="" results="" is="" as="" below:<="" p="">

cout<<endl; }

I output the 'affine' matrix twice, using different methods. The results is as below:

[1.004656149032001, -0.02000349563412032, 2.860194169683911; 0.01286062523971824, 0.9765526069572313, 1.203057387073405]

1400706429 1072698130 -566786328 -428060329 1066030763 1085705763

The first one seems to be reasonable, but the second one is totally a mess. I suppose the problem occurs when forcing CV_32SC1 to int but I don't know how to convert the data type properly.

click to hide/show revision 3
retagged

updated 2014-03-30 01:52:56 -0600

berak gravatar image

How to convert a CV_32SC1 to int

I'm now using opencv for super-resolution. In one step I have to get the affine matrix and apply the transform to another matrix (which is not a Mat). I have some problems when trying to get the data from affine matrix (a 2*3 Mat). My code:

    Mat affine = Mat(2,3,CV_32SC1);
    affine = getAffineTransform(corners_cur, corners_ref);
    cout<<affine<<endl;
    for(int y=0;y<2;y++)
    {
        for(int x=0;x<3;x++)
            cout<<affine.at<int>(y,x)<<' ';
        cout<<endl;
    }

I output the 'affine' matrix twice, using different methods. The results is as below:

[1.004656149032001, -0.02000349563412032, 2.860194169683911; 0.01286062523971824, 0.9765526069572313, 1.203057387073405]

1400706429 1072698130 -566786328 -428060329 1066030763 1085705763

The first one seems to be reasonable, but the second one is totally a mess. I suppose the problem occurs when forcing CV_32SC1 to int but I don't know how to convert the data type properly.