Giter Club home page Giter Club logo

simple-ar's Introduction

Simple-AR

screen capture

Description / Rationale

Simple AR is a web-based image tracking library (platform) based on WebAssembly. Unlike other web-based AR libraries it:

  • allows loading image targets without training;
  • recognizes partially visible targets;
  • can recognize target at a greater distance.

Instructions

In order to use it, attach "simple-ar" to a-entity. The library (platform) has the following attributes (new attributes will be added in the process of development):

  • src: { type: "string" } - The URL or source of image target. Can be .jpg or .png file.
  • minCutOffValue: { type: "float", default: 0.01 } - One Euro Filter related parameter for smoothing the tracking.
  • betaValue: { type: "float", default: 0.1 } - One Euro Filter related parameter for smoothing the tracking.
  • dCutOffValue: { type: "float", default: 0.001 }- One Euro Filter related parameter for smoothing the tracking.

The code below shows the sample implementation:

<!DOCTYPE html>
<html>
  <head>
    <title>Simple AR - A Web based AR for A-Frame</title>
    <script src="https://aframe.io/releases/1.4.2/aframe.min.js"></script>
  </head>
  <body>
    <script
      src="https://cdn.jsdelivr.net/gh/akbartus/Simple-AR/dist/0.1.2/simple-ar.min.js"
      onload="onWasmLoaded();"
    ></script>
    <a-scene>
      <a-entity simple-ar="src: img/target.jpg; minCutOffValue: 1; betaValue:0.1;">
        <a-plane
          position="0 0 0"
          rotation="0 0 0"
          width="1"
          height="1"
          material="src: https://upload.wikimedia.org/wikipedia/en/a/a9/Example.jpg"
        ></a-plane>
      </a-entity>
      <a-camera position="0 0 0"></a-camera>
    </a-scene>
  </body>
</html>

Please note: Current version only supports single image tracking. Sample target, used in this example can be found here. In order to improve smoothness of tracking to the desired level, play with One Euro filter values.

Events Handling

The library has the following events:

  • targetFound: Triggered when the target image is found by Simple AR.
document.addEventListener("targetFound", function (event) {
    console.log("Target found!");
});
  • targetLost: Triggered when the target image is lost by Simple AR.
document.addEventListener("targetLost", function (event) {
    console.log("Target lost!");
});
  • onVideoStarted: Triggered when webcamera video is started.
document.addEventListener("onVideoStarted", () => {
    console.log("video started!");
});
  • arPause: A toggle, which lets pause tracking system or unpause.
const pauseButton = document.createElement("button");
pauseButton.setAttribute("style", "position: absolute; left:10px; top:10px; z-index:3");
pauseButton.textContent = "Pause";
pauseButton.addEventListener("click", arPause); // call here
document.body.appendChild(pauseButton);
  • onDistance: Show distance between camera and image target.
document.addEventListener("onDistance", (event) => {
 const distance = event.detail;
 console.log("Distance:", distance);
});

Version

Most current version is 0.1.2.

Updates / Bug Fixes

Please note that the work on this library (platform) is in progress. Future updates:

  • Adding "onDistance" event, which will let measuring distance between camera and AR target and trigger interactive events.
  • Fixing rotation bug.
  • Fixing positioning bug.
  • Fixing centering issue.
  • Full Babylon.js example created.
  • Full Three.js example created.
  • Adding runtime target image loading feature.
  • Adding a computer vision example for reading/segmenting texture of image target on a screen.
  • Adding interactive examples.
  • Adding Unity support (Unity WebGL exporter)

Tech Stack

The library(platform) is powered by AFrame, Three.js and WebAssembly (Emscripten). One Euro Filter was taken/adapted from the following sources ( https://github.com/hiukim/mind-ar-js/blob/master/src/libs/one-euro-filter.js, https://jaantollander.com/post/noise-filtering-using-one-euro-filter/#mjx-eqn%3A1). The library(platform) is compatible with latest version of A-Frame (1.4.2). Tests with older versions of A-Frame were not perfomed yet.

Example implementation of Simple AR is also given for Three.js and Babylon.js (see "other_frameworks" folder).

Demo

See A-Frame demo here: Demo

See ThreeJs demo here: Demo

See BabylonJs demo here: Demo

See a computer vision example for reading/segmenting texture of image target on a screen here: Demo. Get image target here. For further guidance refer to this repository.

simple-ar's People

Contributors

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

Watchers

 avatar  avatar  avatar  avatar

simple-ar's Issues

browser compatibility and multiple image trackes

Hi! Thanks for this amazing library!

I was wondering if you've tried it on Apple WebKit and how the performance compares to Chrome?

Also when you mention it currently supports a single image, does it mean it can only track one image at a time? Or do you mean it can only detect one image at each frame? I was wondering if I could provide 20 images to it to detect as long as I want one image to be tracked?

Ideally I wanna see if I can integrate it in an Ionic Capacitor app.

Thanks a ton!

about WebAssembly code

Hi @akbartus nice app for WebAR! Just some simple questions: Do you use Opencv in your WASM code? or other library? Would you share also the source code if not a problem?

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.