我正在尝试校准相机,使用AruCo标记进行头部姿势估计。我尝试用C ++中的OpenCV库进行校准但没有成功,所以我使用MATLAB相机校准工具箱校准了我的相机,我的AruCo标记检测代码是用C ++编写的,需要相机矩阵和失真系数作为参数。我的问题是如何在标记检测功能中加载这些参数。我尝试将相机矩阵和失真系数存储在数组中,它向我显示错误“类型int *的参数与int 的参数不兼容”。负责标记检测的部分代码如下。
using namespace std;
using namespace cv;
int cameraMatrix[] = { 4.499, 0, 1.827, 0, 4.485, 0.97, 0, 0, 1 };
int distanceCoefficients[] = { 0.20255, -0.45448, -0.00117, 0.00241, 0 };
int startWebcamMonitoring(const int cameraMatrix, const int
distanceCoefficients, float arucoSquareDimensions)
{
Mat frame, Croppedframe;
vector<int> markerIds;
vector < vector<Point2f>> markerCorners, rejectedCandidates;
aruco::DetectorParameters parameters;
Ptr<aruco::Dictionary> makerDiktionary =
aruco :: getPredefinedDictionary(aruco :: PREDEFINED_DICTIONARY_NAME :: DICT_4X4_50);
VideoCapture vid(0);
if (!vid.isOpened())
{
return -1;
}
//namedWindow("Webcam", CV_WINDOW_AUTOSIZE);
vid.set(CAP_PROP_FRAME_WIDTH, 3840);
vid.set(CAP_PROP_FRAME_HEIGHT, 2160);
vector<Vec3d> rotationVectors, translationVectors;
while (true)
{
vid >> frame;
Croppedframe = frame(cv::Rect(1500, 850, 1250, 1250));
if (!vid.read(frame))
break;
aruco::detectMarkers(Croppedframe, makerDiktionary, markerCorners, markerIds);
aruco::estimatePoseSingleMarkers(markerCorners, arucoSquareDimension, cameraMatrix, distanceCoefficients, rotationVectors, translationVectors);
for (int i = 0; i < markerIds.size(); i++)
{
aruco::drawAxis(Croppedframe, cameraMatrix, distanceCoefficients, rotationVectors[i], translationVectors[i], 0.1f);
cout << translationVectors[i] << "translation" << "vector" << markerIds[i] << endl;
markerIds[i] << endl;
}
imshow("Cropped Webcam", Croppedframe);
//imshow("Webcam", frame);
if (waitKey(30) >= 0) break;
}
return 1;
}
int main(int argv, char** argc)
{
startWebcamMonitoring(cameraMatrix, distanceCoefficients, 0.01f);
return 0;
}