GithubHelp home page GithubHelp logo

jp.keijiro.apriltag's Introduction

jp.keijiro.apriltag - AprilTag package for Unity

gif

jp.keijiro.apriltag is a Unity package providing a native code implementation of an AprilTag tracker.

AprilTag is a marker based tracking system developed by the APRIL Robotics Laboratory at the University of Michigan. Please see the AprilTag web page for further details.

System requirements

  • Unity 2021.3

At the moment, this package supports the following systems:

  • Windows (x86-64), macOS (x86-64), Linux (x86-64), iOS (arm64), Android (arm64)

How to install

This package is available in the Keijiro scoped registry.

  • Name: Keijiro
  • URL: https://registry.npmjs.com
  • Scope: jp.keijiro

Please follow this gist to add the registry to your project.

How to try the sample project

Clone this repository and play DetectionTest.unity on Unity Editor.

The current version of the TagDetector component only supports the tagStandard41h12 tag set. You can download those tag images from the apriltag-imgs repository. Print some of them using a printer, or use a smartphone screen to display the tags.

The DetectionTest component uses the Field of View value of the main camera to estimate tag positions. You can try the sample without adjusting it, but it may give incorrect depth information. To get accurate tag positions, you should match the FoV value with the actual camera FoV.

image

For example, I'm using Zoom Q2n-4K video camera for testing, which gives about 78 degrees horizontal FoV at the mid-angle mode. So I changed the FOV Axis to "Horizontal" and the Field of View value to 78.

How to detect tags

At first, create the AprilTag.TagDetector object specifying the input image dimensions. You can run the detector in a lower resolution by specifying a decimation factor. It may improve the speed at the cost of accuracy and detection rate.

detector = new AprilTag.TagDetector(imageWidth, imageHeight, decimation);

Call the ProcessImage method every frame to detect tags from an input image. You can use ReadonlySpan<Color32> to give an image. At the same time, you have to specify the camera FoV (horizontal) in degrees and the tag size in meters.

texture.GetPixels32(buffer);
detector.ProcessImage(buffer, fov, tagSize);

You can retrieve the detected tags from the DetectedTags property.

foreach (var tag in detector.DetectedTags)
    Debug.Log($"{tag.ID} {tag.Position} {tag.Rotation}");

Dispose the detector object when you no longer need it.

detector.Dispose();

For details, please check the DetectionTest.cs example.

Related repositories

jp.keijiro.apriltag's People

Contributors

keijiro avatar

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  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jp.keijiro.apriltag's Issues

Errors building IOS binaries

Screenshot 2022-11-01 at 6 54 48 PM

Screenshot 2022-11-01 at 6 54 55 PM

i couldn't raise a issue on the main repo so posting it here. I have made binaries for other platforms and those are working with unity but facing this problem while making for IOS, could you please help me with this or show some directions how i can solve that. Thank you in advance.

.NET 4.x Api Compatibility

Is it possible to implement .NET 4.x Api Compatibility.

Only .Net Standard 2.0 is working for now in unity 20202.2f1.

Spawn a GameObject

It would be so helpful now to have a sample scene where we can spawn a prefab into tag locations.
Thank you.

Help wanted for AR Foundation integration

I would like a to integrate this amazing tool into AR Foundation.
How can I use the AR camera stream to track the tags; being able to trace images in a unity scene instead of a webcam would probably also be a useful advance/hint,

thank you.

How I transfer the tag position to world coordinate?

Hi, I have a few questions about the tag position?
Why is the value of tag position always between 0 to 1, and how can I transfer the value to the unity world coordinate?
I have already tried the ViewportToWorldPoint script method, but the result was so weird.

No detection on Realsense D430 using black and white feed

Hi,
I am attempting to implement your system using a Realsense D430 Depth sensor in place of a webcam.

I'm successfully getting sensor data, feeding that into the test script, and parsing it as Color32[]. Im outputting it back to a render tex to debug that.

Using WebcamTest.cs as a guide, I'm following pretty much the same path as you, but I'm not getting any detection results (always zero). Ill attach a gif of the result, worth noting that I compressed the gif res and framerate to fit it here and its a bit slow now, apologies.

TagFail

Is it possible that the tag detection does not work on black and white?

My script Here

I appreciate any help or advice you can give,
Peter

UWP (Universal Windows Platform) support

I'd like to pass to UWP to run this project on windows HoloLens 2, but I can't figure out how to solve these errors:
error CS0246: The type or namespace name 'Span<>' could not be found (are you missing a using directive or an assembly reference?)

Can you help me?

Adding support for other tag families

Currently the plugin only supports the 41h12 family, however this is not always the best family for a task. Would it be possible to at least include 36h11 in the binaries?

For anyone else facing this issue, you can include any family by rebuilding the binaries from https://github.com/keijiro/apriltag after adjusting the common Makefile (build > Common.mk) to include the appropriate C file (eg.: tag36h11.c)

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.