OpenCV实现相机标定板

2021-04-16 12:59:26 IT技术网 互联网
浏览

OpenCV实现相机标定板

 更新时间:2021年04月16日 11:42:16   作者:房东丢的猫  

这篇文章主要为大家详细介绍了OpenCV实现相机标定板,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下

本文实例为大家分享了OpenCV实现相机标定板的具体代码,供大家参考,具体内容如下

1.代码实现

#include <opencv.hpp>
#include "highgui.h"
#include "cxcore.h"

using namespace cv;

int main0(int argc, char *argv[])
{
    int width = 140;//width and heigth of single square
    int height = 140;
        IplImage *src = cvCreateImage(cvSize(width*(10+1),width*(6+1)), IPL_DEPTH_8U, 1);//in the CalibrationAndTest.cpp ,there is a param called boardsize(10,6), causing here:(10+1),(6+1)
        cvZero(src);
        for (int i = 0; i < src->height; i++)
        {
            for (int j = 0; j < src->width; j++)
            {
                if ((i / width + j / height) % 2 != 0)
                {
                    src->imageData[i*src->widthStep + j * src->nChannels] = 255;
                }
            }
        }

        //cvNamedWindow("src");
        cvShowImage("src", src);

        //cvSaveImage("ChessBoard.bmp", src, 0);
        cvWaitKey(0);

        return 0;
}

2.效果展示

3.使用说明

将该程序生成的图片使用A4纸铺满的方式打印出来,贴在一个刚体的板子上,即可用于相机标定。

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持IT技术网。