最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Python OpenCV projectPoints neutral position off center - Stack Overflow

programmeradmin1浏览0评论

I want to draw 3D Positions in a webcam Image using OpenCV's projectPoints function. During testing I noticed, that I always have a certain offset from the real object. This is most obvious when trying to project the origin (0,0,0) to the image center. The image shape is (2988, 5312, 3), the big red dot is the image center at (1494, 2656) and the small red dot with the lines attached is the projection of the origin (0,0,0) with NO translation and NO rotation leading to (1476, 2732).

The main question: Why is the projected point not in the middle of the image?

I determined the projected point like so:

origin_2d, jacobian = cv2.projectPoints(
    np.array([(0.0, 0.0, 0.0)]),
    np.array([(0.0, 0.0, 0.0)]),
    np.array([(0.0, 0.0, 0.0)]),
    mtx,
    dist,
)

So the origin (0,0,0) should be projected to 2D with no translation and no rotation and thus appear in the image center, right?

I obtained the camera mtx and dist by executing a camera calibration routine as described here OpenCV docs:Camera Calibration using the chessboard you see in the image. Is there something wrong with my calibration? Or am I misunderstanding something in the projection process?

Thanks and best regards, Felix

I want to draw 3D Positions in a webcam Image using OpenCV's projectPoints function. During testing I noticed, that I always have a certain offset from the real object. This is most obvious when trying to project the origin (0,0,0) to the image center. The image shape is (2988, 5312, 3), the big red dot is the image center at (1494, 2656) and the small red dot with the lines attached is the projection of the origin (0,0,0) with NO translation and NO rotation leading to (1476, 2732).

The main question: Why is the projected point not in the middle of the image?

I determined the projected point like so:

origin_2d, jacobian = cv2.projectPoints(
    np.array([(0.0, 0.0, 0.0)]),
    np.array([(0.0, 0.0, 0.0)]),
    np.array([(0.0, 0.0, 0.0)]),
    mtx,
    dist,
)

So the origin (0,0,0) should be projected to 2D with no translation and no rotation and thus appear in the image center, right?

I obtained the camera mtx and dist by executing a camera calibration routine as described here OpenCV docs:Camera Calibration using the chessboard you see in the image. Is there something wrong with my calibration? Or am I misunderstanding something in the projection process?

Thanks and best regards, Felix

Share Improve this question edited Nov 20, 2024 at 12:49 Christoph Rackwitz 15.6k5 gold badges39 silver badges51 bronze badges asked Nov 20, 2024 at 11:57 Felix NFelix N 801 silver badge6 bronze badges 1
  • crosspost: forum.opencv./t/projectpoints-origin-projection-off-center/… – Christoph Rackwitz Commented Nov 20, 2024 at 12:47
Add a comment  | 

1 Answer 1

Reset to default 1

The image shape is (2988, 5312, 3), the big red dot is the image center at (1494, 2656)

You calibrated that camera, right? Then that's not the optical center. The optical center is in the camera matrix, along with the focal length.

(1476, 2732)

That looks more like it, although I'd have expected these numbers to also have digits after the decimal point.

发布评论

评论列表(0)

  1. 暂无评论