apriltag icon indicating copy to clipboard operation
apriltag copied to clipboard

What's the meaning of 'apriltag.c:448: homography_compute2: Assertion `max_val_idx >= 0' failed.'?

Open WZG3661 opened this issue 1 year ago • 1 comments

an error ccurred accidentally: apriltag.c:448: homography_compute2: Assertion `max_val_idx >= 0' failed. what's the meaning of this error? did I do something wrong?

WZG3661 avatar Mar 23 '24 03:03 WZG3661

This check was added in #317 to avoid indexing with a negative index. I hope that the proposed fix in #213, which was ported into #317 via 359a98403e64237d6ec7b800dc8b61ddaa7ee570, fixes the issue, but apparently, it does not.

Do you have a reproducible script and data for this?

christian-rauch avatar Mar 23 '24 08:03 christian-rauch

this is my code:

#include "apriltag.h"
#include "tagStandard41h12.h"

#include <iostream>
#include <opencv2/core/core.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv2/opencv.hpp>

int main() {

  std::string img_path = "path_to_img";
  cv::Mat img = cv::imread(img_path, CV_8UC1);

  apriltag_family_t *tf;
  apriltag_detector_t *td;

  tf = tagStandard41h12_create();
  td = apriltag_detector_create();
  apriltag_detector_add_family(td, tf);

  image_u8_t im = {img.cols, img.rows, img.cols, img.data};
  zarray_t *detections = apriltag_detector_detect(td, &im);

  apriltag_detector_destroy(td);
  tagStandard41h12_destroy(tf);
  return 0;
}

this is the picture: 1710383687 256000 and the commit is e6cd3c7afdc

WZG3661 avatar Apr 03 '24 06:04 WZG3661

Thanks. I can reproduce this with the apriltag_demo:

apriltag_demo -f tagStandard41h12 319063435-0f7a44f8-58e7-452c-99bc-142160e24a93.jpg

christian-rauch avatar Apr 03 '24 17:04 christian-rauch

With the debug information

debug_clusters

debug_quads_raw

I can see that there are two odd perfect axis-aligned rectangular quads and with the debugger I can see that those coordinates are horizontally and vertically aligned (identical x and y coordinates).

While it is very unlikely that we will get detections that are perfectly axis-aligned like this on a sub-pixel level, I don't see why homography_compute2 should be able to compute a homography from this.

christian-rauch avatar Apr 03 '24 19:04 christian-rauch