下面是我将矩阵(声明为 rgbMat)旋转 90 度的代码,如下面的代码所示
CvMat* rot = cvCreateMat(2,3,CV_32FC1);
CvPoint2D32f center = cvPoint2D32f(rgbMat->width/2,rgbMat->height/2);
double angle = 90;
double scale = 5;
CvMat* rot3= cv2DRotationMatrix( center, angle, scale, rot);
更新
我正在尝试访问 rot3 的元素,以便我知道我得到了什么值。就像在下面的代码中一样:-
cv::Mat rot3cpp(rot3);
for(int i=0;i<rot3cpp.cols;i++)
{
for (int j =0;j<rot3cpp.rows;j++)
{
CvScalar scal = cvGet2D(rot3,i,j);
printf("new matrix is %f: \n", rot3cpp.at<float>(i,j));
}
}
但我收到这样的错误:
OpenCV Error: One of arguments' values is out of range (index is out of range) in cvGet2D, file /home/xyz/Documents/opencv-2.4.5/modules/core/src/array.cpp, line 1958 terminate called after throwing an instance of 'cv::Exception' what(): /home/xyz/Documents/opencv-2.4.5/modules/core/src/array.cpp:1958: error: (-211) index is out of range in function cvGet2D
谁能告诉我哪里出错了。任何帮助将不胜感激。