Closed walchko closed 3 years ago
The error you get is because you do not have 2 dimensions in your image, but likely 3 due to reading the image as RGB. Try reading/converting to grayscale 1-channel and it should work.
So that doesn't work. I pulled a circular tag from Apriltags pre-rendered tags here
The image RGBA with the alpha layer giving the circular'ish aspect to the tag.
d = Detector(families='tagCircle49h12',
nthreads=1,
quad_decimate=1.0,
quad_sigma=0.0,
refine_edges=1,
decode_sharpening=0.25,
debug=1)
im = cv2.imread("pics/tag49_12_00000.png", cv2.IMREAD_UNCHANGED)
im = cv2.cvtColor(im, cv2.COLOR_BGRA2GRAY)
tags = d.detect(im, estimate_tag_pose=False, camera_params=None, tag_size=None)
print(f"{len(tags)} tags found")
Returns: 0 tags found
I also tried reading it in as grayscale with im = cv2.imread("pics/tag49_12_00000.png", 0)
and that didn't help.
Am I somehow setting up the detector wrong?
Ah yes I didn't think about it, I had the same issue not long ago. If you use the tags as input, the resolution is extremely small and nothing will be detected.
Try upscaling the tag image to 150x150 or something in this range. Beware of resampling that might make edges blurry.
Thanks! Yes, that can be a problem ... I forgot about it too and fixated on the alpha layer as the issue since other tags didn't have an alpha layer.
You can easily scale without blurriness by using cv2.INTER_AREA
or cv2.INTER_NEAREST
since they appear to give nice crisp edges compared to other methods I have tried.
def scale(im, s=1.0):
(h,w) = im.shape
return cv2.resize(im, (s*h, s*w,), interpolation=cv2.INTER_AREA)
This doesn't seem to detect circular apriltags:
Here is the tag:
What am I doing wrong?