Different results for findChessboardCorners in python and C++ environments?

Why do I get different results in python and C++ environments using the findChessboardCorners function?

python and c++ have same opencv version4.6.0. And How can I get the same result in C++ when the same image is detected with the same parameters, but all corner points are detected in python and none or some in C++? The original image is attached and the program is as follows.
your answer would be great appreciatly!

python code:

img = cv2.imread("left.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
subpix_criteria = (cv2.TERM_CRITERIA_EPS +
                       cv2.TERM_CRITERIA_MAX_ITER, 30, 0.1)
checkerboard = (3,14)
ret, corners = cv2.findChessboardCorners(
            gray, checkerboard, cv2.CALIB_CB_ADAPTIVE_THRESH + cv2.CALIB_CB_FAST_CHECK + cv2.CALIB_CB_NORMALIZE_IMAGE)
if ret == True:
    corners2 = cv2.cornerSubPix(gray, corners, (3, 3),
                                        (-1, -1), subpix_criteria)
    cv2.drawChessboardCorners(img, checkerboard, corners, ret)

C++ code:

cv::Mat oriImg = cv::imread("left.jpg");
    cv::Size patternRowsByCols = cv::Size(14, 3);
std::vector<cv::Point2f> corners;  
    cv::Mat gray;
    if (oriImg.channels() == 3) {
        cv::cvtColor(oriImg, gray, cv::COLOR_BGR2GRAY);
    } else {
        gray = oriImg;
    }

    bool isFound = cv::findChessboardCorners(gray, patternRowsByCols, corners, cv::CALIB_CB_ADAPTIVE_THRESH + cv::CALIB_CB_FAST_CHECK + cv::CALIB_CB_NORMALIZE_IMAGE);
    if (isFound) {
        cv::cornerSubPix(gray, corners, cv::Size(3, 3), cv::Size(-1, -1), cv::TermCriteria(cv::TermCriteria::MAX_ITER + cv::TermCriteria::EPS, 30, 0.1));
    }

    cv::drawChessboardCorners(oriImg, patternRowsByCols, corners, isFound);

what about:

checkerboard = (3,14)

vs:

cv::Size patternRowsByCols = cv::Size(14, 3)

(c++ version has it the wrong way, imo)

According to opencv C++ documentation, param
‘patternSize’ is Number of inner corners per a chessboard row and column

( patternSize = cv::Size(points_per_row,points_per_colum) = cv::Size(columns,rows) )

So I think I’ve written it correctly in C++. @berak

so you notice the contradiction?

Even if i change
cv::Size patternRowsByCols = cv::Size(14, 3) to
cv::Size(3, 14) ,it still could’t detect any points. Why? @crackwitz

I’ll try to remember to give the C++ code a look this evening.

@crackwitz Sincerely looking forward to your solutions,thanks!

@crackwitz hi, have you try it?

no, it’s not even evening yet

@crackwitz What about now?