Repository: opencv
Issue: Subpixel coordinates of findChessboardCorners are unintuitive
Labels: category: calib3d,RFC

<!--
If you have a question rather than reporting a bug please go to https://forum.opencv.org where you get much faster responses.
If you need further assistance please read [How To Contribute](https://github.com/opencv/opencv/wiki/How_to_contribute).

This is a template helping you to create an issue which can be processed as quickly as possible. This is the bug reporting section for the OpenCV library.
-->

##### System information (version)
- OpenCV => master
- Operating System / Platform => Ubuntu 22.04
- Compiler => gcc11

##### Detailed description

tl;dr summary; Using chessboard corners of `findChessboardCorners` in conjuction with `solvePnP` to calculate the camera pose results in a slight offset, when using common rendering methods (or `projectPoints`) with that pose.

In [this](https://github.com/opencv/opencv_contrib/pull/3024) `opencv_contrib` PR, I noted the disparity between `projectPoints` and `cornerSubPix`s subpixel coordinate understanding, which are used in `interpolateCornersCharuco`. The "fix" I created there results in `interpolateCornersCharuco` behaving differently from `findChessboardCorners` (or `findChessboardCornersSB`), as the subpixel coordinate system of `cornerSubPix` is used in the latter.

I want to argue here, that the subpixel coordinate system of `projectPoints` is actually more intuitive.

Often, the corners of `findChessboardCorners` are used to estimate the pose of the camera that captured the image. E.g., in order to project something into the image. Common rendering engines (and `projectPoints`) assume that the center of a pixel has the coordinate (0.5, 0.5) (c.f. [this article](https://www.realtimerendering.com/blog/the-center-of-the-pixel-is-0-50-5/)). Therefore, using the pose estimated from the corners given by `findChessboardCornersSB` to render results in a small offset.

To demonstrate this I implemented a loop that finds a pattern, calculates the camera's pose and renders the pattern from that perspective (using Ogre3d via ovis). These are the resulting images:

`findChessboardCorners`
![chessboard-opt](https://user-images.githubusercontent.com/6648759/180578840-37fae7c9-6b0c-447e-9333-be87654e3566.gif)


`findChessboardCornersSB`
![chessboardsb-opt](https://user-images.githubusercontent.com/6648759/180578846-f864a29b-bdff-464b-a898-75e10e87effe.gif)


`interpolateCornersCharuco`
![charuco-opt](https://user-images.githubusercontent.com/6648759/180578852-5b32f7dc-336a-4489-9387-5b995b1eb5e9.gif)


I also calculated the error between the `projectPoints`ed board points and the corners returned by `findChessboardCorners`:

| Method | Mean error 300 frames |
|-|-|
| `findChessboardCorners`      | 0.69035 |
| `findChessboardCornersSB` | 0.67511 |
| `interpolateCornersCharuco` | 0.08741 |

##### Steps to reproduce

The attached zip file contains a `board_render_test.py` script, the used board type can be changed by setting `board_type` to either `chessboard`, `chessboardsb` or `charuco`. The `ovis` module from contrib is necessary.

[board_render_test.zip](https://github.com/opencv/opencv/files/9172627/board_render_test.zip)



<!-- to add code example fence it with triple backticks and optional file extension
    ```.cpp
    // C++ code example
    ```
 or attach as .txt or .zip file
-->

##### Issue submission checklist

 - [x] I report the issue, it's not a question
   <!--
   OpenCV team works with forum.opencv.org, Stack Overflow and other communities
   to discuss problems. Tickets with questions without a real issue statement will be
   closed.
   -->
 - [x] I checked the problem with documentation, FAQ, open issues,
       forum.opencv.org, Stack Overflow, etc and have not found any solution
   <!--
   Places to check:
   * OpenCV documentation: https://docs.opencv.org
   * FAQ page: https://github.com/opencv/opencv/wiki/FAQ
   * OpenCV forum: https://forum.opencv.org
   * OpenCV issue tracker: https://github.com/opencv/opencv/issues?q=is%3Aissue
   * Stack Overflow branch: https://stackoverflow.com/questions/tagged/opencv
   -->
 - [x] I updated to the latest OpenCV version and the issue is still there
   <!--
   master branch for OpenCV 4.x and 3.4 branch for OpenCV 3.x releases.
   OpenCV team supports only the latest release for each branch.
   The ticket is closed if the problem is not reproduced with the modern version.
   -->
 - [x] There is reproducer code and related data files: videos, images, onnx, etc
   <!--
   The best reproducer -- test case for OpenCV that we can add to the library.
   Recommendations for media files and binary files:
   * Try to reproduce the issue with images and videos in opencv_extra repository
     to reduce attachment size
   * Use PNG for images, if you report some CV related bug, but not image reader
     issue
   * Attach the image as an archive to the ticket, if you report some reader issue.
     Image hosting services compress images and it breaks the repro code.
   * Provide ONNX file for some public model or ONNX file with random weights,
     if you report ONNX parsing or handling issue. Architecture details diagram
     from netron tool can be very useful too. See https://lutzroeder.github.io/netron/
   -->