由于3D重建跟双目视觉的需要,对标定棋盘图的生成C++代码如下(修改棋盘的方块cube、角点数x、y即可改变棋盘大小):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <iostream> #include<opencv.hpp> using namespace std; using namespace cv;
int main(int args, char* argv) { int cube = 90; int row_corner = 7; int col_corner = 13;
Mat img(row_corner*cube, col_corner*cube, CV_8UC1, Scalar::all(255)); for (int i = 0; i < img.rows; i++) { for (int j = 0; j < img.cols; j++) { if ((i / cube) % 2 == 0){ if (((i / cube) % 2 == 0) && ((j / cube) % 2 == 0)) { img.at<uchar>(i, j) = 0; } } if ((i / cube) % 2 == 1) { if (((i / cube) % 2 == 1) && ((j / cube) % 2 == 1)) { img.at<uchar>(i, j) = 0; } } } }
imshow("img", img); imwrite("board.jpg", img); waitKey(0);
return 0; }
|
标定板: