chessboard create

来源:互联网 发布:文字播音软件 编辑:程序博客网 时间:2024/06/05 19:26
    const int perBoardPixel = 100const cv::SizeboardSize(8,6); const cv::Sizeresolution(1200,800); int main() { int basisHeight = (resolution.height - perBoardPixel*boardSize.height) /2int basisWidth = (resolution.width - perBoardPixel*boardSize.width) /2if( basisHeight < 0 || basisWidth < 0) { cout<<"Resolution doesn't match!"<<endl; } cv::Mat image(resolution,CV_8UC1,cv::Scalar::all(255)); int flag = 0for(int j =0;j < boardSize.height;j++) { for(int i =0;i < boardSize.width;i++) { flag = (i+j) % 2if(flag == 0) { for(int n = j * perBoardPixel;n < (j+1) * perBoardPixel;n++) for(int m = i * perBoardPixel;m < (i+1) * perBoardPixel;m++) image.at<uchar>(n + basisHeight,m + basisWidth) =0; } } }     return 0; }
原创粉丝点击