fictionlab / ros_aruco_opencv

ROS wrapper for ArUco Opencv module
MIT License
16 stars 16 forks source link

[BUG] Erroneous retrieval of Camera's intrinsic matrix camera_matrix_ [ROS Noetic] #46

Closed real-Sandip-Das closed 5 months ago

real-Sandip-Das commented 5 months ago

Upon adding a few lines to the function callback_image(in aruco_tracker.cpp) for logging as follows:

  void callback_image(const sensor_msgs::ImageConstPtr &img_msg) {
    ROS_INFO_STREAM("distortion_coeffs_:");
    ROS_INFO_STREAM(distortion_coeffs_);
    ROS_INFO_STREAM("camera_matrix_:");
    ROS_INFO_STREAM(camera_matrix_);
    ROS_INFO_STREAM("marker_obj_points_:");
    ROS_INFO_STREAM(marker_obj_points_);

It was observed that the program was retrieving the camera's intrinsic matrix in a wrong way the float64[12] P field(in 'sensor_msgs::CameraInfo') is supposed to be a 3x4 matrix whereas the program is assuming it as a 3x3 matrix

console log:

[ INFO] [1717179696.576882516]: camera_matrix_:
[ INFO] [1717179696.576928720]: [933.15867, 0, 657.59;
 0, 0, 933.1586;
 400.36993, 0, 0]
[ INFO] [1717179696.576959502]: marker_obj_points_:
[ INFO] [1717179696.577009891]: [-0.0055, 0.0055, 0;
 0.0055, 0.0055, 0;
 0.0055, -0.0055, 0;
 -0.0055, -0.0055, 0]
[ INFO] [1717179696.640044745]: distortion_coeffs_:
[ INFO] [1717179696.640184108]: [0;
 0;
 0;
 0]

published camera info(output of rostopic echo /cv_camera/camera_info):

header: 
  seq: 308
  stamp: 
    secs: 1717179691
    nsecs: 133644523
  frame_id: "camera"
height: 480
width: 640
distortion_model: "plumb_bob"
D: []
K: [933.15867, 0.0, 657.59, 0.0, 933.1586, 400.36993, 0.0, 0.0, 1.0]
R: [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0]
P: [933.15867, 0.0, 657.59, 0.0, 0.0, 933.1586, 400.36993, 0.0, 0.0, 0.0, 1.0, 0.0]
binning_x: 0
binning_y: 0
roi: 
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: False
real-Sandip-Das commented 5 months ago

This issue is solved in this Pull Request: https://github.com/fictionlab/ros_aruco_opencv/pull/45