0,,九点标定法的具体实现⽅法参见,https://cloud.tencent.com/developer/article/1835302,本⽂只接受取到数据后的处理⽅法1,我是将两个数据存放在两个txt⽂件内,CameraPos.txt存放是的相机坐标,RobotPos存在的是对应的机器⼈坐标2,定义⼀个结构体存储标定后结果,定义两个vector public : struct CalResult { double A_x; double B_x; double C_x; double A_y; double B_y; double C_y; }myCalResult;public: vector 3,读取两个txt⾥的值,分别保存到两个vector char path[256]; GetModuleFileNameA(NULL, path, 256); string filePath = path; filePath=filePath.substr(0, filePath.rfind('\\\\')); filePath = filePath + \"\\\\\"+ \"CalData\" + \"\\\\\" + \"CameraPos.txt\"; ifstream cameraFile; cameraFile.open(filePath); assert(cameraFile.is_open()); cv::Point2d temp; while (cameraFile.good() && !cameraFile.eof()) { cameraFile >> temp.x >> temp.y; points_camera.push_back(temp); } filePath = filePath.substr(0, filePath.rfind('\\\\')); filePath = filePath + \"\\\\\" + \"RobotPos.txt\"; ifstream robotFile; robotFile.open(filePath); assert(robotFile.is_open()); while (robotFile.good() && !robotFile.eof()) { robotFile >> temp.x >> temp.y; points_robot.push_back(temp); } 4,实现计算的函数 void getCalResult(vector if (points_camera.size()!= calPointCount || points_robot.size()!= calPointCount) { ::MessageBox(NULL,TEXT(\"⼿眼标定错误\"),TEXT(\"错误\"),1); return; } cv::Mat dst = cv::Mat(3, 3, CV_32F, cv::Scalar(0));//初始化系数矩阵A cv::Mat out_x = cv::Mat(3, 1, CV_32F, cv::Scalar(0));//初始化矩阵b cv::Mat out_y = cv::Mat(3, 1, CV_32F, cv::Scalar(0));//初始化矩阵b for (int i = 0; i < points_camera.size(); i++) { //计算3*3的系数矩阵 dst.at dst.at dst.at out_x.at out_y.at } //判断矩阵是否奇异 double determ = determinant(dst); if (abs(determ) < 0.001) { ::MessageBox(NULL, TEXT(\"X标定求解奇异\"), TEXT(\"错误\"), 1); return; } cv::Mat inv; cv::invert(dst, inv);//求矩阵的逆 cv::Mat output = inv * out_x;//计算输出 //X坐标计算结果,robotX=A_x*Camera_X+B_x*Camera_Y+C_x a.A_x = output.at output = inv * out_y;//计算输出 //Y坐标计算结果,robotY=A_y*Camera_X+B_y*Camera_Y+C_y a.A_y = output.at 6 计算结果验证 https://zhuanlan.zhihu.com/p/3919387 7 算法参考:https://blog.csdn.net/AlonewaitingNew/article/details/95217730 因篇幅问题不能全部显示,请点此查看更多更全内容
Copyright © 2019- huatuo3.cn 版权所有 湘ICP备2023017654号-3
违法及侵权请联系:TEL:199 1889 7713 E-MAIL:2724546146@qq.com
本站由北京市万商天勤律师事务所王兴未律师提供法律服务