Tech Tips

  1. Uncategorized
  2. 191 view

[AR]Try to use NyARToolkit

Background

There is the library for developing maker base AR program.
It’s called ARToolKit.
It’s processing version is NyARToolkit.

Implementation

Download library is from
here.
And copy it to processing’s home directory’s libraries directory.
Then, change the library’s directory name is “nyar4psg”. Program is following.
import jp.nyatla.nyar4psg.*;
import processing.video.*;

// Definition camera device interface
Capture cam;
MultiMarker ar;
// Marker ID
int id;

void setup() {
  // Set size
  size(640,480,P3D);
  // Create camera device interface
  cam = new Capture(this, width, height);
  ar = new MultiMarker(this, width, height, "camera_para.dat", NyAR4PsgConfig.CONFIG_PSG);
  // Register marker
  id = ar.addARMarker("patt.hiro", 60);
}

void draw() {
   // Check whether camera is available
  if (cam.available() == false) return;
  // Get camera image
  cam.read();
  // Draw camera image
  background(0);
  ar.drawBackground(cam);
  // Detect marker
  ar.detect(cam);
  if (ar.isExistMarker(id)) {
    // Draw box
    ar.beginTransform(id);
    fill(116,163,241,100);
    translate(0,0,15);
    box(30);
    ar.endTransform();
  }
}
After save the program, copy nyar4ps/data to the directory.

Result

SimpleAR
We can get the following result when we pass printed the marker over a camera.

Uncategorized recent post

  1. Run Amazon FreeRTOS on M5Stack Core2 for AWS …

  2. Udacity Self-Driving Car Engineer Nanodegree …

  3. Install sbt 1.0.0 and run sample template

  4. Visualization of Neural Network and its Train…

  5. [Machine Learning]Created docker image includ…

関連記事

PAGE TOP