MindAR

repository·master·Indexed 25 days ago

https://github.com/hiukim/mind-ar-js

A web-based augmented reality framework (version 1.2.5) written in pure JavaScript that supports image tracking and face tracking. It utilizes WebGL via TensorFlow.js and Web Workers for high performance in the browser. The library provides integrations for A-Frame and Three.js, and includes a Detector class for identifying feature points within images.

Tokens
1.7K
Snippets
5
Records
13
Agent score
83%

What's inside MindAR

  1. Develop the A-Frame version of MindAR

    master

    When developing the A-Frame version, you must run the build command every time you make changes, as the --watch parameter does not currently support automatically generating mindar-XXX-aframe.js files.

    npm run build-dev
  2. Compile Target Images for MindAR

    master

    To use custom images for tracking, you must first compile them into a .mind file. You can use the browser-based Target Images Compiler tool to upload your images and generate the necessary target data for MindAR.

    https://hiukim.github.io/mind-ar-js-doc/tools/compile
  3. Quick Start with MindAR and A-Frame

    master

    You can build a basic Image Tracking AR application using MindAR with the A-Frame extension. This requires three main scripts: the core MindAR image tracking library, the A-Frame library, and the MindAR A-Frame component. The setup involves defining an <a-scene> with the mindar-image component, specifying the imageTargetSrc (a compiled .mind file), and using <a-entity mindar-image-target> to anchor content to specific images.

    <html>
      <head>
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <script src="https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@1.1.4/dist/mindar-image.prod.js"></script>
        <script src="https://aframe.io/releases/1.2.0/aframe.min.js"></script>
        <script src="https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@1.1.4/dist/mindar-image-aframe.prod.js"></script>
      </head>
      <body>
        <a-scene mindar-image="imageTargetSrc: https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@1.1.4/examples/image-tracking/assets/card-example/card.mind;" color-space="sRGB" renderer="colorManagement: true, physicallyCorrectLights" vr-mode-ui="enabled: false" device-orientation-permission-ui="enabled: false">
          <a-assets>
            <img id="card" src="https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@1.1.4/examples/image-tracking/assets/card-example/card.png" />
            <a-asset-item id="avatarModel" src="https://cdn.jsdelivr.net/gh/hiukim/mind-ar-js@1.1.4/examples/image-tracking/assets/card-example/softmind/scene.gltf"></a-asset-item>
          </a-assets>
    
          <a-camera position="0 0 0" look-controls="enabled: false"></a-camera>
          <a-entity mindar-image-target="targetIndex: 0">
            <a-plane src="#card" position="0 0 0" height="0.552" width="1" rotation="0 0 0"></a-plane>
            <a-gltf-model rotation="0 0 0 " position="0 0 0.1" scale="0.005 0.005 0.005" src="#avatarModel" animation="property: position; to: 0 0.1 0.1; dur: 1000; easing: easeInOutQuad; loop: true; dir: alternate">
          </a-entity>
        </a-scene>
      </body>
    </html>
  4. Access MindAR Image Tracking via the global MINDAR object

    master

    The mind-ar package exports its core components for image tracking. These are available both as ES modules and via the global window.MINDAR.IMAGE object in browser environments.

    Key components available under MINDAR.IMAGE:

    • Controller: Manages the image tracking lifecycle and state.
    • Compiler: Used for compiling target images into a compatible format.
    • UI: Provides user interface elements for the AR experience.