Clear Filters
Clear Filters

Camera Calibration with AprilTags not working with png image datafile

2 views (last 30 days)
I'm trying to follow this example.
In both MATLAB online and 2020b, I get the following error when trying to detect tags in my calibration images:
Matrix index is out of range for deletion.
Error in CalibrateCameraUsingAprilTagBasedPatternExample>helperDetectAprilTagCorners (line 161)
imagePoints(:,:,idx) = [];
I have passed imdsCalib my filetype as described here.
I want to use pngs for calibration because I want the most accurate calibration possible, and intend to use pngs for detection, again for the most accurate detections possible. Is there something I'm doing wrong? Or is this not possible at all?
Thank you for any and all help!
  1 Comment
Andrew Roley
Andrew Roley on 12 Jan 2021
So I ended up adding a few statements to diagnose what was happening right before the problematic line 161, and this was helpful:
It prints the number of tags identified in the particular image that is being parsed through. I seemed to get this problem only after multiple poor detections with less than the expected number of tags, and it seemed to happen on the second to last image, which was very odd.
I then went through and individually deleted those files without the full tags detected, and it worked from there. I wouldn't call this a "solution", moreso a workaround, so I'm leaving the question unanswered until someone with better knowledge than I can comment.

Sign in to comment.

Answers (2)

Amrtanshu Raj
Amrtanshu Raj on 5 Feb 2021
I have brought this issue to the notice of our developers. They will investigate the matter further.

Vinoth Venkatesan
Vinoth Venkatesan on 5 Feb 2021
Hi Andrew,
This is a bug in a helper function that is part of the example. Please replace the helperDetectAprilTagCorners function at the end of the example file (CalibrateCameraUsingAprilTagBasedPatternExample.mlx) with the function attached here to resolve the issue.
Thanks, Vinoth

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!