pupil-labs / apriltags

Python bindings for the apriltags3 library
https://pupil-apriltags.readthedocs.io/en/latest/index.html
Other
106 stars 29 forks source link

Very basic example - no detections #30

Closed C-monC closed 4 years ago

C-monC commented 4 years ago

Hi,

I want to compare the performance of apriltags to aruco markers but can't get the apriltags working.

import cv2
from pupil_apriltags import Detector

imagepath = "tag52_13_00000.png"
image = cv2.imread(imagepath, cv2.IMREAD_GRAYSCALE)

at_detector = Detector(families='tagStandard52h13',
                       nthreads=1,
                       quad_decimate=1.0,
                       quad_sigma=0.0,
                       refine_edges=1,
                       decode_sharpening=0.25,
                       debug=0)

tags = at_detector.detect(
    image, False, None, None
)
print(tags)

tag52_13_00000.png is taken straight from the apriltags repo. Does anyone know how to get this working?

Simon

pfaion commented 4 years ago

Hi @C-monC, normally we detect the presence and location of markers within a bigger image. I never tried just feeding in the marker image, this is not really the use case we needed.

Additionally, the original marker images are just "pixel" images of the lowest possible resolution. Normally you would print the markers in a large-enough size, stick them somewhere, and then make a photo/video where you try to detect them. Here is a page with already upscaled markers ready for printing: https://github.com/pupil-labs/pupil-helpers/blob/master/markers_stickersheet/apriltags_tag36h11_0-23.png You can find more information about creating these sheets at: https://github.com/pupil-labs/pupil-helpers/tree/master/markers_stickersheet

pfaion commented 4 years ago

@C-monC I guess for a test you could try feeding in the marker sheet image I linked above. It should detect all markers on there.

C-monC commented 4 years ago

Thanks for the help. Changing it to 300x300 images makes it work on just the marker image.

Sorry to bother again but still using the code above I am unable to detect 'tagStandard41h12' in the following image. Do you have any ideas of what the reason could be?

image

pfaion commented 4 years ago

@C-monC probably yes: the markers normally need an area of 1 marker-block white around them for being detectable well. So referring to your image, the marker consists of 9x9 blocks, you should include another white boundary around it with 1 block width. Can you check if that solves the problem?

C-monC commented 4 years ago

I've edited the texture map but still no detection. I'm pretty sure the dictionaries match because I used the create apriltag java script from the official apriltag github page. Are you able to detect the tag on your side?

Thanks so much for your time.

image

C-monC commented 4 years ago

I've tried using the tag36h11 in the link you sent and it still does not detect. Thought this could potentially be due to aliasing from the simulation camera so I tried blurring the image slightly and no improvement.

here's a test with the same marker and same script that overlays the marker ID.

Marker 0 detected image

Marker 0 not detected image

pfaion commented 4 years ago

@C-monC the problem is that the second image is horizontally mirrored. The markers are not identical to their mirror image. This particular one is not a valid tag36h11 marker. I flipped the image horizontally and it gets detected fine.

C-monC commented 4 years ago

Thank you! It works here too now.