所用棋盘为8*8国际象棋棋盘,共检测7*7个角点
#include "stdafx.h"
#include <opencv2/opencv.hpp>
#include <vector>
using namespace cv;
int main()
{
int CurrentImage = 0;
int CurrentRow = 0; //行
int CurrentColumn = 0; //列
int ChessBoardSize_w = 7; //角点个数
int ChessBoardSize_h = 7;
bool findcorner_result = false;
const int NImages = 4;//图片数量
char* imageArray[NImages] = {"chess1.jpg",
"chess2.jpg",
"chess3.jpg",
"chess4.jpg"};
int NPoints=0;
Mat src;
Mat gray;
namedWindow("Chess",0);
vector<Point2f> corners;//存储角点
//读取图片
for(CurrentImage;CurrentImage<NImages;++CurrentImage)
{
src = imread(imageArray[CurrentImage]);
//灰度
cvtColor(src,gray,CV_BGR2GRAY);
//检测角点
corners.clear();
findcorner_result = findChessboardCorners(gr