Detect the center of a tag
Hello,
How would I go about getting the position of the center of a tag (QR Code, AprilTag...) using opencv ? I only find stuff about decoding the tag or the centroid of a shape. The idea is that i track this tag in a 2d plane, and with the center of the tag position, i get the x and y that I can then use as parameters on an electronics project.
Thanks for any input,
I honestly dont want to troll - maybe its so easy - assuming you do this on an image
1) get bounding box of the object(in your case the tag) as a rectangle
2)
centerX = x + w/2
centerY = y + h/2
i'v thought of this, just trasnform the tag into a shape, and get centroid of the shape, but if the image captured as another similar shape on it, it could give me bad info. I made a small matlab version of it using the shadow through semi transparent glass, basically i would binarize the image (pure black and white) and calculate the centroid of the shape. But just having an arm creating shadow would mess up with the xy position. Thats why I wanted to use a tag, so that only 1 thing gets recognized
@Pigeon unless I am not understanding your question, you probably just have to run a QR code detector first then find the center of the returned bounding box using @holger suggestion. No need to transform it into a shape and so forth. The correctness of the center coordinates will be heavily dependent of the results of the detector.
oh right, i'll give this a try, i had in my mind the shape centroid, but yeah no need to transform it, thx