Camera 摄像机校准:角点计数:0

Camera 摄像机校准:角点计数:0,camera,Camera,我们正在尝试实现相机校准,但角点计数输出为零。这是附加的代码。在这篇文章中,我们给出了高度和宽度为12的静态图像 cvFindChessboardCorners此函数未按预期工作。有人能帮我解决这个错误吗 #include "opencv\cv.h" #include "opencv\highgui.h" #include "conio.h" #include "stdio.h" #include "string.h" #define N 10 int n_boards = 0;

我们正在尝试实现相机校准,但角点计数输出为零。这是附加的代码。在这篇文章中,我们给出了高度和宽度为12的静态图像

cvFindChessboardCorners此函数未按预期工作。有人能帮我解决这个错误吗

#include "opencv\cv.h"
#include "opencv\highgui.h"
#include "conio.h"
#include "stdio.h"
#include "string.h"
#define N 10

int n_boards = 0;       //Number of snapshots of the chessboard
int board_w;            //Enclosed corners horizontally on the chessboard
int board_h;            //Enclosed corners vertically on the chessboard

int main()
{

int start, total;
char str[15],ext[15];
int board_h = 0, board_w = 0;
printf("Enter the name of the Images (String) without numeric denominator:  ");
scanf( "%s", str);
printf("Enter the extension of the Images (String):  ");
scanf( "%s", ext);
printf("Enter the total number of the File (should be integer) starting with index << 1 >> :: ");
scanf( "%d", &total);
printf("Enter the the board width (should be integer) :: ");
scanf( "%d", &board_w);
printf("Enter the the board height (should be integer) :: ");
scanf( "%d", &board_h);

n_boards = total;

//board_w  = 12;
//board_h  = 12;

int board_total  = board_w * board_h;                       //Total enclosed corners on the board
CvSize board_sz = cvSize( board_w, board_h );

//Allocate storage for the parameters according to total number of corners and number of snapshots
    CvMat* image_points      = cvCreateMat(n_boards*board_total,2,CV_32FC1);
    CvMat* object_points     = cvCreateMat(n_boards*board_total,3,CV_32FC1);
    CvMat* point_counts      = cvCreateMat(n_boards,1,CV_32SC1);
    CvMat* intrinsic_matrix  = cvCreateMat(3,3,CV_32FC1);
    CvMat* distortion_coeffs = cvCreateMat(4,1,CV_32FC1);
    CvPoint2D32f* corners = new CvPoint2D32f[ board_total ];

    int corner_count;
    int successes = 0;
    int step, frame = 0;


char imgstr[N][8];

for(int i = 1; i<= total; i++)
{
  sprintf(imgstr[i-1], "%s%d", str, i);
  strcat(imgstr[i-1],".");
  strcat(imgstr[i-1],ext);
}

printf("Loading Images....... \n\n");
IplImage* image;
IplImage *gray_image ;
cvNamedWindow( "Snapshot" );

int k = 0;
for(int i= 0; i< total;i++)
{
    image = cvLoadImage(imgstr[i],1);

    if(image==NULL )
    {
     printf("unable to load the frame --> %s\n",imgstr[i]);exit(0);
     }
            gray_image = cvCreateImage(cvGetSize(image),8,1);
            //Find chessboard corners:
            int found = cvFindChessboardCorners(image, board_sz, corners, &corner_count,CV_CALIB_CB_ADAPTIVE_THRESH | CV_CALIB_CB_FILTER_QUADS | CV_CALIB_CB_NORMALIZE_IMAGE );
            printf("Corner count for %s is << %d >> \n",imgstr[i],corner_count);
}
return 0;
}
#包括“opencv\cv.h”
#包括“opencv\highgui.h”
#包括“conio.h”
#包括“stdio.h”
#包括“string.h”
#定义n10
int n_板=0//棋盘的快照数
国际董事会//棋盘上水平的封闭角
国际董事会//棋盘上垂直的封闭角
int main()
{
int开始,总计;
字符str[15],ext[15];
int board_h=0,board_w=0;
printf(“输入图像(字符串)的名称,不带数字分母:”;
scanf(“%s”,str);
printf(“输入图像的扩展名(字符串):”;
scanf(“%s”,ext);
printf(“输入以索引>::”开头的文件总数(应为整数);
scanf(“%d”,总计(&T);
printf(“输入电路板宽度(应为整数):”;
scanf(“%d”和“board_w”);
printf(“输入电路板高度(应为整数):”;
scanf(“%d”和“board_h”);
n_=总数;
//板w=12;
//板h=12;
int board_total=board_w*board_h;//板上的封闭角总数
CvSize board_sz=CvSize(board_w,board_h);
//根据角点总数和快照数为参数分配存储
CvMat*image_points=cvCreateMat(n个电路板*电路板总数,2个,CV_32FC1);
CvMat*object\u points=cvCreateMat(n个电路板*电路板总数,3个,CV\u 32FC1);
CvMat*点计数=cvCreateMat(n块电路板,1,CV_32SC1);
CvMat*固有矩阵=cvCreateMat(3,3,CV_32FC1);
CvMat*畸变系数=cvCreateMat(4,1,CV_32FC1);
CvPoint2D32f*角点=新CvPoint2D32f[电路板总数];
int角点计数;
int=0;
整数步长,帧=0;
char imgstr[N][8];

对于(int i=1;i您可以添加您想要校准的内容吗?您应该添加一个描述,说明您期望函数的行为以及您得到的回报。这样可以更容易地跟踪问题。