Giter Club home page Giter Club logo

apriltags's Introduction

image

image

tests

Code style: Black

image

image

pupil-apriltags: Python bindings for the apriltags3 library

These are Python bindings for the Apriltags3 library developed by AprilRobotics, specifically adjusted to work with the pupil-labs software. The original bindings were provided by duckietown and were inspired by the Apriltags2 bindings by Matt Zucker.

Install from PyPI

This is the recommended and easiest way to install pupil-apriltags.

pip install pupil-apriltags

We offer pre-built binary wheels for common operating systems. To install from source, see below.

Usage

Some examples of usage can be seen in the src/pupil_apriltags/bindings.py file.

The Detector class is a wrapper around the Apriltags functionality. You can initialize it as following:

from pupil_apriltags import Detector

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

at_detector.detect(img)

See the API reference documentation for details.

Manual installation from source

You can of course clone the repository and build from there. For development you should install the development requirements as well. This project uses the new python build system configuration from PEP 517 and PEP 518.

# clone the repository
git clone --recursive https://github.com/pupil-labs/apriltags.git
cd apriltags

# install apriltags in editable mode with development requirements
pip install -e .[testing]

# run tests
pytest tests/

apriltags's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

apriltags's Issues

python3.8 and python3.9 could not install.

I can pip install it with python3.6 and python3.7,but when i install it with python3.8 or python3.9,it raise an error:

Building wheels for collected packages: pupil-apriltags
  Building wheel for pupil-apriltags (PEP 517) ... error
  ERROR: Command errored out with exit status 1:
   command: 'D:\anaconda\anaconda3\python.exe' 'C:\Users\Administrator\AppData\Roaming\Python\Python38\site-packages\pip\_vendor\pep517\in_process\_in_process.py' build_wheel 'C:\Users\ADMINI~1\AppData\Local\Temp\tmpshyhbug5'
       cwd: C:\Users\Administrator\AppData\Local\Temp\pip-install-imqsq2x3\pupil-apriltags_ad894239cae3485ba82be9b8cb1a0d27
  Complete output (46 lines):
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 15 2017

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/Administrator/AppData/Local/Temp/pip-install-imqsq2x3/pupil-apriltags_ad894239cae3485ba82be9b8cb1a0d27/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".


  --------------------------------------------------------------------------------
  -- Trying "Visual Studio 15 2017 x64 v141" generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying "Visual Studio 15 2017 x64 v141" generator - failure
  --------------------------------------------------------------------------------

  ********************************************************************************
  scikit-build could not get a working generator for your system. Aborting build.

  Building windows wheels for Python 3.8 requires Microsoft Visual Studio 2019.
  Get it with "Visual Studio 2017":

    https://visualstudio.microsoft.com/vs/

  Or with "Visual Studio 2019":

    https://visualstudio.microsoft.com/vs/

  ********************************************************************************
  ----------------------------------------
  ERROR: Failed building wheel for pupil-apriltags

What should i do? thanks.

tagStandard41h12 Segmentation fault (core dumped)

Detecting tagStandard41h12
AprilTag library compiled from source

at_detector = Detector(searchpath=['/usr/local/lib'],
                       families='tagStandard41h12',
                       nthreads=1,
                       quad_decimate=1.0,
                       quad_sigma=0.0,
                       refine_edges=1,
                       decode_sharpening=0.25,
                       debug=0)

Output

[]
Segmentation fault (core dumped)

When change nthreads=1 to nthreads=2

at_detector = Detector(searchpath=['/usr/local/lib'],
                       families='tagStandard41h12',
                       nthreads=2,
                       quad_decimate=1.0,
                       quad_sigma=0.0,
                       refine_edges=1,
                       decode_sharpening=0.25,
                       debug=0)

Output

[]

My image
IMG_6263

How is the coordinate system in pose estimation defined?

I recently used apriltag for object positioning and coordinate system transformation,but when I convert the coordinates, I have doubts. I don't know whether the given rotation matrix is ​​the Apriltag relative to the camera or the camera relative to the Apriltag.

Build Error

I'm trying to install pupil-apriltags on a jetson nano running python 3.8 right now. When I run pip3 install pupil-apriltags, I get an error that I don't quite understand. I don't see any explicit failures besides the failed to build wheel at the end. Is it a problem with my cmake? Or maybe python version?

Collecting pupil-apriltags
  Using cached pupil_apriltags-1.0.4.post10.tar.gz (1.9 MB)
  Installing build dependencies ... done
  Getting requirements to build wheel ... done
    Preparing wheel metadata ... done
Requirement already satisfied: numpy in ./.local/lib/python3.8/site-packages (from pupil-apriltags) (1.24.3)
Building wheels for collected packages: pupil-apriltags
  Building wheel for pupil-apriltags (PEP 517) ... error
  ERROR: Command errored out with exit status -4:
   command: /usr/bin/python3 /tmp/tmp99vlyvjx build_wheel /tmp/tmpqzcikilb
       cwd: /tmp/pip-install-crtkebfk/pupil-apriltags
  Complete output (37 lines):
  
  
  --------------------------------------------------------------------------------
  -- Trying 'Ninja' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  Not searching for unused variables given on the command line.
  -- The C compiler identification is GNU 8.4.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- The CXX compiler identification is GNU 8.4.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done (1.1s)
  -- Generating done (0.0s)
  -- Build files have been written to: /tmp/pip-install-crtkebfk/pupil-apriltags/_cmake_test_compile/build
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja' generator - success
  --------------------------------------------------------------------------------
  
  ----------------------------------------
  ERROR: Failed building wheel for pupil-apriltags
Failed to build pupil-apriltags
ERROR: Could not build wheels for pupil-apriltags which use PEP 517 and cannot be installed directly

More than one new minima found

Hello everyone,

I'm currently facing a problem with the detection of the tag ; the tag seems to be correctly detected but the message '2/2 cameras detected the tagError, more than one new minima found.' appears in the terminal, leading to a wrong reconstruction afterward. Here is an example where the detection of the tag works but with this error of more than one new minima found.

image

It is not the first time that I noticed this error but I wouldn't be able to say exactly in which case it appears.
Do you have any idea on how this issue could be solved ?

Thank you !

Segmentation Fault

I receive a segmentation fault when using this library on a Raspberry Pi 4 and python 3.7. When the entire script exits a seg fault pops up. I've attached the following gdb excerpt:

[Thread 0x9e2fc460 (LWP 4283) exited]
[Thread 0x9f2fd460 (LWP 4282) exited]
[Thread 0xa02fe460 (LWP 4281) exited]
[Thread 0xa12ff460 (LWP 4280) exited]
Thread 1 "python" received signal SIGSEGV, Segmentation fault.
0xaaa33ae8 in quick_decode_uninit ()
   from /home/pi/.local/lib/python3.7/site-packages/pupil_apriltags/lib/libapriltag.so.3
(gdb) backtrace
#0  0xaaa33ae8 in quick_decode_uninit ()
    at /home/pi/.local/lib/python3.7/site-packages/pupil_apriltags/lib/libapriltag.so.3
#1  0xaaa34010 in apriltag_detector_clear_families ()
    at /home/pi/.local/lib/python3.7/site-packages/pupil_apriltags/lib/libapriltag.so.3
(gdb) 

The library works fine on windows with the same code, any ideas what would be causing this on a Pi 4?

poseR* is invalid syntax in python

The documentation states poseR* is the rotation attribute, however this results in a python syntax error. What would be the proper way to grab rotation?

Very basic example - no detections

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

DLL loading process not locating pthreads

Hi,

I'm on Windows 11 10.0.22621 with Python 3.9.13 and using pupil-apriltags 1.0.4.post8, installed with pip in an anaconda environment.

When instantiating the detector, I get:
FileNotFoundError: Could not find module 'C:\Python39\lib\site-packages\pupil_apriltags\lib\apriltag.dll' (or one of its dependencies). Try using the full path with constructor syntax.

On my system, the problem seems to be with the pthreadVC2.dll:

$ ldd lib/apriltag.dll
        ntdll.dll => /c/WINDOWS/SYSTEM32/ntdll.dll (0x7fff79c30000)
        KERNEL32.DLL => /c/WINDOWS/System32/KERNEL32.DLL (0x7fff78280000)
        KERNELBASE.dll => /c/WINDOWS/System32/KERNELBASE.dll (0x7fff77090000)
        msvcrt.dll => /c/WINDOWS/System32/msvcrt.dll (0x7fff78d30000)
        apriltag.dll => /c/Users/myuser/anaconda3/envs/cv/Lib/site-packages/pupil_apriltags/lib/apriltag.dll (0x7ffee6f20000)
        ucrtbase.dll => /c/Windows/System32/ucrtbase.dll (0x7fff778a0000)
        vcruntime140.dll => /c/Windows/System32/vcruntime140.dll (0x7fff621a0000)
        winmm.dll => /c/Windows/System32/winmm.dll (0x7fff72890000)
        pthreadVC2.dll => not found

I installed the pupil-pthreads-win package first, and that didn't solve the problem. I then removed the check for < v3.8 at L315.

After this change the library works. I have no experience w/ how this process is supposed to work on Windows, but maybe this will help identify a problem?

ModuleNotFoundError: No module named 'skbuild'

Collecting git+https://github.com/pupil-labs/apriltags
  Cloning https://github.com/pupil-labs/apriltags to /tmp/pip-rw9h_3fg-build
    Complete output from command python setup.py egg_info:
    Traceback (most recent call last):
      File "<string>", line 1, in <module>
      File "/tmp/pip-rw9h_3fg-build/setup.py", line 11, in <module>
        from skbuild import setup
    ModuleNotFoundError: No module named 'skbuild'

Installation via pip fails for older versions pip that do not parse the build dependencies correctly.
We should check the pip version in setup.py and throw an error with a message on how to update pip for older versions of pip!

Getting around using Visual Studio to Setup Apriltags

Hi,

trying to use Apriltags on Windows. Some circumstances prevent me from using Visual Studio.
In the setup.py it is mentioned that the msvc must be used for compatibility.
Is there a way to use the compiler without Visual Studio?
How would i need to change the setup.py file to do so?

Greetings

Questions about tag position

pose_t = [[-0.16225682]
[-0.20048863]
[ 1.01195728]]

for simplicity
x = -0.16225682
y = -0.20048863
z = 1.01195728

  1. what units? Look like meters
  2. x - is it left\right
    y - is it up\down
    z - is it distance or forward\backward
  3. Is it relative to the center of the image or relative to the optical center (cx,cy from camera_params)?

'corrupted size vs. prev_size' error message

Hi, thanks for your contribution on this apriltag package.
But from time to time, I see the corrupted size vs. prev_size error message in the program. It is related to detector.detect(). Is there any suggestions on how to fix it?

Getting requirements to build wheel ... error

How to solve this issue ??

Getting requirements to build wheel ... error
 ERROR: Command errored out with exit status 1:
   command: /home/robot2/.virtualenvs/cv/bin/python3 /home/robot2/.virtualenvs/cv/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp1a45ur0g
       cwd: /home/robot2/apriltags
  Complete output (17 lines):
  Traceback (most recent call last):
    File "/home/robot2/.virtualenvs/cv/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py", line 207, in <module>
      main()
    File "/home/robot2/.virtualenvs/cv/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py", line 197, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/home/robot2/.virtualenvs/cv/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py", line 54, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/tmp/pip-build-env-p8zgca3k/overlay/lib/python3.5/site-packages/setuptools/build_meta.py", line 146, in get_requires_for_build_wheel
      return self._get_build_requires(config_settings, requirements=['wheel'])
    File "/tmp/pip-build-env-p8zgca3k/overlay/lib/python3.5/site-packages/setuptools/build_meta.py", line 127, in _get_build_requires
      self.run_setup()
    File "/tmp/pip-build-env-p8zgca3k/overlay/lib/python3.5/site-packages/setuptools/build_meta.py", line 142, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 18
      cmake_args.append(f"-DPTHREADS_WIN_INCLUDE_DIR='{ptw.include_path}'")
                                                                         ^
  SyntaxError: invalid syntax
  ----------------------------------------
ERROR: Command errored out with exit status 1: /home/robot2/.virtualenvs/cv/bin/python3 /home/robot2/.virtualenvs/cv/lib/python3.5/site-packages/pip/_vendor/pep517/_in_process.py get_requires_for_build_wheel /tmp/tmp1a45ur0g Check the logs for full command output.

windows env error, self.tag_detector_ptr = self.libc.apriltag_detector_create()

python version: 3.9.16/3.7.16
sys: widows11

I've view all the others' issue, unlucky none fix my problem.

firstly, as common install

pip install pupil-apriltags

then just write the simple test code like:

import pupil_apriltags as apriltag
detector = apriltag.Detector()

this get the error msg: Could not find module

  • FileNotFoundError: Could not find module 'C:\Users\yuanpei.lin\AppData\Roaming\Python\Python39\site-packages\pupil_apriltags\lib\apriltag.dll' (or one of its dependencies). Try using the full path with constructor syntax.

after searched and viewed for a long time, I change line:337 in bindings.py to

self.libc = ctypes.CDLL(str(hit), winmode=1)

winmode=0 doesn't work for me, nothing changes still Could not find module,
and I found a similar problem menthioned in stackoverflow with win11 so I changed to winmode=1

but then get error msg like this:

  • File "C:\Users***\AppData\Roaming\Python\Python39\site-packages\pupil_apriltags\bindings.py", line 351, in init
    self.tag_detector_ptr = self.libc.apriltag_detector_create()
    OSError: exception: access violation writing 0x00000000006338BE

BTW:
I've tried python3.7, it seems work for most others but not me, i got the error msg in python3.7 like:

  • OSError: [WinError 193] %1 is not valid Win32 application.
    Exception ignored in: <function Detector.del at 0x000001A604BDF048>
    Traceback (most recent call last):
    File "D:\apps\miniconda3\envs\python37\lib\site-packages\pupil_apriltags\bindings.py", line 420, in del
    if self.tag_detector_ptr is not None:
    AttributeError: 'Detector' object has no attribute 'tag_detector_ptr'

It seems like a x86 error, after that I install python=3.7 with 32bit, sadly none of it works :(

now I'm really confused! So anyone can help?

'Detector' object has no attribute 'tag_detector_ptr' or ValueError: the environment variable is longer than 32767 characters

Error

Traceback (most recent call last):
  File "apriltags.py", line 75, in <module>
    debug=0)
  File "C:\Users\main\AppData\Local\Programs\Python\Python37\lib\site-packages\pupil_apriltags\bindings.py", line 273, in __init__
    os.environ["PATH"] = dll_path + os.pathsep + os.environ["PATH"]
  File "C:\Users\main\AppData\Local\Programs\Python\Python37\lib\os.py", line 687, in __setitem__
    self.putenv(key, value)
ValueError: the environment variable is longer than 32767 characters
Exception ignored in: <function Detector.__del__ at 0x000001CE22927798>
Traceback (most recent call last):
  File "C:\Users\main\AppData\Local\Programs\Python\Python37\lib\site-packages\pupil_apriltags\bindings.py", line 368, in __del__
    if self.tag_detector_ptr is not None:
AttributeError: 'Detector' object has no attribute 'tag_detector_ptr'

The decoded Tag_id is always the same given different patterns

Hi, I am having a question regarding the tag_id. I am trying to use the AprilTagDetector.detect API to tell me which tag it is. I assume the tag_id could be the indicator. However, no matter which pattern of the tag I used, the tag_id is always the same.

Would you please let me know how to resolve this problem? Thanks!

FileNotFoundError: [WinError 206] The filename or extension is too long in pupil_apriltags

A program has been written to check a series of tags during an approximately 2-3 minute video and we check these tags using the pupil_apritag library. A detailed and quick check is done, but the problem is in doing it in the long term. I didn't use the library to save, I just save a bunch of numbers, but this library gives an error like this:


Traceback (most recent call last):
File "g:\Code_HIT_A_V3.py", line 66, in
sign = function_V3.detect_sign_apriltag(image[100:400, 280:512])
File "g:\function_V3.py", line 109, in detect_sign_apriltag
detector = Detector(
File "C:\Users\Sina\AppData\Local\Programs\Python\Python310\lib\site-packages\pupil_apriltags\bindings.py", line 336, in init
dll_dir = os.add_dll_directory(dll_path)
File "C:\Users\Sina\AppData\Local\Programs\Python\Python310\lib\os.py", line 1117, in add_dll_directory
cookie = nt._add_dll_directory(path)
FileNotFoundError: [WinError 206] The filename or extension is too long: 'C:\Users\Sina\AppData\Local\Programs\Python\Python310\Lib\site-packages\pupil_apriltags\lib'

The program runs for about 1 minute and 30 seconds and suddenly crashes. I will also give you a part of the code on the library side that gets an error:

def add_dll_directory(path):
    """Add a path to the DLL search path.

    This search path is used when resolving dependencies for imported
    extension modules (the module itself is resolved through sys.path),
    and also by ctypes.

    Remove the directory by calling close() on the returned object or
    using it in a with statement.
    """
    import nt
    cookie = nt._add_dll_directory(path)
    return _AddedDllDirectory(
        path,
        cookie,
        nt._remove_dll_directory
    )

This is my function:

from pupil_apriltags import Detector

def detect_sign_apriltag(image):
    types = ['nothing', 'straight', 'right', 'left' ]
    gray = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
    detector = Detector(
            families='tag36h11',
            nthreads=1,
            quad_decimate=1.0,
            quad_sigma=0.0,
            refine_edges=1,
            decode_sharpening=0.25
            )
    tags = detector.detect(gray)
    id = 0
    for tag in tags:
        id = tag.tag_id
        print(f"Tag ID: {tag.tag_id} => {types[id]}")
        # print("Tag center: {}".format(tag.center))
        # print("Tag corners: {}".format(tag.corners))
        # print('tag family: {}'.format(tag.tag_family))

    if id == 0:
        return types[id]
    else:
        return types[id]

I use python 3.10.7 and last version of pip
I found almost no explanation or guidance on the internet about this.

Apriltag not detected in clear image captured by acr010 webcam

Hi, I am using the pupil-apriltag to do some detection. It works well on my built-in camera on my Mac. However, when I try with my usb acr010 webcam, it doesn't work. I have calibrated my webcam and the frame shows on the windows. The frame rate is about 12, however, it doesn't detect apriltag at all.

Here below is my code that running a webcam to detect the Apriltags continuously and a simple test for one of the image that captured by my webcam.

import os
import time

import cv2
import numpy as np
from pupil_apriltags import Detector

# Camera information, NOT CONFIGURED
# FPS = 50
RES = (1920, 1080)
camera_info = {}

# Camera Resolution
camera_info["res"] = RES

# Camera Intrinsic Matrix (3x3)
camera_info["K"] = np.array([[1129.106419355741, 0.0, 958.2530752561653],
                            [0.0, 1126.3550177287352, 546.954031682053],
                            [0.0, 0.0, 1.0]])
# Fisheye Camera Distortion Matrix
camera_info["D"] = np.array([[-0.09285509543388772],
                             [0.08508622717322474],
                             [-0.148664219994183],
                             [0.10812148818670442]])
# The non-default elements of the K array, in the AprilTag specification
camera_info["params"] = [1129.106, 1126.355, 958.253, 546.954]

# Fisheye flag
camera_info["fisheye"] = True
camera_info["map_1"], camera_info["map_2"] = cv2.fisheye.initUndistortRectifyMap(camera_info["K"], camera_info["D"],
                                                                                 np.eye(3), camera_info["K"],
                                                                                 camera_info["res"], cv2.CV_16SC2)

# Tag information
TAG_SIZE = .123
FAMILIES = 'tag36h11'


def main():
    print('\033]0;Video Base\007')

    # Initialize the camera capture
    camera = cv2.VideoCapture(0)
    camera.set(3, RES[0])  # Set horizontal resolution
    camera.set(4, RES[1])  # Set vertical resolution

    # Configure the AprilTags detector
    detector = Detector(families=FAMILIES, nthreads=4)

    # Initialize variables for calculating frame rate
    start_time = time.time()
    frame_count = 0

    while True:
        # Capture frame from the camera
        ret, frame = camera.read()

        # Undistort the frame
        # frame = cv2.remap(frame, camera_info["map_1"], camera_info["map_2"], interpolation=cv2.INTER_LINEAR,
        #                   borderMode=cv2.BORDER_CONSTANT)

        # Convert the frame to grayscale
        gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

        # Detect AprilTags in the grayscale image
        results = detector.detect(gray, estimate_tag_pose=True, camera_params=camera_info["params"], tag_size=TAG_SIZE)
        detected_tags = [tag.tag_id for tag in results]

        # Draw bounding boxes and IDs on the frame
        for tag in results:
            # Add bounding rectangle
            cv2.polylines(frame, [np.int32(tag.corners)], True, (0, 255, 0), thickness=2)
            # Add Tag ID text
            cv2.putText(frame, str(tag.tag_id),
                        org=(tag.corners[0, 0].astype(int) + 10, tag.corners[0, 1].astype(int) + 10),
                        fontFace=cv2.FONT_HERSHEY_SIMPLEX,
                        fontScale=0.8,
                        color=(0, 0, 255),
                        thickness=3)
            cv2.circle(frame, tuple(tag.corners[0].astype(int)), 2, color=(255, 0, 255), thickness=2)

            # Display rotation and translation
            cv2.putText(frame, f"Rot: {tag.pose_R}",
                        (tag.corners[0][0].astype(int), tag.corners[0][1].astype(int) - 30),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)
            cv2.putText(frame, f"Trans: {tag.pose_t}",
                        (tag.corners[0][0].astype(int), tag.corners[0][1].astype(int) - 60),
                        cv2.FONT_HERSHEY_SIMPLEX, 0.7, (0, 0, 255), 2)

        # Calculate frame rate
        frame_count += 1
        elapsed_time = time.time() - start_time
        fps = frame_count / elapsed_time

        # Display the frame rate on the frame
        cv2.putText(frame, f"FPS: {fps:.2f}", (10, 30), cv2.FONT_HERSHEY_SIMPLEX, 1, (0, 0, 255), 2)

        # Display the frame
        cv2.imshow('AprilTags Detection', frame)

        # Prepare the message
        message = {
            "badge_id": "B",  # Replace with a unique ID for each badge
            "detected_tags": detected_tags
        }

        if len(results) != 0:
            print(message)

        # Exit program when 'q' is pressed
        if cv2.waitKey(1) & 0xFF == ord('q'):
            break

    # Release the camera and close windows
    camera.release()
    cv2.destroyAllWindows()


if __name__ == '__main__':
    main()

The test image and the corresponding test code,
test

import pupil_apriltags as apriltag
import cv2

img = cv2.imread("test.jpg")
gray = cv2.cvtColor(img, cv2.COLOR_BGR2GRAY)
print("[INFO] detecting AprilTags...")
detector = apriltag.Detector(families="tag36h11")
results = detector.detect(gray)
print("[INFO] {} total AprilTags detected".format(len(results)))

for tag in results:
    cv2.circle(img, tuple(tag.corners[0].astype(int)), 4,(255,0,0), 2) # left-top
    cv2.circle(img, tuple(tag.corners[1].astype(int)), 4,(255,0,0), 2) # right-top
    cv2.circle(img, tuple(tag.corners[2].astype(int)), 4,(255,0,0), 2) # right-bottom
    cv2.circle(img, tuple(tag.corners[3].astype(int)), 4,(255,0,0), 2) # left-bottom

cv2.imshow("apriltag_test",img)
cv2.waitKey()

Python pupil_Apriltags : Problem with DLL path “Could not find module”

Hello I have a problem with pupil_apriltags in python.
I have been searching for more than 1 week and tried multiple solutions but none of them worked.

My problem is not with the import of the librairy but when I try to create the detector. There is a reference to a xxxx.dll file (I think) which does not work.

My code

Very simple

from pupil_apriltags import Detector
import cv2
import numpy as np


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

My error

Traceback (most recent call last):                                                                                  
File "detection_apriltags.py", line 6, in <module>                                                                        
at_detector = Detector()                                                                                              
File "C:\Users\Utilisateur\anaconda3\lib\site-packages\pupil_apriltags\bindings.py", line 285, in __init__
self.libc = ctypes.CDLL(str(hit))                                                                                     
File "C:\Users\Utilisateur\anaconda3\lib\ctypes\__init__.py", line 381, in __init__                                       
self._handle = _dlopen(self._name, mode)                                                                            
FileNotFoundError: Could not find module 'C:\Users\Utilisateur\anaconda3\lib\site-
packages\pupil_apriltags\lib\apriltag.dll' (or one of its dependencies). Try using the full path 
with constructor syntax.

My configuration

  • Python 3.8.5
  • Windows 10

Custom AprilTag Support?

Is it possible to build this library so that it detects custom generated AprilTags?
APRIL Robotics provides tools to generate custom AprilTag families in the apriltag-generation repo. I've generated my own tag families and successfully built their library to support these custom families. The Python bindings work with them as well.

Failed building wheel for pupil-apriltags

Hello there,

It seems like this repo is able to support apriltags on windows, however, I faced some difficulties when installing it on VS code (windows 10).

It seems like it's stuck at the building wheel step.

I am using the pip install pupil-apriltags method, with the latest python 3.9.6 and pip 21.2.3.

Details:

Building wheel for pupil-apriltags (PEP 517) ... error

  Complete output (46 lines):
  Not searching for unused variables given on the command line.
  CMake Error at CMakeLists.txt:2 (PROJECT):
    Generator

      Visual Studio 15 2017

    could not find any instance of Visual Studio.



  -- Configuring incomplete, errors occurred!
  See also "C:/Users/user/AppData/Local/Temp/pip-req-build-9qtru2dv/_cmake_test_compile/build/CMakeFiles/CMakeOutput.log".       

  -- Trying "Visual Studio 15 2017 x64 v141" generator - failure

  scikit-build could not get a working generator for your system. Aborting build.

  Building windows wheels for Python 3.9 requires Microsoft Visual Studio 2019.
  Get it with "Visual Studio 2017":

    https://visualstudio.microsoft.com/vs/

  Or with "Visual Studio 2019":

    https://visualstudio.microsoft.com/vs/

  ERROR: Failed building wheel for pupil-apriltags
Failed to build pupil-apriltags
ERROR: Could not build wheels for pupil-apriltags which use PEP 517 and cannot be installed directly

Any help provided would be greatly appreciated!

segfault on closing

Occasionally the detector produces a segfault in line 398 in bindings.py - specifically self.libc.apriltag_detector_destroy(self.tag_detector_ptr) causes the segfault
I am using python 3.8 on Ubuntu 20.04 in a WSL box - but this happens on native ubuntu installations as well.

I am running this with 48 threads in the detector.

After running it through the debugger, this turns out to be the same issue as #34:

Thread 1 "python3" received signal SIGSEGV, Segmentation fault.
0x00007fff94fe8306 in quick_decode_uninit () from /usr/local/lib/python3.8/dist-packages/pupil_apriltags/lib/libapriltag.so.3.1.0

circular tags detection error

This doesn't seem to detect circular apriltags:

import cv2
from pupil_apriltags import Detector
import numpy as np

im = cv2.imread("pics/tag21_07_00020.png", cv2.IMREAD_UNCHANGED)
d = Detector(families='tagCircle21h7',
        nthreads=1,
        quad_decimate=1.0,
        quad_sigma=0.0,
        refine_edges=1,
        decode_sharpening=0.25,
        debug=1)

tags = d.detect(im, estimate_tag_pose=False, camera_params=None, tag_size=None)
print(f"{len(tags)} tags found") 

---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-9-86793bd9058c> in <module>
----> 1 tags = d.detect(im, estimate_tag_pose=False, camera_params=None, tag_size=None)
      2 print(f"{len(tags)} tags found")

~/venv/lib/python3.8/site-packages/pupil_apriltags/bindings.py in detect(self, img, estimate_tag_pose, camera_params, tag_size)
    403 image of type numpy.uint8."""
    404 
--> 405         assert len(img.shape) == 2
    406         assert img.dtype == numpy.uint8
    407 

AssertionError: 

Here is the tag:

tag21_07_00020

What am I doing wrong?

Is the order of the corner detection consistent?

I see in the docs it says that the corners are always returned counter-clockwise around the tag.
Is the starting corner always the same corner? Would like to know this so I can detect what angle the tag is at (from a mostly overhead camera).

Segfault via Python

This happens in the pip version and when built locally. I am running Ubuntu 22.04 Python 3.10

The Detector class randomly segfaults (interrupted by signal 11: SIGSEGV).
This is a problem in python because I cant catch it

max_hamming setting is not found

I have created a docker container and wanted to create an apriltag detector of family "tagstandard52h13" and I faced this error:

>>>from pupil_apriltags import Detector
>>> at_detector = Detector(families="tagStandard52h13")
apriltag.c: failed to allocate hamming decode table. Reduce max hamming size.

But I could not find the max_hamming setting on the detector to fix this.

Missing CHANGELOG.md during pypi install

Running pip install pupil-apriltags results in

  Traceback (most recent call last):
    File "/Users/papr/.pyenv/versions/3.8.2/envs/pupil/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 257, in <module>
      main()
    File "/Users/papr/.pyenv/versions/3.8.2/envs/pupil/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 240, in main
      json_out['return_val'] = hook(**hook_input['kwargs'])
    File "/Users/papr/.pyenv/versions/3.8.2/envs/pupil/lib/python3.8/site-packages/pip/_vendor/pep517/_in_process.py", line 91, in get_requires_for_build_wheel
      return hook(config_settings)
    File "/private/var/folders/_r/h72rpp_s1rgdv4xkw8pzm82m0000gp/T/pip-build-env-yamehfsm/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 147, in get_requires_for_build_wheel
      return self._get_build_requires(
    File "/private/var/folders/_r/h72rpp_s1rgdv4xkw8pzm82m0000gp/T/pip-build-env-yamehfsm/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 128, in _get_build_requires
      self.run_setup()
    File "/private/var/folders/_r/h72rpp_s1rgdv4xkw8pzm82m0000gp/T/pip-build-env-yamehfsm/overlay/lib/python3.8/site-packages/setuptools/build_meta.py", line 143, in run_setup
      exec(compile(code, __file__, 'exec'), locals())
    File "setup.py", line 27, in <module>
      with open("CHANGELOG.md") as f:
  FileNotFoundError: [Errno 2] No such file or directory: 'CHANGELOG.md'

Looks like the CHANGELOG.md is missing in the MANIFEST.in.

Trouble installing pupil-apriltags on Ubuntu 18.04 using poetry

Hi,

tried to install pupil-apriltags using poetry using

poetry add pupil-apriltags

But it complains with regards to the package pupil-pthreads-win:

poetry add pupil-apriltags
Using version ^1.0.4 for pupil-apriltags

Updating dependencies
Resolving dependencies... (0.1s)

Writing lock file

Package operations: 2 installs, 0 updates, 0 removals

  • Installing pupil-pthreads-win (2): Failed

  AttributeError

  'NoneType' object has no attribute 'replace'

  at ~/.poetry/lib/poetry/installation/chooser.py:27 in __init__
       23│             raise InvalidWheelName("{} is not a valid wheel filename.".format(filename))
       24│ 
       25│         self.filename = filename
       26│         self.name = wheel_info.group("name").replace("_", "-")
    →  27│         self.version = wheel_info.group("ver").replace("_", "-")
       28│         self.build_tag = wheel_info.group("build")
       29│         self.pyversions = wheel_info.group("pyver").split(".")
       30│         self.abis = wheel_info.group("abi").split(".")
       31│         self.plats = wheel_info.group("plat").split(".")


Failed to add packages, reverting the pyproject.toml file to its original content.

pip install pupil-apriltags works.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.