本文介绍了findChessboardCorners对于校准图像失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让OpenCV 2.4.5从我的网络摄像头识别一个棋盘图案。我不能得到那个工作,所以我决定尝试使用一个完美的形象工作:

I am trying to get OpenCV 2.4.5 to recognize a checkerboard pattern from my webcam. I couldn't get that working, so I decided to try to get it working just using a "perfect" image:

但它仍然无法工作 - patternFound每次都返回false。有没有人知道我在做什么?

but it still won't work--patternFound returns false every time. Does anyone have any idea what I'm doing wrong?

#include <stdio.h>

#include <opencv2/core/core.hpp>
#include <opencv2/imgproc/imgproc.hpp>
#include <opencv2/calib3d/calib3d.hpp>
#include <opencv2/highgui/highgui.hpp>

using namespace cv;
using namespace std;

int main(){
    Size patternsize(8,8); //number of centers
    Mat frame = imread("perfect.png"); //source image
    vector<Point2f> centers; //this will be filled by the detected centers

    bool patternfound = findChessboardCorners(frame,patternsize,centers);

    cout<<patternfound<<endl;
    drawChessboardCorners(frame, patternsize, Mat(centers), patternfound);

    cvNamedWindow("window");
    while(1){
        imshow("window",frame);
        cvWaitKey(33);
    }
}


推荐答案

尝试和错误,我意识到patternsize应该是7x7,因为它是计数内部角。这个参数必须是正确的 - 8x8将不工作,但也不会小于7x7。

Through trial and error, I realized that patternsize should be 7x7 since it is counting internal corners. This parameter has to be exact--8x8 won't work, but neither will anything less than 7x7.

这篇关于findChessboardCorners对于校准图像失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 00:17