资源简介

灰度图和彩色图像均可以标定,已测试通过,标定结果会保存成文档格式,稍微模糊的图检测效果也很好

资源截图

代码片段和文件信息

// CameraCalibration.cpp : 定义控制台应用程序的入口点。
//

#include “stdafx.h“
#include 
#include 
#include 
#include 

int n_boards = 0; //Will be set by input list
int board_w;
int board_h;

int _tmain(int argc _TCHAR* argv[])
{
//board_w = 12;  //水平角点个数
//board_h = 11;  //竖直角点个数
board_w = 9;  //水平角点个数
board_h = 6;  //竖直角点个数
int board_n  = board_w * board_h;  //单张图片的角点总数
CvSize board_sz = cvSize( board_w board_h );

//读取存储标定图片名称的文档
FILE *fptr = fopen(“chessboards.txt““r“);
char names[2048];
//COUNT THE NUMBER OF IMAGES:
while(fscanf(fptr“%s “names)==1){
n_boards++;
}
rewind(fptr);

cvNamedWindow( “Calibration“ );

    //ALLOCATE STORAGE申请存储空间
    CvMat* image_points      = cvCreateMat(n_boards*board_n2CV_32FC1); //存储角点的像素坐标
    CvMat* object_points     = cvCreateMat(n_boards*board_n3CV_32FC1); //存储角点的世界坐标
    CvMat* point_counts      = cvCreateMat(n_boards1CV_32SC1);         //存储标定图片的个数
    CvMat* intrinsic_matrix  = cvCreateMat(33CV_32FC1);                //存储内参数矩阵
    CvMat* distortion_coeffs = cvCreateMat(51CV_32FC1);                //存储畸变系数

    IplImage* image = 0;
    IplImage* gray_image = 0; //for subpixel亚像素标定所需的灰度图像
    CvPoint2D32f* corners = new CvPoint2D32f[ board_n ];
    int corner_count;
    int successes = 0;
    int step;

//读取标定图片
    for( int frame=0; frameame++ ) {
    fscanf(fptr“%s “names);

    if(image){
    cvReleaseImage(&image);
    image = 0;
    }
    image = cvLoadImage( names);

        if(gray_image == 0  && image) //We‘ll need this for subpixel accurate stuff
    gray_image = cvCreateImage(cvGetSize(image)81);

if (!image)
{
//printf(“null image\n“);
exit(-1);
}
    
//查找棋盘角点
        int found = cvFindChessboardCorners(imageboard_szcorners&corner_count CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS);

cvCvtColor(image gray_image CV_RGB2GRAY);
    
//Get Subpixel accuracy on those corners
      cvFindCornerSubPix(gray_image corners corner_countcvSize(1111)cvSize(-1-1) cvTermCriteria( CV_TERMCRIT_EPS+CV_TERMCRIT_ITER 30 0.1 ));
  

//Draw it
    cvDrawChessboardCorners(image board_sz corners corner_count found);

//Show it
        cvShowImage( “Calibration“ image );
    cvWaitKey(10);


        // If we got a good board add it to our data
        if( corner_count == board_n ) {
    step = successes*board_n;
            for( int i=step j=0; j                CV_MAT_ELEM(*image_points floati0) = corners[j].x;
                CV_MAT_ELEM(*image_points floati1) = corners[j].y;
                CV_MAT_ELEM(*object_pointsfloati0) = j/board_w;
                CV_MAT_ELEM(*object_pointsfloati1) = j%board_w;
                CV_MAT_ELEM(*object_pointsfloati2) = 0.0f;
    }
            CV_MAT_ELEM(*point_counts intsuccesses0) = board_n;
            s

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件    3736518  2015-03-19 14:20  CameraCalibration\CameraCalibration\1.bmp

     文件    3736518  2015-03-19 14:19  CameraCalibration\CameraCalibration\800z.bmp

     文件    1246566  2018-01-02 10:57  CameraCalibration\CameraCalibration\calibration\1.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\10.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\11.bmp

     文件    1246566  2018-01-02 11:01  CameraCalibration\CameraCalibration\calibration\12.bmp

     文件    1246566  2018-01-02 11:01  CameraCalibration\CameraCalibration\calibration\13.bmp

     文件    1246566  2018-01-02 11:01  CameraCalibration\CameraCalibration\calibration\14.bmp

     文件    1246566  2018-01-02 11:01  CameraCalibration\CameraCalibration\calibration\15.bmp

     文件    1246566  2018-01-02 11:01  CameraCalibration\CameraCalibration\calibration\16.bmp

     文件    1246566  2018-01-02 11:01  CameraCalibration\CameraCalibration\calibration\17.bmp

     文件    1246566  2018-01-02 11:02  CameraCalibration\CameraCalibration\calibration\18.bmp

     文件    1246566  2018-01-02 11:02  CameraCalibration\CameraCalibration\calibration\19.bmp

     文件    1246566  2018-01-02 10:57  CameraCalibration\CameraCalibration\calibration\2.bmp

     文件    1246566  2018-01-02 11:02  CameraCalibration\CameraCalibration\calibration\20.bmp

     文件    1246566  2018-01-02 11:02  CameraCalibration\CameraCalibration\calibration\21.bmp

     文件    1246566  2018-01-02 11:02  CameraCalibration\CameraCalibration\calibration\22.bmp

     文件    1246566  2018-01-02 10:59  CameraCalibration\CameraCalibration\calibration\3.bmp

     文件    1246566  2018-01-02 10:59  CameraCalibration\CameraCalibration\calibration\4.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\5.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\6.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\7.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\8.bmp

     文件    1246566  2018-01-02 11:00  CameraCalibration\CameraCalibration\calibration\9.bmp

     文件     921654  2015-04-15 15:56  CameraCalibration\CameraCalibration\calibration2\1.bmp

     文件     921654  2015-04-15 15:56  CameraCalibration\CameraCalibration\calibration2\10.bmp

     文件     921654  2015-04-15 15:56  CameraCalibration\CameraCalibration\calibration2\11.bmp

     文件     921654  2015-04-15 15:56  CameraCalibration\CameraCalibration\calibration2\12.bmp

     文件     921654  2015-04-15 15:56  CameraCalibration\CameraCalibration\calibration2\13.bmp

     文件     921654  2015-04-15 15:56  CameraCalibration\CameraCalibration\calibration2\14.bmp

............此处省略102个文件信息

评论

共有 条评论