From 65e359c8555100d3f1114636f26fcfe15659daf0 Mon Sep 17 00:00:00 2001 From: wtyuan96 Date: Tue, 4 Apr 2023 21:04:09 +0800 Subject: [PATCH] Call cornerSubPix when using OpenCV to detect corners --- src/chessboard/Chessboard.cc | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/chessboard/Chessboard.cc b/src/chessboard/Chessboard.cc index b2cada6f..c7c2a431 100644 --- a/src/chessboard/Chessboard.cc +++ b/src/chessboard/Chessboard.cc @@ -76,7 +76,17 @@ Chessboard::findChessboardCorners(const cv::Mat& image, { if (useOpenCV) { - return cv::findChessboardCorners(image, patternSize, corners, flags); + bool found = cv::findChessboardCorners(image, patternSize, corners, flags); + if (found) + { + cv::cornerSubPix(image, corners, cv::Size(11, 11), cv::Size(-1,-1), + cv::TermCriteria(CV_TERMCRIT_EPS + CV_TERMCRIT_ITER, 30, 0.1)); + return true; + } + else + { + return false; + } } else {