我使用opencv函数cv::calibrateCamera
来校准相机,并且我想像这样cameraMatrix.at<float>(2,2)
那样访问按索引返回的值,但是失败了!代码和结果是这样的:
cv::Mat cameraMatrix = cv::Mat(3, 3, CV_32F);
cv::Mat distCoeffs = cv::Mat(1, 5, CV_32F);
cv::Mat rvecs;
cv::Mat tvecs;
double reprojectError;
reprojectError = cv::calibrateCamera(pointsOnBoard, pointsOnImg, imgSize,
cameraMatrix, distCoeffs, rvecs, tvecs);
std::cout << "Intrinsic matrix:" << std::endl;
std::cout << cameraMatrix << std::endl;
std::cout << "Value at [2,2]: " << cameraMatrix.at<float>(2,2) << std::endl;
我已经尝试过一些类似的代码,并且一切正常!
float tmp[] = {1,2,3,4,5,6,7,8,9};
cv Mat test = Mat(3,3,CV_32F,tmp);
std::cout << "Value at [2,2]: " << test.at<float>(2,2) << std::endl;