建设银行 访问的网站出错,wordpress显示不全,东莞网络推广建站,做网站要多少钱汉狮标定的程序在官方的源码里有#xff0c;
opencv-4.5.5\samples\cpp\tutorial_code\calib3d\camera_calibration
很多小白不知道怎么跑起来#xff0c;这个也怪OpenCV官方#xff0c;工作没做完善#xff0c;其实的default.xml是要自己手动改的#xff0c;输入的图片也要…标定的程序在官方的源码里有
opencv-4.5.5\samples\cpp\tutorial_code\calib3d\camera_calibration
很多小白不知道怎么跑起来这个也怪OpenCV官方工作没做完善其实的default.xml是要自己手动改的输入的图片也要自己去拍摄还有那个VID5.xml也要改成可以直接找到图片的路径
我这里拍了5张图故意做了鱼眼效果后用于标定校正。程序已经改好了直接visual studio就可以跑了到这里去下载吧
https://github.com/SpaceView/OpenCV455_cameraCalibrationDemo
关于标定板
OpenCV官方曾经提供的标定板是CHESSBOARD 9x6和7x7的实际应用根据场景的需要可能需要不同的标定板。
标定程序实际支持三种标定板包括chessboardgrid circle, asymmetric grid circle格子这里我们手动生成标定板包括这里提到的三种标定板的图片 程序如下
class CalibTools {public:cv::Mat GenerateChessboard(int xBlockNum, int yBlockNum, int BLOCKWIDTH, std::string saveFileName) {//const int BLOCKWIDTH 150;//const int xBlockNum 7;//const int YBlockNum 7;cv::Size sz { xBlockNum * BLOCKWIDTH, yBlockNum * BLOCKWIDTH };cv::Mat mat(sz, CV_8UC3);for (int r 0; r yBlockNum; r) {for (int c 0; c xBlockNum; c) {int IX c * BLOCKWIDTH, IY r * BLOCKWIDTH;int EX IX BLOCKWIDTH, EY IY BLOCKWIDTH;cv::Vec3b value;if (0 (c r) % 2) {value { 0xFF,0xFF, 0xFF };}else {value 0x000000;}for (int y IY; y EY; y) {cv::Vec3b* p mat.ptrcv::Vec3b(y);for (int x IX; x EX; x) {p[x] value;}}}}if (!saveFileName.empty()) {saveFileName .png;cv::imwrite(saveFileName, mat);}return mat;}/** * * * * * * * -- xDotNum1 7 _|_ 1* * * * * * * * _|_ 2* * * * * * * * _|_ 3* * * * * * * * _|_ 4* * * * * * * * _|_ 5* * * * * * * * _|_ 6* * * * * * * * _|_ 7 -- In total yDotNum 7*/cv::Mat GenerateGridCircle(int xDotNum, int yDotNum, int dotRadius, int BLOCKWIDTH, std::string saveFileName) {cv::Size sz { (xDotNum 1) * BLOCKWIDTH, (yDotNum1) * BLOCKWIDTH };cv::Mat mat(sz, CV_8UC3);mat.setTo(cv::Scalar(255,255,255));for (int r 1; r yDotNum; r) {int y r * BLOCKWIDTH;for (int c 1; c xDotNum; c) {int x c * BLOCKWIDTH;cv::circle(mat, cv::Point(x, y), dotRadius, cv::Scalar(0, 0, 0), cv::FILLED);}}if (!saveFileName.empty()) {saveFileName .png;cv::imwrite(saveFileName, mat);}return mat;}/** * * * * * * * -- xDotNum1 7 |* * * * * * * -- xDotNum2 6 _|_ 1, -- 2 rows make 1 unit in yDotNum* * * * * * * * |* * * * * * * _|_ 2* * * * * * * * |* * * * * * * _|_ 3* * * * * * * * |* * * * * * * _|_ 4, -- In total yDotNum 4* * *---* --- DOTDIST* ** * **/cv::Mat GenerateAsymmetricGridCircle(int xDotNum1, int xDotNum2, int yDotNum, int dotRadius, int DOTDIST, std::string saveFileName) {int totXDotNum xDotNum1 xDotNum2 2;int totYDotNum 2 * yDotNum 2;int DIST DOTDIST / 2;int HDIST DIST / 2;cv::Size sz { totXDotNum * DIST, totYDotNum * DIST };cv::Mat mat(sz, CV_8UC3);mat.setTo(cv::Scalar(255, 255, 255));for (int r 1; r totYDotNum-1; r) {for (int c 1; c totXDotNum-1; c) {int IX c * DIST, IY r * DIST;int CX IX HDIST, CY IY HDIST;if (0 (c r) % 2) {cv::circle(mat, cv::Point(CX, CY), dotRadius, cv::Scalar(0, 0, 0), cv::FILLED);}}}if (!saveFileName.empty()) {saveFileName .png;cv::imwrite(saveFileName, mat);}return mat;}
};
调用方式举例如下
CalibTools ct;
ct.GenerateChessboard(7, 7, 100, GenerateChessboard);
ct.GenerateGridCircle(8, 8, 20, 80, GeneratedGridCircles);
ct.GenerateAsymmetricGridCircle(8, 7, 6, 20, 100, GenerateAsymmetricGridCircle);
这样就可以生成下列形状的标定板 然后打印出来就可以做标定板了。
关于非对称的圆形标定板可以参考下面的贴子
OpenCv相机标定——圆形标定板标定_opencv圆形标定板-CSDN博客
本文结束。