Camera - centric Point of image_geometry::PinholeCameraModel [closed]

asked 2023-03-26 14:53:09 -0500

WhateverKatzenfutter gravatar image

Hey guys,

I am trying to understand the project3dToPixel(...) function of image_geometry::PinholeCameraModel, but still not sure if I understand it right, because I get other results then I think I should get.....

Here is a piece of the code with which I try to get the camera centric Point:

cv::Point2d pInImage;   
cv::Point3d coordinates;
image_geometry::PinholeCameraModel cameraModel;

// Axis directions in the image plane are: x - to the right | y - down | z - into the plane
coordinates.x = 0;
coordinates.y = 0;
coordinates.z = 1;   

RCLCPP_INFO(this->get_logger(), "Coordinates: x=%f | y=%f | z=%f", coordinates.x, coordinates.y, coordinates.z);

RCLCPP_INFO(this->get_logger(), "-------------------------------------");

cameraModel.fromCameraInfo(cameraInfo);
pInImage = cameraModel.project3dToPixel(coordinates);

RCLCPP_INFO(this->get_logger(), "Rubik Cube in image: u=%f | v=%f", pInImage.x, pInImage.y);

RCLCPP_INFO(this->get_logger(), "-------------------------------------");

This is the calibration file of the camera which I use:

image_width: 640
image_height: 480
camera_name: trust_qhd_webcam:_trust_qhd_web
camera_matrix:
rows: 3
cols: 3
data: [626.00986,   0.     , 313.4817 ,
                   0.     , 626.95054, 254.95665,
                   0.     ,   0.     ,   1.     ]
distortion_model: plumb_bob
distortion_coefficients:
rows: 1
cols: 5
data: [0.146588, -0.316449, 0.005444, -0.001867, 0.000000]
rectification_matrix:
rows: 3
cols: 3
data: [1., 0., 0.,
          0., 1., 0.,
          0., 0., 1.] 
projection_matrix:
rows: 3
cols: 4
data: [636.19208,   0.     , 311.96673,   0.     ,
                   0.     , 636.69824, 256.23645,   0.     ,
                   0.     ,   0.     ,   1.     ,   0.     ]

Because the image plane of my camera has the size of 640x480 I would assume, that if I want to project a 3D Point with the coordinates x=0, y=0, z=1 I would get u=320, v=240 as the image plane coordinates, but I am getting u=311.966730, v=256.236450....So its almost right, but where does the difference from the expected result comes from?

Could this be an issue because of bad calibration of the camera?

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by WhateverKatzenfutter
close date 2023-03-30 13:32:29.922519