Ask Your Question

Unable to detect AprilTag using ROS on Raspberry Pi

asked 2019-05-21 09:11:59 -0500

qzt gravatar image


I'm running ROS indigo on a Raspberry Pi with IMX219 Raspberry Pi Camera V2. Yet I can’t seem to detect the AprilTag. The raw images and camera info are being published by raspicam_node. The code of the launch file for raspicam_node is:


  <node pkg="raspicam" type="raspicam_raw_node" name="raspicam_node" respawn="true" ns="camera" output="screen">
    <param name="quality" type="double" value="10.0"/>
    <param name="framerate" type="double" value="50.0"/>
    <param name="width" type="double" value="320.0" />
    <param name="height" type="double" value="240.0" />

  <!--node pkg="image_proc" type="image_proc" name="image_proc" respawn="true" ns="/camera"/-->

The raw images and camera info are then subscribed by apriltag_detector. The code of the launch file for apriltag_detector is:

<?xml version="1.0" encoding="ISO-8859-15"?>

  <node pkg="apriltags_ros" type="apriltag_detector_node" name="apriltag_detector" output="screen" ns="camera">
    <remap from="image_rect" to="image_raw" />
    <remap from="camera_info" to="camera_info" />

    <!-- 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" />

    <!-- Enter your AprilTag information below. Add all tag IDs that will be used, with their sizes -->
    <rosparam param="tag_descriptions">[
      {id: 0, size: 0.08, frame_name: tag_0},
      {id: 1, size: 0.08, frame_name: tag_1},
      {id: 2, size: 0.08, frame_name: tag_2},
      {id: 3, size: 0.08, frame_name: tag_3},
      {id: 4, size: 0.08, frame_name: tag_4},
      {id: 5, size: 0.08, frame_name: tag_5},
      {id: 6, size: 0.08, frame_name: tag_6},
      {id: 7, size: 0.08, frame_name: tag_7},
      {id: 8, size: 0.08, frame_name: tag_8},
      {id: 9, size: 0.08, frame_name: tag_9},
      {id: 10, size: 0.08, frame_name: tag_10},
      {id: 11, size: 0.08, frame_name: tag_11},
      {id: 12, size: 0.08, frame_name: tag_12},
      {id: 13, size: 0.08, frame_name: tag_13},
      {id: 14, size: 0.08, frame_name: tag_14},
      {id: 15, size: 0.08, frame_name: tag_15},

I have tried the following measures to debug this issue, but with no luck:

  1. Adjust the camera focal length to make sure the images are reasonably focused.
  2. Recalibrate the camera using rosrun camera_calibration
  3. Feed an original tag image directely to the apriltag_detector node.

Any idea what should I do to debug this issue? I am new to ROS, so any help would be greatly appreciated.

edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted

answered 2019-05-28 02:34:42 -0500

qzt gravatar image

OK. I think I have figured it out. It turns out the raw images being published by raspicam_node are mirrowed. That's why the tagcode can't be identified. So I change line 55-59 in apriltag_detector.cpp:

cv::Mat gray;
cv::cvtColor(cv_ptr->image, gray, CV_BGR2GRAY);
std::vector<AprilTags::TagDetection>    detections = tag_detector_->extractTags(gray);


cv::Mat gray, gray_fliped;
cv::cvtColor(cv_ptr->image, gray, CV_BGR2GRAY);
cv::flip(gray,gray_fliped, 1);
std::vector<AprilTags::TagDetection>  detections = tag_detector_->extractTags(gray_fliped);

My solution is more like a patch. I would love to know if I can filp the raw images using the launch file for raspicam_node.

edit flag offensive delete link more



This is unusual, the images are probably being flipped already somewhere inside the raspicam node. If you can find what setting is making this happen then turning it off would be the best solution.

PeteBlackerThe3rd gravatar image PeteBlackerThe3rd  ( 2019-05-28 04:44:54 -0500 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools



Asked: 2019-05-21 09:11:59 -0500

Seen: 382 times

Last updated: May 28 '19