RIVeR-Lab / apriltags_ros

AprilTags for ROS
http://wiki.ros.org/apriltags_ros
83 stars 101 forks source link

image_pipeline: issue with the decimation #15

Open fabrizioschiano opened 7 years ago

fabrizioschiano commented 7 years ago

Hi everyone,

I am trying to use apriltags with a flea3 USB camera by pointgrey. The resolution of the camera is too big and therefore I need to reduce it via the image_pipeline stack of ROS. I can't reduce it through the official SDK FlyCapture (It should be a known problem of the SDK).

Anyway, I use the image_pipeline to decimate the image via the following launch file

<launch>
    <arg name="qcID" default="5"/>
    <arg name="bond" value="" />

    <node pkg="nodelet" type="nodelet" name="decimator_$(arg qcID)"
          args="load image_proc/crop_decimate camera_manager_$(arg qcID)">
      <param name="decimation_x" type="int" value="4" />
      <param name="decimation_y" type="int" value="4" />

      <remap from="/camera_$(arg qcID)/image_raw" to="camera/image_raw"/>
      <remap from="camera/image_info" to="/camera_$(arg qcID)/camera_info"/>

      <remap from="camera_out/image_raw" to="/camera_$(arg qcID)_dec/image_raw"/>
      <remap from="camera_out/image_info" to="/camera_$(arg qcID)_dec/camera_info"/>
    </node>

    <node name="drop_cam_$(arg qcID)" pkg="topic_tools" type="drop"
        args="/camera_$(arg qcID)_dec/image_raw/compressed 1 15 /camera_$(arg qcID)_drop/image_raw/compressed" />
    <node name="drop_info_$(arg qcID)" pkg="topic_tools" type="drop"
        args="/camera_$(arg qcID)_dec/camera_info 1 15 /camera_$(arg qcID)_drop/camera_info" />
</launch>

After doing this the pose estimated through the apriltag gets wrong, in the sense that I have a z which is 4 times the real one, and the same goes for x and y.

I can solve that by dividing the size of the marker by 4 in the example.launch file which I use to launch the apriltag ros node, which looks like that:

<launch>
  <node pkg="apriltags_ros" type="apriltag_detector_node" name="apriltag_detector" output="screen">
    <!-- Remap topic required by the node to custom topics -->
    <remap from="image_rect" to="/camera_5_drop/image_raw" /> 
    <remap from="camera_info" to="/camera_5_drop/camera_5_info" />

    <!-- Optional: Subscribe to the compressed stream-->
    <param name="image_transport" type="str" value="compressed" />

    <!-- Select the tag family: 16h5, 25h7, 25h9, 36h9, or 36h11(default) -->
    <param name="tag_family" type="str" value="36h11" />

    <!-- Enable projected optical measurements for more accurate tag transformations -->
    <!-- This exists for backwards compatability and should be left true for new setups -->
    <param name="projected_optics" type="bool" value="true" />

    <!-- Describe the tags -->
    <rosparam param="tag_descriptions">[
      {id: 0, size: 0.0215},
      {id: 1, size: 0.086, frame_id: a_frame},
      {id: 2, size: 0.167,frame_id: a_frame},
      {id: 3, size: 0.167},
      {id: 4, size: 0.167},
      {id: 5, size: 0.167}]
    </rosparam>
  </node>
</launch>

I don't think this is a SOLUTION but just a workaround. Could you please help me to understand this?

I think that the problem has to be found in the binning parameter sent on the camera_info topic. If the apriltags_ros node does not support the camera_info binning parameter , for sure this will not work.

If you look at the camera_info in the case of the original image I have:

rostopic echo -n 1 /camera/camera_info 
header: 
  seq: 29157
  stamp: 
    secs: 1478102548
    nsecs: 328822432
  frame_id: camera
height: 1552
width: 2080
distortion_model: plumb_bob
D: [-0.001312, 0.003408, -0.004684, 0.014525, 0.0]
K: [687.216761, 0.0, 1111.575057, 0.0, 673.787664, 747.109306, 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: [706.72345, 0.0, 1172.617419, 0.0, 0.0, 713.655701, 732.345523, 0.0, 0.0, 0.0, 1.0, 0.0]
binning_x: 1
binning_y: 1
roi: 
  x_offset: 0
  y_offset: 0
  height: 0
  width: 0
  do_rectify: True

---

While for the decimated image is:

rostopic echo -n 1 /camera_5_dec/camera_info 
header: 
  seq: 29025
  stamp: 
    secs: 1478102543
    nsecs: 931340616
  frame_id: camera
height: 1552
width: 2080
distortion_model: plumb_bob
D: [-0.001312, 0.003408, -0.004684, 0.014525, 0.0]
K: [687.216761, 0.0, 1111.575057, 0.0, 673.787664, 747.109306, 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: [706.72345, 0.0, 1172.617419, 0.0, 0.0, 713.655701, 732.345523, 0.0, 0.0, 0.0, 1.0, 0.0]
binning_x: 4
binning_y: 4
roi: 
  x_offset: 0
  y_offset: 0
  height: 1552
  width: 2080
  do_rectify: True

---

Thanks in advance.