@webarkit/jsartoolkit-nft
    Preparing search index...

    Threaded build: serve ARToolkitNFT_td.worker.js next to the script that loads this bundle (with a plain <script> tag, the folder of ARToolkitNFT_td.js; with importScripts(), the calling worker's folder; in re-bundled apps, see the README section "Threaded build: deploying"), with the COOP/COEP headers.

    Hierarchy

    • ARControllerNFTBase
      • ARControllerNFT
    Index
    • The ARControllerNFT default constructor. It has no params (see above). These properties are initialized: id, width, height, cameraParam, cameraId, cameraLoaded, artoolkitNFT, listeners, nftMarkers, transform_mat, transformGL_RH, videoWidth, videoHeight, videoSize, videoLuma, framesize, camera_mat.

      Returns ARControllerNFT

    • The ARControllerNFT default constructor. It has 2 params (see above). These properties are initialized: id, width, height, cameraParam, cameraId, cameraLoaded, artoolkitNFT, listeners, nftMarkers, transform_mat, transformGL_RH, videoWidth, videoHeight, videoSize, videoLuma, framesize, camera_mat.

      Parameters

      • width: number
      • height: number

      Returns ARControllerNFT

    • The ARControllerNFT constructor. It has 4 params (see above). These properties are initialized: id, width, height, cameraParam, cameraId, cameraLoaded, artoolkitNFT, listeners, nftMarkers, transform_mat, transformGL_RH, videoWidth, videoHeight, videoSize, framesize, camera_mat.

      Parameters

      • width: number
      • height: number
      • cameraParam: string
      • internalLuma: boolean

      Returns ARControllerNFT

    • get cameraParam(): string

      Returns string

    • set cameraParam(cameraParam: string): void

      Parameters

      • cameraParam: string

      Returns void

    • Add an event listener on this ARControllerNFT for the named event, calling the callback function whenever that event is dispatched. Possible events are:

      • getNFTMarker - dispatched by process() for every NFT marker found in the frame
      • lostNFTMarker - dispatched by process() once a tracked NFT marker has been out of view for longer than the lost threshold (a single missed frame is not a loss)
      • load - dispatched when the ARControllerNFT is ready to use (useful if passing in a camera URL in the constructor)

      Listeners are kept in an array, not a set: registering the same callback twice makes it fire twice per event, and each removeEventListener() call drops one registration.

      Parameters

      • name: string

        Name of the event to listen to.

      • callback: NFTEventListener

        Callback function to call when an event with the given name is dispatched.

      Returns void

    • Converts the given 4x4 openGL matrix in the 16-element transMat array into a 4x4 OpenGL Right-Hand-View matrix and writes the result into the 16-element glMat array. If scale parameter is given, scales the transform of the glMat by the scale parameter.

      Parameters

      • glMatrix: Float64Array

        The 4x4 marker transformation matrix.

      • OptionalglRhMatrix: Float64Array

        The 4x4 GL right hand transformation matrix.

      • Optionalscale: number

        The scale for the transform.

      Returns Float64Array

      the modified gl matrix

    • Changes several runtime settings at once (#720): the planes, the detection policy, filtering, the log level and the AR2 tracking parameters. The patch is deep-merged into getRuntimeSettings (ar2 field by field) and applied in one native call, which validates everything first and changes nothing on failure. getCameraMatrix() reflects new planes at once.

      logLevel is per controller: the level lives in the WASM module's globals, and each controller's init() creates its own module. The core takes 0..4 (or -1 for "leave it"), so a level above 4 is refused with a RangeError, except the controller's current level: that counts as no change, so a getRuntimeSettings() round trip succeeds at any level, a silenced one included. Set a level above 4 with setLogLevel() or the init option.

      Parameters

      Returns void

      ar.configure({ near: 1, far: 5000, ar2: { simThresh: 0.6 } });
      

      on an unknown key (including the deprecated square-marker keys threshold, thresholdMode, imageProcMode, debugMode), a value of the wrong type, or a non-integer for an integer field (logLevel, ar2.searchFeatureNum, ar2.templateSize1/2, ar2.searchSize); nothing is changed.

      when the values are out of range; nothing is changed.

    • Sets up the square-marker detector's debug image: enables debug mode and keeps the image's address.

      Returns void

      The image is never filled for NFT tracking: only the square-marker labeling writes it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Detects the NFT markers in the process() function, with the given tracked id.

      Returns number

    • Dispatches the given event to all listeners registered on event.name, in registration order, with this bound to the controller. The listener list is snapshotted before the loop, so a listener that removes itself (or adds or removes other listeners) during dispatch does not change which listeners the current dispatch reaches; such changes apply from the next dispatch.

      Parameters

      Returns void

    • Returns the projection matrix computed from camera parameters for the ARControllerNFT. It follows the near and far planes: it is built with them from initialisation on, and rebuilt by setProjectionNearPlane(), setProjectionFarPlane() and configure().

      Returns Float64Array

      The 16-element WebGL camera matrix for the ARControllerNFT camera parameters.

    • Returns whether the square-marker detector's debug mode is enabled.

      Returns boolean

      true when debug mode is enabled

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Returns the square-marker detector's image processing mode.

      Returns number

      The current image processing mode.

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Gets the logging level used by ARToolKit.

      Returns number

      return the log level in use.

    • GetNFTData will return the width. height and dpi of the NFT marker.

      Parameters

      • index: number

        the index of the NFT marker, in case you have multi NFT markers.

      Returns object

    • Get the NFT marker info struct for the given NFT marker index in detected markers. The returned object is the global artoolkitNFT.NFTMarkerInfo object and will be overwritten by subsequent calls. Returns undefined if no marker was found. A markerIndex of -1 is used to access the global custom marker.

      Parameters

      • markerIndex: number

        The index of the NFT marker to query.

      Returns INFTMarkerInfo

      The NFTMarkerInfo struct.

    • Returns the Emscripten HEAP offset of the square-marker detector's debug image.

      Returns number

      HEAP offset of the debug image.

      The image is never filled for NFT tracking: only the square-marker labeling writes it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Gets the value of the far plane of the camera with the give id.

      Returns number

      the value of the far plane.

    • Gets the value of the near plane of the camera with the give id.

      Returns number

      the value of the near plane.

    • The current runtime settings (#720), with the effective values: detectionInterval and ar2.searchSize are the build's resolved defaults when they were not set, and logLevel is this controller's current level.

      Returns NFTRuntimeSettings

      a fresh object; changing it changes nothing until passed to configure().

    • Returns the square-marker labeling threshold.

      Returns number

      The current threshold value.

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Returns the square-marker labeling threshold mode.

      Returns number

      The current threshold mode.

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Returns the 16-element WebGL transformation matrix used by ARControllerNFT.process to pass marker WebGL matrices to event listeners. Unique to each ARControllerNFT.

      Returns Float64Array

      The 16-element WebGL transformation matrix used by the ARControllerNFT.

    • Loads one NFT marker and resolves once it is registered, so tracking can start right after the await.

      Promise style (preferred): it rejects with an NFTLoadError, whose kind tells a missing file ("http") from a bad one ("format"), or with the abort reason when opts.signal fires.

      try {
      const [id] = await arController.loadNFTMarker("path/to/marker");
      } catch (err) {
      if (err.kind === "http") console.error("Not found:", err.url, err.status);
      }

      Callback style (deprecated, kept for existing callers): it never rejects for a load failure; the failure goes to onError, or to console.error when there is no onError, and the Promise resolves [].

      arController.loadNFTMarker("path/to/marker", (id) => {
      console.log("Marker loaded with ID:", id);
      }, (code) => {
      console.error("Failed to load marker:", code);
      });

      Parameters

      • url: string | string[]

        The marker's base URL, or the list of its file URLs.

      • OptionalonSuccess: (id: number) => void

        Deprecated. Called with the marker ID.

      • OptionalonError: (code: number) => void

        Deprecated. Called with the HTTP status, or -1.

      • Optionalopts: NFTLoadOptions

        Loading options, such as an abort signal.

      Returns Promise<number[]>

      A Promise that resolves to [id].

    • Loads several NFT markers and resolves once they are all registered.

      Promise style (preferred): it rejects with an NFTLoadError, or with the abort reason when opts.signal fires. Nothing is registered on failure.

      try {
      const ids = await arController.loadNFTMarkers(["path/to/a", "path/to/b"]);
      } catch (err) {
      if (err.kind === "http") console.error("Not found:", err.url, err.status);
      }

      Callback style (deprecated, kept for existing callers): it never rejects for a load failure; the failure goes to onError, or to console.error when there is no onError, and the Promise resolves [].

      arController.loadNFTMarkers(["path/to/a", "path/to/b"], (ids) => {
      console.log("Markers loaded with IDs:", ids);
      }, (code) => {
      console.error("Failed to load markers:", code);
      });

      Parameters

      • urls: (string | string[])[]

        One entry per marker: its base URL, or the list of its file URLs.

      • OptionalonSuccess: (ids: number[]) => void

        Deprecated. Called with the marker IDs.

      • OptionalonError: (code: number) => void

        Deprecated. Called with the HTTP status, or -1.

      • Optionalopts: NFTLoadOptions

        Loading options, such as an abort signal.

      Returns Promise<number[]>

      A Promise that resolves to the marker IDs.

    • Runs one tracking step on the given frame: copies the image to the WASM heap, detects the loaded NFT markers and updates the state of every marker registered with trackNFTMarkerId(). For each marker found it dispatches a "getNFTMarker" event carrying the NFTMarkerInfo and the pose; for a tracked marker that has not been seen for longer than the lost threshold it dispatches "lostNFTMarker" once, with the last known pose (see MarkerLostTracker).

      Parameters

      • image: IImageObj

        The frame to process (video, canvas, image or raw pixel data).

      Returns void

    • Rebuilds the camera frustum from the near and far planes. Kept for compatibility: since WebARKitLib 0.12.0 the lens follows the planes, as setProjectionNearPlane(), setProjectionFarPlane() and configure() rebuild it themselves, so calling this changes nothing.

      Returns void

    • Remove an event listener from the named event. Only the first registration of the callback is removed; a callback registered twice needs two calls. Safe to call from inside a listener while the event is being dispatched: the current dispatch still reaches every listener that was registered when it started.

      Parameters

      • name: string

        Name of the event to stop listening to.

      • callback: NFTEventListener

        Callback function to remove from the listeners of the named event.

      Returns void

    • Turn continuous detection on or off.

      Detection (KPM) is the expensive step that finds a marker which is not yet tracked; a pass costs the full detection time on the frame where it runs, far more than tracking an already-found marker. The policy is:

      • while no marker is tracked, detection runs on every frame;
      • while at least one marker is tracked and at least one loaded marker is not, detection runs at most once per detection interval (see setDetectionInterval), so a marker that enters the view is still picked up;
      • while every loaded marker is tracked, detection does not run.

      With continuous detection off, no detection runs once any marker is tracked, until tracking is lost: the single-marker behaviour of 1.12.0. That is cheapest, but a second marker entering the view is not found while the first one is held.

      Parameters

      • enabled: boolean

        Default true.

      Returns void

    • Enables or disables the square-marker detector's debug mode.

      Parameters

      • mode: boolean

        true to enable debug mode, false to disable it

      Returns number

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Set the minimum time from the end of one detection pass to the start of the next, while at least one marker is tracked and at least one is not (see setContinuousDetection).

      Detection is measured in time, not frames. A longer interval spends less time detecting, at the cost of noticing a newly visible marker later. This build detects on a worker thread, one search at a time, so a search does not block process(); 0 starts a new one whenever the worker is free, and an interval here only saves worker CPU.

      Parameters

      • ms: number

        Milliseconds. 0 means no throttling; negative values are treated as 0. Default: 0.

      Returns void

    • Set the filtering mode.

      Parameters

      • enableFiltering: boolean

      Returns void

    • Set the custom gray data (videoLuma) in case you want to add additional trasnformation to gray data: for example gaussianblur or boxblur with external libs.

      Parameters

      • data: Uint8Array

        Uint8Array

      Returns void

    • Sets the square-marker detector's image processing mode (frame or field).

      Parameters

      • mode: number

        AR_IMAGE_PROC_FRAME_IMAGE or AR_IMAGE_PROC_FIELD_IMAGE.

      Returns number

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Set the logging verbosity.

      Lower is more verbose: ARLogLevel.Debug (0) shows everything, ARLogLevel.RelInfo (4) the least. The library starts at ARLogLevel.Info.

      Parameters

      • level: number

        one of the ARLogLevel values. Returns nothing: the native setter is void. Use getLogLevel() to read back the effective level, which also reveals when a negative value was rejected by the guard.

      Returns void

    • Sets the value of the far plane of the camera. The camera lens follows at once, and getCameraMatrix() returns the rebuilt matrix (WebARKitLib 0.12.0).

      Parameters

      • value: number

        the value of the far plane, > the near plane

      Returns void

      0 (void)

    • Sets the value of the near plane of the camera. The camera lens follows at once, and getCameraMatrix() returns the rebuilt matrix (WebARKitLib 0.12.0).

      Parameters

      • value: number

        the value of the near plane, > 0

      Returns void

      0 (void)

    • Sets the square-marker labeling threshold.

      Parameters

      • threshold: number

        An integer in the range [0,255] (inclusive).

      Returns number

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Sets the square-marker labeling threshold mode (auto/manual).

      Parameters

      • mode: number

        One of the AR_LABELING_THRESH_MODE_* values.

      Returns number

      Has no effect on NFT tracking: only the square-marker labeling reads it, and NFT tracking never runs it. Will be removed in the next major version (#659).

    • Adds the given NFT marker ID to the set of tracked IDs, or returns the existing entry if the ID is already tracked. Used by process() to implement continuous tracking: the entry keeps the marker's transformation matrices and its visibility in the current and previous frame.

      Parameters

      • id: number

        ID of the NFT marker to track.

      • OptionalmarkerWidth: number

        Width of the marker; overrides the width of an already tracked entry, and falls back to defaultMarkerWidth for a new one.

      Returns INFTMarker

      The marker tracking object (the same object on every call for a given ID).

    • Converts the given 3x4 marker transformation matrix in the 12-element transMat array into a 4x4 WebGL matrix and writes the result into the 16-element glMat array. If scale parameter is given, scales the transform of the glMat by the scale parameter.

      Parameters

      • transMat: Float64Array

        The 3x4 marker transformation matrix.

      • glMat: Float64Array

        The 4x4 GL transformation matrix.

      • Optionalscale: number

        The scale for the transform.

      Returns Float64Array

      the modified matrix

    • The static method customInit is the start of your app. This method is only for advanced users. Define it with the width and height of the video stream, the camera parameter file path and the callback function where you define custom behaviours. As with initWithDimensions it return a Promise with the ARControllerNFT object. Use a thenable to load the NFT marker and all the code stuff. Example:

        import ARControllerNFT from '@webarkit/jsartoolkit-nft'
      ARControllerNFT.customInit(
      640,
      480,
      "camera_para.dat",
      true,
      function() { // your code here }
      ).then(
      (nft) => {
      nft.loadNFTMarker();
      // other code...
      })

      Parameters

      • width: number
      • height: number
      • cameraParam: string
      • internalLuma: boolean
      • callback: () => void
      • Optionaloptions: ARInitOptions

        logLevel is applied before the core is constructed, so the start-up output follows it (#677). Per controller in JS.

      Returns Promise<ARControllerNFT>

      this

    • The static method initWithDimensions is the start of your app. Define it with the width and height of the video stream and the camera parameter file path. It return a Promise with the ARControllerNFT object. Use a thenable to load the NFT marker and all the code stuff. Example:

        import ARControllerNFT from '@webarkit/jsartoolkit-nft'
      ARControllerNFT.initWithDimensions(640, 480, "camera_para.dat", true).then(
      (nft) => {
      nft.loadNFTMarker();
      // other code...
      })

      Parameters

      • width: number
      • height: number
      • cameraParam: string
      • internalLuma: boolean
      • Optionaloptions: ARInitOptions

        logLevel is applied before the core is constructed, so the start-up output follows it (#677). Per controller in JS.

      Returns Promise<ARControllerNFT>

      this

    • The static method initWithImage is the start of your app. Define it with an HTML element like a video or a static Image and the camera parameter file path. As with initWithDimensions it return a Promise with the ARControllerNFT object. Use a thenable to load the NFT marker and all the code stuff. Example:

        import ARControllerNFT from '@webarkit/jsartoolkit-nft'
      const image = document.getElementById('image')
      ARControllerNFT.initWithImage(image, "camera_para.dat", true).then(
      (nft) => {
      nft.loadNFTMarker();
      // other code...
      })

      Parameters

      • image: IImageObj
      • cameraParam: string
      • internalLuma: boolean
      • Optionaloptions: ARInitOptions

        logLevel is applied before the core is constructed, so the start-up output follows it (#677). Per controller in JS.

      Returns Promise<ARControllerNFT>

      this