views:

165

answers:

2

What do 2 & 3 mean in this and how can I change them?

CvMat* rot = cvCreateMat(2,3,CV_32FC1)

When I change these two values I get an openCV GUI error handler.

size of input arguments do not match()

in function cvConvertScale.\cxconvert.cpp(1601)

I want to understand what that means

Update:

The code is:

#include <cv.h>
#include <highgui.h>
int main()
{
    CvMat* rot = cvCreateMat(2,3,CV_32FC1);
    IplImage *src, *dst;
    src=cvLoadImage("doda.jpg");
//  make acopy of gray image(src)
    dst = cvCloneImage( src );
    dst->origin = src->origin;
// make dstof zeros 
    cvZero( dst );
// Compute rotation matrix
    double x=0.0;
// loop to get rotation from 0 to 360 by 4 press on anykey
    for(int i=1;i<=5;i++)
    {
     CvPoint2D32f center = cvPoint2D32f(src->width/2,src->height/2);
     double angle = 0+x;
     double scale = 0.6;
     cv2DRotationMatrix( center, angle, scale, rot );
// Do the transformation
     cvWarpAffine( src, dst, rot);
     cvNamedWindow( "Affine_Transform", 1 );
     cvShowImage( "Affine_Transform", dst );
     if (i<=4)
      x=x+90.0;
     else
      x=0.0;
     cvWaitKey();
    }
    cvReleaseImage( &dst );
    cvReleaseMat( &rot );
    return 0;
}
A: 

2 and 3 are the row and column counts of the matrix you're creating.

From Introduction to programming with OpenCV:

Allocate a matrix:

CvMat* cvCreateMat(int rows, int cols, int type);

type: Type of the matrix elements. Specified in form CV_<bit_depth>(S|U|F)C<number_of_channels>. E.g.: CV_8UC1 means an 8-bit unsigned single-channel matrix, CV_32SC2 means a 32-bit signed matrix with two channels.

Example:

 CvMat* M = cvCreateMat(4,4,CV_32FC1);

Changing them is as simple as substituting different values. But I guess you should already know that.

Joey
A: 

2 = number of rows and 3 = number of columns in your matrix, rot.

Can you post the entire code? Or maybe tell us what you want to achieve? Are you trying to rotate an image?

Also, I'd recommend upgrading to OpenCV 2.0 which has a C++ interface. With the new version, you can extensively use the Mat class which handles everything (matrices,images,etc.) and makes things much simpler.

Jacob